54 lines
1.3 KiB
Plaintext
54 lines
1.3 KiB
Plaintext
package slangc.bytecode;
|
|
|
|
import slang.data.Mappable;
|
|
|
|
public final class TypeSignature implements Mappable {
|
|
public final String packageName;
|
|
public final String typeName;
|
|
|
|
public static final TypeSignature VOID = new TypeSignature("kebab0.core", "void"); // TODO: Make translatable
|
|
|
|
public TypeSignature(String packageName, String typeName) {
|
|
/*if (packageName == null) {
|
|
throw new Error("Can't create type signature with null package");
|
|
}*/
|
|
if (typeName == null) {
|
|
throw new Error("Can't create type signature with null type");
|
|
}
|
|
this.packageName = packageName;
|
|
this.typeName = typeName;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return packageName + "." + typeName;
|
|
}
|
|
|
|
public static String arrayToString(TypeSignature[] types) {
|
|
String result = "";
|
|
|
|
for (int i = 0; i < types.length; i++) {
|
|
if (i != 0) {
|
|
result += ",";
|
|
}
|
|
result += types[i].toString();
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public int mappableHash() {
|
|
return Mappable.hashOf(toString());//toString().hashCode();
|
|
}
|
|
|
|
@Override
|
|
public boolean mappableEquals(Mappable obj) {
|
|
if (obj instanceof TypeSignature) {
|
|
return this.toString().equals(((TypeSignature)obj).toString());
|
|
} else {
|
|
return false; //super.equals(obj);
|
|
}
|
|
}
|
|
}
|