commit 642af82e81bbc54b634649f197c62a35e156c096
parent 636c629e563262e7f0d02606abbe3605b7e0747a
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 19 Nov 2002 06:50:34 -0200
small bugs (state could keep its CI_HASFRAME attribute after returning)
Diffstat:
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/lvm.c b/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.262 2002/11/18 11:01:55 roberto Exp roberto $
+** $Id: lvm.c,v 1.263 2002/11/18 15:24:11 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -382,7 +382,8 @@ StkId luaV_execute (lua_State *L) {
if (L->hookmask & LUA_MASKCALL)
luaD_callhook(L, LUA_HOOKCALL, -1);
retentry: /* entry point when returning to old functions */
- lua_assert(L->ci->state & CI_SAVEDPC);
+ lua_assert(L->ci->state == CI_SAVEDPC ||
+ L->ci->state == (CI_SAVEDPC | CI_CALLING));
L->ci->state = CI_HASFRAME; /* activate frame */
pc = L->ci->u.l.savedpc;
base = L->ci->base;
@@ -397,11 +398,12 @@ StkId luaV_execute (lua_State *L) {
traceexec(L);
if (L->ci->state & CI_YIELD) { /* did hook yield? */
L->ci->u.l.savedpc = pc - 1;
- L->ci->state |= CI_SAVEDPC;
+ L->ci->state = CI_YIELD | CI_SAVEDPC;
return NULL;
}
}
/* warning!! several calls may realloc the stack and invalidate `ra' */
+ lua_assert((L->ci->state & CI_HASFRAME) && base == L->ci->base);
ra = RA(i);
lua_assert(L->top <= L->stack + L->stacksize && L->top >= L->ci->base);
lua_assert(L->top == L->ci->top ||
@@ -600,8 +602,9 @@ StkId luaV_execute (lua_State *L) {
firstResult = luaD_precall(L, ra);
if (firstResult) {
if (firstResult > L->top) { /* yield? */
+ lua_assert(L->ci->state == (CI_C | CI_YIELD));
(L->ci - 1)->u.l.savedpc = pc;
- (L->ci - 1)->state |= CI_SAVEDPC;
+ (L->ci - 1)->state = CI_SAVEDPC;
return NULL;
}
/* it was a C function (`precall' called it); adjust results */
@@ -623,7 +626,7 @@ StkId luaV_execute (lua_State *L) {
lua_assert(L->ci->state & CI_SAVEDPC);
(L->ci - 1)->u.l.savedpc = L->ci->u.l.savedpc;
(L->ci - 1)->state = CI_SAVEDPC;
- L->ci--; /* remove previous frame */
+ L->ci--; /* remove new frame */
}
goto callentry;
}