aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-23 11:28:32 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-23 11:28:32 +0100
commit533f367444e198ed7294bfa4d5a96b4d4e542547 (patch)
treeaef5a064e83d9e6c0274f5d17aeabeb54df9d868 /src/main/java
parent179af029a24147ffc09f8b165b7d812b135d3f2d (diff)
Add bool-to-int instruction to Patio
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java7
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBoolToInt.java12
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java2
3 files changed, 20 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 7a170d58..fe96a467 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
@@ -145,6 +145,13 @@ public class PatioSerializer {
dataLayoutToTree(alloc.layout())
);
+ case PatioBoolToInt boolToInt ->
+ treeList(
+ treeIdentifier("bool-to-int"),
+ operandToTree(boolToInt.target()),
+ operandToTree(boolToInt.value())
+ );
+
case PatioCall call ->
treeList(
treeIdentifier("call"),
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBoolToInt.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBoolToInt.java
new file mode 100644
index 00000000..5edf01e9
--- /dev/null
+++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioBoolToInt.java
@@ -0,0 +1,12 @@
+package org.shedlang.compiler.patio.ast.instructions;
+
+import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
+import org.shedlang.compiler.patio.ast.operands.PatioOperand;
+import org.shedlang.compiler.sources.Source;
+
+public record PatioBoolToInt(
+ PatioLocalRef target,
+ PatioOperand value,
+ Source source
+) implements PatioInstruction {
+}
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 b4cf464b..7db82b0a 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, PatioCall, PatioCallPointer, PatioDataPtrToInt, PatioIf, PatioIntAdd, PatioIntEquals, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioReturn {
+public sealed interface PatioInstruction permits PatioAlloc, PatioBoolToInt, PatioCall, PatioCallPointer, PatioDataPtrToInt, PatioIf, PatioIntAdd, PatioIntEquals, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioReturn {
Source source();
}