MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / forbody

Function forbody

Dependencies/lua/src/lparser.c:1544–1566  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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