MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / retstat

Function retstat

lib/lua/src/lparser.c:1813–1842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1811
1812
1813static void retstat (LexState *ls) {
1814 /* stat -> RETURN [explist] [';'] */
1815 FuncState *fs = ls->fs;
1816 expdesc e;
1817 int nret; /* number of values being returned */
1818 int first = luaY_nvarstack(fs); /* first slot to be returned */
1819 if (block_follow(ls, 1) || ls->t.token == ';')
1820 nret = 0; /* return no values */
1821 else {
1822 nret = explist(ls, &e); /* optional return values */
1823 if (hasmultret(e.k)) {
1824 luaK_setmultret(fs, &e);
1825 if (e.k == VCALL && nret == 1 && !fs->bl->insidetbc) { /* tail call? */
1826 SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
1827 lua_assert(GETARG_A(getinstruction(fs,&e)) == luaY_nvarstack(fs));
1828 }
1829 nret = LUA_MULTRET; /* return all values */
1830 }
1831 else {
1832 if (nret == 1) /* only one single value? */
1833 first = luaK_exp2anyreg(fs, &e); /* can use original slot */
1834 else { /* values must go to the top of the stack */
1835 luaK_exp2nextreg(fs, &e);
1836 lua_assert(nret == fs->freereg - first);
1837 }
1838 }
1839 }
1840 luaK_ret(fs, first, nret);
1841 testnext(ls, ';'); /* skip optional semicolon */
1842}
1843
1844
1845static 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