MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fornum

Function fornum

app/redis-6.2.6/deps/lua/src/lparser.c:1071–1090  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1069
1070
1071static void fornum (LexState *ls, TString *varname, int line) {
1072 /* fornum -> NAME = exp1,exp1[,exp1] forbody */
1073 FuncState *fs = ls->fs;
1074 int base = fs->freereg;
1075 new_localvarliteral(ls, "(for index)", 0);
1076 new_localvarliteral(ls, "(for limit)", 1);
1077 new_localvarliteral(ls, "(for step)", 2);
1078 new_localvar(ls, varname, 3);
1079 checknext(ls, '=');
1080 exp1(ls); /* initial value */
1081 checknext(ls, ',');
1082 exp1(ls); /* limit */
1083 if (testnext(ls, ','))
1084 exp1(ls); /* optional step */
1085 else { /* default step = 1 */
1086 luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
1087 luaK_reserveregs(fs, 1);
1088 }
1089 forbody(ls, base, line, 1, 1);
1090}
1091
1092
1093static void forlist (LexState *ls, TString *indexname) {

Callers 1

forstatFunction · 0.70

Calls 8

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

Tested by

no test coverage detected