Package org.apache.flex.abc.instructionlist

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


                new Namespace(ABCConstants.CONSTANT_PackageNs, "mx.core"),
                "IFlexModuleFactory");
        paramTypes.add(flexModuleFactoryTypeName);
        methodInfo.setParamTypes(paramTypes);
       
        final InstructionList methodInstructions = new InstructionList();
       
        // super.moduleFactory = factory;
        methodInstructions.addInstruction(ABCConstants.OP_getlocal0);
        methodInstructions.addInstruction(ABCConstants.OP_getlocal1);
        methodInstructions.addInstruction(ABCConstants.OP_setsuper, moduleFactoryName);
       
        // if (mfi)
        //     return;
        Label label1 = new Label();
        methodInstructions.addInstruction(OP_getlocal0);
        methodInstructions.addInstruction(OP_getproperty, NAME_MODULE_FACTORY_INITIALIZED);
        methodInstructions.addInstruction(OP_iffalse, label1);
       
        methodInstructions.addInstruction(OP_returnvoid);
        methodInstructions.labelNext(label1);

        // mfi = true;
        methodInstructions.addInstruction(OP_getlocal0);
        methodInstructions.addInstruction(OP_pushtrue);
        methodInstructions.addInstruction(OP_setproperty, NAME_MODULE_FACTORY_INITIALIZED);
       
        if (hasStyleSpecifiers || hasEffectSpecifiers)
        {
            FlexProject project = this.getProject();
            Name cssStyleDeclarationName = project.getCSSStyleDeclarationClassName();
           
            // Create an anonymous function from the style and effect-style specifiers
            // for the class definition tag. It will be set as the value of
            // styleDeclaration.defaultFactory.
            MethodInfo styleDeclarationDefaultFactory = createStyleDeclarationDefaultFactory(context);
           
            // if (this.styleDeclaration == null)
            //     this.styleDeclaration = new CSSStyleDeclaration(null, this.styleManager);
            Label label2 = new Label();
            methodInstructions.addInstruction(OP_getlocal0);
            methodInstructions.addInstruction(OP_getproperty, NAME_STYLE_DECLARATION);
            methodInstructions.addInstruction(OP_iftrue, label2);
   
            methodInstructions.addInstruction(OP_getlocal0);
            methodInstructions.addInstruction(OP_findpropstrict, cssStyleDeclarationName);
            methodInstructions.addInstruction(OP_pushnull);
            methodInstructions.addInstruction(OP_getlocal0);
            methodInstructions.addInstruction(OP_getproperty, NAME_STYLE_MANAGER);
            methodInstructions.addInstruction(OP_constructprop, new Object[] { cssStyleDeclarationName, 2} );
            methodInstructions.addInstruction(OP_setproperty, NAME_STYLE_DECLARATION);
            methodInstructions.labelNext(label2);
   
            // this.styleDeclaration.defaultFactory = <anonymous function>
            methodInstructions.addInstruction(OP_getlocal0);
            methodInstructions.addInstruction(OP_getproperty, NAME_STYLE_DECLARATION);
            methodInstructions.addInstruction(OP_newfunction, styleDeclarationDefaultFactory);
            methodInstructions.addInstruction(OP_setproperty, NAME_DEFAULT_FACTORY);
        }
       
        if (hasEffectSpecifiers)
        {
            // this.registerEffects([ ... ]);
            methodInstructions.addInstruction(OP_getlocal0);
            methodInstructions.addAll(context.get(IL.MODULE_FACTORY_EFFECTS));
            methodInstructions.addInstruction(OP_newarray, context.getCounter(IL.MODULE_FACTORY_EFFECTS));
            methodInstructions.addInstruction(OP_callpropvoid, REGISTER_EFFECTS_CALL_OPERANDS);
        }
       
        if (hasStyleTags)
        {
            // generateCSSStyleDeclarationsForComponents(super.styleManager, factoryFunctions, data);
            methodInstructions.addInstruction(ABCConstants.OP_getlex, styleManagerReferenceName);
            methodInstructions.addInstruction(ABCConstants.OP_getlocal0);
            methodInstructions.addInstruction(ABCConstants.OP_getsuper, NAME_STYLE_MANAGER);
            methodInstructions.addInstruction(ABCConstants.OP_getlex, CSSReducer.NAME_FACTORY_FUNCTIONS);
            methodInstructions.addInstruction(ABCConstants.OP_getlex, CSSReducer.NAME_DATA_ARRAY);
            methodInstructions.addInstruction(ABCConstants.OP_callproperty, new Object[] { NAME_GENERATE_CSSSTYLEDECLARATIONS, 3 });
        }
       
        // styleManager.initProtoChainRoots();
        methodInstructions.addInstruction(ABCConstants.OP_getlocal0);
        methodInstructions.addInstruction(ABCConstants.OP_getsuper, NAME_STYLE_MANAGER);
        methodInstructions.addInstruction(ABCConstants.OP_callpropvoid, new Object[] {new Name("initProtoChainRoots"), 0 });
        methodInstructions.addInstruction(ABCConstants.OP_returnvoid);
       
        generateMethodBody(methodInfo, classScope, methodInstructions);

        addSetter(moduleFactoryName, methodInfo, true);
    }
