MCPcopy Index your code
hub / github.com/python/cpython / merge

Method merge

Tools/cases_generator/stack.py:389–404  ·  view source on GitHub ↗
(self, other: "Stack", out: CWriter)

Source from the content-addressed store, hash-verified

387 self.physical_sp = other.physical_sp
388
389 def merge(self, other: "Stack", out: CWriter) -> None:
390 if len(self.variables) != len(other.variables):
391 raise StackError("Cannot merge stacks: differing variables")
392 for self_var, other_var in zip(self.variables, other.variables):
393 if self_var.name != other_var.name:
394 raise StackError(f"Mismatched variables on stack: {self_var.name} and {other_var.name}")
395 self_var.in_local = self_var.in_local and other_var.in_local
396 if other_var.memory_offset is None:
397 self_var.memory_offset = None
398 self.align(other, out)
399 for self_var, other_var in zip(self.variables, other.variables):
400 if self_var.memory_offset is not None:
401 if self_var.memory_offset != other_var.memory_offset:
402 raise StackError(f"Mismatched stack depths for {self_var.name}: {self_var.memory_offset} and {other_var.memory_offset}")
403 elif other_var.memory_offset is None:
404 self_var.memory_offset = None
405
406
407def stacks(inst: Instruction | PseudoInstruction) -> Iterator[StackEffect]:

Callers 3

mergeMethod · 0.45
emit_MacroIfStmtMethod · 0.45
emit_IfStmtMethod · 0.45

Calls 2

alignMethod · 0.95
StackErrorClass · 0.85

Tested by

no test coverage detected