Package org.apache.flex.compiler.definitions.references

Examples of org.apache.flex.compiler.definitions.references.IResolvedQualifiersReference


        INamespaceReference qualifier = def.getNamespaceReference();
        if (!qualifier.isPublicOrInternalNamespace())
            return def;
        INamespaceDefinition qualifierDef = (INamespaceDefinition)qualifier;
        IResolvedQualifiersReference refToDefinition =
                ReferenceFactory.resolvedQualifierQualifiedReference(project.getWorkspace(), qualifierDef, def.getBaseName());
        return refToDefinition.resolve(project);
    }
View Full Code Here


        String deferredInstanceFromFunctionClass = project.getDeferredInstanceFromFunctionClass();
        Name deferredInstanceFromFunctionName = project.getDeferredInstanceFromFunctionName();

        if (!(classDefinition.isInstanceOf("mx.core.IStateClient2", project)))
        {
            final IResolvedQualifiersReference stateClient2Reference = ReferenceFactory.packageQualifiedReference(
                    this.getProject().getWorkspace(),
                    "mx.core.IStateClient2");
            final Name stateClient2Name = stateClient2Reference.getMName();

            IReference[] implementedInterfaces = classDefinition.getImplementedInterfaceReferences();
            IReference[] newInterfaces = null;
            Name[] newNames = null;
            if (implementedInterfaces != null)
            {
                int n = implementedInterfaces.length;
                newInterfaces = new IReference[n + 1];
                newNames = new Name[n + 1];
                for (int i = 0; i < n; i++)
                {
                    newInterfaces[i] = implementedInterfaces[i];
                    newNames[i] = iinfo.interfaceNames[i];
                }
                newInterfaces[n] = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "mx.core.IStateClient2");
                newNames[n] = stateClient2Name;
            }
            else
            {
                newInterfaces = new IReference[1];
                newInterfaces[0] = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "mx.core.IStateClient2");
                newNames = new Name[1];
                newNames[0] = stateClient2Name;
            }
            classDefinition.setImplementedInterfaceReferences(newInterfaces);
            iinfo.interfaceNames = newNames;
        }
       
        // now, process all the state dependent nodes
       
        int instanceNodeCounter = 0;
        IASNode anInstanceNode = null;
        for   (IMXMLNode node : stateDependentNodes)
        {
             // here we only care about instance nodes
            if (node instanceof IMXMLInstanceNode)
            {
                anInstanceNode = node;
                // Generate a map that tell for each state dependent instance node, what slot
                // it corresponds to in the array of
                // deferredInstanceFromFunction's
                if (nodeToIndexMap==null)     
                    nodeToIndexMap = new HashMap<IMXMLNode, Integer>();
                nodeToIndexMap.put(node, instanceNodeCounter);
                ++instanceNodeCounter; 
               
                InstructionList il;
                if (getProject().getTargetSettings().getMxmlChildrenAsData())
                {
                    if (nodeToInstanceDescriptorMap==null)     
                        nodeToInstanceDescriptorMap = new HashMap<IMXMLNode, InstructionList>();
                    il = new InstructionList();
                    nodeToInstanceDescriptorMap.put(node, il);
                    // build the initializer function by processing the node
                    Context stateContext = new Context((IMXMLInstanceNode)node, il);
                    stateContext.isContentFactory = true;
                    processNode(node, stateContext);
                    stateContext.transfer(IL.MXML_CONTENT_FACTORY);
                    stateContext.addInstruction(OP_newarray, stateContext.getCounter(IL.MXML_CONTENT_FACTORY));     
                }
                else
                {
                    context.addInstruction(OP_findpropstrict, deferredInstanceFromFunctionName)
                    // stack: ..., DeferredInstaceFromFunction class
                   
                    // build the initializer function by processing the node
                    processNode(node, context);
                    // stack: ..., DeferredInstaceFromFunction class, initializerFunc
                   
                    context.addInstruction(OP_constructprop, new Object[] { deferredInstanceFromFunctionName, 1});  
                    // stack: ..., DeferredInstaceFromFunction object
                }
            }
        }
       
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
            return;

        // if we didn't find any state dependent instance nodes, then leave
        if (instanceNodeCounter==0)
            return;
               
        // stack: ..., arg[0], arg[1],.., arg[n-1]
        context.addInstruction(OP_newarray, instanceNodeCounter);
        context.addInstruction(OP_setlocal3);
       
        // now local3= array of deferredInstanceFromFunctionName
       
        // make a dependency on the sdk class DeferredInstanceFromFunction
        IWorkspace workspace = project.getWorkspace();
        IResolvedQualifiersReference ref = ReferenceFactory.packageQualifiedReference(workspace, deferredInstanceFromFunctionClass);
      
        IScopedNode scopedNode = anInstanceNode.getContainingScope();
        IASScope iscope = scopedNode.getScope();
        ASScope scope = (ASScope)iscope;
       
        if (ref == null)
            assert false;
        IDefinition def = ref.resolve(project, scope, DependencyType.EXPRESSION, false);
        if (def == null)
            assert false;
    }