View Full Code Here


     * }
     * </pre>
     */
    private MethodInfo createStyleDeclarationDefaultFactory(Context context)
    {
        InstructionList body = new InstructionList();
       
        body.addAll(context.get(IL.MODULE_FACTORY_STYLES));
        body.addAll(context.get(IL.MODULE_FACTORY_EFFECT_STYLES));
        body.addInstruction(OP_returnvoid);
       
        return createNoParameterAnonymousFunction(NAME_VOID, body);
    }
View Full Code Here

        private InstructionList get(IL whichList)
        {
            if (instructionListMap == null)
                instructionListMap = new EnumMap<IL, InstructionList>(IL.class);
           
            InstructionList instructionList = instructionListMap.get(whichList);
           
            if (instructionList == null)
            {
                instructionList = new InstructionList();
                instructionListMap.put(whichList, instructionList);
            }
           
            return instructionList;
        }
View Full Code Here

         * Makes a specified helper instruction list the current one
         * on which addInstruction() etc. will operate.
         */
        void startUsing(IL whichList)
        {
            InstructionList instructionListToUse = get(whichList);
           
            if (instructionListDeque == null)
                instructionListDeque = new ArrayDeque<InstructionList>();
           
            instructionListDeque.push(currentInstructionList);
View Full Code Here

         * Transfers the instructions from one helper list to another
         * and then frees the source list.
          */
        private void transfer(IL source, IL destination)
        {
            InstructionList sourceInstructionList = get(source);
            InstructionList destinationInstructionList = get(destination);
           
            destinationInstructionList.addAll(sourceInstructionList);
                       
            remove(source);
        }
View Full Code Here

         * Transfers the instructions from a helper list to the
         * current list and then frees the source list.
         */
        private void transfer(IL source)
        {
            InstructionList sourceInstructionList = get(source);
           
            currentInstructionList.addAll(sourceInstructionList);
           
            remove(source);
        }
View Full Code Here

    /**
     *  @return the computed GOTO that implements the "return" from a finally block.
     */
    public InstructionList getFinallySwitch()
    {
        InstructionList result = new InstructionList();

        ExceptionHandlingContext finally_context = getFinallyContext();
        int n_alternatives = getFinallyAlternativesSize();

        Label[] finally_labels;
        if ( 0 == n_alternatives )
        {
            finally_labels = new Label[] { finally_context.finallyDoFallthrough, finally_context.finallyDoRethrow };
        }
        else
        {
            finally_labels = new Label[n_alternatives + 2];
            finally_labels[0] = finally_context.finallyDoFallthrough;

            int i = 1;
            for ( ExceptionHandlingContext.FinallyReturn ret: getFinallyContext().finallyReturns )
                finally_labels[i++] = ret.getLabel();

            finally_labels[i] = finally_context.finallyDoRethrow;
        }
        result.addInstruction(OP_lookupswitch, finally_labels);
        return result;
    }
View Full Code Here

     @return the instruction fragment that re-initializes the
     *    enclosing scopes on the scope stack.
     */
    public InstructionList getScopeStackReinit()
    {
        InstructionList result = new InstructionList();
        assert activeFlowContexts.size() >= 2;
        assert activeFlowContexts.lastElement() instanceof LabelScopeControlFlowContext;
       
        for ( int i = 0; i < activeFlowContexts.size() - 2; i++ )
        {
View Full Code Here

    {
        int criterion_index = findControlFlowContext(criterion);

        //  Synthesize an instruction sequence that re-balances the
        //  stack to its condition on entry to this control flow region.
        InstructionList result = original;

        for (int i = criterion_index; i < activeFlowContexts.size(); i++ )
        {
            ControlFlowContext context = activeFlowContexts.elementAt(i);
            result = context.addExitPath(result);
View Full Code Here

    /**
     *  @return a code fragment that sets up the "fail" finally return.
     */
    public InstructionList getFinallyFailSignal()
    {
        InstructionList result = new InstructionList();
        //  Allow for the "success" alternative.
        CmcEmitter.pushNumericConstant(getFinallyAlternativesSize() + 1, result);
        return result;
    }
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.