MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / lua_settop

Function lua_settop

lib/lua/src/lapi.c:181–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 15

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

Calls 1

luaF_closeFunction · 0.85

Tested by

no test coverage detected