diff --git a/compiler/ir.py b/compiler/ir.py index 6035c61..a269d8f 100644 --- a/compiler/ir.py +++ b/compiler/ir.py @@ -5,7 +5,7 @@ from abc import abstractmethod from .errors import OverrideMandatoryError from .logger import Logger -from .source import SourceLocation +from .source import SourceLocation, IRLocation as Location from .typechecking import typecheck logger = Logger(__name__) @@ -28,7 +28,19 @@ class IRItem: class IRAction(IRItem, abc.ABC): - pass + def __init__(self, location: SourceLocation, reads: list[IRValue], writes: list[IRAssignable]): + super().__init__(location) + + # Must be changed updated in a second pass, when every item has been generated + self.ir_location: Location = Location(-1, []) + self.reads = reads + self.writes = writes + + for read in reads: + read.readers += [self] + + for write in writes: + write.writers += [self] class IRNop(IRAction):