Skip to content

Commit

Permalink
fix IRVariable constructor, clean up other IROperand constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Dec 24, 2024
1 parent 1728bee commit 74c2446
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions vyper/venom/basicblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class IROperand:
"""

value: Any
_hash: Optional[int]
_hash: Optional[int] = None

def __init__(self, value: Any) -> None:
self.value = value
Expand Down Expand Up @@ -149,9 +149,8 @@ class IRLiteral(IROperand):
value: int

def __init__(self, value: int) -> None:
super().__init__(value)
assert isinstance(value, int), "value must be an int"
self.value = value
super().__init__(value)


class IRVariable(IROperand):
Expand All @@ -163,17 +162,17 @@ class IRVariable(IROperand):
version: Optional[int]

def __init__(self, name: str, version: int = 0) -> None:
super().__init__(name)
assert isinstance(name, str)
assert isinstance(version, int | None)
# TODO: allow version to be None
assert isinstance(version, int)
if not name.startswith("%"):
name = f"%{name}"
self._name = name
self.version = version
value = name
if version > 0:
self.value = f"{name}:{version}"
else:
self.value = name
value = f"{name}:{version}"
super().__init__(value)

@property
def name(self) -> str:
Expand All @@ -193,8 +192,8 @@ class IRLabel(IROperand):
def __init__(self, value: str, is_symbol: bool = False) -> None:
assert isinstance(value, str), f"not a str: {value} ({type(value)})"
assert len(value) > 0
super().__init__(value)
self.is_symbol = is_symbol
super().__init__(value)

_IS_IDENTIFIER = re.compile("[0-9a-zA-Z_]*")

Expand Down

0 comments on commit 74c2446

Please sign in to comment.