diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-20 23:36:47 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-20 23:36:47 +0100 |
| commit | 686447f7ddce7d29e20c3b570d6b039ddfe1fb01 (patch) | |
| tree | 884a91fa6c1aa5c7ef64a296b11a4a6188d9dfc1 /src/main/java | |
| parent | 88f7aecdecf5a4e2d4f4f243aa2517129a191b25 (diff) | |
Add int as Patio operand
Diffstat (limited to 'src/main/java')
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 bfdbac89..44f738f6 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.PatioInt; import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; import org.shedlang.compiler.patio.ast.operands.PatioOperand; import org.shedlang.compiler.patio.ast.types.*; @@ -228,6 +229,9 @@ public class PatioSerializer { private static Tree operandToTree(PatioOperand operand) { return switch (operand) { + case PatioInt int_ -> + treeList(treeIdentifier("int"), treeInt(int_.value())); + case PatioLocalRef localRef -> treeList(treeIdentifier("local"), treeString(localRef.name())); }; diff --git a/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioInt.java b/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioInt.java new file mode 100644 index 00000000..0a19de4e --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/ast/operands/PatioInt.java @@ -0,0 +1,4 @@ +package org.shedlang.compiler.patio.ast.operands; + +public record PatioInt(int 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 e7526d44..ad3d1416 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 PatioLocalRef { +public sealed interface PatioOperand permits PatioInt, PatioLocalRef { } |
