ir: add IRCall
This commit is contained in:
parent
5b42c05eab
commit
39a5f084ba
1 changed files with 14 additions and 0 deletions
|
|
@ -62,6 +62,20 @@ class IRMove(IRAction):
|
||||||
return f"MOVE {self.source} -> {self.dest}"
|
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):
|
class IRImmediate(IRValue):
|
||||||
@typecheck
|
@typecheck
|
||||||
def __init__(self, location: SourceLocation, value: int | float | str):
|
def __init__(self, location: SourceLocation, value: int | float | str):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue