commit 58453dc1e1cb8c77f91cb858ec9b475a945f7f3c
parent f555e493f0a12513f79f999ceed5467085b1c9c4
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 14 Aug 2000 14:46:05 -0300
small bug in symbolic execution
Diffstat:
3 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/lcode.c b/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 1.46 2000/08/09 19:16:57 roberto Exp roberto $
+** $Id: lcode.c,v 1.47 2000/08/10 19:50:47 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -330,7 +330,8 @@ void luaK_tostack (LexState *ls, expdesc *v, int onlyone) {
luaK_concat(fs, &v->u.l.t, fs->pc-1); /* put `previous' in t. list */
else {
j = code_label(fs, OP_JMP, NO_JUMP); /* to jump over both pushes */
- luaK_deltastack(fs, -1); /* next PUSHes may be skipped */
+ /* correct stack for compiler and simbolic execution */
+ luaK_adjuststack(fs, 1);
}
p_nil = code_label(fs, OP_PUSHNILJMP, 0);
p_1 = code_label(fs, OP_PUSHINT, 1);
diff --git a/ldebug.c b/ldebug.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldebug.c,v 1.32 2000/08/10 19:50:47 roberto Exp roberto $
+** $Id: ldebug.c,v 1.33 2000/08/11 16:17:28 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@@ -296,11 +296,15 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
const Instruction i = code[pc++];
LUA_ASSERT(0 <= top && top <= pt->maxstacksize, "wrong stack");
switch (GET_OPCODE(i)) {
- case OP_RETURN:
- case OP_TAILCALL:
- case OP_END: {
- LUA_INTERNALERROR("invalid symbolic run");
- return CREATE_0(OP_END); /* stop execution */
+ case OP_RETURN: {
+ LUA_ASSERT(top >= GETARG_U(i), "wrong stack");
+ top = GETARG_U(i);
+ break;
+ }
+ case OP_TAILCALL: {
+ LUA_ASSERT(top >= GETARG_A(i), "wrong stack");
+ top = GETARG_B(i);
+ break;
}
case OP_CALL: {
int nresults = GETARG_B(i);
@@ -336,6 +340,18 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
stack[top++] = pc-1;
break;
}
+ case OP_JMPONT:
+ case OP_JMPONF: {
+ int newpc = pc + GETARG_S(i);
+ /* jump is forward and do not skip `lastpc'? */
+ if (pc < newpc && newpc <= lastpc) {
+ stack[top-1] = pc-1; /* value comes from `and'/`or' */
+ pc = newpc; /* do the jump */
+ }
+ else
+ top--; /* do not jump; pop value */
+ break;
+ }
default: {
OpCode op = GET_OPCODE(i);
LUA_ASSERT(luaK_opproperties[op].push != VD,
@@ -343,15 +359,6 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
top -= luaK_opproperties[op].pop;
LUA_ASSERT(top >= 0, "wrong stack");
top = pushpc(stack, pc, top, luaK_opproperties[op].push);
- if (ISJUMP(op)) {
- int newpc = pc + GETARG_S(i);
- /* jump is forward and do not skip `lastpc'? */
- if (pc < newpc && newpc <= lastpc) {
- if (op == OP_JMPONT || op == OP_JMPONF)
- stack[top++] = pc-1; /* do not pop when jumping */
- pc = newpc; /* do the jump */
- }
- }
}
}
}
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 1.106 2000/08/09 14:49:13 roberto Exp roberto $
+** $Id: lparser.c,v 1.107 2000/08/09 19:16:57 roberto Exp roberto $
** LL(1) Parser and code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -1024,7 +1024,8 @@ static void breakstat (LexState *ls) {
next(ls); /* skip BREAK */
luaK_adjuststack(fs, currentlevel - bl->stacklevel);
luaK_concat(fs, &bl->breaklist, luaK_jump(fs));
- fs->stacklevel = currentlevel;
+ /* correct stack for compiler and simbolic execution */
+ luaK_adjuststack(fs, bl->stacklevel - currentlevel);
}