Package org.apache.flex.abc.instructionlist

Examples of org.apache.flex.abc.instructionlist.InstructionList


     */
    InstructionList getBranchTarget(ControlFlowContextSearchCriteria criterion)
        throws UnknownControlFlowTargetException
    {

        InstructionList result = new InstructionList();

        int context_idx = findControlFlowContext(criterion);
        ControlFlowContext ctx = activeFlowContexts.elementAt(context_idx);

        result.addInstruction(OP_jump, criterion.getLabel(ctx));
        return result;
    }
View Full Code Here


        this.project = project;
        this.generator = generator;
        this.syntheticNamePrefix = syntheticNamePrefix;
        this.inInvisibleCompilationUnit = inInvisibleCompilationUnit;
        this.encodedDebugFiles = encodedDebugFiles;
        this.initInstructions = new InstructionList();

        super.methodBodySemanticChecker = new MethodBodySemanticChecker(this);

        if ( emitter != USE_DEFAULT_EMITTER )
            this.emitter = emitter;
View Full Code Here

    boolean hasFinally = false;

    @Override
    InstructionList addExitPath(InstructionList exitBranch)
    {
        InstructionList result = exitBranch;
       
        //  Enter any finally blocks
        //  that are not already active.
        if ( hasFinallyBlock() )
        {
            if ( ! isActiveFinally() )
                result = addFinallyReturn(result);
           
        }

        //  Pop the scope of any active catch blocks.
        if ( isActiveCatchBlock() )
        {
            InstructionList catch_fixup = new InstructionList();
            catch_fixup.addInstruction(OP_popscope);
            catch_fixup.addInstruction(getExceptionStorage().kill());

            catch_fixup.addAll(result);
            result = catch_fixup;
        }
        return result;
    }
View Full Code Here

        Label retblock_label = new Label();
        retblock.labelFirst(retblock_label);
        finallyReturns.add(new FinallyReturn(retblock_label, retblock));

        InstructionList result = new InstructionList();
        CmcEmitter.pushNumericConstant(finallyReturns.size(), result);
        result.addInstruction(OP_coerce_a);
        result.addInstruction(finallyReturnStorage.setlocal());
        result.addInstruction(OP_jump, finallyBlock);
        return result;
    }
View Full Code Here

     */
    @Override
    void processDirective(IASNode n)
    {
        //  Handle a loose statement.
        InstructionList stmt_insns = currentScope.getGenerator().generateInstructions(n, CmcEmitter.__statement_NT, currentScope);
        if ( stmt_insns != null )
            directiveInsns.addAll(stmt_insns);
    }
View Full Code Here

        //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));
                        }
                        break;

                    default:
                        //This shouldn't happen. Should we handle this case by collecting a problem?
                }
            }
        }

        bodyInstructionList.addInstruction(ABCConstants.OP_newobject, entryCount);
        bodyInstructionList.addInstruction(ABCConstants.OP_returnvalue);

        Name getContentsMethodName = new Name(ABCConstants.CONSTANT_Qname,
                new Nsset(classGen.getProtectedNamespace()), "getContent");

        //Create getContents method
View Full Code Here

    @Override
    public void visitInstructionList(InstructionList new_list)
    {
        // for the delegates that run after this IVisitor, they will be processing
        // a new copy of the instruction list, which will have the optimized opcodes
        InstructionList newInstructions = new InstructionList();
        InstructionFinisher old = this.finisher;

        // Create a new finisher, which will put the instruction into a new InstructionList
        // instead of passing them on to the next delegate
        this.finisher = new InstructionListFinisher(newInstructions);
View Full Code Here

    {
        final CSSReducer reducer = new CSSReducer(project, cssDocument, abcEmitter, cssCompilationSession, true);
        final CSSEmitter cssEmitter = new CSSEmitter(reducer);
        cssEmitter.burm(cssDocument);
       
        final InstructionList cinit = reducer.getClassInitializationInstructions();
        cinit.addInstruction(ABCConstants.OP_returnvoid);
        final ClassGeneratorHelper helper = new ClassGeneratorHelper(
                project,
                abcEmitter,
                stylesDataClassName,
                (ClassDefinition)project.resolveQNameToDefinition(IASLanguageConstants.Object),
View Full Code Here

     */
    public PairOfInstructionLists reduceDocument(ICSSNode site, PairOfInstructionLists namespaceList, PairOfInstructionLists ruleList)
    {
        // Instructions to push an array object on the stack.
        final int elementSize = ruleList.arrayReduction.getInstructions().size();
        final InstructionList arrayInstructions = new InstructionList();
        arrayInstructions.addAll(ruleList.arrayReduction);
        arrayInstructions.addInstruction(ABCConstants.OP_newarray, elementSize);

        final PairOfInstructionLists pair = new PairOfInstructionLists(arrayInstructions, ruleList.closureReduction);
        generateABC(pair);

        return pair;
View Full Code Here

     * {@code StyleDataClass}.
     */
    private void generateABC(final PairOfInstructionLists pair)
    {
        assert cinitInstructionList == null : "generateABC should only be called once per reducer because each document should only be reduced once.";
        cinitInstructionList = new InstructionList();

        // Generate instructions for "StyleDataClass$cinit()".
        final InstructionList initializeFactoryFunctions = cinitInstructionList;

        // Initialize "factoryFunctions".
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_getlocal0);
        initializeFactoryFunctions.addAll(pair.closureReduction);
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_initproperty, NAME_FACTORY_FUNCTIONS);

        // Initialize "data".
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_getlocal0);
        initializeFactoryFunctions.addAll(pair.arrayReduction);
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_initproperty, NAME_DATA_ARRAY);

        // Initialize "inheritingStyles".
        @SuppressWarnings("unused")
        final String inheritingStylesText =
                Joiner.on(",").skipNulls().join(session.inheritingStyles);
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_getlocal0);
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_pushnull);
        initializeFactoryFunctions.addInstruction(ABCConstants.OP_initproperty, NAME_INHERITING_STYLES);
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.abc.instructionlist.InstructionList

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.