in modules/asc/src/java/adobe/abc/GlobalOptimizer.java [3138:3275]
void emitBlock(AbcWriter out, Block b, Abc abc)
{
addTraceAttr("Block", b);
// emit all but the last instruction of each block.
for (Expr e: b)
{
// Don't emit control-flow insns here;
// they're handled by intrablock
// processing.
if (e.succ != null)
break;
traceEntry("Expr", "Expr", e);
addTraceAttr("op", opNames[e.op]);
addTraceAttr("pos", out.size());
out.write(e.op);
switch (e.op)
{
case OP_hasnext2:
out.writeU30(e.imm[0]);
out.writeU30(e.imm[1]);
break;
case OP_findproperty:
case OP_findpropstrict:
case OP_getlex:
case OP_getsuper: case OP_setsuper:
case OP_getproperty: case OP_setproperty:
case OP_deleteproperty: case OP_getdescendants:
case OP_initproperty:
case OP_istype:
case OP_coerce:
case OP_astype:
case OP_finddef:
out.writeU30(abc.namePool.id(e.ref));
break;
case OP_callproperty:
case OP_callproplex:
case OP_callpropvoid:
case OP_callsuper:
case OP_callsupervoid:
case OP_constructprop:
out.writeU30(abc.namePool.id(e.ref));
out.writeU30(argc(e));
break;
case OP_constructsuper:
case OP_call:
case OP_construct:
case OP_newarray:
case OP_newobject:
out.writeU30(argc(e));
break;
case OP_getlocal:
case OP_setlocal:
if (e.imm[0] < 4)
{
out.rewind(1);
out.write((e.op == OP_getlocal ? OP_getlocal0 : OP_setlocal0)+e.imm[0]);
break;
}
// else fall through
case OP_getslot:
case OP_setslot:
case OP_kill:
case OP_inclocal:
case OP_declocal:
case OP_inclocal_i:
case OP_declocal_i:
case OP_newcatch:
//case OP_getglobalslot:
//case OP_setglobalslot:
out.writeU30(e.imm[0]);
break;
case OP_newclass:
out.writeU30(abc.classId(e.c));
break;
case OP_newfunction:
out.writeU30(abc.methodId(e.m));
break;
case OP_applytype:
out.writeU30(argc(e));
break;
case OP_callstatic:
//case OP_callmethod:
out.writeU30(abc.methodId(e.m));
out.writeU30(argc(e));
break;
case OP_pushshort:
out.writeU30(intValue(e.value));
break;
case OP_pushbyte:
out.write(intValue(e.value));
break;
case OP_getscopeobject:
out.write(e.imm[0]);
break;
case OP_pushstring:
case OP_dxns:
out.writeU30(abc.stringPool.id((String)e.value));
break;
case OP_debugfile:
if (STRIP_DEBUG_INFO)
throw new RuntimeException("impossible");
out.writeU30(abc.stringPool.id((String)e.value));
break;
case OP_pushnamespace:
out.writeU30(abc.nsPool.id((Namespace)e.value));
break;
case OP_pushint:
out.writeU30(abc.intPool.id(intValue(e.value)));
break;
case OP_pushuint:
out.writeU30(abc.uintPool.id(uintValue(e.value)));
break;
case OP_pushdouble:
out.writeU30(abc.doublePool.id(doubleValue(e.value)));
break;
case OP_debugline:
case OP_bkptline:
if (STRIP_DEBUG_INFO)
throw new RuntimeException("impossible");
out.writeU30(e.imm[0]);
break;
case OP_debug:
if (STRIP_DEBUG_INFO)
throw new RuntimeException("impossible");
out.write(e.imm[0]);
out.writeU30(e.imm[1]);
out.write(e.imm[2]);
out.writeU30(e.imm[3]);
break;
}
}
}