IR: minor, move IrMemberAccessExpression utils to a separate file
To help git understand that IrMemberAccessExpression is moved in the subsequent commits where it's changed to be auto-generated.
This commit is contained in:
committed by
Alexander Udalov
parent
35776ed4fa
commit
9fa5bd386c
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
|
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
||||||
@@ -64,3 +67,33 @@ fun IrExpression.isUnchanging(): Boolean =
|
|||||||
|
|
||||||
fun IrExpression.hasNoSideEffects(): Boolean =
|
fun IrExpression.hasNoSideEffects(): Boolean =
|
||||||
isUnchanging() || this is IrGetValue
|
isUnchanging() || this is IrGetValue
|
||||||
|
|
||||||
|
internal fun IrMemberAccessExpression<*>.throwNoSuchArgumentSlotException(kind: String, index: Int, total: Int): Nothing {
|
||||||
|
throw AssertionError(
|
||||||
|
"No such $kind argument slot in ${this::class.java.simpleName}: $index (total=$total)" +
|
||||||
|
(symbol.signature?.let { ".\nSymbol: $it" } ?: "")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun IrMemberAccessExpression<*>.copyTypeArgumentsFrom(other: IrMemberAccessExpression<*>, shift: Int = 0) {
|
||||||
|
assert(typeArgumentsCount == other.typeArgumentsCount + shift) {
|
||||||
|
"Mismatching type arguments: $typeArgumentsCount vs ${other.typeArgumentsCount} + $shift"
|
||||||
|
}
|
||||||
|
for (i in 0 until other.typeArgumentsCount) {
|
||||||
|
putTypeArgument(i + shift, other.getTypeArgument(i))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val CallableDescriptor.typeParametersCount: Int
|
||||||
|
get() =
|
||||||
|
when (this) {
|
||||||
|
is PropertyAccessorDescriptor -> correspondingProperty.typeParameters.size
|
||||||
|
else -> typeParameters.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fun IrMemberAccessExpression<*>.putArgument(callee: IrFunction, parameter: IrValueParameter, argument: IrExpression) =
|
||||||
|
when (parameter) {
|
||||||
|
callee.dispatchReceiverParameter -> dispatchReceiver = argument
|
||||||
|
callee.extensionReceiverParameter -> extensionReceiver = argument
|
||||||
|
else -> putValueArgument(parameter.index, argument)
|
||||||
|
}
|
||||||
|
|||||||
-36
@@ -5,16 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.expressions
|
package org.jetbrains.kotlin.ir.expressions
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
|
||||||
|
|
||||||
// todo: autogenerate
|
// todo: autogenerate
|
||||||
/**
|
/**
|
||||||
@@ -80,33 +74,3 @@ abstract class IrMemberAccessExpression<S : IrSymbol> : IrDeclarationReference()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun IrMemberAccessExpression<*>.throwNoSuchArgumentSlotException(kind: String, index: Int, total: Int): Nothing {
|
|
||||||
throw AssertionError(
|
|
||||||
"No such $kind argument slot in ${this::class.java.simpleName}: $index (total=$total)" +
|
|
||||||
(symbol.signature?.let { ".\nSymbol: $it" } ?: "")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun IrMemberAccessExpression<*>.copyTypeArgumentsFrom(other: IrMemberAccessExpression<*>, shift: Int = 0) {
|
|
||||||
assert(typeArgumentsCount == other.typeArgumentsCount + shift) {
|
|
||||||
"Mismatching type arguments: $typeArgumentsCount vs ${other.typeArgumentsCount} + $shift"
|
|
||||||
}
|
|
||||||
for (i in 0 until other.typeArgumentsCount) {
|
|
||||||
putTypeArgument(i + shift, other.getTypeArgument(i))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val CallableDescriptor.typeParametersCount: Int
|
|
||||||
get() =
|
|
||||||
when (this) {
|
|
||||||
is PropertyAccessorDescriptor -> correspondingProperty.typeParameters.size
|
|
||||||
else -> typeParameters.size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun IrMemberAccessExpression<*>.putArgument(callee: IrFunction, parameter: IrValueParameter, argument: IrExpression) =
|
|
||||||
when (parameter) {
|
|
||||||
callee.dispatchReceiverParameter -> dispatchReceiver = argument
|
|
||||||
callee.extensionReceiverParameter -> extensionReceiver = argument
|
|
||||||
else -> putValueArgument(parameter.index, argument)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user