MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / funcargs

Function funcargs

third-party/lua-5.4.6/src/lparser.c:1024–1068  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1022
1023
1024static void funcargs (LexState *ls, expdesc *f) {
1025 FuncState *fs = ls->fs;
1026 expdesc args;
1027 int base, nparams;
1028 int line = ls->linenumber;
1029 switch (ls->t.token) {
1030 case '(': { /* funcargs -> '(' [ explist ] ')' */
1031 luaX_next(ls);
1032 if (ls->t.token == ')') /* arg list is empty? */
1033 args.k = VVOID;
1034 else {
1035 explist(ls, &args);
1036 if (hasmultret(args.k))
1037 luaK_setmultret(fs, &args);
1038 }
1039 check_match(ls, ')', '(', line);
1040 break;
1041 }
1042 case '{': { /* funcargs -> constructor */
1043 constructor(ls, &args);
1044 break;
1045 }
1046 case TK_STRING: { /* funcargs -> STRING */
1047 codestring(&args, ls->t.seminfo.ts);
1048 luaX_next(ls); /* must use 'seminfo' before 'next' */
1049 break;
1050 }
1051 default: {
1052 luaX_syntaxerror(ls, "function arguments expected");
1053 }
1054 }
1055 lua_assert(f->k == VNONRELOC);
1056 base = f->u.info; /* base register for call */
1057 if (hasmultret(args.k))
1058 nparams = LUA_MULTRET; /* open call */
1059 else {
1060 if (args.k != VVOID)
1061 luaK_exp2nextreg(fs, &args); /* close last argument */
1062 nparams = fs->freereg - (base+1);
1063 }
1064 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
1065 luaK_fixline(fs, line);
1066 fs->freereg = base+1; /* call removes function and arguments and leaves
1067 one result (unless changed later) */
1068}
1069
1070
1071

Callers 1

suffixedexpFunction · 0.70

Calls 10

luaX_nextFunction · 0.70
explistFunction · 0.70
check_matchFunction · 0.70
constructorFunction · 0.70
codestringFunction · 0.70
luaX_syntaxerrorFunction · 0.70
luaK_exp2nextregFunction · 0.70
init_expFunction · 0.70
luaK_fixlineFunction · 0.70
luaK_codeABCFunction · 0.50

Tested by

no test coverage detected