[FIR] Support the simple case of java field interpretation
#KT-57802
This commit is contained in:
+19
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user