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;
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 {
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 int skeletonHashCode(int hash) {
+ hash = HashCodeUtils.updateWithPreprocessedValue(hash, PRED_HASH);
+ hash = typeClass.skeletonHashCode(hash);
+ for(Type parameter : parameters)
+ hash = parameter.skeletonHashCode(hash);
+ return hash;
+ }
+
+ @Override
+ public int skeletonHashCode(int hash, TVar[] boundVars) {
+ hash = HashCodeUtils.updateWithPreprocessedValue(hash, PRED_HASH);
+ hash = typeClass.skeletonHashCode(hash, boundVars);
+ for(Type parameter : parameters)
+ hash = parameter.skeletonHashCode(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<parameters.length;++i)
+ if(!Types.canonical(parameters[i]).equalsCanonical(Types.canonical(pred.parameters[i])))
+ return false;
+ return true;
+ }
+
+ @Override
+ public Kind getKind(Environment context) {
+ return Kinds.STAR;
+ }
+
+ @Override
+ public Type[] skeletonCanonicalChildren() {
+ Type[] result = new Type[parameters.length];
+ for(int i=0;i<parameters.length;++i)
+ result[i] = Skeletons.canonicalSkeleton(parameters[i]);
+ return result;
+ }
}