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

Function fornum

deps/lua/src/lparser.c:1067–1086  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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