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

Function forbody

third-party/lua-5.4.6/src/lparser.c:1543–1565  ·  view source on GitHub ↗

** Generate code for a 'for' loop. */

Source from the content-addressed store, hash-verified

1541** Generate code for a 'for' loop.
1542*/
1543static void forbody (LexState *ls, int base, int line, int nvars, int isgen) {
1544 /* forbody -> DO block */
1545 static const OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP};
1546 static const OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP};
1547 BlockCnt bl;
1548 FuncState *fs = ls->fs;
1549 int prep, endfor;
1550 checknext(ls, TK_DO);
1551 prep = luaK_codeABx(fs, forprep[isgen], base, 0);
1552 enterblock(fs, &bl, 0); /* scope for declared variables */
1553 adjustlocalvars(ls, nvars);
1554 luaK_reserveregs(fs, nvars);
1555 block(ls);
1556 leaveblock(fs); /* end of scope for declared variables */
1557 fixforjump(fs, prep, luaK_getlabel(fs), 0);
1558 if (isgen) { /* generic for? */
1559 luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars);
1560 luaK_fixline(fs, line);
1561 }
1562 endfor = luaK_codeABx(fs, forloop[isgen], base, 0);
1563 fixforjump(fs, endfor, prep + 1, 1);
1564 luaK_fixline(fs, line);
1565}
1566
1567
1568static void fornum (LexState *ls, TString *varname, int line) {

Callers 2

fornumFunction · 0.70
forlistFunction · 0.70

Calls 11

checknextFunction · 0.70
luaK_codeABxFunction · 0.70
enterblockFunction · 0.70
adjustlocalvarsFunction · 0.70
luaK_reserveregsFunction · 0.70
blockFunction · 0.70
leaveblockFunction · 0.70
fixforjumpFunction · 0.70
luaK_getlabelFunction · 0.70
luaK_fixlineFunction · 0.70
luaK_codeABCFunction · 0.50

Tested by

no test coverage detected