MCPcopy Create free account
hub / github.com/DFHack/dfhack / fornum

Function fornum

depends/lua/src/lparser.c:1318–1337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1316
1317
1318static void fornum (LexState *ls, TString *varname, int line) {
1319 /* fornum -> NAME = exp1,exp1[,exp1] forbody */
1320 FuncState *fs = ls->fs;
1321 int base = fs->freereg;
1322 new_localvarliteral(ls, "(for index)");
1323 new_localvarliteral(ls, "(for limit)");
1324 new_localvarliteral(ls, "(for step)");
1325 new_localvar(ls, varname);
1326 checknext(ls, '=');
1327 exp1(ls); /* initial value */
1328 checknext(ls, ',');
1329 exp1(ls); /* limit */
1330 if (testnext(ls, ','))
1331 exp1(ls); /* optional step */
1332 else { /* default step = 1 */
1333 luaK_codek(fs, fs->freereg, luaK_intK(fs, 1));
1334 luaK_reserveregs(fs, 1);
1335 }
1336 forbody(ls, base, line, 1, 1);
1337}
1338
1339
1340static 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_codekFunction · 0.85
luaK_intKFunction · 0.85
luaK_reserveregsFunction · 0.85
forbodyFunction · 0.85

Tested by

no test coverage detected