| 1571 | |
| 1572 | |
| 1573 | static void forlist (LexState *ls, TString *indexname) { |
| 1574 | /* forlist -> NAME {,NAME} IN explist forbody */ |
| 1575 | FuncState *fs = ls->fs; |
| 1576 | expdesc e; |
| 1577 | int nvars = 5; /* gen, state, control, toclose, 'indexname' */ |
| 1578 | int line; |
| 1579 | int base = fs->freereg; |
| 1580 | /* create control variables */ |
| 1581 | new_localvarliteral(ls, "(for state)"); |
| 1582 | new_localvarliteral(ls, "(for state)"); |
| 1583 | new_localvarliteral(ls, "(for state)"); |
| 1584 | new_localvarliteral(ls, "(for state)"); |
| 1585 | /* create declared variables */ |
| 1586 | new_localvar(ls, indexname); |
| 1587 | while (testnext(ls, ',')) { |
| 1588 | new_localvar(ls, str_checkname(ls)); |
| 1589 | nvars++; |
| 1590 | } |
| 1591 | checknext(ls, TK_IN); |
| 1592 | line = ls->linenumber; |
| 1593 | adjust_assign(ls, 4, explist(ls, &e), &e); |
| 1594 | adjustlocalvars(ls, 4); /* control variables */ |
| 1595 | markupval(fs, luaY_nvarstack(fs)); /* state may create an upvalue */ |
| 1596 | luaK_checkstack(fs, 3); /* extra space to call generator */ |
| 1597 | forbody(ls, base, line, nvars - 4, 1); |
| 1598 | } |
| 1599 | |
| 1600 | |
| 1601 | static void forstat (LexState *ls, int line) { |
no test coverage detected