diff options
Diffstat (limited to 'src/main/java')
4 files changed, 27 insertions, 2 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 62e7fa68..4b7c32d4 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -312,8 +312,21 @@ public class PatioSerializer { private static Tree dataValueToTree(PatioDataValue value) { return switch (value) { + case PatioDataValueArray array -> + treeList( + treeIdentifier("array"), + treeList( + array.elements().stream() + .map(element -> dataValueToTree(element)) + .toList() + ) + ); + case PatioDataValueByte byte_ -> - treeList(treeIdentifier("byte"), treeIdentifier(String.format("0x%02x", byte_.value()))); + treeList( + treeIdentifier("byte"), + treeIdentifier(String.format("0x%02x", byte_.value())) + ); }; } diff --git a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValue.java b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValue.java index 5ccf1f21..e2b9c7a9 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValue.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValue.java @@ -1,4 +1,4 @@ package org.shedlang.compiler.patio.ast.types; -public sealed interface PatioDataValue permits PatioDataValueByte { +public sealed interface PatioDataValue permits PatioDataValueArray, PatioDataValueByte { } diff --git a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValueArray.java b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValueArray.java new file mode 100644 index 00000000..136ef54b --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValueArray.java @@ -0,0 +1,6 @@ +package org.shedlang.compiler.patio.ast.types; + +import java.util.List; + +public record PatioDataValueArray(List<PatioDataValue> elements) implements PatioDataValue { +} diff --git a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValues.java b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValues.java index 88dd0898..ad011ef5 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValues.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioDataValues.java @@ -1,8 +1,14 @@ package org.shedlang.compiler.patio.ast.types; +import java.util.List; + public class PatioDataValues { private PatioDataValues() {} + public static PatioDataValue array(List<PatioDataValue> elements) { + return new PatioDataValueArray(elements); + } + public static PatioDataValue byte_(int value) { return new PatioDataValueByte((byte) value); } |
