diff --git a/compiler/ir.py b/compiler/ir.py index 360f2b8..84a5c5d 100644 --- a/compiler/ir.py +++ b/compiler/ir.py @@ -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):