diff options
Diffstat (limited to 'ldebug.c')
| -rw-r--r-- | ldebug.c | 37 |
1 files changed, 22 insertions, 15 deletions
| @@ -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 | } |
