diff --git a/src/main/java/de/hsrm/compiler/Klang/types/StructType.java b/src/main/java/de/hsrm/compiler/Klang/types/StructType.java new file mode 100644 index 0000000..9fac760 --- /dev/null +++ b/src/main/java/de/hsrm/compiler/Klang/types/StructType.java @@ -0,0 +1,43 @@ +package de.hsrm.compiler.Klang.types; + +public class StructType extends Type { + + public String name; + + public StructType(String name) { + this.name = name; + } + + @Override + public String getName() { + return this.name; + } + + @Override + public Type combine(Type that) { + if (that.equals(this)) { + return this; + } + + throw new RuntimeException("Type missmatch: cannot combine " + this.getName() + " and " + that.getName()); + } + + @Override + public boolean isPrimitiveType() { + return false; + } + + @Override + public boolean equals(Object that) { + if (this == that) { + return true; + } + + if (that instanceof StructType) { + StructType thatType = (StructType) that; + return this.getName().equals(thatType.getName()); + } + + return false; + } +} \ No newline at end of file