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

Function lua_settop

extlibs/lua/src/lapi.c:172–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170
171
172LUA_API void lua_settop (lua_State *L, int idx) {
173 CallInfo *ci = L->ci;
174 StkId func = ci->func;
175 ptrdiff_t diff; /* difference for new top */
176 lua_lock(L);
177 if (idx >= 0) {
178 api_check(L, idx <= ci->top - (func + 1), "new top too large");
179 diff = ((func + 1) + idx) - L->top;
180 for (; diff > 0; diff--)
181 setnilvalue(s2v(L->top++)); /* clear new slots */
182 }
183 else {
184 api_check(L, -(idx+1) <= (L->top - (func + 1)), "invalid new top");
185 diff = idx + 1; /* will "subtract" index (as it is negative) */
186 }
187 if (diff < 0 && hastocloseCfunc(ci->nresults))
188 luaF_close(L, L->top + diff, LUA_OK);
189 L->top += diff; /* correct top only after closing any upvalue */
190 lua_unlock(L);
191}
192
193
194/*

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