| 1290 | |
| 1291 | |
| 1292 | static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { |
| 1293 | /* forbody -> DO block */ |
| 1294 | BlockCnt bl; |
| 1295 | FuncState *fs = ls->fs; |
| 1296 | int prep, endfor; |
| 1297 | adjustlocalvars(ls, 3); /* control variables */ |
| 1298 | checknext(ls, TK_DO); |
| 1299 | prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); |
| 1300 | enterblock(fs, &bl, 0); /* scope for declared variables */ |
| 1301 | adjustlocalvars(ls, nvars); |
| 1302 | luaK_reserveregs(fs, nvars); |
| 1303 | block(ls); |
| 1304 | leaveblock(fs); /* end of scope for declared variables */ |
| 1305 | luaK_patchtohere(fs, prep); |
| 1306 | if (isnum) /* numeric for? */ |
| 1307 | endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); |
| 1308 | else { /* generic for */ |
| 1309 | luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); |
| 1310 | luaK_fixline(fs, line); |
| 1311 | endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); |
| 1312 | } |
| 1313 | luaK_patchlist(fs, endfor, prep + 1); |
| 1314 | luaK_fixline(fs, line); |
| 1315 | } |
| 1316 | |
| 1317 | |
| 1318 | static void fornum (LexState *ls, TString *varname, int line) { |
no test coverage detected