(builder: IRBuilder, s: WhileStmt)
| 610 | |
| 611 | |
| 612 | def transform_while_stmt(builder: IRBuilder, s: WhileStmt) -> None: |
| 613 | body, next, top, else_block = BasicBlock(), BasicBlock(), BasicBlock(), BasicBlock() |
| 614 | normal_loop_exit = else_block if s.else_body is not None else next |
| 615 | |
| 616 | builder.push_loop_stack(top, next) |
| 617 | |
| 618 | # Split block so that we get a handle to the top of the loop. |
| 619 | builder.goto_and_activate(top) |
| 620 | process_conditional(builder, s.expr, body, normal_loop_exit) |
| 621 | |
| 622 | builder.activate_block(body) |
| 623 | builder.accept(s.body) |
| 624 | # Add branch to the top at the end of the body. |
| 625 | builder.goto(top) |
| 626 | |
| 627 | builder.pop_loop_stack() |
| 628 | |
| 629 | if s.else_body is not None: |
| 630 | builder.activate_block(else_block) |
| 631 | builder.accept(s.else_body) |
| 632 | builder.goto(next) |
| 633 | |
| 634 | builder.activate_block(next) |
| 635 | |
| 636 | |
| 637 | def transform_for_stmt(builder: IRBuilder, s: ForStmt) -> None: |
no test coverage detected
searching dependent graphs…