MCPcopy Create free account
hub / github.com/F-Stack/f-stack / funcargs

Function funcargs

app/redis-6.2.6/deps/lua/src/lparser.c:613–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611
612
613static void funcargs (LexState *ls, expdesc *f) {
614 FuncState *fs = ls->fs;
615 expdesc args;
616 int base, nparams;
617 int line = ls->linenumber;
618 switch (ls->t.token) {
619 case '(': { /* funcargs -> `(' [ explist1 ] `)' */
620 if (line != ls->lastline)
621 luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
622 luaX_next(ls);
623 if (ls->t.token == ')') /* arg list is empty? */
624 args.k = VVOID;
625 else {
626 explist1(ls, &args);
627 luaK_setmultret(fs, &args);
628 }
629 check_match(ls, ')', '(', line);
630 break;
631 }
632 case '{': { /* funcargs -> constructor */
633 constructor(ls, &args);
634 break;
635 }
636 case TK_STRING: { /* funcargs -> STRING */
637 codestring(ls, &args, ls->t.seminfo.ts);
638 luaX_next(ls); /* must use `seminfo' before `next' */
639 break;
640 }
641 default: {
642 luaX_syntaxerror(ls, "function arguments expected");
643 return;
644 }
645 }
646 lua_assert(f->k == VNONRELOC);
647 base = f->u.s.info; /* base register for call */
648 if (hasmultret(args.k))
649 nparams = LUA_MULTRET; /* open call */
650 else {
651 if (args.k != VVOID)
652 luaK_exp2nextreg(fs, &args); /* close last argument */
653 nparams = fs->freereg - (base+1);
654 }
655 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
656 luaK_fixline(fs, line);
657 fs->freereg = base+1; /* call remove function and arguments and leaves
658 (unless changed) one result */
659}
660
661
662

Callers 1

primaryexpFunction · 0.70

Calls 10

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

Tested by

no test coverage detected