MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / forbody

Function forbody

extlibs/lua/src/lparser.c:1525–1547  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1523** Generate code for a 'for' loop.
1524*/
1525static void forbody (LexState *ls, int base, int line, int nvars, int isgen) {
1526 /* forbody -> DO block */
1527 static const OpCode forprep[2] = {OP_FORPREP, OP_TFORPREP};
1528 static const OpCode forloop[2] = {OP_FORLOOP, OP_TFORLOOP};
1529 BlockCnt bl;
1530 FuncState *fs = ls->fs;
1531 int prep, endfor;
1532 checknext(ls, TK_DO);
1533 prep = luaK_codeABx(fs, forprep[isgen], base, 0);
1534 enterblock(fs, &bl, 0); /* scope for declared variables */
1535 adjustlocalvars(ls, nvars);
1536 luaK_reserveregs(fs, nvars);
1537 block(ls);
1538 leaveblock(fs); /* end of scope for declared variables */
1539 fixforjump(fs, prep, luaK_getlabel(fs), 0);
1540 if (isgen) { /* generic for? */
1541 luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars);
1542 luaK_fixline(fs, line);
1543 }
1544 endfor = luaK_codeABx(fs, forloop[isgen], base, 0);
1545 fixforjump(fs, endfor, prep + 1, 1);
1546 luaK_fixline(fs, line);
1547}
1548
1549
1550static void fornum (LexState *ls, TString *varname, int line) {

Callers 2

fornumFunction · 0.85
forlistFunction · 0.85

Calls 10

checknextFunction · 0.85
luaK_codeABxFunction · 0.85
enterblockFunction · 0.85
adjustlocalvarsFunction · 0.85
luaK_reserveregsFunction · 0.85
blockFunction · 0.85
leaveblockFunction · 0.85
fixforjumpFunction · 0.85
luaK_getlabelFunction · 0.85
luaK_fixlineFunction · 0.85

Tested by

no test coverage detected