new flag in 'CallInfo.callstatus' to tell whether function is running

as a finalizer
This commit is contained in:
Roberto Ierusalimschy
2016-10-19 10:31:42 -02:00
parent 8edbf57fb8
commit 138d00176c
2 changed files with 5 additions and 2 deletions

4
lgc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.211 2015/12/10 18:12:30 roberto Exp roberto $
** $Id: lgc.c,v 2.212 2016/03/31 19:02:03 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -818,7 +818,9 @@ static void GCTM (lua_State *L, int propagateerrors) {
setobj2s(L, L->top, tm); /* push finalizer... */
setobj2s(L, L->top + 1, &v); /* ... and its argument */
L->top += 2; /* and (next line) call the finalizer */
L->ci->callstatus |= CIST_FIN; /* will run a finalizer */
status = luaD_pcall(L, dothecall, NULL, savestack(L, L->top - 2), 0);
L->ci->callstatus &= ~CIST_FIN; /* not running a finalizer anymore */
L->allowhook = oldah; /* restore hooks */
g->gcrunning = running; /* restore state */
if (status != LUA_OK && propagateerrors) { /* error while running __gc? */