MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / fornum

Function fornum

lua/lparser.c:1127–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1125
1126
1127static void fornum (LexState *ls, TString *varname, int line) {
1128 /* fornum -> NAME = exp1,exp1[,exp1] forbody */
1129 FuncState *fs = ls->fs;
1130 int base = fs->freereg;
1131 new_localvarliteral(ls, "(for index)", 0);
1132 new_localvarliteral(ls, "(for limit)", 1);
1133 new_localvarliteral(ls, "(for step)", 2);
1134 new_localvar(ls, varname, 3);
1135 checknext(ls, '=');
1136 exp1(ls); /* initial value */
1137 checknext(ls, ',');
1138 exp1(ls); /* limit */
1139 if (testnext(ls, ','))
1140 exp1(ls); /* optional step */
1141 else { /* default step = 1 */
1142 luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
1143 luaK_reserveregs(fs, 1);
1144 }
1145 forbody(ls, base, line, 1, 1);
1146}
1147
1148
1149static void forlist (LexState *ls, TString *indexname) {

Callers 1

forstatFunction · 0.85

Calls 8

new_localvarFunction · 0.85
checknextFunction · 0.85
exp1Function · 0.85
testnextFunction · 0.85
luaK_codeABxFunction · 0.85
luaK_numberKFunction · 0.85
luaK_reserveregsFunction · 0.85
forbodyFunction · 0.85

Tested by

no test coverage detected