diff options
author | Li Jin <dragon-fly@qq.com> | 2021-03-11 08:56:23 +0800 |
---|---|---|
committer | Li Jin <dragon-fly@qq.com> | 2021-03-11 08:56:23 +0800 |
commit | b359d1a69e9c2db09444264a8d9d874e156fd14b (patch) | |
tree | 388e0ef24a1537e8f9cd75c3754dd1e133b8c902 /src/lua/lapi.c | |
parent | 3eedd027bddc1ad9099d647e83ae4a83589db191 (diff) | |
download | yuescript-b359d1a69e9c2db09444264a8d9d874e156fd14b.tar.gz yuescript-b359d1a69e9c2db09444264a8d9d874e156fd14b.tar.bz2 yuescript-b359d1a69e9c2db09444264a8d9d874e156fd14b.zip |
update Lua.
Diffstat (limited to 'src/lua/lapi.c')
-rw-r--r-- | src/lua/lapi.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lua/lapi.c b/src/lua/lapi.c index a9cf2fd..f8f70cd 100644 --- a/src/lua/lapi.c +++ b/src/lua/lapi.c | |||
@@ -173,7 +173,7 @@ LUA_API int lua_gettop (lua_State *L) { | |||
173 | 173 | ||
174 | LUA_API void lua_settop (lua_State *L, int idx) { | 174 | LUA_API void lua_settop (lua_State *L, int idx) { |
175 | CallInfo *ci; | 175 | CallInfo *ci; |
176 | StkId func; | 176 | StkId func, newtop; |
177 | ptrdiff_t diff; /* difference for new top */ | 177 | ptrdiff_t diff; /* difference for new top */ |
178 | lua_lock(L); | 178 | lua_lock(L); |
179 | ci = L->ci; | 179 | ci = L->ci; |
@@ -188,12 +188,13 @@ LUA_API void lua_settop (lua_State *L, int idx) { | |||
188 | api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); | 188 | api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top"); |
189 | diff = idx + 1; /* will "subtract" index (as it is negative) */ | 189 | diff = idx + 1; /* will "subtract" index (as it is negative) */ |
190 | } | 190 | } |
191 | #if defined(LUA_COMPAT_5_4_0) | 191 | api_check(L, L->tbclist < L->top, "previous pop of an unclosed slot"); |
192 | if (diff < 0 && hastocloseCfunc(ci->nresults)) | 192 | newtop = L->top + diff; |
193 | luaF_close(L, L->top + diff, CLOSEKTOP, 0); | 193 | if (diff < 0 && L->tbclist >= newtop) { |
194 | #endif | 194 | lua_assert(hastocloseCfunc(ci->nresults)); |
195 | api_check(L, L->tbclist < L->top + diff, "cannot pop an unclosed slot"); | 195 | luaF_close(L, newtop, CLOSEKTOP, 0); |
196 | L->top += diff; | 196 | } |
197 | L->top = newtop; /* correct top only after closing any upvalue */ | ||
197 | lua_unlock(L); | 198 | lua_unlock(L); |
198 | } | 199 | } |
199 | 200 | ||