]> git.mxchange.org Git - simgear.git/commitdiff
The previous update (and, embarassingly, the "nasal 1.0" release I
authorandy <andy>
Wed, 5 Jul 2006 02:52:06 +0000 (02:52 +0000)
committerandy <andy>
Wed, 5 Jul 2006 02:52:06 +0000 (02:52 +0000)
announced on Freshmeat.net) was broken.  This is the proper
break/continue fix.

simgear/nasal/code.c
simgear/nasal/code.h
simgear/nasal/codegen.c

index 6d63658780df629e9416262cb01464e3d541e65a..5c0c2896be9fdb7bf5a33aa3f2ea2078e39f2ced 100644 (file)
@@ -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");
         }
index 7ef76cf449a289990cfc89fcba3384525fc0dded..f8cbe3812c986c2c8f42a88218307720f225934e 100644 (file)
@@ -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 {
index ce005b1fb6e99252c4a776fa29956df431ed41c5..8966722f9d73f39f52fab193281dcbd3ccdfa6a0 100644 (file)
@@ -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; 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);