MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lua_settop

Function lua_settop

third-party/lua-5.5.0/src/lapi.c:179–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178
179LUA_API void lua_settop (lua_State *L, int idx) {
180 CallInfo *ci;
181 StkId func, newtop;
182 ptrdiff_t diff; /* difference for new top */
183 lua_lock(L);
184 ci = L->ci;
185 func = ci->func.p;
186 if (idx >= 0) {
187 api_check(L, idx <= ci->top.p - (func + 1), "new top too large");
188 diff = ((func + 1) + idx) - L->top.p;
189 for (; diff > 0; diff--)
190 setnilvalue(s2v(L->top.p++)); /* clear new slots */
191 }
192 else {
193 api_check(L, -(idx+1) <= (L->top.p - (func + 1)), "invalid new top");
194 diff = idx + 1; /* will "subtract" index (as it is negative) */
195 }
196 newtop = L->top.p + diff;
197 if (diff < 0 && L->tbclist.p >= newtop) {
198 lua_assert(ci->callstatus & CIST_TBC);
199 newtop = luaF_close(L, newtop, CLOSEKTOP, 0);
200 }
201 L->top.p = newtop; /* correct top only after closing any upvalue */
202 lua_unlock(L);
203}
204
205
206LUA_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