Package org.apache.flex.compiler.internal.definitions

Examples of org.apache.flex.compiler.internal.definitions.AppliedVectorDefinition


    public AppliedVectorDefinition newVectorClass(ITypeDefinition elementType)
    {
        // First try to get an existing vector class
        // just using the read lock.
        AppliedVectorDefinition existingVectorClass = getExistingVectorClass(elementType);
        if (existingVectorClass != null)
            return existingVectorClass;

        // No dice, looks like we might have to create the
        // vector class.
        writeLock.lock();
        try
        {
            // Now that we have the write lock, make sure nobody created
            // the vector class we need while we were waiting for the write lock.
            existingVectorClass = getExistingVectorClass(elementType);
            if (existingVectorClass != null)
                return existingVectorClass;

            // ok.  Now we know for sure we'll have to create the new vector class.

            //Default to creating a subclass of Vector$object.       
            String vectorTypeName = null;

            // We need to see if the elementType is int, Number, or uint.
            // If the elementType is int, Number, or uint, then the vector class is a special
            // class that we just need to look up in the project symbol table, otherwise we
            // need to sub-class Vector$object.

            // Some short cuts here to avoid extra lookups.
            INamespaceReference elementTypeNSRef = elementType.getNamespaceReference();
            if ((elementTypeNSRef.equals(NamespaceDefinition.getPublicNamespaceDefinition())) && // int, Number, and uint are all public classes.
            (elementType.getPackageName().length() == 0) && // int, Number, and uint are all in the unnamed package.
            (elementType instanceof IClassDefinition) && // int, Number, and uint are all classes.
            (!(elementType instanceof AppliedVectorDefinition))) // int, Number and uint are not Vector classes.
            {
                // Now just compare the elementType's string base name to
                // int, uint, and Number.  If one of those matches, then
                // we'll lookup the corresponding type and see if it matches
                // the specified element type.
                String elementTypeName = elementType.getBaseName();
                if (elementTypeName.equals(IASLanguageConstants._int))
                    vectorTypeName = IASLanguageConstants.Vector_int;
                else if (elementTypeName.equals(IASLanguageConstants.uint))
                    vectorTypeName = IASLanguageConstants.Vector_uint;
                else if (elementTypeName.equals(IASLanguageConstants.Number))
                    vectorTypeName = IASLanguageConstants.Vector_double;

                if (vectorTypeName != null)
                {
                    IDefinition numberTypeClassDef = findDefinitionByName(elementTypeName);
                    assert numberTypeClassDef != null : "Unable to lookup: " + elementTypeName;
                    if (!numberTypeClassDef.equals(elementType))
                    {
                        // The element type was not actually a number class
                        // back to square 1.
                        vectorTypeName = null;
                    }
                }

            }
            if (vectorTypeName == null)
                vectorTypeName = IASLanguageConstants.Vector_object;
           
            IClassDefinition vectorImplClass = AppliedVectorDefinition.lookupVectorImplClass(project, vectorTypeName);
            AppliedVectorDefinition result = new AppliedVectorDefinition(project, vectorImplClass, elementType);
            vectorElementTypeToVectorClassMap.put(elementType, result);

            if (vectorTypeName == IASLanguageConstants.Vector_object)
                result.adjustVectorMethods(this.project);

            return result;
        }
        finally
        {
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.definitions.AppliedVectorDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.