public void visitInstruction()

in compiler/src/main/java/org/apache/royale/abc/semantics/FrameCountVisitor.java [136:469]


    public void visitInstruction(Instruction i)
    {
        switch (i.opcode)
        {
            case OP_add:
            case OP_add_i:
            case OP_astypelate:
            case OP_bitand:
            case OP_bitor:
            case OP_bitxor:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_applytype:
            case OP_astype:
            case OP_bitnot:
            case OP_bkpt:
            case OP_bkptline:
            case OP_checkfilter:
            case OP_coerce:
            case OP_coerce_a:
            case OP_coerce_i:
            case OP_coerce_d:
            case OP_coerce_s:
            case OP_coerce_u:
            case OP_convert_b:
            case OP_convert_d:
            case OP_convert_i:
            case OP_convert_o:
            case OP_convert_s:
            case OP_convert_u:
            case OP_debug:
            case OP_debugfile:
            case OP_debugline:
            case OP_declocal:
            case OP_declocal_i:
            case OP_decrement:
            case OP_decrement_i:
            case OP_dxns:
            case OP_esc_xattr:
            case OP_esc_xelem:
            case OP_inclocal:
            case OP_inclocal_i:
            case OP_increment:
            case OP_increment_i:
            case OP_jump:
            case OP_kill:
            case OP_label:
            case OP_negate:
            case OP_negate_i:
            case OP_returnvoid:
            case OP_nop:
            case OP_not:
            case OP_swap:
            case OP_timestamp:
            case OP_typeof:
            case OP_unplus:
                // Net effect zero.
                break;

            case OP_call:
                stkdepth = adjustValueStack(stkdepth, -(i.getImmediate() + 1));
                break;

            case OP_callmethod:
                assert false : "internal only instruction!";
                stkdepth = adjustValueStack(stkdepth, -i.getImmediate());
                break;

            case OP_callstatic:
                stkdepth = adjustValueStack(stkdepth, -((Integer)i.getOperand(1)));
                break;

            case OP_callproperty:
            case OP_callproplex:
            case OP_callsuper:
            case OP_constructprop:
                stkdepth = adjustValueStack(stkdepth, -((Integer)i.getOperand(1)) + runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_callpropvoid:
            case OP_callsupervoid:
                // void calls do not push a result
                stkdepth = adjustValueStack(stkdepth, -((Integer)i.getOperand(1)) + runtimeNameAllowance((Name)i.getOperand(0)) - 1);
                break;

            case OP_construct:
                stkdepth = adjustValueStack(stkdepth, -i.getImmediate());
                break;

            case OP_constructsuper:
                stkdepth = adjustValueStack(stkdepth, -i.getImmediate() - 1);
                break;

            case OP_deleteproperty:
                stkdepth = adjustValueStack(stkdepth, runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_divide:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;
            case OP_dup:
                stkdepth = adjustValueStack(stkdepth, 1);
                break;
            case OP_dxnslate:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;
            case OP_equals:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;
            case OP_finddef:
            case OP_findproperty:
            case OP_findpropstrict:
                stkdepth = adjustValueStack(stkdepth, 1 + runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_getdescendants:
            case OP_getproperty:
            case OP_getsuper:
                stkdepth = adjustValueStack(stkdepth, runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_getglobalscope:
            case OP_getglobalslot:
            case OP_getlex:
            case OP_getouterscope:
                stkdepth = adjustValueStack(stkdepth, 1);
                break;

            case OP_getlocal:
                stkdepth = adjustValueStack(stkdepth, 1);
                adjustMaxLocal(i.getImmediate());
                if (i.getImmediate() < 4)
                    i.opcode = OP_getlocal0 + i.getImmediate();
                break;
            case OP_getlocal0:
            case OP_getlocal1:
            case OP_getlocal2:
            case OP_getlocal3:
                stkdepth = adjustValueStack(stkdepth, 1);
                adjustMaxLocal(i.opcode - OP_getlocal0);
                break;

            case OP_getslot:
                if (i.getImmediate() > max_slot)
                    max_slot = i.getImmediate();
                break;

            case OP_getscopeobject:
                stkdepth = adjustValueStack(stkdepth, 1);
                break;

            case OP_greaterequals:
            case OP_greaterthan:
            case OP_hasnext:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;
            case OP_hasnext2:
            {
                //  Both hasnext2 operands are locals.
                adjustMaxLocal((Integer)i.getOperand(0));
                adjustMaxLocal((Integer)i.getOperand(1));
                stkdepth = adjustValueStack(stkdepth, 1);
                break;
            }
            case OP_ifeq:
            case OP_ifge:
            case OP_ifgt:
            case OP_ifle:
            case OP_iflt:
            case OP_ifnge:
            case OP_ifngt:
            case OP_ifnle:
            case OP_ifnlt:
            case OP_ifne:
            case OP_ifstricteq:
            case OP_ifstrictne:
                stkdepth = adjustValueStack(stkdepth, -2);
                break;
            case OP_iffalse:
            case OP_iftrue:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_in:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_initproperty:
                stkdepth = adjustValueStack(stkdepth, -2 + runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_instanceof:
            case OP_istypelate:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_istype:
                stkdepth = adjustValueStack(stkdepth, runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_lessequals:
            case OP_lessthan:
            case OP_lookupswitch:
            case OP_lshift:
            case OP_modulo:
            case OP_multiply:
            case OP_multiply_i:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_newactivation:
            case OP_newcatch:
            case OP_newfunction:
                stkdepth = adjustValueStack(stkdepth, 1);
                break;

            case OP_newarray:
                stkdepth = adjustValueStack(stkdepth, 1 - i.getImmediate());
                break;

            case OP_newobject:
                //  The operands are name-value pairs.
                stkdepth = adjustValueStack(stkdepth, 1 - (i.getImmediate() * 2));
                break;

            case OP_nextname:
            case OP_nextvalue:
            case OP_pop:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_popscope:
                scpdepth = adjustScopeStack(scpdepth, -1);
                break;

            case OP_pushbyte:
            case OP_pushdouble:
            case OP_pushfalse:
            case OP_pushint:
            case OP_pushnamespace:
            case OP_pushnan:
            case OP_pushnull:
            case OP_pushshort:
            case OP_pushstring:
            case OP_pushtrue:
            case OP_pushuint:
            case OP_pushundefined:
                stkdepth = adjustValueStack(stkdepth, 1);
                break;

            case OP_pushscope:
            case OP_pushwith:
                stkdepth = adjustValueStack(stkdepth, -1);
                scpdepth = adjustScopeStack(scpdepth, 1);
                break;

            case OP_returnvalue:
            case OP_rshift:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_setlocal:
                stkdepth = adjustValueStack(stkdepth, -1);
                adjustMaxLocal(i.getImmediate());
                if (i.getImmediate() < 4)
                    i.opcode = OP_setlocal0 + i.getImmediate();
                break;
            case OP_setlocal0:
            case OP_setlocal1:
            case OP_setlocal2:
            case OP_setlocal3:
                stkdepth = adjustValueStack(stkdepth, -1);
                adjustMaxLocal(i.opcode - OP_setlocal0);
                break;

            case OP_setglobalslot:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_setproperty:
            case OP_setsuper:
                stkdepth = adjustValueStack(stkdepth, -2 + runtimeNameAllowance((Name)i.getOperand(0)));
                break;

            case OP_setslot:
                stkdepth = adjustValueStack(stkdepth, -2);
                if (max_slot < i.getImmediate())
                    max_slot = i.getImmediate();
                break;

            case OP_strictequals:
            case OP_subtract:
            case OP_subtract_i:
            case OP_throw:
            case OP_urshift:
                stkdepth = adjustValueStack(stkdepth, -1);
                break;

            case OP_newclass:
                this.hasNewclass = true;
                break;

            case OP_li8:
            case OP_li16:
            case OP_li32:
            case OP_lf32:
            case OP_lf64:
            case OP_sxi1:
            case OP_sxi8:
            case OP_sxi16:
                // consume one stack entry, and produce 1 stack entry.
                break;
            case OP_si8:
            case OP_si16:
            case OP_si32:
            case OP_sf32:
            case OP_sf64:
                // consume two stack entries
                stkdepth = adjustValueStack(stkdepth, -2);
                break;

            case OP_callinterface:
            case OP_callsuperid:
            case OP_deletepropertylate:
            case OP_setpropertylate:
                assert false : "internal only instruction!";
                break;
            default:
                assert false : "unknown instruction!";
                break;
        }
        this.instructionIndex++;
    }