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%2FTMetaVar.java;h=d78d745eb670c0ccb99719c2690e314e6a610488;hp=0d3114fc5765b0bad9a3ad11df5aaef8dc803bf1;hb=a8758de5bc19e5adb3f618d3038743a164f09912;hpb=12d9af17384d960b75d58c3935d2b7b46d93e87b diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TMetaVar.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TMetaVar.java index 0d3114fc5..d78d745eb 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TMetaVar.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/TMetaVar.java @@ -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; + } }