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

Function createvarargtab

third-party/lua-5.5.0/src/ltm.c:231–246  ·  view source on GitHub ↗

** Create a vararg table at the top of the stack, with 'n' elements ** starting at 'f'. */

Source from the content-addressed store, hash-verified

229** starting at 'f'.
230*/
231static void createvarargtab (lua_State *L, StkId f, int n) {
232 int i;
233 TValue key, value;
234 Table *t = luaH_new(L);
235 sethvalue(L, s2v(L->top.p), t);
236 L->top.p++;
237 luaH_resize(L, t, cast_uint(n), 1);
238 setsvalue(L, &key, luaS_new(L, "n")); /* key is "n" */
239 setivalue(&value, n); /* value is n */
240 /* No need to anchor the key: Due to the resize, the next operation
241 cannot trigger a garbage collection */
242 luaH_set(L, t, &key, &value); /* t.n = n */
243 for (i = 0; i < n; i++)
244 luaH_setint(L, t, i + 1, s2v(f + i));
245 luaC_checkGC(L);
246}
247
248
249/*

Callers 1

luaT_adjustvarargsFunction · 0.85

Calls 5

luaH_newFunction · 0.70
luaH_resizeFunction · 0.70
luaS_newFunction · 0.70
luaH_setFunction · 0.70
luaH_setintFunction · 0.70

Tested by

no test coverage detected