Skip to content

Commit

Permalink
add to_dict for WritableASTBlock
Browse files Browse the repository at this point in the history
As title
  • Loading branch information
esc committed Apr 19, 2024
1 parent 7ae7668 commit 377d161
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions numba_rvsdg/core/datastructures/ast_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ def seal_inside_loop(
else:
self.set_jump_targets(default_index)

def to_dict(self) -> dict[str, Any]:
return {
"name": self.name,
"instructions": [ast.unparse(n) for n in self.instructions],
"jump_targets": self.jump_targets,
}

def __repr__(self) -> str:
return (
f"WritableASTBlock({self.name}, "
Expand All @@ -100,14 +107,7 @@ def convert_blocks(self) -> MutableMapping[str, Any]:

def to_dict(self) -> dict[str, dict[str, object]]:
"""Convert ASTCFG to simple dict based data structure."""
return {
k: {
"name": v.name,
"instructions": [ast.unparse(n) for n in v.instructions],
"jump_targets": v.jump_targets,
}
for (k, v) in self.items()
}
return {k: v.to_dict() for (k, v) in self.items()}

def to_SCFG(self) -> SCFG:
"""Convert ASTCFG to SCFG"""
Expand Down

0 comments on commit 377d161

Please sign in to comment.