Mark the end of basic block as unreachable. This is sometimes necessary when the end of a basic block is never reached. This can also be explicitly added to the end of non-None returning functions (in None-returning function we can just return None). Mypy statically guarantees
| 522 | |
| 523 | @final |
| 524 | class Unreachable(ControlOp): |
| 525 | """Mark the end of basic block as unreachable. |
| 526 | |
| 527 | This is sometimes necessary when the end of a basic block is never |
| 528 | reached. This can also be explicitly added to the end of non-None |
| 529 | returning functions (in None-returning function we can just return |
| 530 | None). |
| 531 | |
| 532 | Mypy statically guarantees that the end of the function is not |
| 533 | unreachable if there is not a return statement. |
| 534 | |
| 535 | This prevents the block formatter from being confused due to lack |
| 536 | of a leave and also leaves a nifty note in the IR. It is not |
| 537 | generally processed by visitors. |
| 538 | """ |
| 539 | |
| 540 | error_kind = ERR_NEVER |
| 541 | |
| 542 | def __init__(self, line: int = -1) -> None: |
| 543 | super().__init__(line) |
| 544 | |
| 545 | def sources(self) -> list[Value]: |
| 546 | return [] |
| 547 | |
| 548 | def set_sources(self, new: list[Value]) -> None: |
| 549 | assert not new |
| 550 | |
| 551 | def accept(self, visitor: OpVisitor[T]) -> T: |
| 552 | return visitor.visit_unreachable(self) |
| 553 | |
| 554 | |
| 555 | class RegisterOp(Op): |
no outgoing calls
searching dependent graphs…