diff --git a/src/org/rascalmpl/library/util/Reflective.java b/src/org/rascalmpl/library/util/Reflective.java index 70c821fa58e..98f50a5a981 100644 --- a/src/org/rascalmpl/library/util/Reflective.java +++ b/src/org/rascalmpl/library/util/Reflective.java @@ -433,6 +433,10 @@ public IInteger getFingerprintNode(INode nd){ return values.integer(ToplevelType.getFingerprintNode(nd)); } + public IInteger getHashCode(IValue v) { + return values.integer(v.hashCode()); + } + public void throwNullPointerException() { throw new NullPointerException(); } diff --git a/src/org/rascalmpl/library/util/Reflective.rsc b/src/org/rascalmpl/library/util/Reflective.rsc index f86ec6058fa..2955befe5d0 100644 --- a/src/org/rascalmpl/library/util/Reflective.rsc +++ b/src/org/rascalmpl/library/util/Reflective.rsc @@ -287,6 +287,17 @@ public java int getFingerprint(value val, int arity, bool concretePatterns); @javaClass{org.rascalmpl.library.util.Reflective} public java int getFingerprintNode(node nd); +@synopsis{Get the internal hash code of a value. For the benefit of debugging the Rascal implementation.} +@description{ +This function is useless for Rascal programmer's as it is a part of the under-the-hood implementation of values. +You can use a value directly as a lookup key. The internal data-structures probably use this hashCode for +optimal lookups in `O(log(size))`. + +We use this function to diagnose possible performance issues caused by hash collisions. +} +@javaClass{org.rascalmpl.library.util.Reflective} +public java int getHashCode(value v); + @synopsis{Throw a raw Java NullPointerException, to help simulate an unexpected exception in test scenarios} @javaClass{org.rascalmpl.library.util.Reflective} java void throwNullPointerException();