From d14a7d7cbde2d25c38e404aa24f64aeccff9d1ea Mon Sep 17 00:00:00 2001 From: Marvin Kaiser Date: Mon, 4 Nov 2019 15:41:32 +0100 Subject: [PATCH] Added basic typing structure --- .../compiler/Klang/types/IntegerType.java | 20 +++++++++++++++++++ .../compiler/Klang/types/PrimitiveType.java | 13 ++++++++++++ .../de/hsrm/compiler/Klang/types/Type.java | 12 +++++++++++ 3 files changed, 45 insertions(+) create mode 100644 src/main/java/de/hsrm/compiler/Klang/types/IntegerType.java create mode 100644 src/main/java/de/hsrm/compiler/Klang/types/PrimitiveType.java create mode 100644 src/main/java/de/hsrm/compiler/Klang/types/Type.java diff --git a/src/main/java/de/hsrm/compiler/Klang/types/IntegerType.java b/src/main/java/de/hsrm/compiler/Klang/types/IntegerType.java new file mode 100644 index 0000000..3803b9e --- /dev/null +++ b/src/main/java/de/hsrm/compiler/Klang/types/IntegerType.java @@ -0,0 +1,20 @@ +package de.hsrm.compiler.Klang.types; + +public class IntegerType extends PrimitiveType { + + private static IntegerType instance = null; + + public static IntegerType getType() { + if (instance != null) { + return instance; + } + instance = new IntegerType(); + return instance; + } + + @Override + public boolean isIntegerType() { + return true; + } + +} \ No newline at end of file diff --git a/src/main/java/de/hsrm/compiler/Klang/types/PrimitiveType.java b/src/main/java/de/hsrm/compiler/Klang/types/PrimitiveType.java new file mode 100644 index 0000000..b45c08f --- /dev/null +++ b/src/main/java/de/hsrm/compiler/Klang/types/PrimitiveType.java @@ -0,0 +1,13 @@ +package de.hsrm.compiler.Klang.types; + +public abstract class PrimitiveType extends Type { + + @Override + public boolean isPrimitiveType() { + return true; + } + + public boolean isIntegerType() { + return false; + }; +} \ No newline at end of file diff --git a/src/main/java/de/hsrm/compiler/Klang/types/Type.java b/src/main/java/de/hsrm/compiler/Klang/types/Type.java new file mode 100644 index 0000000..db90f30 --- /dev/null +++ b/src/main/java/de/hsrm/compiler/Klang/types/Type.java @@ -0,0 +1,12 @@ +package de.hsrm.compiler.Klang.types; + +public abstract class Type { + + // Returns an instance of IntegerType + // Used for adding new types to a node + public static IntegerType getIntegerType() { + return IntegerType.getType(); + } + + public abstract boolean isPrimitiveType(); +} \ No newline at end of file