View Full Code Here

     * </pre>
     */
    private void overrideModuleFactorySetter(Context context)
    {
        final Name moduleFactoryName = new Name("moduleFactory");
        final IResolvedQualifiersReference styleManagerReference = ReferenceFactory.packageQualifiedReference(
                this.getProject().getWorkspace(),
                "mx.styles.StyleManagerImpl");
        final Name styleManagerReferenceName = styleManagerReference.getMName();

        final MethodInfo methodInfo = new MethodInfo();
        methodInfo.setMethodName("moduleFactory");
        methodInfo.setReturnType(NAME_VOID);
        methodInfo.setParamNames(ImmutableList.<String> of("factory"));
View Full Code Here

           
            byte[] generatedBytes = null;
            try
            {
                //this class extends "flex.compiler.support.ResourceModuleBase"
                IResolvedQualifiersReference resourceModuleBaseRef = ReferenceFactory.packageQualifiedReference(
                        flexProject.getWorkspace(), flexProject.getResourceModuleBaseClass());
               
                //Create constructor instruction list
                InstructionList constructorInstructionList = new InstructionList();
                constructorInstructionList.addInstruction(ABCConstants.OP_getlocal0);
                constructorInstructionList.addInstruction(ABCConstants.OP_pushscope)
               
                int resourceBundleCount = 0;
                for(ICompilationUnit compUnit : resourceBundleCompUnits)
                {
                    for(IDefinition def : compUnit.getDefinitionPromises())
                    {
                        constructorInstructionList.addInstruction(ABCConstants.OP_pushstring, def.getQualifiedName());
                        resourceBundleCount++;
                    }
                }
               
                constructorInstructionList.addInstruction(ABCConstants.OP_newarray, resourceBundleCount);
                constructorInstructionList.addInstruction(ABCConstants.OP_constructsuper, 1);
                constructorInstructionList.addInstruction(ABCConstants.OP_returnvoid);
               
                ClassGeneratorHelper classGen = new ClassGeneratorHelper(flexProject, emitter,
                        new Name(qname),
                        (ClassDefinition)resourceModuleBaseRef.resolve(flexProject),
                        Collections.<Name> emptyList(),
                        constructorInstructionList);

                classGen.finishScript();
                generatedBytes = emitter.emit();
View Full Code Here

            // Kick off code generation to add all the dependencies found by code generation.
            getABCBytesRequest().get();

            //Add dependency to 'mx.resources.ResourceBundle' since we want it to be picked up.
            FlexProject project = getFlexProject();
            IResolvedQualifiersReference resourceBundleClassRef = ReferenceFactory.packageQualifiedReference(
                    getProject().getWorkspace(), project.getResourceBundleClass());
            resourceBundleClassRef.resolve(project, this, DependencyType.INHERITANCE);

            return new IOutgoingDependenciesRequestResult()
            {
                @Override
                public ICompilerProblem[] getProblems()
View Full Code Here

    {

        FlexProject project = getFlexProject();

        //this class extends "mx.resources.ResourceBundle"
        IResolvedQualifiersReference resourceBundleReference = ReferenceFactory.packageQualifiedReference(
                project.getWorkspace(), project.getResourceBundleClass());

        //Create constructor instruction list
        InstructionList constructorInstructionList = new InstructionList();
        constructorInstructionList.addInstruction(ABCConstants.OP_getlocal0);
        constructorInstructionList.addInstruction(ABCConstants.OP_pushstring, locale);
        constructorInstructionList.addInstruction(ABCConstants.OP_pushstring, bundleName);
        constructorInstructionList.addInstruction(ABCConstants.OP_constructsuper, 2);
        constructorInstructionList.addInstruction(ABCConstants.OP_returnvoid);

       
        IResolvedQualifiersReference mainClassRef = ReferenceFactory.packageQualifiedReference(
                project.getWorkspace(), qualifiedClassName);
       
        ClassGeneratorHelper classGen = new ClassGeneratorHelper(project, emitter,
                mainClassRef.getMName(),
                (ClassDefinition)resourceBundleReference.resolve(project),
                Collections.<Name> emptyList(), Collections.<Name> emptyList(),
                constructorInstructionList, true);

        //Create method body for getContents
        InstructionList bodyInstructionList = new InstructionList();
        bodyInstructionList.addInstruction(ABCConstants.OP_getlocal0);
        bodyInstructionList.addInstruction(ABCConstants.OP_pushscope);

        //Create key value pair entries "key":"value"
        int entryCount = 0;
        for (int i = 0; i < fileNode.getChildCount(); i++)
        {
            IASNode node = fileNode.getChild(i);
            if (node instanceof ResourceBundleEntryNode)
            {
                entryCount++;
                ResourceBundleEntryNode entryNode = (ResourceBundleEntryNode)node;

                //push key
                bodyInstructionList.addInstruction(ABCConstants.OP_pushstring, entryNode.getKeyNode().getValue());

                //push value
                ExpressionNodeBase valueNode = entryNode.getValueNode();
                switch (valueNode.getNodeID())
                {

                    case LiteralStringID:
                        bodyInstructionList.addInstruction(ABCConstants.OP_pushstring,
                                ((LiteralNode)valueNode).getValue());
                        break;

                    case ClassReferenceID:
                        ClassReferenceNode crn = (ClassReferenceNode)valueNode;
                        if (crn.getName() != null)
                        {

                            IResolvedQualifiersReference refClass = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), crn.getName());

                            if (refClass.resolve(project, crn.getASScope(), DependencyType.EXPRESSION, true) == null)
                            {
                                ICompilerProblem problem = new UnresolvedClassReferenceProblem(crn, crn.getName());
                                problems.add(problem);
                            }
                        }
                        String className = crn.getName();
                        if(className == null)
                        {
                            bodyInstructionList.addInstruction(ABCConstants.OP_pushnull);
                        }
                        else
                        {
                            IResolvedQualifiersReference classRef = ReferenceFactory.packageQualifiedReference(
                                    project.getWorkspace(), className);

                            bodyInstructionList.addInstruction(ABCConstants.OP_getlex, classRef.getMName());
                        }
                       
                        break;

                    case EmbedID:
                        EmbedNode embedNode = (EmbedNode)valueNode;
                        try
                        {
                            String name = embedNode.getName(project, problems);
                            IResolvedQualifiersReference embedClassRef = ReferenceFactory.packageQualifiedReference(
                                    project.getWorkspace(), name);
                            bodyInstructionList.addInstruction(ABCConstants.OP_getlex, embedClassRef.getMName());
                        }
                        catch (InterruptedException ex)
                        {
                            problems.add(new CodegenInternalProblem(embedNode, ex));
                        }
View Full Code Here

        return returnedDefinitionSet;
    }

    private static boolean referenceMatchesQName(IWorkspace workspace, IResolvedQualifiersReference reference, String qualifiedName)
    {
        IResolvedQualifiersReference qualifiedNameReference = ReferenceFactory.packageQualifiedReference(workspace, qualifiedName, true);
        ImmutableSet<INamespaceDefinition> referenceQualifiers = reference.getQualifiers();
        for (INamespaceDefinition qNameNS : qualifiedNameReference.getQualifiers())
        {
            if (referenceQualifiers.contains(qNameNS))
                return true;
        }
        return false;
View Full Code Here

    @Override
    public void visitClassTraits(ITraitsVisitor classTraitsVisitor)
    {

        // Resolve "Object" type.
        final IResolvedQualifiersReference referenceObject = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "Object");

        // Resolve "String" type.
        @SuppressWarnings("unused")
        final IResolvedQualifiersReference referenceString = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "String");

        // Resolve "Array" type.
        final IResolvedQualifiersReference referenceArray = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "Array");

        // Generate "public static var factoryFunctions:Object;"
        classTraitsVisitor.visitSlotTrait(
                ABCConstants.TRAIT_Const,
                NAME_FACTORY_FUNCTIONS,
                ITraitsVisitor.RUNTIME_SLOT,
                referenceObject.getMName(),
                LexicalScope.noInitializer);

        // Generate "public static var data:Array;"
        classTraitsVisitor.visitSlotTrait(
                ABCConstants.TRAIT_Const,
                NAME_DATA_ARRAY,
                ITraitsVisitor.RUNTIME_SLOT,
                referenceArray.getMName(),
                LexicalScope.noInitializer);

        // Generate "public static var inheritingStyles:Array"
        classTraitsVisitor.visitSlotTrait(
                ABCConstants.TRAIT_Var,
                NAME_INHERITING_STYLES,
                ITraitsVisitor.RUNTIME_SLOT,
                referenceArray.getMName(),
                LexicalScope.noInitializer);
    }
View Full Code Here

            updateStyleCompilationUnitDependencies(
                    session,
                    flexProject,
                    ImmutableList.<ICSSDocument> of(syntaxResult.cssDocument),
                    cssSemanticProblems);
            IResolvedQualifiersReference styleModuleBaseClassRef = ReferenceFactory.packageQualifiedReference(
                    getProject().getWorkspace(), "StyleModuleBase");
            styleModuleBaseClassRef.resolve(flexProject, this, DependencyType.INHERITANCE);
        }

        return new StyleModuleSemanticRequestResult(syntaxResult.cssDocument, session, cssSemanticProblems);
    }
