Package org.apache.flex.abc.semantics

Examples of org.apache.flex.abc.semantics.Label


    }

    public InstructionList reduce_logicalOrExpr(IASNode iNode, InstructionList l, InstructionList r)
    {
        InstructionList result = createInstructionList(iNode, l.size() + r.size() + 3);
        Label tail = new Label();

        result.addAll(l);
        result.addInstruction(OP_dup);
        result.addInstruction(OP_iftrue, tail);
        result.addInstruction(OP_pop);
View Full Code Here


     */
    private void addRelevantReturnOpcode(FunctionDefinition functionDef, int opcode, InstructionList result)
    {
        if (currentScope.insideInlineFunction())
        {
            Label inlinedFunctionCallSiteLabel = ((InlineFunctionLexicalScope)currentScope).getInlinedFunctionCallSiteLabel();
            switch (opcode)
            {
                case OP_returnvoid:
                {
                    // returnvoid pushes undefined onto the stack, so mimic that behavior
View Full Code Here

            lookupSwitchInfo.maxCase = lookupSwitchInfo.maxCase - caseOffset;
            result.addInstruction(OP_pushint, new Integer(lookupSwitchInfo.minCase + 1));
            result.addInstruction(OP_add_i);
        }

        Label switchTail = null;
        Label defaultLabel;

        if (lookupSwitchInfo.defaultCase != null)
            defaultLabel = lookupSwitchInfo.defaultCase.getLabel();
        else
            defaultLabel = switchTail = new Label();

        // generate the case table, maxCase+2, as count from zero
        // and add one for the default label at the end
        Label[] caseLabels = new Label[lookupSwitchInfo.maxCase + 2];

        // pre-fill the case label table with the default label.
        Arrays.fill(caseLabels, defaultLabel);

        // fill in specific labels for any specified values
        for (ConditionalFragment current_case : cases)
        {
            if (current_case.isUnconditionalAlternative())
                continue;

            Object caseValue = current_case.constantCondition;
            // a constant of value 90000 was in a SWC as a double even though
            // the type of the constant was int
            if (caseValue instanceof Double)
                caseValue = new Integer(((Double)caseValue).intValue());
            assert (caseValue instanceof Integer) : "reduce_lookup_switchStmt called on non integer case value";
            final int index = (Integer)caseValue - caseOffset;
            // if there is already a non-default value for this
            // index, ignore it, as only the first case counts
            if (caseLabels[index] != defaultLabel)
                continue;

            caseLabels[index] = current_case.getLabel();
        }

        result.addInstruction(OP_lookupswitch, caseLabels);

        Label default_case_label = null;
        for (ConditionalFragment current_case : cases)
        {
            if (current_case.isUnconditionalAlternative())
            {
                //  The parser rejects duplicate default alternatives
View Full Code Here

        // a lookup switch
        convertConstantValueConditionsToInstructions(cases);

        //  TODO: Optimize InstructionList size.
        InstructionList result = createInstructionList(iNode);
        Label default_case_label = null;
        Label switch_tail = null;

        //  Get the switch value and save it in a temp.
        Binding switch_temp = currentScope.allocateTemp();
        result.addAll(switch_expr);
        result.addInstruction(switch_temp.setlocal());
View Full Code Here

        IDefinition type_def; //= valueNode.resolveType(currentScope.getProject()); //SemanticUtils.getDefinitionOfUnderlyingType(,
                           // true, currentScope.getProject());
        boolean need_coerce = false;
       
        InstructionList result = createInstructionList(iNode, test.size() + when_true.size() + when_false.size() + 2);
        Label tail = new Label();

        result.addAll(test);
        result.addInstruction(OP_iffalse, when_false.getLabel());
        result.addAll(when_true);
        valueNode = ternaryNode.getLeftOperandNode();
View Full Code Here

        callInContext.addInstruction(ABCConstants.OP_getlocal1);
        callInContext.addInstruction(ABCConstants.OP_getlocal2);
        callInContext.addInstruction(ABCConstants.OP_getlocal3);
        callInContext.addInstruction(ABCConstants.OP_callproperty, new Object[] {applyReference.getMName(), 2});
        callInContext.addInstruction(ABCConstants.OP_getlocal, 4);
        Label callInContextReturnVoid = new Label();
        callInContext.addInstruction(ABCConstants.OP_iffalse, callInContextReturnVoid);
        callInContext.addInstruction(ABCConstants.OP_returnvalue);
        callInContext.labelNext(callInContextReturnVoid);
        // TODO This should be OP_returnvoid, but the Boolean default value
        // for the 'returns' parameter isn't defaulting to true.
View Full Code Here

        Name getDefinitionByName = getDefinitionByNameReference.getMName();
        InstructionList create = new InstructionList();
        create.addInstruction(ABCConstants.OP_getlocal1);
        create.addInstruction(ABCConstants.OP_getproperty, new Name("length"));
        create.addInstruction(ABCConstants.OP_pushbyte, 0);
        Label createL1 = new Label();
        create.addInstruction(ABCConstants.OP_ifgt, createL1);
        create.addInstruction(ABCConstants.OP_findproperty, mainApplicationName);
        create.addInstruction(ABCConstants.OP_getproperty, mainApplicationName);
        Label createL3 = new Label();
        create.addInstruction(ABCConstants.OP_jump, createL3);
        create.labelNext(createL1);
        create.addInstruction(ABCConstants.OP_getlocal1);
        create.addInstruction(ABCConstants.OP_getproperty, new Name("0"));
        create.addInstruction(ABCConstants.OP_istype, new Name("String"));
        Label createL2 = new Label();
        create.addInstruction(ABCConstants.OP_iffalse, createL2);
        create.addInstruction(ABCConstants.OP_finddef, getDefinitionByName);
        create.addInstruction(ABCConstants.OP_getlocal1);
        create.addInstruction(ABCConstants.OP_getproperty, new Name("0"));
        create.addInstruction(ABCConstants.OP_callproperty, new Object[] {getDefinitionByName, 1});
        create.addInstruction(ABCConstants.OP_jump, createL3);
        create.labelNext(createL2);
        create.addInstruction(ABCConstants.OP_getlocal0);
        create.addInstruction(ABCConstants.OP_getsuper, new Name("create"));
        create.addInstruction(ABCConstants.OP_getlocal0);
        create.addInstruction(ABCConstants.OP_getlocal1);
        create.addInstruction(ABCConstants.OP_callproperty, new Object[] {applyReference.getMName(), 2});
        create.addInstruction(ABCConstants.OP_returnvalue);
        create.labelNext(createL3);
        create.addInstruction(ABCConstants.OP_astype, new Name("Class"));
        create.addInstruction(ABCConstants.OP_dup);
        Label createL5 = new Label();
        create.addInstruction(ABCConstants.OP_iffalse, createL5);
        create.addInstruction(ABCConstants.OP_construct, 0);
        create.addInstruction(ABCConstants.OP_dup);
        create.addInstruction(ABCConstants.OP_istype, iFlexModule.getMName());
        Label createL4 = new Label();
        create.addInstruction(ABCConstants.OP_iffalse, createL4);
        create.addInstruction(ABCConstants.OP_dup);
        create.addInstruction(ABCConstants.OP_getlocal0);
        create.addInstruction(ABCConstants.OP_setproperty, new Name("moduleFactory"));
        create.labelNext(createL4);
View Full Code Here

        InstructionList info = new InstructionList();
        info.addInstruction(ABCConstants.OP_getlocal0);
        info.addInstruction(ABCConstants.OP_getproperty, infoSlotName);
        info.addInstruction(ABCConstants.OP_dup);
        Label infoL1 = new Label();
        info.addInstruction(ABCConstants.OP_iftrue, infoL1);

        int infoEntries = 0;
       
        // currentDomain:
View Full Code Here

        insns.addInstruction(OP_getproperty, new Name("length"));   // stack: _bindings.length, _bindings
        insns.addInstruction(OP_setlocal2);        
        // now stack: _bindings
     
        //---------------------- LOOP OVER BINDINGS ----------------
        Label label = new Label();
       
        insns.addInstruction(OP_label);
        insns.labelCurrent(label);
        insns.addInstruction(OP_dup);            // stack: _bindings, _bindings
        insns.addInstruction(OP_getlocal1);     // stack: index, _bindings, _bindings
View Full Code Here

            InstructionList body = new InstructionList();
            Name scale9Grid = new Name("scale9Grid");
            body.addInstruction(ABCConstants.OP_getlocal0);
            body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);

            Label trueLabel = new Label();
            body.addInstruction(ABCConstants.OP_iftrue, trueLabel);

            Name edgeMetrics = ReferenceFactory.packageQualifiedReference(workspace, CORE_PACKAGE + ".EdgeMetrics").getMName();
            body.addInstruction(ABCConstants.OP_getlex, edgeMetrics);
            body.addInstruction(ABCConstants.OP_getproperty, new Name("EMPTY"));
            body.addInstruction(ABCConstants.OP_returnvalue);

            body.labelNext(trueLabel);
            body.addInstruction(ABCConstants.OP_findpropstrict, edgeMetrics);
           
            body.addInstruction(ABCConstants.OP_getlocal0);
            body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
            body.addInstruction(ABCConstants.OP_getproperty, new Name("left"));

            body.addInstruction(ABCConstants.OP_getlocal0);
            body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
            body.addInstruction(ABCConstants.OP_getproperty, new Name("top"));

            Name math = new Name("Math");
            body.addInstruction(ABCConstants.OP_getlex, math);
            body.addInstruction(ABCConstants.OP_getlocal0);

            body.addInstruction(ABCConstants.OP_getproperty, new Name("measuredWidth"));
            body.addInstruction(ABCConstants.OP_getlocal0);
            body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
            body.addInstruction(ABCConstants.OP_getproperty, new Name("right"));
            body.addInstruction(ABCConstants.OP_subtract);

            Object[] ceil = new Object[] {new Name("ceil"), 1};
            body.addInstruction(ABCConstants.OP_callproperty, ceil);
            body.addInstruction(ABCConstants.OP_getlex, math);
            body.addInstruction(ABCConstants.OP_getlocal0);

            body.addInstruction(ABCConstants.OP_getproperty, new Name("measuredHeight"));
            body.addInstruction(ABCConstants.OP_getlocal0);
            body.addInstruction(ABCConstants.OP_getproperty, scale9Grid);
            body.addInstruction(ABCConstants.OP_getproperty, new Name("bottom"));
            body.addInstruction(ABCConstants.OP_subtract);

            body.addInstruction(ABCConstants.OP_callproperty, ceil);
            body.addInstruction(ABCConstants.OP_constructprop, new Object[] {edgeMetrics, 4});
            body.addInstruction(ABCConstants.OP_returnvalue);

            classGen.addITraitsGetter(new Name("borderMetrics"), edgeMetrics, body);
        }

        if (skinClassInfo.needsIFlexDisplayObject)
        {
            // generate:
            // public function get measuredWidth():Number
            // {
            //     return _measuredWidth;
            // }
            if (skinClassInfo.needsMeasuredWidth)
            {
                InstructionList body = new InstructionList();
                body.addInstruction(ABCConstants.OP_getlocal0);
                body.addInstruction(ABCConstants.OP_getproperty, _measuredWidth);
                body.addInstruction(ABCConstants.OP_returnvalue);

                classGen.addMemberVariable(_measuredWidth, numberName);
                classGen.addITraitsGetter(new Name("measuredWidth"), numberName, body);
            }

            // generate:
            // public function get measuredHeight():Number
            // {
            //     return _measuredHeight;
            // }
            if (skinClassInfo.needsMeasuredHeight)
            {
                InstructionList body = new InstructionList();
                body.addInstruction(ABCConstants.OP_getlocal0);
                body.addInstruction(ABCConstants.OP_getproperty, _measuredHeight);
                body.addInstruction(ABCConstants.OP_returnvalue);

                classGen.addMemberVariable(_measuredHeight, numberName);
                classGen.addITraitsGetter(new Name("measuredHeight"), numberName, body);
            }

            // generate:
            // public function move(x:Number, y:Number):void
            // {
            //     this.x = x;
            //     this.y = y;
            // }
            if (skinClassInfo.needsMove)
            {
                InstructionList body = new InstructionList();

                body.addInstruction(ABCConstants.OP_getlocal0);
                body.addInstruction(ABCConstants.OP_getlocal1);
                body.addInstruction(ABCConstants.OP_setproperty, new Name("x"));

                body.addInstruction(ABCConstants.OP_getlocal0);
                body.addInstruction(ABCConstants.OP_getlocal2);
                body.addInstruction(ABCConstants.OP_setproperty, new Name("y"));

                body.addInstruction(ABCConstants.OP_returnvoid);

                Collection<Name> paramTypes = new ImmutableList.Builder<Name>()
                .add(numberName)
                .add(numberName)
                .build();

                classGen.addITraitsMethod(new Name("move"), paramTypes, new Name("void"), Collections.<Object>emptyList(), false, false, false, body);
            }

            // generate:
            // public function setActualSize(newWidth:Number, newHeight:Number):void
            // {
            //     if (width != newWidth)
            //     {
            //         width = newWidth;
            //     }
            //     if (height != newHeight)
            //     {
            //         height = newHeight;
            //     }
            // }
            if (skinClassInfo.needsSetActualSize)
            {
                InstructionList body = new InstructionList();

                Name width = new Name("width");
                body.addInstruction(ABCConstants.OP_getlocal0);
                body.addInstruction(ABCConstants.OP_getproperty, width);
                body.addInstruction(ABCConstants.OP_getlocal1);

                Label trueLabel = new Label();
                body.addInstruction(ABCConstants.OP_ifeq, trueLabel);

                body.addInstruction(ABCConstants.OP_findproperty, width);
                body.addInstruction(ABCConstants.OP_getlocal1);
                body.addInstruction(ABCConstants.OP_setproperty, width);

                body.labelNext(trueLabel);

                Name height = new Name("height");
                body.addInstruction(ABCConstants.OP_getlocal0);
                body.addInstruction(ABCConstants.OP_getproperty, height);
                body.addInstruction(ABCConstants.OP_getlocal2);

                trueLabel = new Label();
                body.addInstruction(ABCConstants.OP_ifeq, trueLabel);

                body.addInstruction(ABCConstants.OP_findproperty, height);
                body.addInstruction(ABCConstants.OP_getlocal2);
                body.addInstruction(ABCConstants.OP_setproperty, height);
View Full Code Here

TOP

Related Classes of org.apache.flex.abc.semantics.Label

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.