| 1683 | |
| 1684 | |
| 1685 | static void fornum (LexState *ls, TString *varname, int line) { |
| 1686 | /* fornum -> NAME = exp,exp[,exp] forbody */ |
| 1687 | FuncState *fs = ls->fs; |
| 1688 | int base = fs->freereg; |
| 1689 | new_localvarliteral(ls, "(for state)"); |
| 1690 | new_localvarliteral(ls, "(for state)"); |
| 1691 | new_varkind(ls, varname, RDKCONST); /* control variable */ |
| 1692 | checknext(ls, '='); |
| 1693 | exp1(ls); /* initial value */ |
| 1694 | checknext(ls, ','); |
| 1695 | exp1(ls); /* limit */ |
| 1696 | if (testnext(ls, ',')) |
| 1697 | exp1(ls); /* optional step */ |
| 1698 | else { /* default step = 1 */ |
| 1699 | luaK_int(fs, fs->freereg, 1); |
| 1700 | luaK_reserveregs(fs, 1); |
| 1701 | } |
| 1702 | adjustlocalvars(ls, 2); /* start scope for internal variables */ |
| 1703 | forbody(ls, base, line, 1, 0); |
| 1704 | } |
| 1705 | |
| 1706 | |
| 1707 | static void forlist (LexState *ls, TString *indexname) { |
no test coverage detected