View Full Code Here

                    // ClassReference(null) resets the property's class reference.
                    valueInstructions.addInstruction(ABCConstants.OP_pushnull);
                }
                else
                {
                    final IResolvedQualifiersReference reference = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), className);
                    valueInstructions.addInstruction(ABCConstants.OP_getlex, reference.getMName());
                }
            }
            else if ("url".equals(functionCall.name))
            {
                final String urlString = CSSFunctionCallPropertyValue.getSingleArgumentFromRaw(functionCall.rawArguments);
                valueInstructions.addInstruction(ABCConstants.OP_pushstring, urlString);
            }
            else if ("PropertyReference".equals(functionCall.name))
            {
                // TODO: implement me
            }
            else if ("Embed".equals(functionCall.name))
            {
                final EmbedCompilationUnit embedCompilationUnit = session.resolvedEmbedProperties.get(functionCall);
                if (embedCompilationUnit == null)
                {
                    final ICompilerProblem e = new CSSCodeGenProblem(
                            new IllegalStateException("Unable to find compilation unit for " + functionCall));
                    problems.add(e);
                }
                else
                {
                    final String qName = embedCompilationUnit.getName();
                    final IResolvedQualifiersReference reference = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), qName);
                    valueInstructions.addInstruction(ABCConstants.OP_getlex, reference.getMName());
                }
            }
            else
            {
                assert false : "CSS parser bug: unexpected function call property value: " + functionCall;
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.definitions.references.IResolvedQualifiersReference

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.