Remove dependency of fir2ir/fir.entrypoint on psi2ir

This commit is contained in:
Alexander Udalov
2023-03-05 12:42:33 +01:00
committed by Space Team
parent 4b8471d806
commit d96112b944
9 changed files with 20 additions and 27 deletions
@@ -41,7 +41,6 @@ import org.jetbrains.kotlin.psi2ir.intermediate.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor
import org.jetbrains.kotlin.resolve.calls.components.isArrayOrArrayLiteral
import org.jetbrains.kotlin.resolve.calls.components.isVararg
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.tower.NewResolvedCallImpl
@@ -210,12 +209,6 @@ private fun StatementGenerator.generateThisOrSuperReceiver(receiver: ReceiverVal
return generateThisReceiver(ktReceiver.startOffsetSkippingComments, ktReceiver.endOffset, type, classDescriptor)
}
fun IrExpression.implicitCastTo(expectedType: IrType?): IrExpression {
if (expectedType == null) return this
return IrTypeOperatorCallImpl(startOffset, endOffset, expectedType, IrTypeOperator.IMPLICIT_CAST, expectedType, this)
}
internal fun StatementGenerator.generateBackingFieldReceiver(
startOffset: Int,
endOffset: Int,
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.psi2ir.generators
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.types.IrDynamicType
@@ -454,16 +453,6 @@ internal class CallGenerator(statementGenerator: StatementGenerator) : Statement
}
}
fun IrExpression.isUnchanging(): Boolean =
this is IrFunctionExpression ||
(this is IrCallableReference<*> && dispatchReceiver == null && extensionReceiver == null) ||
this is IrClassReference ||
this is IrConst<*> ||
(this is IrGetValue && !symbol.owner.let { it is IrVariable && it.isVar })
fun IrExpression.hasNoSideEffects(): Boolean =
isUnchanging() || this is IrGetValue
internal fun CallGenerator.generateCall(
ktElement: KtElement,
call: CallBuilder,
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.psi2ir.generators.hasNoSideEffects
import org.jetbrains.kotlin.ir.expressions.hasNoSideEffects
import org.jetbrains.kotlin.psi2ir.isValueArgumentReorderingRequired
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.types.KotlinType
@@ -6,7 +6,10 @@
package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
import org.jetbrains.kotlin.ir.symbols.IrFileSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.fileOrNull
@Suppress("unused") // Used in kotlin-native
@@ -51,3 +54,19 @@ fun IrStringConcatenation.addArgument(argument: IrExpression) {
val IrContainerExpression.isTransparentScope: Boolean
get() = this is IrComposite
fun IrExpression.implicitCastTo(expectedType: IrType?): IrExpression {
if (expectedType == null) return this
return IrTypeOperatorCallImpl(startOffset, endOffset, expectedType, IrTypeOperator.IMPLICIT_CAST, expectedType, this)
}
fun IrExpression.isUnchanging(): Boolean =
this is IrFunctionExpression ||
(this is IrCallableReference<*> && dispatchReceiver == null && extensionReceiver == null) ||
this is IrClassReference ||
this is IrConst<*> ||
(this is IrGetValue && !symbol.owner.let { it is IrVariable && it.isVar })
fun IrExpression.hasNoSideEffects(): Boolean =
isUnchanging() || this is IrGetValue