Package org.apache.flex.abc.instructionlist

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


    public InstructionList reduce_postIncBracketExpr(IASNode iNode, InstructionList stem, InstructionList index, boolean need_result)
    {       
        IDynamicAccessNode arrayIndexNode = (IDynamicAccessNode)((IUnaryOperatorNode)iNode).getOperandNode();

        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, true);
        InstructionList result = createInstructionList(iNode);

        result.addAll(stem);
        result.addInstruction(OP_dup);
        Binding stem_tmp = currentScope.allocateTemp();
        result.addInstruction(stem_tmp.setlocal() );

        result.addAll(index);
        result.addInstruction(OP_dup);

        //  Get the initial value, and dup a copy
        //  onto the stack as the value of this expression.
        Binding index_tmp = currentScope.allocateTemp();
        result.addInstruction(index_tmp.setlocal() );
        result.addInstruction(arrayAccess(arrayIndexNode, OP_getproperty));
        result.addInstruction(op_unplus());
       
        if( need_result )
            result.addInstruction(OP_dup);

        result.addInstruction(OP_increment);
        Binding result_tmp = currentScope.allocateTemp();
        result.addInstruction(result_tmp.setlocal());

        result.addInstruction(stem_tmp.getlocal() );
        result.addInstruction(index_tmp.getlocal() );
        result.addInstruction(result_tmp.getlocal() );
        result.addInstruction(arrayAccess(arrayIndexNode, OP_setproperty));

        currentScope.releaseTemp(stem_tmp);
        currentScope.releaseTemp(index_tmp);
        currentScope.releaseTemp(result_tmp);
View Full Code Here


    public InstructionList reduce_postIncMemberExpr(IASNode iNode, InstructionList stem, Binding field, boolean need_result)
    {
        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, true, field);

        InstructionList result = createInstructionList(iNode);
        result.addAll(stem);
        result.addInstruction(OP_dup);
        result.addInstruction(OP_getproperty, field.getName());
        result.addInstruction(op_unplus());

        //  Save a copy of the original value to use as the value of this expression.
        Binding orig_tmp = null;
        if( need_result )
        {
            result.addInstruction(OP_dup);
            orig_tmp = currentScope.allocateTemp();
            result.addInstruction(orig_tmp.setlocal() );
        }
       
        result.addInstruction(OP_increment);
        result.addInstruction(OP_setproperty, field.getName());

        if( need_result )
        {
            result.addInstruction(orig_tmp.getlocal() );
            currentScope.releaseTemp(orig_tmp);
        }

        return result;
    }
View Full Code Here

    public InstructionList reduce_postIncNameExpr(IASNode iNode, Binding unary, boolean need_result)
    {
        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, true, unary);

        InstructionList result = createInstructionList(iNode);

        if ( unary.isLocal() ) {
            ICompilerProject project = currentScope.getProject();

            IDefinition inType = SemanticUtils.resolveUnaryExprType(iNode, project);

            IDefinition intType = project.getBuiltinType(BuiltinType.INT);
            IDefinition numberType = project.getBuiltinType(BuiltinType.NUMBER);
            if( inType == intType)
            {
                // Incrementing a local, typed as int
                // we can use inclocal_i since we know the result will be stored in an int
                if( need_result )
                    result.addInstruction(unary.getlocal());
                result.addInstruction(unary.inclocal_i());
            }
            else if( inType == numberType)
            {
                // Incrementing a local, typed as Number
                // we can use inclocal since we know the result will be stored in a Number
                if( need_result )
                    result.addInstruction(unary.getlocal());
                result.addInstruction(unary.inclocal());
            }
            else
            {
                result.addInstruction(unary.getlocal());
                result.addInstruction(op_unplus());
                if( need_result )
                    result.addInstruction(OP_dup);
                result.addInstruction(OP_increment);
                coerce(result, inType);
                result.addInstruction(unary.setlocal());
            }
        }
        else
        {
            Name n = unary.getName();
            result.addAll(currentScope.findProperty(unary, true));
            result.addInstruction(OP_getproperty,n);
            result.addInstruction(op_unplus());
            if( need_result )
                result.addInstruction(OP_dup);
            result.addInstruction(OP_increment);
            result.addAll(currentScope.findProperty(unary, true));
            result.addInstruction(OP_swap);
            result.addInstruction(OP_setproperty,n);
        }

        return result;
    }
