ctx->markTop--;
break;
case OP_BREAK: // restore stack state (FOLLOW WITH JMP!)
- ctx->opTop = ctx->markStack[--ctx->markTop];
- break;
- case OP_CONTINUE: // same, but don't modify markTop
ctx->opTop = ctx->markStack[ctx->markTop-1];
break;
+ case OP_BREAK2: // same, but also pop the mark stack
+ ctx->opTop = ctx->markStack[--ctx->markTop];
+ break;
default:
ERR(ctx, "BUG: bad opcode");
}
OP_DUP, OP_XCHG, OP_INSERT, OP_EXTRACT, OP_MEMBER, OP_SETMEMBER,
OP_LOCAL, OP_SETLOCAL, OP_NEWVEC, OP_VAPPEND, OP_NEWHASH, OP_HAPPEND,
OP_MARK, OP_UNMARK, OP_BREAK, OP_FTAIL, OP_MTAIL, OP_SETSYM, OP_DUP2,
- OP_INDEX, OP_CONTINUE
+ OP_INDEX, OP_BREAK2
};
struct Frame {
bp = p->cg->loops[p->cg->loopTop - levels].breakIP;
cp = p->cg->loops[p->cg->loopTop - levels].contIP;
for(i=0; i<levels; i++)
- emit(p, (t->type == TOK_BREAK || i>0) ? OP_BREAK : OP_CONTINUE);
+ emit(p, (i<levels-1) ? OP_BREAK2 : OP_BREAK);
if(t->type == TOK_BREAK)
emit(p, OP_PUSHNIL); // breakIP is always a JIFNOT/JIFNIL!
emitImmediate(p, OP_JMP, t->type == TOK_BREAK ? bp : cp);