MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / forbody

Function forbody

deps/lua/src/lparser.c:1046–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044
1045
1046static void forbody (LexState *ls, int base, int line, int nvars, int isnum) {
1047 /* forbody -> DO block */
1048 BlockCnt bl;
1049 FuncState *fs = ls->fs;
1050 int prep, endfor;
1051 adjustlocalvars(ls, 3); /* control variables */
1052 checknext(ls, TK_DO);
1053 prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs);
1054 enterblock(fs, &bl, 0); /* scope for declared variables */
1055 adjustlocalvars(ls, nvars);
1056 luaK_reserveregs(fs, nvars);
1057 block(ls);
1058 leaveblock(fs); /* end of scope for declared variables */
1059 luaK_patchtohere(fs, prep);
1060 endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) :
1061 luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars);
1062 luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */
1063 luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1);
1064}
1065
1066
1067static 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