[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
@@ -24,11 +24,15 @@ class ConstEvaluationLowering(
private val onWarning: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
private val onError: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
) : FileLoweringPass {
val interpreter = IrInterpreter(IrInterpreterEnvironment(context.irBuiltIns, configuration), emptyMap())
private val interpreter = IrInterpreter(IrInterpreterEnvironment(context.irBuiltIns, configuration), emptyMap())
private val evaluatedConstTracker = context.configuration[CommonConfigurationKeys.EVALUATED_CONST_TRACKER]
override fun lower(irFile: IrFile) {
val transformer = IrConstTransformer(
interpreter, irFile, mode = EvaluationMode.ONLY_INTRINSIC_CONST, onWarning, onError, suppressErrors
interpreter, irFile,
mode = EvaluationMode.ONLY_INTRINSIC_CONST,
evaluatedConstTracker,
onWarning, onError, suppressErrors
)
irFile.transformChildren(transformer, null)
}