diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-19 21:18:51 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-19 21:18:51 +0100 |
| commit | 6e7df5e2a5cf3edf4d027dc0deb6f62498794913 (patch) | |
| tree | 0b94afca4109fd93b56eff79f99e4c77562d33be /src/main/java | |
| parent | eccd9209f6a1a45560ec343fa953d53bdcbe183a (diff) | |
Add push-int instruction to Patio IR
Diffstat (limited to 'src/main/java')
3 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/PatioInstructionSerializer.java b/src/main/java/org/shedlang/compiler/patio/PatioInstructionSerializer.java index b8ef7fb6..4ebb08d0 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioInstructionSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioInstructionSerializer.java @@ -67,10 +67,16 @@ public class PatioInstructionSerializer { treeNamed("offset", treeInt(memoryStore.offset())) ); - case PatioPushFunctionPointer patioPushFunctionPointer -> + case PatioPushFunctionPointer pushFunctionPointer -> treeList( treeIdentifier("push-function-pointer"), - treeString(patioPushFunctionPointer.name()) + treeString(pushFunctionPointer.name()) + ); + + case PatioPushInt pushInt -> + treeList( + treeIdentifier("push-int"), + treeInt(pushInt.value()) ); case PatioReturn return_ -> diff --git a/src/main/java/org/shedlang/compiler/patio/instructions/PatioInstruction.java b/src/main/java/org/shedlang/compiler/patio/instructions/PatioInstruction.java index 9a015fdf..efea5694 100644 --- a/src/main/java/org/shedlang/compiler/patio/instructions/PatioInstruction.java +++ b/src/main/java/org/shedlang/compiler/patio/instructions/PatioInstruction.java @@ -2,6 +2,6 @@ package org.shedlang.compiler.patio.instructions; import org.shedlang.compiler.sources.Source; -public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDiscard, PatioLocalLoad, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioPushFunctionPointer, PatioReturn { +public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDiscard, PatioLocalLoad, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioPushFunctionPointer, PatioPushInt, PatioReturn { Source source(); } diff --git a/src/main/java/org/shedlang/compiler/patio/instructions/PatioPushInt.java b/src/main/java/org/shedlang/compiler/patio/instructions/PatioPushInt.java new file mode 100644 index 00000000..ef455051 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/instructions/PatioPushInt.java @@ -0,0 +1,9 @@ +package org.shedlang.compiler.patio.instructions; + +import org.shedlang.compiler.sources.Source; + +/** + * Push an integer onto the stack. + */ +public record PatioPushInt(int value, Source source) implements PatioInstruction { +} |
