X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Ftypes%2FTypeHashCodeContext.java;fp=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Ftypes%2FTypeHashCodeContext.java;h=5e7aec1a0b4b9ded0efff5298963158578a37b2f;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..5e7aec1a0 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/types/TypeHashCodeContext.java @@ -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 varHashCode; + + public void append(int hash) { + result = result*31 + hash; + } + + public int getResult() { + return result; + } + + public TObjectIntHashMap getVarHashCode() { + return varHashCode; + } + + public TObjectIntHashMap createVarHashCode() { + if(varHashCode == null) + varHashCode = new TObjectIntHashMap(); + return varHashCode; + } +}