aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-20 23:43:23 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-20 23:43:23 +0100
commit0ad8010046cd7ba59d145731427897867387b575 (patch)
tree2b7e69944f13174e966e1ec77e371c89b1f7572e /src/main/java
parent557d07b3ab23feb67b094ede24dcb475008d5a7e (diff)
Add bool operand
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/operands/PatioBool.java4
-rw-r--r--src/main/java/org/shedlang/compiler/patio/ast/operands/PatioOperand.java2
3 files changed, 9 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 de8e2eaa..9fdfbdb5 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java
@@ -1,6 +1,7 @@
package org.shedlang.compiler.patio.ast;
import org.shedlang.compiler.patio.ast.instructions.*;
+import org.shedlang.compiler.patio.ast.operands.PatioBool;
import org.shedlang.compiler.patio.ast.operands.PatioInt;
import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
import org.shedlang.compiler.patio.ast.operands.PatioOperand;
@@ -222,6 +223,9 @@ public class PatioSerializer {
private static Tree operandToTree(PatioOperand operand) {
return switch (operand) {
+ case PatioBool bool ->
+ treeList(treeIdentifier("bool"), treeBool(bool.value()));
+
case PatioInt int_ ->
treeList(treeIdentifier("int"), treeInt(int_.value()));
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioBool.java b/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioBool.java
new file mode 100644
index 00000000..c39c17d3
--- /dev/null
+++ b/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioBool.java
@@ -0,0 +1,4 @@
+package org.shedlang.compiler.patio.ast.operands;
+
+public record PatioBool(boolean value) implements PatioOperand {
+}
diff --git a/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioOperand.java b/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioOperand.java
index ad3d1416..8316867b 100644
--- a/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioOperand.java
+++ b/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioOperand.java
@@ -1,5 +1,5 @@
package org.shedlang.compiler.patio.ast.operands;
-public sealed interface PatioOperand permits PatioInt, PatioLocalRef {
+public sealed interface PatioOperand permits PatioBool, PatioInt, PatioLocalRef {
}