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

Function forbody

depends/lua/src/lparser.c:1292–1315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1290
1291
1292static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
1293 /* forbody -> DO block */
1294 BlockCnt bl;
1295 FuncState *fs = ls->fs;
1296 int prep, endfor;
1297 adjustlocalvars(ls, 3); /* control variables */
1298 checknext(ls, TK_DO);
1299 prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
1300 enterblock(fs, &bl, 0); /* scope for declared variables */
1301 adjustlocalvars(ls, nvars);
1302 luaK_reserveregs(fs, nvars);
1303 block(ls);
1304 leaveblock(fs); /* end of scope for declared variables */
1305 luaK_patchtohere(fs, prep);
1306 if (isnum) /* numeric for? */
1307 endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP);
1308 else { /* generic for */
1309 luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars);
1310 luaK_fixline(fs, line);
1311 endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP);
1312 }
1313 luaK_patchlist(fs, endfor, prep + 1);
1314 luaK_fixline(fs, line);
1315}
1316
1317
1318static void fornum (LexState *ls, TString *varname, int line) {

Callers 2

fornumFunction · 0.85
forlistFunction · 0.85

Calls 11

adjustlocalvarsFunction · 0.85
checknextFunction · 0.85
luaK_jumpFunction · 0.85
enterblockFunction · 0.85
luaK_reserveregsFunction · 0.85
blockFunction · 0.85
leaveblockFunction · 0.85
luaK_patchtohereFunction · 0.85
luaK_codeABCFunction · 0.85
luaK_fixlineFunction · 0.85
luaK_patchlistFunction · 0.85

Tested by

no test coverage detected