| 1346 | |
| 1347 | |
| 1348 | static void forbody(LexState *ls, int base, int line, int nvars, int isnum) { |
| 1349 | /* forbody -> DO block */ |
| 1350 | BlockCnt bl; |
| 1351 | FuncState *fs = ls->fs; |
| 1352 | int prep, endfor; |
| 1353 | adjustlocalvars(ls, 3); /* control variables */ |
| 1354 | checknext(ls, TK_DO); |
| 1355 | prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); |
| 1356 | enterblock(fs, &bl, 0); /* scope for declared variables */ |
| 1357 | adjustlocalvars(ls, nvars); |
| 1358 | luaK_reserveregs(fs, nvars); |
| 1359 | block(ls); |
| 1360 | leaveblock(fs); /* end of scope for declared variables */ |
| 1361 | luaK_patchtohere(fs, prep); |
| 1362 | if (isnum) /* numeric for? */ |
| 1363 | endfor = luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP); |
| 1364 | else { /* generic for */ |
| 1365 | luaK_codeABC(fs, OP_TFORCALL, base, 0, nvars); |
| 1366 | luaK_fixline(fs, line); |
| 1367 | endfor = luaK_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP); |
| 1368 | } |
| 1369 | luaK_patchlist(fs, endfor, prep + 1); |
| 1370 | luaK_fixline(fs, line); |
| 1371 | } |
| 1372 | |
| 1373 | |
| 1374 | static void fornum(LexState *ls, TString *varname, int line) { |
no test coverage detected