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

Function forlist

depends/lua/src/lparser.c:1340–1362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1338
1339
1340static void forlist (LexState *ls, TString *indexname) {
1341 /* forlist -> NAME {,NAME} IN explist forbody */
1342 FuncState *fs = ls->fs;
1343 expdesc e;
1344 int nvars = 4; /* gen, state, control, plus at least one declared var */
1345 int line;
1346 int base = fs->freereg;
1347 /* create control variables */
1348 new_localvarliteral(ls, "(for generator)");
1349 new_localvarliteral(ls, "(for state)");
1350 new_localvarliteral(ls, "(for control)");
1351 /* create declared variables */
1352 new_localvar(ls, indexname);
1353 while (testnext(ls, ',')) {
1354 new_localvar(ls, str_checkname(ls));
1355 nvars++;
1356 }
1357 checknext(ls, TK_IN);
1358 line = ls->linenumber;
1359 adjust_assign(ls, 3, explist(ls, &e), &e);
1360 luaK_checkstack(fs, 3); /* extra space to call generator */
1361 forbody(ls, base, line, nvars - 3, 0);
1362}
1363
1364
1365static void forstat (LexState *ls, int line) {

Callers 1

forstatFunction · 0.85

Calls 8

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

Tested by

no test coverage detected