MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / lua_settop

Function lua_settop

xrepo/packages/l/lua/port/lua/src/lapi.c:184–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182
183
184LUA_API void lua_settop (lua_State *L, int idx) {
185 CallInfo *ci;
186 StkId func, newtop;
187 ptrdiff_t diff; /* difference for new top */
188 lua_lock(L);
189 ci = L->ci;
190 func = ci->func;
191 if (idx >= 0) {
192 api_check(L, idx <= ci->top - (func + 1), "new top too large");
193 diff = ((func + 1) + idx) - L->top;
194 for (; diff > 0; diff--)
195 setnilvalue(s2v(L->top++)); /* clear new slots */
196 }
197 else {
198 api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
199 diff = idx + 1; /* will "subtract" index (as it is negative) */
200 }
201 api_check(L, L->tbclist < L->top, "previous pop of an unclosed slot");
202 newtop = L->top + diff;
203 if (diff < 0 && L->tbclist >= newtop) {
204 lua_assert(hastocloseCfunc(ci->nresults));
205 luaF_close(L, newtop, CLOSEKTOP, 0);
206 }
207 L->top = newtop; /* correct top only after closing any upvalue */
208 lua_unlock(L);
209}
210
211
212LUA_API void lua_closeslot (lua_State *L, int idx) {

Callers 15

loadlineFunction · 0.70
doREPLFunction · 0.70
luaB_tonumberFunction · 0.70
luaB_errorFunction · 0.70
luaB_setmetatableFunction · 0.70
luaB_rawgetFunction · 0.70
luaB_rawsetFunction · 0.70
luaB_nextFunction · 0.70
luaB_loadFunction · 0.70
luaB_dofileFunction · 0.70
luaB_assertFunction · 0.70
math_floorFunction · 0.70

Calls 1

luaF_closeFunction · 0.70

Tested by

no test coverage detected