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

Method visit_cast

mypyc/codegen/emitfunc.py:671–697  ·  view source on GitHub ↗
(self, op: Cast)

Source from the content-addressed store, hash-verified

669 self.emitter.emit_box(self.reg(op.src), self.reg(op), op.src.type, can_borrow=True)
670
671 def visit_cast(self, op: Cast) -> None:
672 if op.is_unchecked and op.is_borrowed:
673 self.emit_line(f"{self.reg(op)} = {self.reg(op.src)};")
674 return
675 branch = self.next_branch()
676 handler = None
677 if branch is not None:
678 if (
679 branch.value is op
680 and branch.op == Branch.IS_ERROR
681 and branch.traceback_entry is not None
682 and not branch.negated
683 and branch.false is self.next_block
684 ):
685 # Generate code also for the following branch here to avoid
686 # redundant branches in the generated code.
687 handler = TracebackAndGotoHandler(
688 self.label(branch.true),
689 self.source_path,
690 self.module_name,
691 branch.traceback_entry,
692 )
693 self.op_index += 1
694
695 self.emitter.emit_cast(
696 self.reg(op.src), self.reg(op), op.type, src_type=op.src.type, error=handler
697 )
698
699 def visit_unbox(self, op: Unbox) -> None:
700 self.emitter.emit_unbox(self.reg(op.src), self.reg(op), op.type)

Callers

nothing calls this directly

Calls 6

emit_lineMethod · 0.95
regMethod · 0.95
next_branchMethod · 0.95
labelMethod · 0.95
emit_castMethod · 0.80

Tested by

no test coverage detected