aboutsummaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lapi.c b/lapi.c
index 00e95a11..0f0e31af 100644
--- a/lapi.c
+++ b/lapi.c
@@ -187,9 +187,26 @@ LUA_API void lua_settop (lua_State *L, int idx) {
187 api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); 187 api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
188 diff = idx + 1; /* will "subtract" index (as it is negative) */ 188 diff = idx + 1; /* will "subtract" index (as it is negative) */
189 } 189 }
190#if defined(LUA_COMPAT_5_4_0)
190 if (diff < 0 && hastocloseCfunc(ci->nresults)) 191 if (diff < 0 && hastocloseCfunc(ci->nresults))
191 luaF_close(L, L->top + diff, CLOSEKTOP); 192 luaF_close(L, L->top + diff, CLOSEKTOP);
192 L->top += diff; /* correct top only after closing any upvalue */ 193#endif
194 L->top += diff;
195 api_check(L, L->openupval == NULL || uplevel(L->openupval) < L->top,
196 "cannot pop an unclosed slot");
197 lua_unlock(L);
198}
199
200
201LUA_API void lua_closeslot (lua_State *L, int idx) {
202 StkId level;
203 lua_lock(L);
204 level = index2stack(L, idx);
205 api_check(L, hastocloseCfunc(L->ci->nresults) && L->openupval != NULL &&
206 uplevel(L->openupval) == level,
207 "no variable to close at given level");
208 luaF_close(L, level, CLOSEKTOP);
209 setnilvalue(s2v(level));
193 lua_unlock(L); 210 lua_unlock(L);
194} 211}
195 212