Skip to content

Commit

Permalink
[IR] Drop valueArgumentsCount from IrCallImpl
Browse files Browse the repository at this point in the history
KT-70057
  • Loading branch information
mcpiroman authored and Space Cloud committed Sep 5, 2024
1 parent 79a6b2e commit c420d37
Show file tree
Hide file tree
Showing 62 changed files with 47 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,7 @@ class Fir2IrDelegatedMembersGenerationStrategy(
offset,
callReturnType,
delegateTargetFunction.symbol,
delegatedFunction.typeParameters.size,
delegatedFunction.valueParameters.size
delegatedFunction.typeParameters.size
).apply {
val thisDispatchReceiverParameter = delegatedFunction.dispatchReceiverParameter!!
val getField = IrGetFieldImpl(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Fir2IrBuiltinSymbolsContainer(
constructorSymbol,
typeArgumentsCount = 0,
constructorTypeArgumentsCount = 0,
valueArgumentsCount = 0,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ internal class AdapterGenerator(
type,
adapteeSymbol,
typeArgumentsCount = callableReferenceAccess.typeArguments.size,
valueArgumentsCount = firAdaptee.valueParameters.size + firAdaptee.contextReceivers.size,
origin = null,
superQualifierSymbol = null
)
Expand Down Expand Up @@ -676,8 +675,7 @@ internal class AdapterGenerator(
startOffset, endOffset,
adapterFunction.returnType,
invokeSymbol,
typeArgumentsCount = 0,
valueArgumentsCount = adapterFunction.valueParameters.size
typeArgumentsCount = 0
)
irCall.dispatchReceiver = adapterFunction.extensionReceiverParameter!!.toIrGetValue(startOffset, endOffset)
for (irAdapterParameter in adapterFunction.valueParameters) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ class CallAndReferenceGenerator(
startOffset, endOffset, irType,
declarationStorage.findGetterOfProperty(irSymbol),
typeArgumentsCount = calleeReference.toResolvedCallableSymbol()!!.fir.typeParameters.size,
valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_LOCAL_PROPERTY,
superQualifierSymbol = dispatchReceiver?.superQualifierSymbolForFunctionAndPropertyAccess()
)
Expand Down Expand Up @@ -767,7 +766,6 @@ class CallAndReferenceGenerator(
setterSymbol != null -> IrCallImpl(
startOffset, endOffset, type, setterSymbol,
typeArgumentsCount = firProperty.typeParameters.size,
valueArgumentsCount = 1 + firProperty.contextReceivers.size,
origin = origin,
superQualifierSymbol = variableAssignment.dispatchReceiver?.superQualifierSymbolForFunctionAndPropertyAccess()
).apply {
Expand Down Expand Up @@ -812,7 +810,6 @@ class CallAndReferenceGenerator(
IrCallImpl(
startOffset, endOffset, type, symbol,
typeArgumentsCount = firFunction?.typeParameters?.size ?: 0,
valueArgumentsCount = 1,
origin = origin
).apply {
putValueArgument(0, irRhsWithCast)
Expand Down Expand Up @@ -1243,8 +1240,7 @@ class CallAndReferenceGenerator(
startOffset, endOffset,
firConversionFunction.fir.returnTypeRef.toIrType(),
irConversionFunction,
typeArgumentsCount = 0,
valueArgumentsCount = 0
typeArgumentsCount = 0
).apply {
extensionReceiver = this@applyToElement
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ internal class OperatorExpressionGenerator(
irExpression.startOffset, irExpression.endOffset,
conversionFirFunction.resolvedReturnType.toIrType(c),
conversionFunctionSymbol as IrSimpleFunctionSymbol,
valueArgumentsCount = 0,
typeArgumentsCount = 0
).also {
it.dispatchReceiver = irExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fun IrInlinable.inline(target: IrDeclarationParent, arguments: List<IrValueDecla
val invoke = invokable.type.getClass()!!.functions.single { it.name == OperatorNameConventions.INVOKE }
IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, invoke.returnType, invoke.symbol,
typeArgumentsCount = 0, valueArgumentsCount = arguments.size,
typeArgumentsCount = 0,
).apply {
dispatchReceiver = IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, invokable.symbol)
for ((index, argument) in arguments.withIndex()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ fun CommonBackendContext.createArrayOfExpression(
arrayType,
ir.symbols.arrayOf,
typeArgumentsCount = 1,
valueArgumentsCount = 1
).apply {
putTypeArgument(0, arrayElementType)
putValueArgument(0, arg0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ open class DefaultParameterInjector<TContext : CommonBackendContext>(
IrCallImpl(
startOffset, endOffset, (it as IrSimpleFunctionSymbol).owner.returnType, it,
typeArgumentsCount = typeArgumentsCount - typeParametersToRemove,
valueArgumentsCount = it.owner.valueParameters.size,
origin = LoweredStatementOrigins.DEFAULT_DISPATCH_CALL,
superQualifierSymbol = superQualifierSymbol
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ open class EnumWhenLowering(protected open val context: CommonBackendContext) :
return IrCallImpl(
expression.startOffset, expression.endOffset,
expression.type, expression.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 2
typeArgumentsCount = 0
).apply {
putValueArgument(0, IrGetValueImpl(lhs.startOffset, lhs.endOffset, subjectOrdinal.type, subjectOrdinal.symbol))
putValueArgument(1, IrConstImpl.int(rhs.startOffset, rhs.endOffset, context.irBuiltIns.intType, entryOrdinal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,6 @@ open class LocalDeclarationsLowering(
oldCall.type,
newCallee.symbol,
typeArgumentsCount = newCallee.typeParameters.size,
valueArgumentsCount = newCallee.valueParameters.size,
origin = oldCall.origin,
superQualifierSymbol = oldCall.superQualifierSymbol
).also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ abstract class SyntheticAccessorGenerator<Context : BackendContext, ScopeInfo>(
val call = IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type,
accessorSymbol, 0, accessorSymbol.owner.valueParameters.size,
accessorSymbol, 0,
oldExpression.origin
)
oldExpression.receiver?.let {
Expand Down Expand Up @@ -541,7 +541,7 @@ abstract class SyntheticAccessorGenerator<Context : BackendContext, ScopeInfo>(
val call = IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type,
accessorSymbol, 0, accessorSymbol.owner.valueParameters.size,
accessorSymbol, 0,
oldExpression.origin
)
oldExpression.receiver?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ internal abstract class UnsignedProgressionType(
startOffset, endOffset,
unsignedType,
unsafeCoerceIntrinsic,
typeArgumentsCount = 2,
valueArgumentsCount = 1
typeArgumentsCount = 2
).apply {
putTypeArgument(0, fromType)
putTypeArgument(1, unsignedType)
Expand All @@ -136,8 +135,7 @@ internal abstract class UnsignedProgressionType(
IrCallImpl(
startOffset, endOffset, unsignedConversionFunction.owner.returnType,
unsignedConversionFunction,
typeArgumentsCount = 0,
valueArgumentsCount = 0
typeArgumentsCount = 0
).apply {
extensionReceiver = this@asUnsigned
}
Expand All @@ -152,8 +150,7 @@ internal abstract class UnsignedProgressionType(
IrCallImpl(
startOffset, endOffset, toType,
unsafeCoerceIntrinsic,
typeArgumentsCount = 2,
valueArgumentsCount = 1
typeArgumentsCount = 2
).apply {
putTypeArgument(0, unsignedType)
putTypeArgument(1, toType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ internal fun IrExpression.negate(): IrExpression {
IrCallImpl(
startOffset, endOffset, unaryMinusFun.returnType,
unaryMinusFun.symbol,
valueArgumentsCount = 0,
typeArgumentsCount = 0
).apply {
dispatchReceiver = this@negate
Expand All @@ -61,7 +60,6 @@ internal fun IrExpression.decrement(): IrExpression {
IrCallImpl(
startOffset, endOffset, type,
decFun.symbol,
valueArgumentsCount = 0,
typeArgumentsCount = 0
).apply {
dispatchReceiver = this@decrement
Expand Down Expand Up @@ -201,8 +199,7 @@ private fun IrExpression.makeIrCallConversionToTargetClass(
return IrCallImpl(
startOffset, endOffset,
castFun.returnType, castFun.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 0
typeArgumentsCount = 0
).also { it.dispatchReceiver = this }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class IrValidatorTest {
IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, TestIrBuiltins.anyType, function.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 1,
).apply {
dispatchReceiver = stringConcatenationWithWrongType
putValueArgument(0, stringConcatenationWithWrongType)
Expand All @@ -105,7 +104,6 @@ class IrValidatorTest {
IrCallImpl(
6, 23, TestIrBuiltins.anyType, function.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 1,
).apply {
dispatchReceiver = stringConcatenationWithWrongType
putValueArgument(0, stringConcatenationWithWrongType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol

class JsSharedVariablesManager(context: JsIrBackendContext) : SharedVariablesManager {

Expand All @@ -39,7 +38,6 @@ class JsSharedVariablesManager(context: JsIrBackendContext) : SharedVariablesMan
IrCallImpl(
initializer.startOffset, initializer.endOffset,
dynamicType, createBox,
valueArgumentsCount = 1,
typeArgumentsCount = 1
).apply {
putTypeArgument(0, valueType)
Expand Down Expand Up @@ -68,7 +66,6 @@ class JsSharedVariablesManager(context: JsIrBackendContext) : SharedVariablesMan
originalGet.type,
readBox,
typeArgumentsCount = 1,
valueArgumentsCount = 1,
originalGet.origin
).apply {
putTypeArgument(0, originalGet.type)
Expand All @@ -91,7 +88,6 @@ class JsSharedVariablesManager(context: JsIrBackendContext) : SharedVariablesMan
builtIns.unitType,
writeBox,
typeArgumentsCount = 1,
valueArgumentsCount = 2,
originalSet.origin
).apply {
putTypeArgument(0, originalSet.value.type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ object JsIrBuilder {
target,
superQualifierSymbol = superQualifierSymbol,
typeArgumentsCount = owner.typeParameters.size,
valueArgumentsCount = owner.valueParameters.size,
origin = origin
).apply {
typeArguments?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ class CallableReferenceLowering(private val context: JsCommonBackendContext) : B
callee.returnType,
callee.symbol,
callee.typeParameters.size,
callee.valueParameters.size,
JsStatementOrigins.CALLABLE_REFERENCE_INVOKE
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class CreateScriptFunctionsPhase(val context: CommonBackendContext) : FileLoweri
return IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.returnType,
function.symbol,
valueArgumentsCount = function.valueParameters.size,
typeArgumentsCount = function.typeParameters.size
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class EscapedIdentifiersLowering(context: JsIrBackendContext) : BodyLoweringPass
type = context.dynamicType,
symbol = context.intrinsics.globalThis.owner.getter!!.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 0,
)

private val IrFunction.dummyDispatchReceiverParameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo
UNDEFINED_OFFSET,
context.irBuiltIns.anyType,
context.intrinsics.jsBind,
valueArgumentsCount = 2,
typeArgumentsCount = 0,
origin = JsStatementOrigins.BIND_CALL,
).apply {
Expand Down Expand Up @@ -170,7 +169,7 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo
factory: IrSimpleFunctionSymbol
): IrCall {
val newCall = expression.run {
IrCallImpl(startOffset, endOffset, type, factory, typeArgumentsCount, valueArgumentsCount, origin)
IrCallImpl(startOffset, endOffset, type, factory, typeArgumentsCount, origin)
}

newCall.dispatchReceiver = expression.dispatchReceiver
Expand Down Expand Up @@ -434,7 +433,6 @@ class InteropCallableReferenceLowering(val context: JsIrBackendContext) : BodyLo
invokeFun.returnType,
invokeFun.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = invokeFun.valueParameters.size,
origin = JsStatementOrigins.EXPLICIT_INVOKE,
superQualifierSymbol = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class InvokeStaticInitializersLowering(val context: JsCommonBackendContext) : Bo
context.irBuiltIns.unitType,
instance.symbol,
typeArgumentsCount = 0,
valueArgumentsCount = 0,
origin = JsStatementOrigins.SYNTHESIZED_STATEMENT
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class JsDefaultParameterInjector(context: JsIrBackendContext) :
context.dynamicType,
context.intrinsics.jsPrototypeOfSymbol,
typeArgumentsCount = 0,
valueArgumentsCount = 1
).apply {
putValueArgument(0, owner.jsConstructorReference(context))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ class PrivateMemberBodiesLowering(val context: JsIrBackendContext) : BodyLowerin
expression.type,
staticTarget.symbol,
typeArgumentsCount = expression.typeArgumentsCount,
valueArgumentsCount = expression.valueArgumentsCount + 1,
origin = expression.origin,
superQualifierSymbol = expression.superQualifierSymbol
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
val irCall = IrCallImpl(
startOffset, endOffset, jsClassSymbol.owner.returnType, jsClassSymbol,
typeArgumentsCount = 1,
valueArgumentsCount = 0,
)
irCall.putTypeArgument(0, type)
return irCall
Expand All @@ -212,8 +211,7 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
expression.endOffset,
expression.type,
factoryFunction.symbol,
expression.typeArgumentsCount,
factoryFunction.valueParameters.size
expression.typeArgumentsCount
).apply {
for (ti in 0 until typeArgumentsCount) {
putTypeArgument(ti, expression.getTypeArgument(ti))
Expand All @@ -229,7 +227,7 @@ class PropertyReferenceLowering(private val context: JsIrBackendContext) : BodyL
expression.transformChildrenVoid(this)

val builderCall = expression.run {
IrCallImpl(startOffset, endOffset, type, localDelegateBuilderSymbol, typeArgumentsCount, valueArgumentsCount = 4)
IrCallImpl(startOffset, endOffset, type, localDelegateBuilderSymbol, typeArgumentsCount)
}

val localName = expression.symbol.owner.name.asString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ private class CallsiteRedirectionTransformer(private val context: JsIrBackendCon
return IrCallImpl(
call.startOffset, call.endOffset, call.type, newTarget,
typeArgumentsCount = call.typeArgumentsCount,
valueArgumentsCount = newTarget.owner.valueParameters.size,
superQualifierSymbol = irClass.symbol.takeIf { context.es6mode && call.isSyntheticDelegatingReplacement }
).apply {
copyTypeArgumentsFrom(call)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class ThrowableLowering(val context: JsIrBackendContext, val extendThrowableFunc
return expression.run {
IrCallImpl(
startOffset, endOffset, type, newThrowableFunction,
valueArgumentsCount = 2,
typeArgumentsCount = 0
).also {
it.putValueArgument(0, messageArg)
Expand All @@ -93,7 +92,6 @@ class ThrowableLowering(val context: JsIrBackendContext, val extendThrowableFunc
val expressionReplacement = expression.run {
IrCallImpl(
startOffset, endOffset, type, extendThrowableFunction,
valueArgumentsCount = 3,
typeArgumentsCount = 0
).also {
it.putValueArgument(0, thisReceiver)
Expand Down
Loading

0 comments on commit c420d37

Please sign in to comment.