| 1316 | |
| 1317 | |
| 1318 | static void fornum (LexState *ls, TString *varname, int line) { |
| 1319 | /* fornum -> NAME = exp1,exp1[,exp1] forbody */ |
| 1320 | FuncState *fs = ls->fs; |
| 1321 | int base = fs->freereg; |
| 1322 | new_localvarliteral(ls, "(for index)"); |
| 1323 | new_localvarliteral(ls, "(for limit)"); |
| 1324 | new_localvarliteral(ls, "(for step)"); |
| 1325 | new_localvar(ls, varname); |
| 1326 | checknext(ls, '='); |
| 1327 | exp1(ls); /* initial value */ |
| 1328 | checknext(ls, ','); |
| 1329 | exp1(ls); /* limit */ |
| 1330 | if (testnext(ls, ',')) |
| 1331 | exp1(ls); /* optional step */ |
| 1332 | else { /* default step = 1 */ |
| 1333 | luaK_codek(fs, fs->freereg, luaK_intK(fs, 1)); |
| 1334 | luaK_reserveregs(fs, 1); |
| 1335 | } |
| 1336 | forbody(ls, base, line, 1, 1); |
| 1337 | } |
| 1338 | |
| 1339 | |
| 1340 | static void forlist (LexState *ls, TString *indexname) { |
no test coverage detected