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

Function retstat

lua/lparser.c:1324–1354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1322
1323
1324static void retstat (LexState *ls) {
1325 /* stat -> RETURN explist */
1326 FuncState *fs = ls->fs;
1327 expdesc e;
1328 int first, nret; /* registers with returned values */
1329 luaX_next(ls); /* skip RETURN */
1330 if (block_follow(ls->t.token) || ls->t.token == ';')
1331 first = nret = 0; /* return no values */
1332 else {
1333 nret = explist1(ls, &e); /* optional return values */
1334 if (hasmultret(e.k)) {
1335 luaK_setmultret(fs, &e);
1336 if (e.k == VCALL && nret == 1) { /* tail call? */
1337 SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
1338 lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
1339 }
1340 first = fs->nactvar;
1341 nret = LUA_MULTRET; /* return all values */
1342 }
1343 else {
1344 if (nret == 1) /* only one single value? */
1345 first = luaK_exp2anyreg(fs, &e);
1346 else {
1347 luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
1348 first = fs->nactvar; /* return all `active' values */
1349 lua_assert(nret == fs->freereg - first);
1350 }
1351 }
1352 }
1353 luaK_ret(fs, first, nret);
1354}
1355
1356
1357static int statement (LexState *ls) {

Callers 1

statementFunction · 0.85

Calls 6

luaX_nextFunction · 0.85
block_followFunction · 0.85
explist1Function · 0.85
luaK_exp2anyregFunction · 0.85
luaK_exp2nextregFunction · 0.85
luaK_retFunction · 0.85

Tested by

no test coverage detected