From: andy Date: Wed, 5 Jul 2006 02:52:06 +0000 (+0000) Subject: The previous update (and, embarassingly, the "nasal 1.0" release I X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7d2134c488f5ae87b8bed0c65a0219e0abddd819;p=simgear.git The previous update (and, embarassingly, the "nasal 1.0" release I announced on Freshmeat.net) was broken. This is the proper break/continue fix. --- diff --git a/simgear/nasal/code.c b/simgear/nasal/code.c index 6d636587..5c0c2896 100644 --- a/simgear/nasal/code.c +++ b/simgear/nasal/code.c @@ -601,11 +601,11 @@ static naRef run(struct Context* ctx) 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"); } diff --git a/simgear/nasal/code.h b/simgear/nasal/code.h index 7ef76cf4..f8cbe381 100644 --- a/simgear/nasal/code.h +++ b/simgear/nasal/code.h @@ -22,7 +22,7 @@ enum { 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 { diff --git a/simgear/nasal/codegen.c b/simgear/nasal/codegen.c index ce005b1f..8966722f 100644 --- a/simgear/nasal/codegen.c +++ b/simgear/nasal/codegen.c @@ -520,7 +520,7 @@ static void genBreakContinue(struct Parser* p, struct Token* t) bp = p->cg->loops[p->cg->loopTop - levels].breakIP; cp = p->cg->loops[p->cg->loopTop - levels].contIP; for(i=0; itype == TOK_BREAK || i>0) ? OP_BREAK : OP_CONTINUE); + emit(p, (itype == TOK_BREAK) emit(p, OP_PUSHNIL); // breakIP is always a JIFNOT/JIFNIL! emitImmediate(p, OP_JMP, t->type == TOK_BREAK ? bp : cp);