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

Function retstat

depends/lua/src/lparser.c:1505–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1503
1504
1505static void retstat (LexState *ls) {
1506 /* stat -> RETURN [explist] [';'] */
1507 FuncState *fs = ls->fs;
1508 expdesc e;
1509 int first, nret; /* registers with returned values */
1510 if (block_follow(ls, 1) || ls->t.token == ';')
1511 first = nret = 0; /* return no values */
1512 else {
1513 nret = explist(ls, &e); /* optional return values */
1514 if (hasmultret(e.k)) {
1515 luaK_setmultret(fs, &e);
1516 if (e.k == VCALL && nret == 1) { /* tail call? */
1517 SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
1518 lua_assert(GETARG_A(getinstruction(fs,&e)) == fs->nactvar);
1519 }
1520 first = fs->nactvar;
1521 nret = LUA_MULTRET; /* return all values */
1522 }
1523 else {
1524 if (nret == 1) /* only one single value? */
1525 first = luaK_exp2anyreg(fs, &e);
1526 else {
1527 luaK_exp2nextreg(fs, &e); /* values must go to the stack */
1528 first = fs->nactvar; /* return all active values */
1529 lua_assert(nret == fs->freereg - first);
1530 }
1531 }
1532 }
1533 luaK_ret(fs, first, nret);
1534 testnext(ls, ';'); /* skip optional semicolon */
1535}
1536
1537
1538static void statement (LexState *ls) {

Callers 1

statementFunction · 0.85

Calls 6

block_followFunction · 0.85
explistFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_exp2nextregFunction · 0.85
luaK_retFunction · 0.85
testnextFunction · 0.85

Tested by

no test coverage detected