MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / retstat

Function retstat

extlibs/lua/src/lparser.c:1832–1861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1830
1831
1832static void retstat (LexState *ls) {
1833 /* stat -> RETURN [explist] [';'] */
1834 FuncState *fs = ls->fs;
1835 expdesc e;
1836 int nret; /* number of values being returned */
1837 int first = luaY_nvarstack(fs); /* first slot to be returned */
1838 if (block_follow(ls, 1) || ls->t.token == ';')
1839 nret = 0; /* return no values */
1840 else {
1841 nret = explist(ls, &e); /* optional return values */
1842 if (hasmultret(e.k)) {
1843 luaK_setmultret(fs, &e);
1844 if (e.k == VCALL && nret == 1 && !fs->bl->insidetbc) { /* tail call? */
1845 SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
1846 lua_assert(GETARG_A(getinstruction(fs,&e)) == luaY_nvarstack(fs));
1847 }
1848 nret = LUA_MULTRET; /* return all values */
1849 }
1850 else {
1851 if (nret == 1) /* only one single value? */
1852 first = luaK_exp2anyreg(fs, &e); /* can use original slot */
1853 else { /* values must go to the top of the stack */
1854 luaK_exp2nextreg(fs, &e);
1855 lua_assert(nret == fs->freereg - first);
1856 }
1857 }
1858 }
1859 luaK_ret(fs, first, nret);
1860 testnext(ls, ';'); /* skip optional semicolon */
1861}
1862
1863
1864static 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