| 1566 | |
| 1567 | |
| 1568 | static void fornum (LexState *ls, TString *varname, int line) { |
| 1569 | /* fornum -> NAME = exp,exp[,exp] forbody */ |
| 1570 | FuncState *fs = ls->fs; |
| 1571 | int base = fs->freereg; |
| 1572 | new_localvarliteral(ls, "(for state)"); |
| 1573 | new_localvarliteral(ls, "(for state)"); |
| 1574 | new_localvarliteral(ls, "(for state)"); |
| 1575 | new_localvar(ls, varname); |
| 1576 | checknext(ls, '='); |
| 1577 | exp1(ls); /* initial value */ |
| 1578 | checknext(ls, ','); |
| 1579 | exp1(ls); /* limit */ |
| 1580 | if (testnext(ls, ',')) |
| 1581 | exp1(ls); /* optional step */ |
| 1582 | else { /* default step = 1 */ |
| 1583 | luaK_int(fs, fs->freereg, 1); |
| 1584 | luaK_reserveregs(fs, 1); |
| 1585 | } |
| 1586 | adjustlocalvars(ls, 3); /* control variables */ |
| 1587 | forbody(ls, base, line, 1, 0); |
| 1588 | } |
| 1589 | |
| 1590 | |
| 1591 | static void forlist (LexState *ls, TString *indexname) { |
no test coverage detected