| 1104 | |
| 1105 | |
| 1106 | static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { |
| 1107 | /* forbody -> DO block */ |
| 1108 | BlockCnt bl; |
| 1109 | FuncState *fs = ls->fs; |
| 1110 | int prep, endfor; |
| 1111 | adjustlocalvars(ls, 3); /* control variables */ |
| 1112 | checknext(ls, TK_DO); |
| 1113 | prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); |
| 1114 | enterblock(fs, &bl, 0); /* scope for declared variables */ |
| 1115 | adjustlocalvars(ls, nvars); |
| 1116 | luaK_reserveregs(fs, nvars); |
| 1117 | block(ls); |
| 1118 | leaveblock(fs); /* end of scope for declared variables */ |
| 1119 | luaK_patchtohere(fs, prep); |
| 1120 | endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : |
| 1121 | luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); |
| 1122 | luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ |
| 1123 | luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); |
| 1124 | } |
| 1125 | |
| 1126 | |
| 1127 | static void fornum (LexState *ls, TString *varname, int line) { |
no test coverage detected