diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-20 15:24:44 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-20 15:24:44 +0100 |
| commit | 2d6ca67c0a0ca4e72ab409e5503a112f30e1f0a7 (patch) | |
| tree | fadca824a91811da64a73a4cd68535485919b294 /src/main/java | |
| parent | 70882baa0eb2cecf83089ffcdf540976186c5e67 (diff) | |
Add int-add instruction
Diffstat (limited to 'src/main/java')
3 files changed, 21 insertions, 1 deletions
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java index 77a8ec7c..3243c3ab 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -106,6 +106,14 @@ public class PatioSerializer { localRefToTree(dataPtrToInt.value()) ); + case PatioIntAdd intAdd -> + treeList( + treeIdentifier("int-add"), + localRefToTree(intAdd.target()), + localRefToTree(intAdd.left()), + localRefToTree(intAdd.right()) + ); + case PatioIntGet intGet -> treeList( treeIdentifier("int-get"), diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java index dbedce9a..c86ff657 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java @@ -2,6 +2,6 @@ package org.shedlang.compiler.patio.ast.instructions; import org.shedlang.compiler.sources.Source; -public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIntGet, PatioIntToDataPtr, PatioLocalCopy, PatioMemoryLoad, PatioMemoryStore, PatioReturn { +public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIntAdd, PatioIntGet, PatioIntToDataPtr, PatioLocalCopy, PatioMemoryLoad, PatioMemoryStore, PatioReturn { Source source(); } diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntAdd.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntAdd.java new file mode 100644 index 00000000..eae6a3fa --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioIntAdd.java @@ -0,0 +1,12 @@ +package org.shedlang.compiler.patio.ast.instructions; + +import org.shedlang.compiler.patio.ast.PatioLocalRef; +import org.shedlang.compiler.sources.Source; + +public record PatioIntAdd( + PatioLocalRef target, + PatioLocalRef left, + PatioLocalRef right, + Source source +) implements PatioInstruction { +} |
