Added basic typing structure
This commit is contained in:
20
src/main/java/de/hsrm/compiler/Klang/types/IntegerType.java
Normal file
20
src/main/java/de/hsrm/compiler/Klang/types/IntegerType.java
Normal file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
12
src/main/java/de/hsrm/compiler/Klang/types/Type.java
Normal file
12
src/main/java/de/hsrm/compiler/Klang/types/Type.java
Normal file
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user