diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-19 17:34:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-19 17:34:22 -0300 |
commit | f407b3c4a1bc9667867ec51e835c20d97aab55a2 (patch) | |
tree | ad629983fbde70d5446411d765a99a1b724eb82b /lapi.c | |
parent | a546138d158d79d44b2c5b42630be00d306f4e7c (diff) | |
download | lua-f407b3c4a1bc9667867ec51e835c20d97aab55a2.tar.gz lua-f407b3c4a1bc9667867ec51e835c20d97aab55a2.tar.bz2 lua-f407b3c4a1bc9667867ec51e835c20d97aab55a2.zip |
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.
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -207,7 +207,7 @@ LUA_API void lua_settop (lua_State *L, int idx) { | |||
207 | } | 207 | } |
208 | newtop = L->top.p + diff; | 208 | newtop = L->top.p + diff; |
209 | if (diff < 0 && L->tbclist.p >= newtop) { | 209 | if (diff < 0 && L->tbclist.p >= newtop) { |
210 | lua_assert(hastocloseCfunc(ci->nresults)); | 210 | lua_assert(ci->callstatus & CIST_CLSRET); |
211 | newtop = luaF_close(L, newtop, CLOSEKTOP, 0); | 211 | newtop = luaF_close(L, newtop, CLOSEKTOP, 0); |
212 | } | 212 | } |
213 | L->top.p = newtop; /* correct top only after closing any upvalue */ | 213 | 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) { | |||
219 | StkId level; | 219 | StkId level; |
220 | lua_lock(L); | 220 | lua_lock(L); |
221 | level = index2stack(L, idx); | 221 | level = index2stack(L, idx); |
222 | api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist.p == level, | 222 | api_check(L, (L->ci->callstatus & CIST_CLSRET) && L->tbclist.p == level, |
223 | "no variable to close at given level"); | 223 | "no variable to close at given level"); |
224 | level = luaF_close(L, level, CLOSEKTOP, 0); | 224 | level = luaF_close(L, level, CLOSEKTOP, 0); |
225 | setnilvalue(s2v(level)); | 225 | setnilvalue(s2v(level)); |
@@ -1287,9 +1287,7 @@ LUA_API void lua_toclose (lua_State *L, int idx) { | |||
1287 | nresults = L->ci->nresults; | 1287 | nresults = L->ci->nresults; |
1288 | api_check(L, L->tbclist.p < o, "given index below or equal a marked one"); | 1288 | api_check(L, L->tbclist.p < o, "given index below or equal a marked one"); |
1289 | luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ | 1289 | luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ |
1290 | if (!hastocloseCfunc(nresults)) /* function not marked yet? */ | 1290 | L->ci->callstatus |= CIST_CLSRET; /* mark that function has TBC slots */ |
1291 | L->ci->nresults = codeNresults(nresults); /* mark it */ | ||
1292 | lua_assert(hastocloseCfunc(L->ci->nresults)); | ||
1293 | lua_unlock(L); | 1291 | lua_unlock(L); |
1294 | } | 1292 | } |
1295 | 1293 | ||