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

Function luaT_getvarargs

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

** Get 'wanted' vararg arguments and put them in 'where'. 'vatab' is ** the register of the vararg table or -1 if there is no vararg table. */

Source from the content-addressed store, hash-verified

336** the register of the vararg table or -1 if there is no vararg table.
337*/
338void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted,
339 int vatab) {
340 Table *h = (vatab < 0) ? NULL : hvalue(s2v(ci->func.p + vatab + 1));
341 int nargs = getnumargs(L, ci, h); /* number of available vararg args. */
342 int i, touse; /* 'touse' is minimum between 'wanted' and 'nargs' */
343 if (wanted < 0) {
344 touse = wanted = nargs; /* get all extra arguments available */
345 checkstackp(L, nargs, where); /* ensure stack space */
346 L->top.p = where + nargs; /* next instruction will need top */
347 }
348 else
349 touse = (nargs > wanted) ? wanted : nargs;
350 if (h == NULL) { /* no vararg table? */
351 for (i = 0; i < touse; i++) /* get vararg values from the stack */
352 setobjs2s(L, where + i, ci->func.p - nargs + i);
353 }
354 else { /* get vararg values from vararg table */
355 for (i = 0; i < touse; i++) {
356 lu_byte tag = luaH_getint(h, i + 1, s2v(where + i));
357 if (tagisempty(tag))
358 setnilvalue(s2v(where + i));
359 }
360 }
361 for (; i < wanted; i++) /* complete required results with nil */
362 setnilvalue(s2v(where + i));
363}
364

Callers 1

luaV_executeFunction · 0.70

Calls 2

getnumargsFunction · 0.85
luaH_getintFunction · 0.70

Tested by

no test coverage detected