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

Function funcargs

third-party/lua-5.5.0/src/lparser.c:1138–1183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1136
1137
1138static void funcargs (LexState *ls, expdesc *f) {
1139 FuncState *fs = ls->fs;
1140 expdesc args;
1141 int base, nparams;
1142 int line = ls->linenumber;
1143 switch (ls->t.token) {
1144 case '(': { /* funcargs -> '(' [ explist ] ')' */
1145 luaX_next(ls);
1146 if (ls->t.token == ')') /* arg list is empty? */
1147 args.k = VVOID;
1148 else {
1149 explist(ls, &args);
1150 if (hasmultret(args.k))
1151 luaK_setmultret(fs, &args);
1152 }
1153 check_match(ls, ')', '(', line);
1154 break;
1155 }
1156 case '{' /*}*/: { /* funcargs -> constructor */
1157 constructor(ls, &args);
1158 break;
1159 }
1160 case TK_STRING: { /* funcargs -> STRING */
1161 codestring(&args, ls->t.seminfo.ts);
1162 luaX_next(ls); /* must use 'seminfo' before 'next' */
1163 break;
1164 }
1165 default: {
1166 luaX_syntaxerror(ls, "function arguments expected");
1167 }
1168 }
1169 lua_assert(f->k == VNONRELOC);
1170 base = f->u.info; /* base register for call */
1171 if (hasmultret(args.k))
1172 nparams = LUA_MULTRET; /* open call */
1173 else {
1174 if (args.k != VVOID)
1175 luaK_exp2nextreg(fs, &args); /* close last argument */
1176 nparams = fs->freereg - (base+1);
1177 }
1178 init_exp(f, VCALL, luaK_codeABC(fs, OP_CALL, base, nparams+1, 2));
1179 luaK_fixline(fs, line);
1180 /* call removes function and arguments and leaves one result (unless
1181 changed later) */
1182 fs->freereg = cast_byte(base + 1);
1183}
1184
1185
1186

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