View Full Code Here

    {
        IDynamicAccessNode arrayIndexNode = (IDynamicAccessNode)((IUnaryOperatorNode)iNode).getOperandNode();

        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, false);
       
        InstructionList result = createInstructionList(iNode);

        result.addAll(stem);
        Binding stem_tmp = currentScope.allocateTemp();
        result.addInstruction(OP_dup);
        result.addInstruction(stem_tmp.setlocal() );

        result.addAll(index);
        result.addInstruction(OP_dup);

        //  Get the initial value.
        Binding index_tmp = currentScope.allocateTemp();
        result.addInstruction(index_tmp.setlocal());
        result.addInstruction(arrayAccess(arrayIndexNode, OP_getproperty));

        //  Increment, and dup a copy onto
        //  the stack as the value of this expression.
        result.addInstruction(OP_decrement);
        if( need_result )
            result.addInstruction(OP_dup);
        Binding result_tmp = currentScope.allocateTemp();
        result.addInstruction(result_tmp.setlocal());

        result.addInstruction(stem_tmp.getlocal() );
        result.addInstruction(index_tmp.getlocal() );
        result.addInstruction(result_tmp.getlocal() );
        result.addInstruction(arrayAccess(arrayIndexNode, OP_setproperty));

        currentScope.releaseTemp(stem_tmp);
        currentScope.releaseTemp(index_tmp);
        currentScope.releaseTemp(result_tmp);
View Full Code Here

    public InstructionList reduce_preDecMemberExpr(IASNode iNode, InstructionList stem, Binding field, boolean need_result)
    {
        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, false, field);
       
        InstructionList result = createInstructionList(iNode);
        result.addAll(stem);
        result.addInstruction(OP_dup);
        result.addInstruction(OP_getproperty, field.getName());
        result.addInstruction(OP_decrement);

        Binding result_tmp = null;
        //  Save a copy of the result to use as the value of this expression.
        if( need_result )
        {
            result.addInstruction(OP_dup);
            result_tmp = currentScope.allocateTemp();
            result.addInstruction(result_tmp.setlocal() );
        }

        result.addInstruction(OP_setproperty, field.getName());

        if( need_result )
        {
            result.addInstruction(result_tmp.getlocal() );
            currentScope.releaseTemp(result_tmp);
        }
       
        return result;
    }
View Full Code Here

    public InstructionList reduce_preDecNameExpr(IASNode iNode, Binding unary, boolean need_result)
    {
        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, false, unary);

        InstructionList result = createInstructionList(iNode);

        if ( unary.isLocal() ) {
            ICompilerProject project = currentScope.getProject();

            IDefinition inType = SemanticUtils.resolveUnaryExprType(iNode, project);

            IDefinition intType = project.getBuiltinType(BuiltinType.INT);
            IDefinition numberType = project.getBuiltinType(BuiltinType.NUMBER);
            if( inType == intType)
            {
                // Decrementing a local, typed as int
                // we can use declocal_i since we know the result will be stored in an int
                result.addInstruction(unary.declocal_i());
                if( need_result )
                    result.addInstruction(unary.getlocal());
            }
            else if( inType == numberType)
            {
                // Decrementing a local, typed as Number
                // we can use declocal since we know the result will be stored in a Number
                result.addInstruction(unary.declocal());
                if( need_result )
                    result.addInstruction(unary.getlocal());
            }
            else
            {
                result.addInstruction(unary.getlocal());
                result.addInstruction(OP_decrement);
                if( need_result )
                    result.addInstruction(OP_dup);
                coerce(result, inType);
                result.addInstruction(unary.setlocal());
            }
        }
        else
        {
            Name n = unary.getName();
            result.addAll(currentScope.findProperty(unary, true));
            result.addInstruction(OP_getproperty,n);
            result.addInstruction(OP_decrement);
            if( need_result )
                result.addInstruction(OP_dup);
            result.addAll(currentScope.findProperty(unary, true));
            result.addInstruction(OP_swap);
            result.addInstruction(OP_setproperty,n);
        }

        return result;
    }
