MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / lua_settop

Function lua_settop

3rd/lua-5.4.3/src/lapi.c:174–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

formatFunction · 0.85
range_formatFunction · 0.85
type_formatFunction · 0.85
update_configFunction · 0.85
diagnose_fileFunction · 0.85
set_default_configFunction · 0.85
set_nonstandard_symbolFunction · 0.85
spell_analysisFunction · 0.85
update_name_style_configFunction · 0.85

Calls 1

luaF_closeFunction · 0.85

Tested by

no test coverage detected