]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/types/TypeHashCodeContext.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / types / TypeHashCodeContext.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/types/TypeHashCodeContext.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/types/TypeHashCodeContext.java
new file mode 100644 (file)
index 0000000..5e7aec1
--- /dev/null
@@ -0,0 +1,34 @@
+package org.simantics.scl.compiler.internal.types;
+
+import gnu.trove.map.hash.TObjectIntHashMap;
+
+import org.simantics.scl.compiler.types.TVar;
+
+public class TypeHashCodeContext {
+        
+    public static final int APPLY = 0x12345678;
+    public static final int FORALL = 0xf2341233;
+    public static final int UNION = 0x9f8f7f6f;
+    public static final int FUN = 0xff294313;
+    
+    int result;
+    TObjectIntHashMap<TVar> varHashCode;
+    
+    public void append(int hash) {
+        result = result*31 + hash;
+    }
+    
+    public int getResult() {
+        return result;
+    }
+    
+    public TObjectIntHashMap<TVar> getVarHashCode() {
+        return varHashCode;
+    }
+    
+    public TObjectIntHashMap<TVar> createVarHashCode() {
+        if(varHashCode == null)
+            varHashCode = new TObjectIntHashMap<TVar>();
+        return varHashCode;
+    }
+}