]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TCon.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / types / TCon.java
index 7e9d25001cbfa42f4fe38672e083e1c320935d74..675047ae8510a8c583ddcd8a6c3c80bfdee9e7df 100644 (file)
@@ -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;
 
@@ -70,11 +71,6 @@ public class TCon extends Type {
         return this == obj;
     }
     
-    @Override
-    public int hashCode() {
-        return System.identityHashCode(this);
-    }
-    
     @Override
     public void updateHashCode(TypeHashCodeContext context) {
         context.append(System.identityHashCode(this));        
@@ -102,8 +98,12 @@ public class TCon extends Type {
     }
 
        public Kind inferKind(Environment context) throws KindUnificationException {
-        return context.getTypeConstructor(this).kind;
+        return context.getTypeDescriptor(this).getKind();
     }
+       
+       public Kind getKind(Environment context) {
+           return context.getTypeDescriptor(this).getKind();
+       }
 
     @Override
     public boolean containsMetaVars() {
@@ -148,4 +148,44 @@ public class TCon extends Type {
     public Type copySkeleton(THashMap<TMetaVar, TMetaVar> metaVarMap) {
         return this;
     }
+    
+    @Override
+    public int hashCode() {
+        return System.identityHashCode(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 int skeletonHashCode() {
+        return System.identityHashCode(this);
+    }
+
+    @Override
+    public int skeletonHashCode(int hash) {
+        return HashCodeUtils.update(hash, System.identityHashCode(this));
+    }
+    
+    @Override
+    public int skeletonHashCode(int hash, TVar[] boundVars) {
+        return HashCodeUtils.update(hash, System.identityHashCode(this));
+    }
+    
+    @Override
+    public boolean equalsCanonical(Type other) {
+        return this == other;
+    }
+
+    @Override
+    public Type[] skeletonCanonicalChildren() {
+        return EMPTY_ARRAY;
+    }
 }