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

Function forlist

deps/lua/src/lparser.c:1089–1109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087
1088
1089static void forlist (LexState *ls, TString *indexname) {
1090 /* forlist -> NAME {,NAME} IN explist1 forbody */
1091 FuncState *fs = ls->fs;
1092 expdesc e;
1093 int nvars = 0;
1094 int line;
1095 int base = fs->freereg;
1096 /* create control variables */
1097 new_localvarliteral(ls, "(for generator)", nvars++);
1098 new_localvarliteral(ls, "(for state)", nvars++);
1099 new_localvarliteral(ls, "(for control)", nvars++);
1100 /* create declared variables */
1101 new_localvar(ls, indexname, nvars++);
1102 while (testnext(ls, ','))
1103 new_localvar(ls, str_checkname(ls), nvars++);
1104 checknext(ls, TK_IN);
1105 line = ls->linenumber;
1106 adjust_assign(ls, 3, explist1(ls, &e), &e);
1107 luaK_checkstack(fs, 3); /* extra space to call generator */
1108 forbody(ls, base, line, nvars - 3, 0);
1109}
1110
1111
1112static void forstat (LexState *ls, int line) {

Callers 1

forstatFunction · 0.85

Calls 8

new_localvarFunction · 0.85
testnextFunction · 0.85
str_checknameFunction · 0.85
checknextFunction · 0.85
adjust_assignFunction · 0.85
explist1Function · 0.85
luaK_checkstackFunction · 0.85
forbodyFunction · 0.85

Tested by

no test coverage detected