MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / fornum

Function fornum

lib/lua/src/lparser.c:1569–1589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1567
1568
1569static void fornum (LexState *ls, TString *varname, int line) {
1570 /* fornum -> NAME = exp,exp[,exp] forbody */
1571 FuncState *fs = ls->fs;
1572 int base = fs->freereg;
1573 new_localvarliteral(ls, "(for state)");
1574 new_localvarliteral(ls, "(for state)");
1575 new_localvarliteral(ls, "(for state)");
1576 new_localvar(ls, varname);
1577 checknext(ls, '=');
1578 exp1(ls); /* initial value */
1579 checknext(ls, ',');
1580 exp1(ls); /* limit */
1581 if (testnext(ls, ','))
1582 exp1(ls); /* optional step */
1583 else { /* default step = 1 */
1584 luaK_int(fs, fs->freereg, 1);
1585 luaK_reserveregs(fs, 1);
1586 }
1587 adjustlocalvars(ls, 3); /* control variables */
1588 forbody(ls, base, line, 1, 0);
1589}
1590
1591
1592static 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