[IR] Drop WITH_ANNOTATIONS evaluation mode in interpreter
This is old mode, that was used mainly in prototype phase
This commit is contained in:
-23
@@ -26,29 +26,6 @@ enum class EvaluationMode(protected val mustCheckBody: Boolean) {
|
|||||||
override fun canEvaluateReference(reference: IrCallableReference<*>, context: IrCall?): Boolean = true
|
override fun canEvaluateReference(reference: IrCallableReference<*>, context: IrCall?): Boolean = true
|
||||||
},
|
},
|
||||||
|
|
||||||
WITH_ANNOTATIONS(mustCheckBody = false) {
|
|
||||||
override fun canEvaluateFunction(function: IrFunction, context: IrCall?): Boolean {
|
|
||||||
if (function.isCompileTimePropertyAccessor()) return true
|
|
||||||
return function.isMarkedAsCompileTime() || function.origin == IrBuiltIns.BUILTIN_OPERATOR ||
|
|
||||||
(function is IrSimpleFunction && function.isOperator && function.name.asString() == "invoke") ||
|
|
||||||
(function is IrSimpleFunction && function.isFakeOverride && function.overriddenSymbols.any { canEvaluateFunction(it.owner) }) ||
|
|
||||||
function.isCompileTimeTypeAlias()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun IrFunction?.isCompileTimePropertyAccessor(): Boolean {
|
|
||||||
val property = this?.property ?: return false
|
|
||||||
if (property.isConst) return true
|
|
||||||
if (property.isMarkedAsCompileTime() || property.isCompileTimeTypeAlias()) return true
|
|
||||||
|
|
||||||
val backingField = property.backingField
|
|
||||||
val backingFieldExpression = backingField?.initializer?.expression as? IrGetValue
|
|
||||||
return backingFieldExpression?.origin == IrStatementOrigin.INITIALIZE_PROPERTY_FROM_PARAMETER
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun canEvaluateEnumValue(enumEntry: IrGetEnumValue, context: IrCall?): Boolean = true
|
|
||||||
override fun canEvaluateReference(reference: IrCallableReference<*>, context: IrCall?): Boolean = true
|
|
||||||
},
|
|
||||||
|
|
||||||
ONLY_BUILTINS(mustCheckBody = false) {
|
ONLY_BUILTINS(mustCheckBody = false) {
|
||||||
private val allowedMethodsOnPrimitives = setOf(
|
private val allowedMethodsOnPrimitives = setOf(
|
||||||
"not", "unaryMinus", "unaryPlus", "inv",
|
"not", "unaryMinus", "unaryPlus", "inv",
|
||||||
|
|||||||
+1
-2
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
|||||||
|
|
||||||
class IrCompileTimeChecker(
|
class IrCompileTimeChecker(
|
||||||
containingDeclaration: IrElement? = null,
|
containingDeclaration: IrElement? = null,
|
||||||
private val mode: EvaluationMode = EvaluationMode.WITH_ANNOTATIONS,
|
private val mode: EvaluationMode,
|
||||||
private val interpreterConfiguration: IrInterpreterConfiguration,
|
private val interpreterConfiguration: IrInterpreterConfiguration,
|
||||||
) : IrElementVisitor<Boolean, Nothing?> {
|
) : IrElementVisitor<Boolean, Nothing?> {
|
||||||
private var contextExpression: IrCall? = null
|
private var contextExpression: IrCall? = null
|
||||||
@@ -344,7 +344,6 @@ class IrCompileTimeChecker(
|
|||||||
return with(mode) {
|
return with(mode) {
|
||||||
when (this) {
|
when (this) {
|
||||||
EvaluationMode.FULL -> true
|
EvaluationMode.FULL -> true
|
||||||
EvaluationMode.WITH_ANNOTATIONS -> (expression.symbol.owner as IrClass).isMarkedAsCompileTime()
|
|
||||||
EvaluationMode.ONLY_BUILTINS, EvaluationMode.ONLY_INTRINSIC_CONST -> false
|
EvaluationMode.ONLY_BUILTINS, EvaluationMode.ONLY_INTRINSIC_CONST -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user