MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / forlist

Function forlist

3rd/lua-5.4.3/src/lparser.c:1580–1605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1578
1579
1580static void forlist (LexState *ls, TString *indexname) {
1581 /* forlist -> NAME {,NAME} IN explist forbody */
1582 FuncState *fs = ls->fs;
1583 expdesc e;
1584 int nvars = 5; /* gen, state, control, toclose, 'indexname' */
1585 int line;
1586 int base = fs->freereg;
1587 /* create control variables */
1588 new_localvarliteral(ls, "(for state)");
1589 new_localvarliteral(ls, "(for state)");
1590 new_localvarliteral(ls, "(for state)");
1591 new_localvarliteral(ls, "(for state)");
1592 /* create declared variables */
1593 new_localvar(ls, indexname);
1594 while (testnext(ls, ',')) {
1595 new_localvar(ls, str_checkname(ls));
1596 nvars++;
1597 }
1598 checknext(ls, TK_IN);
1599 line = ls->linenumber;
1600 adjust_assign(ls, 4, explist(ls, &e), &e);
1601 adjustlocalvars(ls, 4); /* control variables */
1602 markupval(fs, fs->nactvar); /* last control var. must be closed */
1603 luaK_checkstack(fs, 3); /* extra space to call generator */
1604 forbody(ls, base, line, nvars - 4, 1);
1605}
1606
1607
1608static void forstat (LexState *ls, int line) {

Callers 1

forstatFunction · 0.85

Calls 10

new_localvarFunction · 0.85
testnextFunction · 0.85
str_checknameFunction · 0.85
checknextFunction · 0.85
adjust_assignFunction · 0.85
explistFunction · 0.85
adjustlocalvarsFunction · 0.85
markupvalFunction · 0.85
luaK_checkstackFunction · 0.85
forbodyFunction · 0.85

Tested by

no test coverage detected