MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / retstat

Function retstat

3rd/lua-5.4.3/src/lparser.c:1802–1831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1800
1801
1802static void retstat (LexState *ls) {
1803 /* stat -> RETURN [explist] [';'] */
1804 FuncState *fs = ls->fs;
1805 expdesc e;
1806 int nret; /* number of values being returned */
1807 int first = luaY_nvarstack(fs); /* first slot to be returned */
1808 if (block_follow(ls, 1) || ls->t.token == ';')
1809 nret = 0; /* return no values */
1810 else {
1811 nret = explist(ls, &e); /* optional return values */
1812 if (hasmultret(e.k)) {
1813 luaK_setmultret(fs, &e);
1814 if (e.k == VCALL && nret == 1 && !fs->bl->insidetbc) { /* tail call? */
1815 SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
1816 lua_assert(GETARG_A(getinstruction(fs,&e)) == luaY_nvarstack(fs));
1817 }
1818 nret = LUA_MULTRET; /* return all values */
1819 }
1820 else {
1821 if (nret == 1) /* only one single value? */
1822 first = luaK_exp2anyreg(fs, &e); /* can use original slot */
1823 else { /* values must go to the top of the stack */
1824 luaK_exp2nextreg(fs, &e);
1825 lua_assert(nret == fs->freereg - first);
1826 }
1827 }
1828 }
1829 luaK_ret(fs, first, nret);
1830 testnext(ls, ';'); /* skip optional semicolon */
1831}
1832
1833
1834static void statement (LexState *ls) {

Callers 1

statementFunction · 0.85

Calls 7

luaY_nvarstackFunction · 0.85
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