| 783 | |
| 784 | |
| 785 | static void checkrule (lua_State *L, Instruction *op, int from, int to, |
| 786 | int postable, int rule) { |
| 787 | int i; |
| 788 | int lastopen = 0; /* more recent OpenCall seen in the code */ |
| 789 | for (i = from; i < to; i += sizei(op + i)) { |
| 790 | if (op[i].i.code == IPartialCommit && op[i].i.offset < 0) { /* loop? */ |
| 791 | int start = dest(op, i); |
| 792 | assert(op[start - 1].i.code == IChoice && |
| 793 | dest(op, start - 1) == target(op, i + 1)); |
| 794 | if (start <= lastopen) { /* loop does contain an open call? */ |
| 795 | if (!verify(L, op, op + start, op + i, postable, rule)) /* check body */ |
| 796 | luaL_error(L, "possible infinite loop in %s", val2str(L, rule)); |
| 797 | } |
| 798 | } |
| 799 | else if (op[i].i.code == IOpenCall) |
| 800 | lastopen = i; |
| 801 | } |
| 802 | assert(op[i - 1].i.code == IRet); |
| 803 | verify(L, op, op + from, op + to - 1, postable, rule); |
| 804 | } |
| 805 | |
| 806 | |
| 807 | |