| 1590 | |
| 1591 | |
| 1592 | static void forlist (LexState *ls, TString *indexname) { |
| 1593 | /* forlist -> NAME {,NAME} IN explist forbody */ |
| 1594 | FuncState *fs = ls->fs; |
| 1595 | expdesc e; |
| 1596 | int nvars = 5; /* gen, state, control, toclose, 'indexname' */ |
| 1597 | int line; |
| 1598 | int base = fs->freereg; |
| 1599 | /* create control variables */ |
| 1600 | new_localvarliteral(ls, "(for state)"); |
| 1601 | new_localvarliteral(ls, "(for state)"); |
| 1602 | new_localvarliteral(ls, "(for state)"); |
| 1603 | new_localvarliteral(ls, "(for state)"); |
| 1604 | /* create declared variables */ |
| 1605 | new_localvar(ls, indexname); |
| 1606 | while (testnext(ls, ',')) { |
| 1607 | new_localvar(ls, str_checkname(ls)); |
| 1608 | nvars++; |
| 1609 | } |
| 1610 | checknext(ls, TK_IN); |
| 1611 | line = ls->linenumber; |
| 1612 | adjust_assign(ls, 4, explist(ls, &e), &e); |
| 1613 | adjustlocalvars(ls, 4); /* control variables */ |
| 1614 | marktobeclosed(fs); /* last control var. must be closed */ |
| 1615 | luaK_checkstack(fs, 3); /* extra space to call generator */ |
| 1616 | forbody(ls, base, line, nvars - 4, 1); |
| 1617 | } |
| 1618 | |
| 1619 | |
| 1620 | static void forstat (LexState *ls, int line) { |
no test coverage detected