| 1569 | |
| 1570 | |
| 1571 | static void retstat(LexState *ls) { |
| 1572 | /* stat -> RETURN [explist] [';'] */ |
| 1573 | FuncState *fs = ls->fs; |
| 1574 | expdesc e; |
| 1575 | int first, nret; /* registers with returned values */ |
| 1576 | if (block_follow(ls, 1) || ls->t.token == ';') |
| 1577 | first = nret = 0; /* return no values */ |
| 1578 | else { |
| 1579 | nret = explist(ls, &e); /* optional return values */ |
| 1580 | if (hasmultret(e.k)) { |
| 1581 | luaK_setmultret(fs, &e); |
| 1582 | if (e.k == VCALL && nret == 1) { /* tail call? */ |
| 1583 | SET_OPCODE(getcode(fs, &e), OP_TAILCALL); |
| 1584 | lua_assert(GETARG_A(getcode(fs, &e)) == fs->nactvar); |
| 1585 | } |
| 1586 | first = fs->nactvar; |
| 1587 | nret = LUA_MULTRET; /* return all values */ |
| 1588 | } |
| 1589 | else { |
| 1590 | if (nret == 1) /* only one single value? */ |
| 1591 | first = luaK_exp2anyreg(fs, &e); |
| 1592 | else { |
| 1593 | luaK_exp2nextreg(fs, &e); /* values must go to the stack */ |
| 1594 | first = fs->nactvar; /* return all active values */ |
| 1595 | lua_assert(nret == fs->freereg - first); |
| 1596 | } |
| 1597 | } |
| 1598 | } |
| 1599 | luaK_ret(fs, first, nret); |
| 1600 | testnext(ls, ';'); /* skip optional semicolon */ |
| 1601 | } |
| 1602 | |
| 1603 | |
| 1604 | static void statement(LexState *ls) { |
no test coverage detected