]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TMetaVar.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / types / TMetaVar.java
index 0d3114fc5765b0bad9a3ad11df5aaef8dc803bf1..d78d745eb670c0ccb99719c2690e314e6a610488 100644 (file)
@@ -97,14 +97,6 @@ public class TMetaVar extends Type {
             return ref.toTypeAst(context);
     }
     
-    @Override
-    public int hashCode() {
-        if(ref == null)
-            return System.identityHashCode(this);
-        else
-            return ref.hashCode();
-    }
-    
     @Override
     public void updateHashCode(TypeHashCodeContext context) {
         if(ref == null)
@@ -142,6 +134,10 @@ public class TMetaVar extends Type {
     }
 
     public void setRef(Type type) throws UnificationException {
+        if(type instanceof TMetaVar && ((TMetaVar)type).ref != null)
+            throw new InternalCompilerError("Not canonical!");
+        if(type == this)
+            throw new InternalCompilerError("Illegal setRef");
         if(DEBUG)
             System.out.println("setRef " + System.identityHashCode(this) + " -> " + type);
         if(ref != null)
@@ -280,6 +276,14 @@ public class TMetaVar extends Type {
         fireNotifyAboutChange();
     }
     
+    @Override
+    public int hashCode() {
+        if(ref == null)
+            return System.identityHashCode(this);
+        else
+            return ref.hashCode();
+    }
+    
     @Override
     public int hashCode(int hash) {
         if(ref == null)
@@ -296,6 +300,36 @@ public class TMetaVar extends Type {
             return ref.hashCode(hash, boundVars);
     }
     
+    @Override
+    public int skeletonHashCode() {
+        if(ref != null)
+            return ref.skeletonHashCode();
+        else if(skeletonRef != null)
+            return skeletonRef.skeletonHashCode();
+        else
+            return System.identityHashCode(this);
+    }
+    
+    @Override
+    public int skeletonHashCode(int hash) {
+        if(ref != null)
+            return ref.skeletonHashCode(hash);
+        else if(skeletonRef != null)
+            return skeletonRef.skeletonHashCode(hash);
+        else
+            return HashCodeUtils.update(hash, System.identityHashCode(this));
+    }
+    
+    @Override
+    public int skeletonHashCode(int hash, TVar[] boundVars) {
+        if(ref != null)
+            return ref.skeletonHashCode(hash, boundVars);
+        else if(skeletonRef != null)
+            return skeletonRef.skeletonHashCode(hash, boundVars);
+        else
+            return HashCodeUtils.update(hash, System.identityHashCode(this));
+    }
+    
     @Override
     public boolean equalsCanonical(Type other) {
         return this == other;
@@ -343,4 +377,10 @@ public class TMetaVar extends Type {
     public Kind getKind(Environment context) {
         return kind;
     }
+
+    @Override
+    public Type[] skeletonCanonicalChildren() {
+        // Assumes that this is already canonical skeleton
+        return EMPTY_ARRAY;
+    }
 }