package org.simantics.scl.compiler.types;
-import gnu.trove.map.hash.THashMap;
-import gnu.trove.set.hash.THashSet;
-
import java.util.ArrayList;
import java.util.Map;
import org.simantics.scl.compiler.environment.Environment;
+import org.simantics.scl.compiler.internal.types.HashCodeUtils;
import org.simantics.scl.compiler.internal.types.TypeHashCodeContext;
import org.simantics.scl.compiler.internal.types.ast.TypeAst;
import org.simantics.scl.compiler.types.exceptions.KindUnificationException;
import org.simantics.scl.compiler.types.util.Polarity;
import org.simantics.scl.compiler.types.util.TypeUnparsingContext;
+import gnu.trove.map.hash.THashMap;
+import gnu.trove.set.hash.THashSet;
+
/**
public static final int METAVAR_ID = 5;
public static final int VAR_ID = 6;
public static final int UNION_ID = 7;
- public static final int ALIAS_ID = 8;
+ protected static final int APPLY_HASH = HashCodeUtils.preprocessValue(0);
+ protected static final int FORALL_HASH = HashCodeUtils.preprocessValue(1);
+ protected static final int FUN_HASH = HashCodeUtils.preprocessValue(2);
+ protected static final int PRED_HASH = HashCodeUtils.preprocessValue(3);
+ protected static final int UNION_HASH = HashCodeUtils.preprocessValue(4);
+ protected static final int BOUND_VAR_HASH = HashCodeUtils.preprocessValue(5);
/*
* This class is not meant to be extended outside of this package.
@Override
public int hashCode() {
- TypeHashCodeContext context = new TypeHashCodeContext();
- updateHashCode(context);
- return context.getResult();
+ return hashCode(HashCodeUtils.SEED);
}
public abstract void updateHashCode(TypeHashCodeContext context);
+ public abstract int hashCode(int hash);
+ public abstract int hashCode(int hash, TVar[] boundVars);
public abstract void collectFreeVars(ArrayList<TVar> vars);
* Creates an independent copy of the type, but replaces all effects by metavars
*/
public abstract Type copySkeleton(THashMap<TMetaVar,TMetaVar> metaVarMap);
+
+ public abstract boolean equalsCanonical(Type other);
+
+ public Type canonical() {
+ return this;
+ }
+
+ public abstract Kind getKind(Environment context);
}
\ No newline at end of file