MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / funcargs

Function funcargs

Source/Misc/lua/src/lua.c:8185–8231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8183
8184
8185static void funcargs (LexState *ls, expdesc *f) {
8186FuncState *fs = ls->fs;
8187expdesc args;
8188int base, nparams;
8189int line = ls->linenumber;
8190switch (ls->t.token) {
8191case '(': { /* funcargs -> `(' [ explist1 ] `)' */
8192if (line != ls->lastline)
8193luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
8194luaX_next(ls);
8195if (ls->t.token == ')') /* arg list is empty? */
8196args.k = VVOID;
8197else {
8198explist1(ls, &args);
8199luaK_setmultret(fs, &args);
8200}
8201check_match(ls, ')', '(', line);
8202break;
8203}
8204case '{': { /* funcargs -> constructor */
8205constructor(ls, &args);
8206break;
8207}
8208case TK_STRING: { /* funcargs -> STRING */
8209codestring(ls, &args, ls->t.seminfo.ts);
8210luaX_next(ls); /* must use `seminfo' before `next' */
8211break;
8212}
8213default: {
8214luaX_syntaxerror(ls, "function arguments expected");
8215return;
8216}
8217}
8218lua_assert(f->k == VNONRELOC);
8219base = f->u.s.info; /* base register for call */
8220if (hasmultret(args.k))
8221nparams = LUA_MULTRET; /* open call */
8222else {
8223if (args.k != VVOID)
8224luaK_exp2nextreg(fs, &args); /* close last argument */
8225nparams = fs->freereg - (base+1);
8226}
8227init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
8228luaK_fixline(fs, line);
8229fs->freereg = base+1; /* call remove function and arguments and leaves
8230(unless changed) one result */
8231}
8232
8233
8234

Callers 1

primaryexpFunction · 0.85

Calls 10

luaX_syntaxerrorFunction · 0.85
luaX_nextFunction · 0.85
explist1Function · 0.85
codestringFunction · 0.85
luaK_exp2nextregFunction · 0.85
init_expFunction · 0.85
luaK_codeABCFunction · 0.85
luaK_fixlineFunction · 0.85
check_matchFunction · 0.70
constructorFunction · 0.70

Tested by

no test coverage detected