MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / fornum

Function fornum

extlibs/lua/src/lparser.c:1550–1570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1548
1549
1550static 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
1573static void forlist (LexState *ls, TString *indexname) {

Callers 1

forstatFunction · 0.85

Calls 8

new_localvarFunction · 0.85
checknextFunction · 0.85
exp1Function · 0.85
testnextFunction · 0.85
luaK_intFunction · 0.85
luaK_reserveregsFunction · 0.85
adjustlocalvarsFunction · 0.85
forbodyFunction · 0.85

Tested by

no test coverage detected