import org.cojen.classfile.TypeDesc;
import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
+import org.simantics.scl.compiler.elaboration.modules.TypeAlias;
import org.simantics.scl.compiler.elaboration.modules.TypeConstructor;
+import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
import org.simantics.scl.compiler.environment.Environment;
import org.simantics.scl.compiler.internal.codegen.utils.Constants;
import org.simantics.scl.compiler.types.TApply;
parameters[len-i-1] = temp;
}
}
+
+ private TypeConstructor getTypeConstructor(TCon con) {
+ TypeDescriptor typeDescriptor = environment.getTypeDescriptor(con);
+ if(typeDescriptor == null)
+ throw new InternalCompilerError("Didn't find type constructor " + con.module + "/" + con.name + ".");
+ if(typeDescriptor instanceof TypeAlias)
+ throw new InternalCompilerError("Type " + con.module + "/" + con.name + " is a type alias.");
+ return (TypeConstructor)typeDescriptor;
+ }
public TypeDesc toTypeDesc(Type type) {
while(true) {
- if(type instanceof TCon) {
- TCon con = (TCon)type;
- TypeConstructor typeConstructor = environment.getTypeConstructor(con);
- if(typeConstructor == null)
- throw new InternalCompilerError("Didn't find type constructor " + con.module + "/" + con.name + ".");
- return typeConstructor.construct(this, Type.EMPTY_ARRAY);
- }
+ if(type instanceof TCon)
+ return getTypeConstructor((TCon)type).construct(this, Type.EMPTY_ARRAY);
else if(type instanceof TApply) {
int i=0;
while(true) {
type = Types.canonical(apply.function);
if(type instanceof TCon) {
reverseParameters(i);
- return environment.getTypeConstructor((TCon)type).construct(this, parameters);
+ return getTypeConstructor((TCon)type).construct(this, parameters);
}
else if(type instanceof TApply)
;