diff options
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -1207,12 +1207,19 @@ LUA_API int lua_next (lua_State *L, int idx) { | |||
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | 1209 | ||
1210 | LUA_API void lua_toclose (lua_State *L) { | 1210 | LUA_API void lua_toclose (lua_State *L, int idx) { |
1211 | int nresults = L->ci->nresults; | 1211 | int nresults; |
1212 | luaF_newtbcupval(L, L->top - 1); /* create new to-be-closed upvalue */ | 1212 | StkId o; |
1213 | lua_lock(L); | ||
1214 | o = index2stack(L, idx); | ||
1215 | nresults = L->ci->nresults; | ||
1216 | api_check(L, L->openupval == NULL || uplevel(L->openupval) < o, | ||
1217 | "there is an already marked index below"); | ||
1218 | luaF_newtbcupval(L, o); /* create new to-be-closed upvalue */ | ||
1213 | if (!hastocloseCfunc(nresults)) /* function not marked yet? */ | 1219 | if (!hastocloseCfunc(nresults)) /* function not marked yet? */ |
1214 | L->ci->nresults = codeNresults(nresults); /* mark it */ | 1220 | L->ci->nresults = codeNresults(nresults); /* mark it */ |
1215 | lua_assert(hastocloseCfunc(L->ci->nresults)); | 1221 | lua_assert(hastocloseCfunc(L->ci->nresults)); |
1222 | lua_unlock(L); | ||
1216 | } | 1223 | } |
1217 | 1224 | ||
1218 | 1225 | ||