]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TForAll.java
Merged changes from feature/scl to master.
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / types / TForAll.java
index 98b4578af676642e54288a161037eda249314150..b4b1af8196486fc14e2209983d425e8279d83edc 100644 (file)
@@ -203,6 +203,56 @@ public class TForAll extends Type {
         return t.type.hashCode(hash, boundVars);
     }
     
+    @Override
+    public int skeletonHashCode(int hash) {
+        int count=1;
+        {
+            Type t = Types.canonical(type);
+            while(t instanceof TForAll) {
+                t = Types.canonical( ((TForAll)t).type );
+                ++count;
+            }
+        }
+        TVar[] boundVars = new TVar[count];
+        boundVars[0] = var;
+        TForAll t = this;
+        {
+            for(int i=1;i<count;++i) {
+                t = (TForAll)Types.canonical(t.type);
+                boundVars[i] = t.var;
+            }
+        }
+        
+        for(int i=0;i<count;++i)
+            hash = HashCodeUtils.updateWithPreprocessedValue(hash, FORALL_HASH);
+        return t.type.skeletonHashCode(hash, boundVars);
+    }
+    
+    @Override
+    public int skeletonHashCode(int hash, TVar[] oldBoundVars) {
+        int count=1;
+        {
+            Type t = Types.canonical(type);
+            while(t instanceof TForAll) {
+                t = Types.canonical( ((TForAll)t).type );
+                ++count;
+            }
+        }
+        TVar[] boundVars = Arrays.copyOf(oldBoundVars, oldBoundVars.length + count);
+        boundVars[oldBoundVars.length] = var;
+        TForAll t = this;
+        {
+            for(int i=1;i<count;++i) {
+                t = (TForAll)Types.canonical(t.type);
+                boundVars[oldBoundVars.length + i] = t.var;
+            }
+        }
+        
+        for(int i=0;i<count;++i)
+            hash = HashCodeUtils.updateWithPreprocessedValue(hash, FORALL_HASH);
+        return t.type.skeletonHashCode(hash, boundVars);
+    }
+    
     public Type getCanonicalType() {
         if(type instanceof TMetaVar)
             type = type.canonical();
@@ -222,6 +272,11 @@ public class TForAll extends Type {
     @Override
     public Kind getKind(Environment context) {
         return Kinds.STAR;
+    }
+
+    @Override
+    public Type[] skeletonCanonicalChildren() {
+        return new Type[] { Skeletons.canonicalSkeleton(type) };
     } 
     
 }