MCPcopy Create free account
hub / github.com/DFHack/dfhack / funcargs

Function funcargs

depends/lua/src/lparser.c:818–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

816
817
818static void funcargs (LexState *ls, expdesc *f, int line) {
819 FuncState *fs = ls->fs;
820 expdesc args;
821 int base, nparams;
822 switch (ls->t.token) {
823 case '(': { /* funcargs -> '(' [ explist ] ')' */
824 luaX_next(ls);
825 if (ls->t.token == ')') /* arg list is empty? */
826 args.k = VVOID;
827 else {
828 explist(ls, &args);
829 luaK_setmultret(fs, &args);
830 }
831 check_match(ls, ')', '(', line);
832 break;
833 }
834 case '{': { /* funcargs -> constructor */
835 constructor(ls, &args);
836 break;
837 }
838 case TK_STRING: { /* funcargs -> STRING */
839 codestring(ls, &args, ls->t.seminfo.ts);
840 luaX_next(ls); /* must use 'seminfo' before 'next' */
841 break;
842 }
843 default: {
844 luaX_syntaxerror(ls, "function arguments expected");
845 }
846 }
847 lua_assert(f->k == VNONRELOC);
848 base = f->u.info; /* base register for call */
849 if (hasmultret(args.k))
850 nparams = LUA_MULTRET; /* open call */
851 else {
852 if (args.k != VVOID)
853 luaK_exp2nextreg(fs, &args); /* close last argument */
854 nparams = fs->freereg - (base+1);
855 }
856 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
857 luaK_fixline(fs, line);
858 fs->freereg = base+1; /* call remove function and arguments and leaves
859 (unless changed) one result */
860}
861
862
863

Callers 1

suffixedexpFunction · 0.85

Calls 10

luaX_nextFunction · 0.85
explistFunction · 0.85
check_matchFunction · 0.85
constructorFunction · 0.85
codestringFunction · 0.85
luaX_syntaxerrorFunction · 0.85
luaK_exp2nextregFunction · 0.85
init_expFunction · 0.85
luaK_codeABCFunction · 0.85
luaK_fixlineFunction · 0.85

Tested by

no test coverage detected