MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / retstat

Function retstat

third-party/lua-5.5.0/src/lparser.c:2017–2046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2015
2016
2017static void retstat (LexState *ls) {
2018 /* stat -> RETURN [explist] [';'] */
2019 FuncState *fs = ls->fs;
2020 expdesc e;
2021 int nret; /* number of values being returned */
2022 int first = luaY_nvarstack(fs); /* first slot to be returned */
2023 if (block_follow(ls, 1) || ls->t.token == ';')
2024 nret = 0; /* return no values */
2025 else {
2026 nret = explist(ls, &e); /* optional return values */
2027 if (hasmultret(e.k)) {
2028 luaK_setmultret(fs, &e);
2029 if (e.k == VCALL && nret == 1 && !fs->bl->insidetbc) { /* tail call? */
2030 SET_OPCODE(getinstruction(fs,&e), OP_TAILCALL);
2031 lua_assert(GETARG_A(getinstruction(fs,&e)) == luaY_nvarstack(fs));
2032 }
2033 nret = LUA_MULTRET; /* return all values */
2034 }
2035 else {
2036 if (nret == 1) /* only one single value? */
2037 first = luaK_exp2anyreg(fs, &e); /* can use original slot */
2038 else { /* values must go to the top of the stack */
2039 luaK_exp2nextreg(fs, &e);
2040 lua_assert(nret == fs->freereg - first);
2041 }
2042 }
2043 }
2044 luaK_ret(fs, first, nret);
2045 testnext(ls, ';'); /* skip optional semicolon */
2046}
2047
2048
2049static void statement (LexState *ls) {

Callers 1

statementFunction · 0.70

Calls 7

luaY_nvarstackFunction · 0.70
block_followFunction · 0.70
explistFunction · 0.70
luaK_exp2anyregFunction · 0.70
luaK_exp2nextregFunction · 0.70
luaK_retFunction · 0.70
testnextFunction · 0.70

Tested by

no test coverage detected