mirror of
https://github.com/lua/lua
synced 2024-11-26 14:51:21 +03:00
symbolic execution must handle return and tailcall
This commit is contained in:
parent
014a09c509
commit
aa01d2568d
21
ldebug.c
21
ldebug.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: ldebug.c,v 1.24 2000/06/26 19:28:31 roberto Exp roberto $
|
||||
** $Id: ldebug.c,v 1.25 2000/06/28 20:20:36 roberto Exp roberto $
|
||||
** Debug Interface
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -245,15 +245,27 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
|
||||
top++; /* `arg' */
|
||||
while (pc < lastpc) {
|
||||
const Instruction i = code[pc++];
|
||||
LUA_ASSERT(NULL, top <= pt->maxstacksize, "wrong stack");
|
||||
switch (GET_OPCODE(i)) {
|
||||
case OP_RETURN: {
|
||||
LUA_ASSERT(NULL, top >= GETARG_U(i), "wrong stack");
|
||||
top = GETARG_U(i);
|
||||
break;
|
||||
}
|
||||
case OP_CALL: {
|
||||
int nresults = GETARG_B(i);
|
||||
if (nresults == MULT_RET) nresults = 1;
|
||||
LUA_ASSERT(NULL, top >= GETARG_A(i), "wrong stack");
|
||||
top = GETARG_A(i);
|
||||
while (nresults--)
|
||||
stack[top++] = pc-1;
|
||||
break;
|
||||
}
|
||||
case OP_TAILCALL: {
|
||||
LUA_ASSERT(NULL, top >= GETARG_A(i), "wrong stack");
|
||||
top = GETARG_B(i);
|
||||
break;
|
||||
}
|
||||
case OP_PUSHNIL: {
|
||||
int n;
|
||||
for (n=0; n<GETARG_U(i); n++)
|
||||
@ -281,12 +293,12 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
|
||||
case OP_JMPONT:
|
||||
case OP_JMPONF: {
|
||||
int newpc = pc + GETARG_S(i);
|
||||
if (newpc >= lastpc) {
|
||||
if (lastpc < newpc)
|
||||
top--; /* original code did not jump; condition was false */
|
||||
else {
|
||||
stack[top-1] = pc-1; /* value generated by or-and */
|
||||
pc = newpc; /* do the jump */
|
||||
}
|
||||
else
|
||||
top--; /* original code did not jump; condition was false */
|
||||
break;
|
||||
}
|
||||
case OP_PUSHNILJMP: {
|
||||
@ -302,6 +314,7 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
|
||||
LUA_ASSERT(NULL, luaK_opproperties[GET_OPCODE(i)].push != VD,
|
||||
"invalid opcode for default");
|
||||
top -= luaK_opproperties[GET_OPCODE(i)].pop;
|
||||
LUA_ASSERT(NULL, top >= 0, "wrong stack");
|
||||
for (n=0; n<luaK_opproperties[GET_OPCODE(i)].push; n++)
|
||||
stack[top++] = pc-1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user