diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-14 14:46:27 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-14 14:46:27 -0300 |
commit | 58453dc1e1cb8c77f91cb858ec9b475a945f7f3c (patch) | |
tree | 0ad99964acf87f941b318f6edbe9413b71b7e8b6 | |
parent | f555e493f0a12513f79f999ceed5467085b1c9c4 (diff) | |
download | lua-58453dc1e1cb8c77f91cb858ec9b475a945f7f3c.tar.gz lua-58453dc1e1cb8c77f91cb858ec9b475a945f7f3c.tar.bz2 lua-58453dc1e1cb8c77f91cb858ec9b475a945f7f3c.zip |
small bug in symbolic execution
-rw-r--r-- | lcode.c | 5 | ||||
-rw-r--r-- | ldebug.c | 37 | ||||
-rw-r--r-- | lparser.c | 5 |
3 files changed, 28 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 1.46 2000/08/09 19:16:57 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.47 2000/08/10 19:50:47 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -330,7 +330,8 @@ void luaK_tostack (LexState *ls, expdesc *v, int onlyone) { | |||
330 | luaK_concat(fs, &v->u.l.t, fs->pc-1); /* put `previous' in t. list */ | 330 | luaK_concat(fs, &v->u.l.t, fs->pc-1); /* put `previous' in t. list */ |
331 | else { | 331 | else { |
332 | j = code_label(fs, OP_JMP, NO_JUMP); /* to jump over both pushes */ | 332 | j = code_label(fs, OP_JMP, NO_JUMP); /* to jump over both pushes */ |
333 | luaK_deltastack(fs, -1); /* next PUSHes may be skipped */ | 333 | /* correct stack for compiler and simbolic execution */ |
334 | luaK_adjuststack(fs, 1); | ||
334 | } | 335 | } |
335 | p_nil = code_label(fs, OP_PUSHNILJMP, 0); | 336 | p_nil = code_label(fs, OP_PUSHNILJMP, 0); |
336 | p_1 = code_label(fs, OP_PUSHINT, 1); | 337 | p_1 = code_label(fs, OP_PUSHINT, 1); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.32 2000/08/10 19:50:47 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.33 2000/08/11 16:17:28 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -296,11 +296,15 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
296 | const Instruction i = code[pc++]; | 296 | const Instruction i = code[pc++]; |
297 | LUA_ASSERT(0 <= top && top <= pt->maxstacksize, "wrong stack"); | 297 | LUA_ASSERT(0 <= top && top <= pt->maxstacksize, "wrong stack"); |
298 | switch (GET_OPCODE(i)) { | 298 | switch (GET_OPCODE(i)) { |
299 | case OP_RETURN: | 299 | case OP_RETURN: { |
300 | case OP_TAILCALL: | 300 | LUA_ASSERT(top >= GETARG_U(i), "wrong stack"); |
301 | case OP_END: { | 301 | top = GETARG_U(i); |
302 | LUA_INTERNALERROR("invalid symbolic run"); | 302 | break; |
303 | return CREATE_0(OP_END); /* stop execution */ | 303 | } |
304 | case OP_TAILCALL: { | ||
305 | LUA_ASSERT(top >= GETARG_A(i), "wrong stack"); | ||
306 | top = GETARG_B(i); | ||
307 | break; | ||
304 | } | 308 | } |
305 | case OP_CALL: { | 309 | case OP_CALL: { |
306 | int nresults = GETARG_B(i); | 310 | int nresults = GETARG_B(i); |
@@ -336,6 +340,18 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
336 | stack[top++] = pc-1; | 340 | stack[top++] = pc-1; |
337 | break; | 341 | break; |
338 | } | 342 | } |
343 | case OP_JMPONT: | ||
344 | case OP_JMPONF: { | ||
345 | int newpc = pc + GETARG_S(i); | ||
346 | /* jump is forward and do not skip `lastpc'? */ | ||
347 | if (pc < newpc && newpc <= lastpc) { | ||
348 | stack[top-1] = pc-1; /* value comes from `and'/`or' */ | ||
349 | pc = newpc; /* do the jump */ | ||
350 | } | ||
351 | else | ||
352 | top--; /* do not jump; pop value */ | ||
353 | break; | ||
354 | } | ||
339 | default: { | 355 | default: { |
340 | OpCode op = GET_OPCODE(i); | 356 | OpCode op = GET_OPCODE(i); |
341 | LUA_ASSERT(luaK_opproperties[op].push != VD, | 357 | LUA_ASSERT(luaK_opproperties[op].push != VD, |
@@ -343,15 +359,6 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
343 | top -= luaK_opproperties[op].pop; | 359 | top -= luaK_opproperties[op].pop; |
344 | LUA_ASSERT(top >= 0, "wrong stack"); | 360 | LUA_ASSERT(top >= 0, "wrong stack"); |
345 | top = pushpc(stack, pc, top, luaK_opproperties[op].push); | 361 | top = pushpc(stack, pc, top, luaK_opproperties[op].push); |
346 | if (ISJUMP(op)) { | ||
347 | int newpc = pc + GETARG_S(i); | ||
348 | /* jump is forward and do not skip `lastpc'? */ | ||
349 | if (pc < newpc && newpc <= lastpc) { | ||
350 | if (op == OP_JMPONT || op == OP_JMPONF) | ||
351 | stack[top++] = pc-1; /* do not pop when jumping */ | ||
352 | pc = newpc; /* do the jump */ | ||
353 | } | ||
354 | } | ||
355 | } | 362 | } |
356 | } | 363 | } |
357 | } | 364 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.106 2000/08/09 14:49:13 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.107 2000/08/09 19:16:57 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1024,7 +1024,8 @@ static void breakstat (LexState *ls) { | |||
1024 | next(ls); /* skip BREAK */ | 1024 | next(ls); /* skip BREAK */ |
1025 | luaK_adjuststack(fs, currentlevel - bl->stacklevel); | 1025 | luaK_adjuststack(fs, currentlevel - bl->stacklevel); |
1026 | luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); | 1026 | luaK_concat(fs, &bl->breaklist, luaK_jump(fs)); |
1027 | fs->stacklevel = currentlevel; | 1027 | /* correct stack for compiler and simbolic execution */ |
1028 | luaK_adjuststack(fs, bl->stacklevel - currentlevel); | ||
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | 1031 | ||