MCPcopy Index your code
hub / github.com/python/mypy / __init__

Method __init__

mypyc/irbuild/for_helpers.py:634–657  ·  view source on GitHub ↗
(
        self,
        builder: IRBuilder,
        index: Lvalue,
        body_block: BasicBlock,
        loop_exit: BasicBlock,
        line: int,
        nested: bool,
    )

Source from the content-addressed store, hash-verified

632 """Abstract base class for generating for loops."""
633
634 def __init__(
635 self,
636 builder: IRBuilder,
637 index: Lvalue,
638 body_block: BasicBlock,
639 loop_exit: BasicBlock,
640 line: int,
641 nested: bool,
642 ) -> None:
643 self.builder = builder
644 self.index = index
645 self.body_block = body_block
646 self.line = line
647 # Some for loops need a cleanup block that we execute at exit. We
648 # create a cleanup block if needed. However, if we are generating a for
649 # loop for a nested iterator, such as "e" in "enumerate(e)", the
650 # outermost generator should generate the cleanup block -- we don't
651 # need to do it here.
652 if self.need_cleanup() and not nested:
653 # Create a new block to handle cleanup after loop exit.
654 self.loop_exit = BasicBlock()
655 else:
656 # Just use the existing loop exit block.
657 self.loop_exit = loop_exit
658
659 def need_cleanup(self) -> bool:
660 """If this returns true, we need post-loop cleanup."""

Callers

nothing calls this directly

Calls 2

need_cleanupMethod · 0.95
BasicBlockClass · 0.90

Tested by

no test coverage detected