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%2FTPred.java;h=e8a0469c5d996f428c205c13018fe1e6e009707c;hp=d9fd79f917f3770b7f730caaacd9017d5aba348f;hb=9a175feb652b2b7bba7afa540831b9076be3c10e;hpb=0b72d3e4ec886838314ffeba0fa201e32c0aae3e diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TPred.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TPred.java index d9fd79f91..e8a0469c5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TPred.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TPred.java @@ -1,11 +1,9 @@ package org.simantics.scl.compiler.types; -import gnu.trove.map.hash.THashMap; -import gnu.trove.set.hash.THashSet; - import java.util.ArrayList; 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.TApplyAst; import org.simantics.scl.compiler.internal.types.ast.TypeAst; @@ -15,6 +13,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; + public class TPred extends Type { @@ -172,4 +173,42 @@ public class TPred extends Type { newParameters[i] = parameters[i].copySkeleton(metaVarMap); return new TPred(typeClass, parameters); } + + @Override + public int hashCode(int hash) { + hash = HashCodeUtils.updateWithPreprocessedValue(hash, PRED_HASH); + hash = typeClass.hashCode(hash); + for(Type parameter : parameters) + hash = parameter.hashCode(hash); + return hash; + } + + @Override + public int hashCode(int hash, TVar[] boundVars) { + hash = HashCodeUtils.updateWithPreprocessedValue(hash, PRED_HASH); + hash = typeClass.hashCode(hash, boundVars); + for(Type parameter : parameters) + hash = parameter.hashCode(hash, boundVars); + return hash; + } + + @Override + public boolean equalsCanonical(Type other) { + if(this == other) + return true; + if(!other.getClass().equals(TPred.class)) + return false; + TPred pred = (TPred)other; + if(typeClass != pred.typeClass || parameters.length != pred.parameters.length) + return false; + for(int i=0;i