| 1705 | |
| 1706 | |
| 1707 | static void forlist (LexState *ls, TString *indexname) { |
| 1708 | /* forlist -> NAME {,NAME} IN explist forbody */ |
| 1709 | FuncState *fs = ls->fs; |
| 1710 | expdesc e; |
| 1711 | int nvars = 4; /* function, state, closing, control */ |
| 1712 | int line; |
| 1713 | int base = fs->freereg; |
| 1714 | /* create internal variables */ |
| 1715 | new_localvarliteral(ls, "(for state)"); /* iterator function */ |
| 1716 | new_localvarliteral(ls, "(for state)"); /* state */ |
| 1717 | new_localvarliteral(ls, "(for state)"); /* closing var. (after swap) */ |
| 1718 | new_varkind(ls, indexname, RDKCONST); /* control variable */ |
| 1719 | /* other declared variables */ |
| 1720 | while (testnext(ls, ',')) { |
| 1721 | new_localvar(ls, str_checkname(ls)); |
| 1722 | nvars++; |
| 1723 | } |
| 1724 | checknext(ls, TK_IN); |
| 1725 | line = ls->linenumber; |
| 1726 | adjust_assign(ls, 4, explist(ls, &e), &e); |
| 1727 | adjustlocalvars(ls, 3); /* start scope for internal variables */ |
| 1728 | marktobeclosed(fs); /* last internal var. must be closed */ |
| 1729 | luaK_checkstack(fs, 2); /* extra space to call iterator */ |
| 1730 | forbody(ls, base, line, nvars - 3, 1); |
| 1731 | } |
| 1732 | |
| 1733 | |
| 1734 | static void forstat (LexState *ls, int line) { |
no test coverage detected