From 03557463044f40f83b21e5b970b3586d749192f3 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 5 Jul 2018 18:50:21 +0200 Subject: [PATCH] Implement OpenAddressLinearProbingHashTable.entries for debug when needed Otherwise it's very difficult to view the contents of BindingContext in debugger views --- .../OpenAddressLinearProbingHashTable.kt | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/slicedMap/OpenAddressLinearProbingHashTable.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/slicedMap/OpenAddressLinearProbingHashTable.kt index c792adf54ec..f8c18f42a30 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/slicedMap/OpenAddressLinearProbingHashTable.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/slicedMap/OpenAddressLinearProbingHashTable.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.util.slicedMap +import java.util.* import java.util.function.BiConsumer // binary representation of fractional part of phi = (sqrt(5) - 1) / 2 @@ -126,7 +127,24 @@ internal class OpenAddressLinearProbingHashTable : AbstractMut } override val entries: MutableSet> - get() = throw IllegalStateException("OpenAddressLinearProbingHashTable::entries is not supported and hardly will be") + get() { + if (@Suppress("ConstantConditionIf") DEBUG) { + return Collections.unmodifiableSet(mutableSetOf>().apply { + forEach { key, value -> add(Entry(key, value)) } + }) + } + + throw IllegalStateException("OpenAddressLinearProbingHashTable::entries is not supported and hardly will be") + } + + private class Entry(override val key: K, override val value: V) : MutableMap.MutableEntry { + override fun setValue(newValue: V): V = throw UnsupportedOperationException("This Entry is not mutable.") + } + + companion object { + // Change to "true" to be able to see the contents of the map in debugger views + private const val DEBUG = false + } } private fun put(array: Array, aShift: Int, key: Any, value: Any?): Boolean {