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

Function funcargs

lua/lparser.c:643–694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641
642
643static void funcargs (LexState *ls, expdesc *f) {
644 FuncState *fs = ls->fs;
645 expdesc args;
646 int base, nparams;
647 int line = ls->linenumber;
648 switch (ls->t.token) {
649 case '(': { /* funcargs -> `(' [ explist1 ] `)' */
650 if (line != ls->lastline)
651 luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
652 luaX_next(ls);
653 if (ls->t.token == ')') /* arg list is empty? */
654 args.k = VVOID;
655 else {
656 explist1(ls, &args);
657 luaK_setmultret(fs, &args);
658 }
659 check_match(ls, ')', '(', line);
660 break;
661 }
662 case '{': { /* funcargs -> constructor */
663 constructor(ls, &args);
664 break;
665 }
666 case TK_STRING: { /* funcargs -> STRING */
667 codestring(ls, &args, ls->t.seminfo.ts);
668 luaX_next(ls); /* must use `seminfo' before `next' */
669 break;
670 }
671 case TK_BLOB: {
672 codeblob(ls, &args, ls->t.seminfo.ts);
673 luaX_next(ls);
674 break;
675 }
676 default: {
677 luaX_syntaxerror(ls, "function arguments expected");
678 return;
679 }
680 }
681 lua_assert(f->k == VNONRELOC);
682 base = f->u.s.info; /* base register for call */
683 if (hasmultret(args.k))
684 nparams = LUA_MULTRET; /* open call */
685 else {
686 if (args.k != VVOID)
687 luaK_exp2nextreg(fs, &args); /* close last argument */
688 nparams = fs->freereg - (base+1);
689 }
690 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
691 luaK_fixline(fs, line);
692 fs->freereg = base+1; /* call remove function and arguments and leaves
693 (unless changed) one result */
694}
695
696
697

Callers 1

primaryexpFunction · 0.85

Calls 11

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

Tested by

no test coverage detected