From ea911841f3b5d8601f7ff9234e5bca442d58925b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Jul 2023 17:21:15 +0100 Subject: Add Patio bool type --- src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java | 3 +++ .../java/org/shedlang/compiler/patio/ast/types/PatioBoolType.java | 5 +++++ src/main/java/org/shedlang/compiler/patio/ast/types/PatioType.java | 2 +- src/main/java/org/shedlang/compiler/patio/ast/types/PatioTypes.java | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/shedlang/compiler/patio/ast/types/PatioBoolType.java (limited to 'src/main/java') 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 3b7e6a7b..850c2fcc 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -206,6 +206,9 @@ public class PatioSerializer { private static Tree typeToTree(PatioType type) { return switch (type) { + case PatioBoolType boolType -> + treeIdentifier("bool"); + case PatioDataPointerType dataPointerType -> treeIdentifier("data-ptr"); diff --git a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioBoolType.java b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioBoolType.java new file mode 100644 index 00000000..3415335d --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioBoolType.java @@ -0,0 +1,5 @@ +package org.shedlang.compiler.patio.ast.types; + +public record PatioBoolType() implements PatioType { + static final PatioBoolType INSTANCE = new PatioBoolType(); +} diff --git a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioType.java b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioType.java index 69b07faf..fe90466f 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioType.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioType.java @@ -1,4 +1,4 @@ package org.shedlang.compiler.patio.ast.types; -public sealed interface PatioType permits PatioDataPointerType, PatioFunctionPointerType, PatioIntType, PatioVoidType { +public sealed interface PatioType permits PatioBoolType, PatioDataPointerType, PatioFunctionPointerType, PatioIntType, PatioVoidType { } diff --git a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioTypes.java b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioTypes.java index 95e07fbf..8e53c095 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/types/PatioTypes.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/types/PatioTypes.java @@ -6,6 +6,7 @@ public class PatioTypes { private PatioTypes() { } + public static final PatioBoolType BOOL = PatioBoolType.INSTANCE; public static final PatioDataPointerType DATA_POINTER = PatioDataPointerType.INSTANCE; public static final PatioFunctionPointerType FUNCTION_POINTER = PatioFunctionPointerType.INSTANCE; public static final PatioIntType INT = PatioIntType.INSTANCE; -- cgit v1.2.3