[FIR] Support the simple case of java field interpretation

#KT-57802
This commit is contained in:
Ivan Kylchik
2023-09-04 16:18:27 +02:00
committed by Space Team
parent 2af73c2b13
commit 886ef1a4b4
11 changed files with 148 additions and 6 deletions
@@ -75,6 +75,24 @@ fun IrFile.runConstOptimizations(
preprocessedFile.transform(irConstExpressionTransformer, IrConstTransformer.Data())
}
// TODO simplify
fun IrProperty.evaluate(
irFile: IrFile,
interpreter: IrInterpreter,
mode: EvaluationMode,
evaluatedConstTracker: EvaluatedConstTracker? = null,
inlineConstTracker: InlineConstTracker? = null,
onWarning: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
onError: (IrFile, IrElement, IrErrorExpression) -> Unit = { _, _, _ -> },
suppressExceptions: Boolean = false,
): IrProperty? {
val checker = IrInterpreterCommonChecker()
val irConstExpressionTransformer = IrConstAllTransformer(
interpreter, irFile, mode, checker, evaluatedConstTracker, inlineConstTracker, onWarning, onError, suppressExceptions
)
return this.transform(irConstExpressionTransformer, IrConstTransformer.Data()) as? IrProperty
}
private fun IrFile.preprocessForConstTransformer(
interpreter: IrInterpreter,
mode: EvaluationMode,
@@ -88,7 +106,7 @@ private fun IrFile.preprocessForConstTransformer(
// Note: We are using `IrElementTransformer` here instead of `IrElementTransformerVoid` to avoid conflicts with `IrTypeVisitorVoid`
// that is used later in `IrConstTypeAnnotationTransformer`.
internal abstract class IrConstTransformer(
abstract class IrConstTransformer(
protected val interpreter: IrInterpreter,
private val irFile: IrFile,
private val mode: EvaluationMode,