| 1466 | |
| 1467 | |
| 1468 | static void repeatstat (LexState *ls, int line) { |
| 1469 | /* repeatstat -> REPEAT block UNTIL cond */ |
| 1470 | int condexit; |
| 1471 | FuncState *fs = ls->fs; |
| 1472 | int repeat_init = luaK_getlabel(fs); |
| 1473 | BlockCnt bl1, bl2; |
| 1474 | enterblock(fs, &bl1, 1); /* loop block */ |
| 1475 | enterblock(fs, &bl2, 0); /* scope block */ |
| 1476 | luaX_next(ls); /* skip REPEAT */ |
| 1477 | statlist(ls); |
| 1478 | check_match(ls, TK_UNTIL, TK_REPEAT, line); |
| 1479 | condexit = cond(ls); /* read condition (inside scope block) */ |
| 1480 | leaveblock(fs); /* finish scope */ |
| 1481 | if (bl2.upval) { /* upvalues? */ |
| 1482 | int exit = luaK_jump(fs); /* normal exit must jump over fix */ |
| 1483 | luaK_patchtohere(fs, condexit); /* repetition must close upvalues */ |
| 1484 | luaK_codeABC(fs, OP_CLOSE, stacklevel(fs, bl2.nactvar), 0, 0); |
| 1485 | condexit = luaK_jump(fs); /* repeat after closing upvalues */ |
| 1486 | luaK_patchtohere(fs, exit); /* normal exit comes to here */ |
| 1487 | } |
| 1488 | luaK_patchlist(fs, condexit, repeat_init); /* close the loop */ |
| 1489 | leaveblock(fs); /* finish loop */ |
| 1490 | } |
| 1491 | |
| 1492 | |
| 1493 | /* |
no test coverage detected