(self)
| 811 | self.stop_reg = Register(bool_rprimitive) |
| 812 | |
| 813 | def gen_condition(self) -> None: |
| 814 | # This does the test and fetches the next value |
| 815 | # try: |
| 816 | # TARGET = await type(iter).__anext__(iter) |
| 817 | # stop = False |
| 818 | # except StopAsyncIteration: |
| 819 | # stop = True |
| 820 | # |
| 821 | # What a pain. |
| 822 | # There are optimizations available here if we punch through some abstractions. |
| 823 | |
| 824 | from mypyc.irbuild.statement import emit_await, transform_try_except |
| 825 | |
| 826 | builder = self.builder |
| 827 | line = self.line |
| 828 | |
| 829 | def except_match() -> Value: |
| 830 | return builder.add( |
| 831 | LoadGlobal(stop_async_iteration_op.type, stop_async_iteration_op.src, line) |
| 832 | ) |
| 833 | |
| 834 | def try_body() -> None: |
| 835 | awaitable = builder.call_c(anext_op, [builder.read(self.iter_target, line)], line) |
| 836 | self.next_reg = emit_await(builder, awaitable, line) |
| 837 | builder.assign(self.stop_reg, builder.false(), line) |
| 838 | |
| 839 | def except_body() -> None: |
| 840 | builder.assign(self.stop_reg, builder.true(), line) |
| 841 | |
| 842 | transform_try_except( |
| 843 | builder, try_body, [((except_match, line), None, except_body)], None, line |
| 844 | ) |
| 845 | |
| 846 | builder.add(Branch(self.stop_reg, self.loop_exit, self.body_block, Branch.BOOL)) |
| 847 | |
| 848 | def begin_body(self) -> None: |
| 849 | # Assign the value obtained from await __anext__ to the |
nothing calls this directly
no test coverage detected