diff options
| author | Li Jin <dragon-fly@qq.com> | 2021-01-22 17:54:39 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2021-01-22 17:54:39 +0800 |
| commit | 236bcc6e10f59b9336603571f1683cbe4aa411a9 (patch) | |
| tree | 7116190d16a12bfcb0819e802c6e1d4ac8b0ec70 /src/lua/lapi.c | |
| parent | f61b96675547c8bf40c7f646e3766f4139efd927 (diff) | |
| download | yuescript-236bcc6e10f59b9336603571f1683cbe4aa411a9.tar.gz yuescript-236bcc6e10f59b9336603571f1683cbe4aa411a9.tar.bz2 yuescript-236bcc6e10f59b9336603571f1683cbe4aa411a9.zip | |
update included Lua.
Diffstat (limited to 'src/lua/lapi.c')
| -rw-r--r-- | src/lua/lapi.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/lua/lapi.c b/src/lua/lapi.c index 03e756d..3583e9c 100644 --- a/src/lua/lapi.c +++ b/src/lua/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, LUA_OK); | 192 | luaF_close(L, L->top + diff, CLOSEKTOP, 0); |
| 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 | |||
| 201 | LUA_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, 0); | ||
| 209 | setnilvalue(s2v(level)); | ||
| 193 | lua_unlock(L); | 210 | lua_unlock(L); |
| 194 | } | 211 | } |
| 195 | 212 | ||
