From 39a5f084ba9b1cf431ecb1aca9a6c2a2045deb8c Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 23 May 2023 23:16:23 +0200 Subject: [PATCH] ir: add IRCall --- compiler/ir.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/compiler/ir.py b/compiler/ir.py index 0ea1569..360f2b8 100644 --- a/compiler/ir.py +++ b/compiler/ir.py @@ -62,6 +62,20 @@ class IRMove(IRAction): return f"MOVE {self.source} -> {self.dest}" +class IRCall(IRAction): + def __init__(self, location: SourceLocation, dest: IRAssignable, function: IRVariable, arguments: list[IRValue]): + super().__init__(location) + self.dest = dest + self.function = function + self.arguments = arguments + + def codegen(self) -> str: + return f"CALL {self.function} -> {self.dest} : {', '.join(repr(arg) for arg in self.arguments)}" + + def destination(self) -> IRValue: + return self.dest + + class IRImmediate(IRValue): @typecheck def __init__(self, location: SourceLocation, value: int | float | str):