Skip to content

Commit

Permalink
start changes
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook committed Feb 12, 2022
1 parent c7bce11 commit 1097e95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions code_data/code_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def line_table_bytes(self) -> bytes:

def _verify(self) -> None:
verify_block(self.blocks)
# self.line_table.verify()

@classmethod
def from_code(cls, code: CodeType) -> CodeData:
Expand Down
11 changes: 11 additions & 0 deletions code_data/line_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,23 @@ def to_bytes(self) -> bytes:
"""
return bytes(chain.from_iterable(self.items))

def verify(self):
for item in self.items:
item.verify()


@dataclass
class LineTableItem:
# TODO: Instead make mapping from bytecode offset to optinal line number
# (but how to represent "missing lines"??) no change of bytecode, but line number change
# means so line numbers were erased here
# With another table of bytecode offset to missing lines added after!
line_offset: int
bytecode_offset: int

def verify(self):
assert self.line_offset and self.bytecode_offset

def __iter__(self) -> Iterator[int]:
yield self.bytecode_offset
yield self.line_offset
Expand Down

0 comments on commit 1097e95

Please sign in to comment.