View Full Code Here

    public InstructionList reduce_preIncBracketExpr(IASNode iNode, InstructionList stem, InstructionList index, boolean need_result)
    {
        IDynamicAccessNode arrayIndexNode = (IDynamicAccessNode)((IUnaryOperatorNode)iNode).getOperandNode();

        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, true);
        InstructionList result = createInstructionList(iNode);

        result.addAll(stem);
        Binding stem_tmp = currentScope.allocateTemp();
        result.addInstruction(OP_dup);
        result.addInstruction(stem_tmp.setlocal() );

        result.addAll(index);
        result.addInstruction(OP_dup);

        //  Get the initial value.
        Binding index_tmp = currentScope.allocateTemp();
        result.addInstruction(index_tmp.setlocal() );
        result.addInstruction(arrayAccess(arrayIndexNode, OP_getproperty));

        //  Increment, and dup a copy onto
        //  the stack as the value of this expression.
        result.addInstruction(OP_increment);
        if( need_result )
            result.addInstruction(OP_dup);
        Binding result_tmp = currentScope.allocateTemp();
        result.addInstruction(result_tmp.setlocal() );

        result.addInstruction(stem_tmp.getlocal() );
        result.addInstruction(index_tmp.getlocal());
        result.addInstruction(result_tmp.getlocal());
        result.addInstruction(arrayAccess(arrayIndexNode, OP_setproperty));

        currentScope.releaseTemp(stem_tmp);
        currentScope.releaseTemp(index_tmp);
        currentScope.releaseTemp(result_tmp);
View Full Code Here

    public InstructionList reduce_preIncMemberExpr(IASNode iNode, InstructionList stem, Binding field, boolean need_result)
    {
        currentScope.getMethodBodySemanticChecker().checkIncDec(iNode, true, field);

        InstructionList result = createInstructionList(iNode);
        result.addAll(stem);
        result.addInstruction(OP_dup);
        result.addInstruction(OP_getproperty, field.getName());
        result.addInstruction(OP_increment);

        Binding result_tmp = null;
        //  Save a copy of the result to use as the value of this expression.
        if( need_result )
        {
            result.addInstruction(OP_dup);
            result_tmp = currentScope.allocateTemp();
            result.addInstruction(result_tmp.setlocal());
        }
       
        result.addInstruction(OP_setproperty, field.getName());

        if( need_result )
        {
            result.addInstruction(result_tmp.getlocal());
            currentScope.releaseTemp(result_tmp);
        }

        return result;
    }
View Full Code Here

        return result;
    }

    public InstructionList reduce_XMLList(IASNode iNode, Vector<InstructionList> exprs)
    {
        InstructionList result = createInstructionList(iNode);
        result.addAll(currentScope.getPropertyValue(xmlListType, currentScope.getProject().getBuiltinType(BuiltinType.XMLLIST)));
        //  The first and last elements are the <> and </> brackets.
        //  An empty XMLList <></> should be reduced by the constant
        //  case, below, so we know we have at least one element.
        result.addAll(exprs.get(1));
        for ( int i = 2; i < exprs.size() - 1; i++ )
        {
            result.addAll(exprs.get(i));
            result.addInstruction(OP_add);
        }
        result.addInstruction(OP_construct, 1);
        return result;
    }
View Full Code Here

        return result;
    }

    public InstructionList reduce_XMLListConst(IASNode iNode, Vector<String> elements)
    {
        InstructionList result = createInstructionList(iNode);
        result.addAll(currentScope.getPropertyValue(xmlListType, currentScope.getProject().getBuiltinType(BuiltinType.XMLLIST)));
        StringBuilder buffer = new StringBuilder();
        //  The first and last elements are the <> and </> brackets.
        for ( int i = 1; i < elements.size() -1; i++ )
            buffer.append(elements.elementAt(i));
        result.addInstruction(OP_pushstring, buffer.toString());
        result.addInstruction(OP_construct, 1);
        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.