ir: IRValue: track readers

This commit is contained in:
Antoine Viallon 2024-01-05 23:13:45 +01:00
parent 18a813f4c7
commit 27ccb1a68a
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -43,9 +43,25 @@ class IRNop(IRAction):
class IRValue(IRItem, abc.ABC):
values: list[IRValue] = []
def __init__(self, location: SourceLocation):
super().__init__(location)
self.readers: list[IRAction] = []
IRValue.values += [self]
def __del__(self):
IRValue.values.remove(self)
def destination(self) -> IRValue:
return self
def __str__(self):
return self.codegen()
def __repr__(self) -> str:
return f"{self.codegen()} (readers: {repr(self.readers)})"
class IRMove(IRAction):