Package org.apache.flex.compiler.projects

Examples of org.apache.flex.compiler.projects.ICompilerProject


    {
        if (!getProject().getTargetSettings().getMxmlChildrenAsData())
        {
            // Get the Name for the mx.core.DeferredInstanceFromClass
            // or mx.core.DeferredInstanceFromFunction class.
            ICompilerProject project = getProject();
            ClassDefinition classReference = (ClassDefinition)deferredInstanceNode.getClassReference(project);
            Name deferredInstanceClassName = classReference.getMName(project);
           
            // Push this class.
            context.addInstruction(OP_finddef, deferredInstanceClassName);
View Full Code Here


        dp.finishClassDefinition();
       
        // Leave a reference to the class on the stack.
        ClassDefinition classDefinition =
            (ClassDefinition)((IMXMLClassDefinitionNode)node).getClassDefinition();
        ICompilerProject project = getProject();
        Name className = classDefinition.getMName(project);
        context.addInstruction(OP_getlex, className);
    }
View Full Code Here

    }
   
    void processMXMLEmbed(IMXMLEmbedNode node, Context context)
    {
        // push a reference to the asset class on the stack
        ICompilerProject project = getProject();
        ClassDefinition classDefinition = (ClassDefinition)node.getClassReference(project);
        Name className = classDefinition != null ? classDefinition.getMName(project) : null;
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
            context.addInstruction(OP_pushtrue);
View Full Code Here

                // Getter/setter pairs, so only emit the warning if this is not the case.
                //
                // Updater: the warning is detected elsewhere, so all we are doing here is
                // generating code to create the new function as per ECMAS

                ICompilerProject project = currentScope.getProject();
                List<IDefinition> defs = SemanticUtils.findPotentialFunctionConflicts(project, funcDef);

                if (!SemanticUtils.isGetterSetterPair(defs, project))
                {
                    // This is a new funciton, so generate code for it
View Full Code Here

        DefinitionBase varDef = var.getDefinition();
        SemanticUtils.checkScopedToDefaultNamespaceProblem(this.currentScope, var, varDef, null);
        if ( var.hasModifier(ASModifier.STATIC))
        {
           
            ICompilerProject project = this.currentScope.getProject();

            Name var_name = varDef.getMName(project);

            TypeDefinitionBase typeDef = (TypeDefinitionBase)varDef.resolveType(project);
            Name var_type = typeDef != null ? typeDef.getMName(project) : null;
View Full Code Here

        {
            classScope.setInitialControlFlowRegionNode(((ClassNode)node).getScopedNode());
            classStaticScope.setInitialControlFlowRegionNode(((ClassNode)node).getScopedNode());
        }
       
        ICompilerProject project = classScope.getProject();
       
        // Set the class Name.
        this.classDefinition = class_definition;
        this.className = classDefinition.getMName(project);
        iinfo.name = className;

        // Check for a duplicate class name.
        switch(SemanticUtils.getMultiDefinitionType(this.classDefinition, project))
        {  
            case AMBIGUOUS:
            classScope.addProblem(new DuplicateClassDefinitionProblem(node, class_definition.getBaseName()));
                break;
            case NONE:
                break;
            default:
               assert false;       // I don't think classes can have other type of multiple definitions
        }
       
        if (node instanceof BaseDefinitionNode)     // test doesn't work for MXML, which is OK.
        {
            BaseDefinitionNode n = (BaseDefinitionNode)node;
            SemanticUtils.checkScopedToDefaultNamespaceProblem(classScope, n, classDefinition, null);
        }
        // Resolve the super class, checking that it exists,
        // that it is a class rather than an interface,
        // that it isn't final, and that it isn't the same as this class.
        ClassDefinition superclassDefinition =
            SemanticUtils.resolveBaseClass(node, class_definition, project, classScope.getProblems());

        // Check that the superclass isn't a forward reference, but only need to do this if both
        // definitions come from the same containing source.  getContainingFilePath() returns the file
        // from the ASFileScope, so no need to worry about included files.
        if (!classDefinition.isGeneratedEmbedClass() && classDefinition.getContainingFilePath().equals(superclassDefinition.getContainingFilePath()))
        {
            // If the absolute offset in the class is less than the
            // offset of the super class, it must be a forward reference in the file
            int classOffset = classDefinition.getAbsoluteStart();
            int superClassOffset = superclassDefinition.getAbsoluteEnd();
            if (classOffset < superClassOffset)
                classScope.addProblem(new ForwardReferenceToBaseClassProblem(node, superclassDefinition.getQualifiedName()));
        }

        // Set the superclass Name.
        this.superclassName = superclassDefinition.getMName(project);
        iinfo.superName = superclassName;
       
        // Resolve the interfaces.
        IInterfaceDefinition[] interfaces = classDefinition.resolveImplementedInterfaces(
            project, classScope.getProblems());
       
        // Set the interface Names.
        int n_interfaces = interfaces.length;
        ArrayList<Name> interface_names = new ArrayList<Name>(n_interfaces);
        for (int i = 0; i < n_interfaces; i++)
        {
            InterfaceDefinition idef = (InterfaceDefinition)interfaces[i];
            if (idef != null)
            {
                Name interfaceName = ((InterfaceDefinition)interfaces[i]).getMName(project);
                interface_names.add(interfaceName);
            }
        }
        iinfo.interfaceNames = interface_names.toArray(new Name[interface_names.size()]);
       
        // Set the flags corresponding to 'final' and 'dynamic'.
        if (classDefinition.isFinal())
            iinfo.flags |= ABCConstants.CLASS_FLAG_final;
        if (!classDefinition.isDynamic())
            iinfo.flags |= ABCConstants.CLASS_FLAG_sealed;
       
        iinfo.protectedNs = ((NamespaceDefinition)classDefinition.getProtectedNamespaceReference()).getAETNamespace();
       
        this.cv = emitter.visitClass(iinfo, cinfo);
        cv.visit();
       
        this.itraits = cv.visitInstanceTraits();
        this.ctraits = cv.visitClassTraits();

        this.classScope.traitsVisitor = this.itraits;
        this.classStaticScope.traitsVisitor = this.ctraits;

        // Build an array of the names of all the ancestor classes.
        ArrayList<Name> ancestorClassNames = new ArrayList<Name>();
       
        // Walk the superclass chain, starting with this class
        // and (unless there are problems) ending with Object.
        // This will accomplish three things:
        // - find loops;
        // - build the array of names of ancestor classes;
        // - set the needsProtected flag if this class or any of its ancestor classes needs it.

        boolean needsProtected = false;

        //  Remember the most recently examined class in case there's a cycle in the superclass
        //  chain, in which case we'll need it to issue a diagnostic.
        ClassDefinition c = null;

        IClassDefinition.IClassIterator classIterator =
            classDefinition.classIterator(project, true);

        while (classIterator.hasNext())
        {
            c = (ClassDefinition)classIterator.next();
            needsProtected |= c.getOwnNeedsProtected();
            if (c != classDefinition)
                ancestorClassNames.add(c.getMName(project));
        }
       
        // Report a loop in the superclass chain, such as A extends B and B extends A.
        // Note: A extends A was found previously by SemanticUtils.resolveBaseClass().
        if (classIterator.foundLoop())
            classScope.addProblem(new CircularTypeReferenceProblem(c, c.getQualifiedName()));
       
        // In the case of class A extends A, ancestorClassNames will be empty at this point.
        // Change it to be Object to prevent "Warning: Stack underflow" in the script init code below.
        if (ancestorClassNames.isEmpty())
        {
            ClassDefinition objectDefinition = (ClassDefinition)project.getBuiltinType(
                IASLanguageConstants.BuiltinType.OBJECT);
            ancestorClassNames.add(objectDefinition.getMName(project));
        }
       
        // If this class or any of its ancestor classes needs the protected flag set, set it.
View Full Code Here

        }
    }

    private void addAnyEmbeddedAsset()
    {
        ICompilerProject project = classScope.getProject();
        if (!(project instanceof CompilerProject))
            return;

        EmbedData embedData = classDefinition.getEmbeddedAsset((CompilerProject)project, classScope.getProblems());
        if (embedData != null)
View Full Code Here

        final FunctionDefinition funcDef = func.getDefinition();

        final boolean is_constructor = func.isConstructor();
       
        ICompilerProject project = classScope.getProject();
       
        boolean isBindable = false;
        if (funcDef instanceof AccessorDefinition)
        {
            IMetaTag[] metaTags = funcDef.getAllMetaTags();
View Full Code Here

        VariableDefinition varDef = (VariableDefinition)var.getDefinition();

        boolean is_static = var.hasModifier(ASModifier.STATIC);
        boolean is_const =  SemanticUtils.isConst(var, classScope.getProject());
       
        final ICompilerProject project = this.classScope.getProject();
       
        ICodeGenerator codeGenerator = classScope.getGenerator();
        IExpressionNode assignedValueNode = var.getAssignedValueNode();
        IConstantValue constantValue = codeGenerator.generateConstantValue(assignedValueNode, project);
View Full Code Here

    }


    ITraitVisitor declareVariable(VariableNode varNode, DefinitionBase varDef, boolean is_static, boolean is_const, Object initializer)
    {
        final ICompilerProject project = this.classScope.getProject();
        Name var_name = varDef.getMName(project);

        TypeDefinitionBase typeDef = varDef.resolveType(project);
        Name var_type = typeDef != null ? typeDef.getMName(project) : null;
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.projects.ICompilerProject

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.