[K2] Add new class to keep track of evaluated const by IrInterpreter

This commit is contained in:
Ivan Kylchik
2023-03-14 19:48:05 +01:00
committed by Space Team
parent 297b6ae64b
commit 37c3dff0c5
7 changed files with 79 additions and 11 deletions
@@ -0,0 +1,26 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.constant
import java.util.concurrent.ConcurrentHashMap
abstract class EvaluatedConstTracker {
abstract fun save(start: Int, end: Int, constant: ConstantValue<*>)
abstract fun load(start: Int, end: Int): ConstantValue<*>?
}
class DefaultEvaluatedConstTracker : EvaluatedConstTracker() {
private val storage = ConcurrentHashMap<Pair<Int, Int>, ConstantValue<*>>()
override fun save(start: Int, end: Int, constant: ConstantValue<*>) {
storage[start to end] = constant
}
override fun load(start: Int, end: Int): ConstantValue<*>? {
return storage[start to end]
}
}