| 1548 | |
| 1549 | |
| 1550 | static void fornum (LexState *ls, TString *varname, int line) { |
| 1551 | /* fornum -> NAME = exp,exp[,exp] forbody */ |
| 1552 | FuncState *fs = ls->fs; |
| 1553 | int base = fs->freereg; |
| 1554 | new_localvarliteral(ls, "(for state)"); |
| 1555 | new_localvarliteral(ls, "(for state)"); |
| 1556 | new_localvarliteral(ls, "(for state)"); |
| 1557 | new_localvar(ls, varname); |
| 1558 | checknext(ls, '='); |
| 1559 | exp1(ls); /* initial value */ |
| 1560 | checknext(ls, ','); |
| 1561 | exp1(ls); /* limit */ |
| 1562 | if (testnext(ls, ',')) |
| 1563 | exp1(ls); /* optional step */ |
| 1564 | else { /* default step = 1 */ |
| 1565 | luaK_int(fs, fs->freereg, 1); |
| 1566 | luaK_reserveregs(fs, 1); |
| 1567 | } |
| 1568 | adjustlocalvars(ls, 3); /* control variables */ |
| 1569 | forbody(ls, base, line, 1, 0); |
| 1570 | } |
| 1571 | |
| 1572 | |
| 1573 | static void forlist (LexState *ls, TString *indexname) { |
no test coverage detected