(self)
| 438 | ) |
| 439 | |
| 440 | def _find_live_blocks(self) -> set[_Block]: |
| 441 | live: set[_Block] = set() |
| 442 | # Externally reachable blocks are live |
| 443 | todo: set[_Block] = {b for b in self._blocks() if b.label in self.globals} |
| 444 | while todo: |
| 445 | block = todo.pop() |
| 446 | live.add(block) |
| 447 | if block.fallthrough: |
| 448 | next = block.link |
| 449 | if next is not None and next not in live: |
| 450 | todo.add(next) |
| 451 | next = block.target |
| 452 | if next is not None and next not in live: |
| 453 | todo.add(next) |
| 454 | return live |
| 455 | |
| 456 | def _remove_unreachable(self) -> None: |
| 457 | live = self._find_live_blocks() |
no test coverage detected