ir: add IRNop and IRVoid action and value (resp.)
This commit is contained in:
parent
a832cd1214
commit
7bb14210a7
1 changed files with 20 additions and 0 deletions
|
|
@ -31,6 +31,17 @@ class IRAction(IRItem, abc.ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IRNop(IRAction):
|
||||||
|
def __init__(self, location: SourceLocation):
|
||||||
|
super().__init__(location)
|
||||||
|
|
||||||
|
def codegen(self) -> str:
|
||||||
|
return "NOP"
|
||||||
|
|
||||||
|
def destination(self) -> IRValue:
|
||||||
|
return IRVoid(self.location)
|
||||||
|
|
||||||
|
|
||||||
class IRValue(IRItem, abc.ABC):
|
class IRValue(IRItem, abc.ABC):
|
||||||
def destination(self) -> IRValue:
|
def destination(self) -> IRValue:
|
||||||
return self
|
return self
|
||||||
|
|
@ -61,6 +72,15 @@ class IRImmediate(IRValue):
|
||||||
return f"{self.value}"
|
return f"{self.value}"
|
||||||
|
|
||||||
|
|
||||||
|
class IRVoid(IRValue):
|
||||||
|
@typecheck
|
||||||
|
def __init__(self, location: SourceLocation):
|
||||||
|
super().__init__(location)
|
||||||
|
|
||||||
|
def codegen(self) -> str:
|
||||||
|
return "<VOID>"
|
||||||
|
|
||||||
|
|
||||||
class IRAssignable(IRValue, metaclass=abc.ABCMeta):
|
class IRAssignable(IRValue, metaclass=abc.ABCMeta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue