MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / retstat

Function retstat

Source/Misc/lua/src/lua.c:8814–8844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8812
8813
8814static void retstat (LexState *ls) {
8815/* stat -> RETURN explist */
8816FuncState *fs = ls->fs;
8817expdesc e;
8818int first, nret; /* registers with returned values */
8819luaX_next(ls); /* skip RETURN */
8820if (block_follow(ls->t.token) || ls->t.token == ';')
8821first = nret = 0; /* return no values */
8822else {
8823nret = explist1(ls, &e); /* optional return values */
8824if (hasmultret(e.k)) {
8825luaK_setmultret(fs, &e);
8826if (e.k == VCALL && nret == 1) { /* tail call? */
8827SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
8828lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
8829}
8830first = fs->nactvar;
8831nret = LUA_MULTRET; /* return all values */
8832}
8833else {
8834if (nret == 1) /* only one single value? */
8835first = luaK_exp2anyreg(fs, &e);
8836else {
8837luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
8838first = fs->nactvar; /* return all `active' values */
8839lua_assert(nret == fs->freereg - first);
8840}
8841}
8842}
8843luaK_ret(fs, first, nret);
8844}
8845
8846
8847static 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