|
@@ -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
|
|
** Debug Interface
|
|
** See Copyright Notice in lua.h
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
*/
|
|
@@ -245,15 +245,27 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int stackpos) {
|
|
top++; /* `arg' */
|
|
top++; /* `arg' */
|
|
while (pc < lastpc) {
|
|
while (pc < lastpc) {
|
|
const Instruction i = code[pc++];
|
|
const Instruction i = code[pc++];
|
|
|
|
+ LUA_ASSERT(NULL, top <= pt->maxstacksize, "wrong stack");
|
|
switch (GET_OPCODE(i)) {
|
|
switch (GET_OPCODE(i)) {
|
|
|
|
+ case OP_RETURN: {
|
|
|
|
+ LUA_ASSERT(NULL, top >= GETARG_U(i), "wrong stack");
|
|
|
|
+ top = GETARG_U(i);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case OP_CALL: {
|
|
case OP_CALL: {
|
|
int nresults = GETARG_B(i);
|
|
int nresults = GETARG_B(i);
|
|
if (nresults == MULT_RET) nresults = 1;
|
|
if (nresults == MULT_RET) nresults = 1;
|
|
|
|
+ LUA_ASSERT(NULL, top >= GETARG_A(i), "wrong stack");
|
|
top = GETARG_A(i);
|
|
top = GETARG_A(i);
|
|
while (nresults--)
|
|
while (nresults--)
|
|
stack[top++] = pc-1;
|
|
stack[top++] = pc-1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ case OP_TAILCALL: {
|
|
|
|
+ LUA_ASSERT(NULL, top >= GETARG_A(i), "wrong stack");
|
|
|
|
+ top = GETARG_B(i);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
case OP_PUSHNIL: {
|
|
case OP_PUSHNIL: {
|
|
int n;
|
|
int n;
|
|
for (n=0; n<GETARG_U(i); 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_JMPONT:
|
|
case OP_JMPONF: {
|
|
case OP_JMPONF: {
|
|
int newpc = pc + GETARG_S(i);
|
|
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 */
|
|
stack[top-1] = pc-1; /* value generated by or-and */
|
|
pc = newpc; /* do the jump */
|
|
pc = newpc; /* do the jump */
|
|
}
|
|
}
|
|
- else
|
|
|
|
- top--; /* original code did not jump; condition was false */
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case OP_PUSHNILJMP: {
|
|
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,
|
|
LUA_ASSERT(NULL, luaK_opproperties[GET_OPCODE(i)].push != VD,
|
|
"invalid opcode for default");
|
|
"invalid opcode for default");
|
|
top -= luaK_opproperties[GET_OPCODE(i)].pop;
|
|
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++)
|
|
for (n=0; n<luaK_opproperties[GET_OPCODE(i)].push; n++)
|
|
stack[top++] = pc-1;
|
|
stack[top++] = pc-1;
|
|
}
|
|
}
|