diff options
-rw-r--r-- | ldebug.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.24 2000/06/26 19:28:31 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.25 2000/06/28 20:20:36 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 | */ |
@@ -245,15 +245,27 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
245 | top++; /* `arg' */ | 245 | top++; /* `arg' */ |
246 | while (pc < lastpc) { | 246 | while (pc < lastpc) { |
247 | const Instruction i = code[pc++]; | 247 | const Instruction i = code[pc++]; |
248 | LUA_ASSERT(NULL, top <= pt->maxstacksize, "wrong stack"); | ||
248 | switch (GET_OPCODE(i)) { | 249 | switch (GET_OPCODE(i)) { |
250 | case OP_RETURN: { | ||
251 | LUA_ASSERT(NULL, top >= GETARG_U(i), "wrong stack"); | ||
252 | top = GETARG_U(i); | ||
253 | break; | ||
254 | } | ||
249 | case OP_CALL: { | 255 | case OP_CALL: { |
250 | int nresults = GETARG_B(i); | 256 | int nresults = GETARG_B(i); |
251 | if (nresults == MULT_RET) nresults = 1; | 257 | if (nresults == MULT_RET) nresults = 1; |
258 | LUA_ASSERT(NULL, top >= GETARG_A(i), "wrong stack"); | ||
252 | top = GETARG_A(i); | 259 | top = GETARG_A(i); |
253 | while (nresults--) | 260 | while (nresults--) |
254 | stack[top++] = pc-1; | 261 | stack[top++] = pc-1; |
255 | break; | 262 | break; |
256 | } | 263 | } |
264 | case OP_TAILCALL: { | ||
265 | LUA_ASSERT(NULL, top >= GETARG_A(i), "wrong stack"); | ||
266 | top = GETARG_B(i); | ||
267 | break; | ||
268 | } | ||
257 | case OP_PUSHNIL: { | 269 | case OP_PUSHNIL: { |
258 | int n; | 270 | int n; |
259 | for (n=0; n<GETARG_U(i); n++) | 271 | for (n=0; n<GETARG_U(i); n++) |
@@ -281,12 +293,12 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
281 | case OP_JMPONT: | 293 | case OP_JMPONT: |
282 | case OP_JMPONF: { | 294 | case OP_JMPONF: { |
283 | int newpc = pc + GETARG_S(i); | 295 | int newpc = pc + GETARG_S(i); |
284 | if (newpc >= lastpc) { | 296 | if (lastpc < newpc) |
297 | top--; /* original code did not jump; condition was false */ | ||
298 | else { | ||
285 | stack[top-1] = pc-1; /* value generated by or-and */ | 299 | stack[top-1] = pc-1; /* value generated by or-and */ |
286 | pc = newpc; /* do the jump */ | 300 | pc = newpc; /* do the jump */ |
287 | } | 301 | } |
288 | else | ||
289 | top--; /* original code did not jump; condition was false */ | ||
290 | break; | 302 | break; |
291 | } | 303 | } |
292 | case OP_PUSHNILJMP: { | 304 | case OP_PUSHNILJMP: { |
@@ -302,6 +314,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) { | |||
302 | LUA_ASSERT(NULL, luaK_opproperties[GET_OPCODE(i)].push != VD, | 314 | LUA_ASSERT(NULL, luaK_opproperties[GET_OPCODE(i)].push != VD, |
303 | "invalid opcode for default"); | 315 | "invalid opcode for default"); |
304 | top -= luaK_opproperties[GET_OPCODE(i)].pop; | 316 | top -= luaK_opproperties[GET_OPCODE(i)].pop; |
317 | LUA_ASSERT(NULL, top >= 0, "wrong stack"); | ||
305 | for (n=0; n<luaK_opproperties[GET_OPCODE(i)].push; n++) | 318 | for (n=0; n<luaK_opproperties[GET_OPCODE(i)].push; n++) |
306 | stack[top++] = pc-1; | 319 | stack[top++] = pc-1; |
307 | } | 320 | } |