create a new type class that represents the type of a struct
This commit is contained in:
43
src/main/java/de/hsrm/compiler/Klang/types/StructType.java
Normal file
43
src/main/java/de/hsrm/compiler/Klang/types/StructType.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user