MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / adjust_varargs

Function adjust_varargs

lua/ldo.c:209–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207
208
209static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
210 int i;
211 int nfixargs = p->numparams;
212 Table *htab = NULL;
213 StkId base, fixed;
214 for (; actual < nfixargs; ++actual)
215 setnilvalue(L->top++);
216#if defined(LUA_COMPAT_VARARG)
217 if (p->is_vararg & VARARG_NEEDSARG) { /* compat. with old-style vararg? */
218 int nvar = actual - nfixargs; /* number of extra arguments */
219 lua_assert(p->is_vararg & VARARG_HASARG);
220 luaC_checkGC(L);
221 htab = luaH_new(L, nvar, 1); /* create `arg' table */
222 for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */
223 setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i);
224 /* store counter in field `n' */
225 setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar));
226 }
227#endif
228 /* move fixed parameters to final position */
229 fixed = L->top - actual; /* first fixed argument */
230 base = L->top; /* final position of first argument */
231 for (i=0; i<nfixargs; i++) {
232 setobjs2s(L, L->top++, fixed+i);
233 setnilvalue(fixed+i);
234 }
235 /* add `arg' parameter */
236 if (htab) {
237 sethvalue(L, L->top++, htab);
238 lua_assert(iswhite(obj2gco(htab)));
239 }
240 return base;
241}
242
243
244static StkId tryfuncTM (lua_State *L, StkId func) {

Callers 1

luaD_precallFunction · 0.85

Calls 3

luaH_newFunction · 0.85
luaH_setnumFunction · 0.85
luaH_setstrFunction · 0.85

Tested by

no test coverage detected