| 1044 | |
| 1045 | |
| 1046 | static void forbody (LexState *ls, int base, int line, int nvars, int isnum) { |
| 1047 | /* forbody -> DO block */ |
| 1048 | BlockCnt bl; |
| 1049 | FuncState *fs = ls->fs; |
| 1050 | int prep, endfor; |
| 1051 | adjustlocalvars(ls, 3); /* control variables */ |
| 1052 | checknext(ls, TK_DO); |
| 1053 | prep = isnum ? luaK_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : luaK_jump(fs); |
| 1054 | enterblock(fs, &bl, 0); /* scope for declared variables */ |
| 1055 | adjustlocalvars(ls, nvars); |
| 1056 | luaK_reserveregs(fs, nvars); |
| 1057 | block(ls); |
| 1058 | leaveblock(fs); /* end of scope for declared variables */ |
| 1059 | luaK_patchtohere(fs, prep); |
| 1060 | endfor = (isnum) ? luaK_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP) : |
| 1061 | luaK_codeABC(fs, OP_TFORLOOP, base, 0, nvars); |
| 1062 | luaK_fixline(fs, line); /* pretend that `OP_FOR' starts the loop */ |
| 1063 | luaK_patchlist(fs, (isnum ? endfor : luaK_jump(fs)), prep + 1); |
| 1064 | } |
| 1065 | |
| 1066 | |
| 1067 | static void fornum (LexState *ls, TString *varname, int line) { |
no test coverage detected