MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / retstat

Function retstat

deps/lua/src/lparser.c:1238–1268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1236
1237
1238static void retstat (LexState *ls) {
1239 /* stat -> RETURN explist */
1240 FuncState *fs = ls->fs;
1241 expdesc e;
1242 int first, nret; /* registers with returned values */
1243 luaX_next(ls); /* skip RETURN */
1244 if (block_follow(ls->t.token) || ls->t.token == ';')
1245 first = nret = 0; /* return no values */
1246 else {
1247 nret = explist1(ls, &e); /* optional return values */
1248 if (hasmultret(e.k)) {
1249 luaK_setmultret(fs, &e);
1250 if (e.k == VCALL && nret == 1) { /* tail call? */
1251 SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
1252 lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
1253 }
1254 first = fs->nactvar;
1255 nret = LUA_MULTRET; /* return all values */
1256 }
1257 else {
1258 if (nret == 1) /* only one single value? */
1259 first = luaK_exp2anyreg(fs, &e);
1260 else {
1261 luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */
1262 first = fs->nactvar; /* return all `active' values */
1263 lua_assert(nret == fs->freereg - first);
1264 }
1265 }
1266 }
1267 luaK_ret(fs, first, nret);
1268}
1269
1270
1271static 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