Skip to content

Commit

Permalink
minias: log bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkin committed Jan 21, 2024
1 parent 62f0a13 commit a04ac3e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pyteleport/bytecode/minias.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,20 +630,24 @@ def verify_instructions(instructions: list[FloatingCell]):
duplicates = {k: v for k, v in counts.items() if v != 1}
if duplicates:
raise ValueError(f"duplicate cells: {duplicates}")
for floating in instructions:
for i, floating in enumerate(instructions):
if floating.instruction is None:
raise ValueError(f"empty cell: {floating}")
if isinstance(floating.instruction, ReferencingInstruction):
target = floating.instruction.arg
if target not in counts:
raise ValueError(f"instruction references outside the bytecode:\n"
f" instruction {floating}\n"
f" target {target}")
f" target {target}\n"
f"bytecode follows\n"
f"{ObjectBytecode(instructions, current=i).to_string()}")
if floating not in target.referenced_by:
raise ValueError(f"instruction target does not contain the reverse reference:\n"
f" instruction {floating}\n"
f" target {target}\n"
f" referenced by {target.referenced_by}")
f" referenced by {target.referenced_by}\n"
f"bytecode follows\n"
f"{ObjectBytecode(instructions, current=i).to_string()}")


@dataclass
Expand Down

0 comments on commit a04ac3e

Please sign in to comment.