X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftypes%2FType.java;h=386accc4ff5e1e941d84a1b84768740d81558877;hp=1709ebbeeeab415361894829982922bf8201bc13;hb=9a175feb652b2b7bba7afa540831b9076be3c10e;hpb=0b72d3e4ec886838314ffeba0fa201e32c0aae3e diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Type.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Type.java index 1709ebbee..386accc4f 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Type.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Type.java @@ -1,12 +1,10 @@ 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; @@ -16,6 +14,9 @@ import org.simantics.scl.compiler.types.kinds.Kinds; 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; + /** @@ -37,8 +38,13 @@ public abstract class Type { 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. @@ -107,12 +113,12 @@ public abstract class Type { @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 vars); @@ -160,5 +166,13 @@ public abstract class Type { * Creates an independent copy of the type, but replaces all effects by metavars */ public abstract Type copySkeleton(THashMap metaVarMap); + + public abstract boolean equalsCanonical(Type other); + + public Type canonical() { + return this; + } + + public abstract Kind getKind(Environment context); } \ No newline at end of file