From f407b3c4a1bc9667867ec51e835c20d97aab55a2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 19 Jul 2024 17:34:22 -0300 Subject: Using CIST_CLSRET instead of trick with 'nresults' The callstatus flag CIST_CLSRET is used in all tests for the presence of variables to be closed in C functions. --- lapi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lapi.c') diff --git a/lapi.c b/lapi.c index dbd291d7..70e2a44a 100644 --- a/lapi.c +++ b/lapi.c @@ -207,7 +207,7 @@ LUA_API void lua_settop (lua_State *L, int idx) { } newtop = L->top.p + diff; if (diff < 0 && L->tbclist.p >= newtop) { - lua_assert(hastocloseCfunc(ci->nresults)); + lua_assert(ci->callstatus & CIST_CLSRET); newtop = luaF_close(L, newtop, CLOSEKTOP, 0); } L->top.p = newtop; /* correct top only after closing any upvalue */ @@ -219,7 +219,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) { StkId level; lua_lock(L); level = index2stack(L, idx); - api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist.p == level, + api_check(L, (L->ci->callstatus & CIST_CLSRET) && L->tbclist.p == level, "no variable to close at given level"); level = luaF_close(L, level, CLOSEKTOP, 0); setnilvalue(s2v(level)); @@ -1287,9 +1287,7 @@ LUA_API void lua_toclose (lua_State *L, int idx) { nresults = L->ci->nresults; api_check(L, L->tbclist.p < o, "given index below or equal a marked one"); luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ - if (!hastocloseCfunc(nresults)) /* function not marked yet? */ - L->ci->nresults = codeNresults(nresults); /* mark it */ - lua_assert(hastocloseCfunc(L->ci->nresults)); + L->ci->callstatus |= CIST_CLSRET; /* mark that function has TBC slots */ lua_unlock(L); } -- cgit v1.2.3-55-g6feb