MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / forbody

Function forbody

third-party/lua-5.2.4/src/lparser.c:1283–1306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

fornumFunction · 0.70
forlistFunction · 0.70

Calls 11

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

Tested by

no test coverage detected