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%2FTCon.java;h=16e0c29eb5b962634cce80b8fe82f904f612461d;hp=7e9d25001cbfa42f4fe38672e083e1c320935d74;hb=9a175feb652b2b7bba7afa540831b9076be3c10e;hpb=0b72d3e4ec886838314ffeba0fa201e32c0aae3e diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TCon.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TCon.java index 7e9d25001..16e0c29eb 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TCon.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TCon.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 org.simantics.scl.compiler.environment.Environment; import org.simantics.scl.compiler.internal.codegen.utils.NameMangling; +import org.simantics.scl.compiler.internal.types.HashCodeUtils; import org.simantics.scl.compiler.internal.types.TypeHashCodeContext; import org.simantics.scl.compiler.internal.types.ast.TConAst; import org.simantics.scl.compiler.internal.types.ast.TypeAst; @@ -15,10 +13,13 @@ import org.simantics.scl.compiler.types.kinds.Kind; 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; + /** * This class represents an SCL type constant with a name given in a module. */ -public class TCon extends Type { +public final class TCon extends Type { public final String module; public final String name; @@ -104,6 +105,10 @@ public class TCon extends Type { public Kind inferKind(Environment context) throws KindUnificationException { return context.getTypeConstructor(this).kind; } + + public Kind getKind(Environment context) { + return context.getTypeConstructor(this).kind; + } @Override public boolean containsMetaVars() { @@ -148,4 +153,19 @@ public class TCon extends Type { public Type copySkeleton(THashMap metaVarMap) { return this; } + + @Override + public int hashCode(int hash) { + return HashCodeUtils.update(hash, System.identityHashCode(this)); + } + + @Override + public int hashCode(int hash, TVar[] boundVars) { + return HashCodeUtils.update(hash, System.identityHashCode(this)); + } + + @Override + public boolean equalsCanonical(Type other) { + return this == other; + } }