| 1494 | |
| 1495 | |
| 1496 | static void retstat (LexState *ls) { |
| 1497 | /* stat -> RETURN [explist] [';'] */ |
| 1498 | FuncState *fs = ls->fs; |
| 1499 | expdesc e; |
| 1500 | int first, nret; /* registers with returned values */ |
| 1501 | if (block_follow(ls, 1) || ls->t.token == ';') |
| 1502 | first = nret = 0; /* return no values */ |
| 1503 | else { |
| 1504 | nret = explist(ls, &e); /* optional return values */ |
| 1505 | if (hasmultret(e.k)) { |
| 1506 | luaK_setmultret(fs, &e); |
| 1507 | if (e.k == VCALL && nret == 1) { /* tail call? */ |
| 1508 | SET_OPCODE(getcode(fs,&e), OP_TAILCALL); |
| 1509 | lua_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar); |
| 1510 | } |
| 1511 | first = fs->nactvar; |
| 1512 | nret = LUA_MULTRET; /* return all values */ |
| 1513 | } |
| 1514 | else { |
| 1515 | if (nret == 1) /* only one single value? */ |
| 1516 | first = luaK_exp2anyreg(fs, &e); |
| 1517 | else { |
| 1518 | luaK_exp2nextreg(fs, &e); /* values must go to the `stack' */ |
| 1519 | first = fs->nactvar; /* return all `active' values */ |
| 1520 | lua_assert(nret == fs->freereg - first); |
| 1521 | } |
| 1522 | } |
| 1523 | } |
| 1524 | luaK_ret(fs, first, nret); |
| 1525 | testnext(ls, ';'); /* skip optional semicolon */ |
| 1526 | } |
| 1527 | |
| 1528 | |
| 1529 | static void statement (LexState *ls) { |
no test coverage detected