+
+ if(next) return code_end(next);
+ else return prev;
+}
+
+code_t*code_cutlast(code_t*c)
+{
+ if(!c) return c;
+ assert(!c->next);
+ return code_cut(c);
+}
+
+code_t* cut_last_push(code_t*c)
+{
+ assert(!c->next);
+ while(c) {
+ if(!c) break;
+ opcode_t*op = opcode_get(c->opcode);
+ /* cut conversion type operations */
+ if(op->stack_minus == -1 && op->stack_plus == 1 && !(op->flags)) {
+ c = code_cutlast(c);
+ continue;
+ }
+ /* cut any type of push */
+ else if(op->stack_minus == 0 && op->stack_plus == 1 && !(op->flags)) {
+ return code_cutlast(c);
+ }
+ /* cut register lookups */
+ else if(c->opcode == OPCODE_GETLOCAL ||
+ c->opcode == OPCODE_GETLOCAL_0 ||
+ c->opcode == OPCODE_GETLOCAL_1 ||
+ c->opcode == OPCODE_GETLOCAL_2 ||
+ c->opcode == OPCODE_GETLOCAL_3) {
+ return code_cutlast(c);
+ }
+ /* discard function call values */
+ else if(c->opcode == OPCODE_CALLPROPERTY) {
+ c->opcode = OPCODE_CALLPROPVOID;
+ return c;
+ } else if(c->opcode == OPCODE_CALLSUPER) {
+ c->opcode = OPCODE_CALLSUPERVOID;
+ return c;
+ } else if(c->opcode == OPCODE_NEWOBJECT ||
+ c->opcode == OPCODE_NEWARRAY) {
+ // we can discard these if they're not eating up stack parameters
+ if(!c->data[0])
+ return code_cutlast(c);
+ } else if(op->stack_minus ==0 && op->stack_plus == 0 &&
+ !(op->flags&~(OP_REGISTER|OP_SET_DXNS)) && c->prev) {
+ // trim code *before* the kill, inclocal, declocal, dxns
+ code_t*p = c->prev;
+ p->next = 0;
+ c->prev = 0;
+ return code_append(cut_last_push(p), c);
+ } else
+ break;
+ }
+ c = abc_pop(c);
+ return c;