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