diff --git a/compiler/ir/backend.common/src/KotlinIr.proto b/compiler/ir/backend.common/src/KotlinIr.proto index a8da4ec2964..ef81201c958 100644 --- a/compiler/ir/backend.common/src/KotlinIr.proto +++ b/compiler/ir/backend.common/src/KotlinIr.proto @@ -232,7 +232,6 @@ message IrCall { enum Primitive { NOT_PRIMITIVE = 1; NULLARY = 2; - UNARY = 3; BINARY = 4; } required Primitive kind = 1; diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt index c8d84ff1581..657593eb91c 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LowerUtils.kt @@ -113,7 +113,7 @@ fun IrBuilderWithScope.irIfThen(condition: IrExpression, thenPart: IrExpression) } fun IrBuilderWithScope.irNot(arg: IrExpression) = - primitiveOp1(startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, IrStatementOrigin.EXCL, arg) + primitiveOp1(startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, IrStatementOrigin.EXCL, arg) fun IrBuilderWithScope.irThrow(arg: IrExpression) = IrThrowImpl(startOffset, endOffset, context.irBuiltIns.nothingType, arg) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt index 6ad76fcfbbc..fa8abe4fa93 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleDeserializer.kt @@ -261,8 +261,6 @@ abstract class IrModuleDeserializer( ) KotlinIr.IrCall.Primitive.NULLARY -> IrNullaryPrimitiveImpl(start, end, type, null, symbol) - KotlinIr.IrCall.Primitive.UNARY -> - IrUnaryPrimitiveImpl(start, end, type, null, symbol) KotlinIr.IrCall.Primitive.BINARY -> IrBinaryPrimitiveImpl(start, end, type, null, symbol) else -> TODO("Unexpected primitive IrCall.") diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleSerializer.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleSerializer.kt index fa322eaf502..b8a2f1ef367 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleSerializer.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/IrModuleSerializer.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrBinaryPrimitiveImpl import org.jetbrains.kotlin.ir.expressions.impl.IrNullaryPrimitiveImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrUnaryPrimitiveImpl import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid @@ -350,8 +349,6 @@ open class IrModuleSerializer( private fun irCallToPrimitiveKind(call: IrCall): KotlinIr.IrCall.Primitive = when (call) { is IrNullaryPrimitiveImpl -> KotlinIr.IrCall.Primitive.NULLARY - is IrUnaryPrimitiveImpl - -> KotlinIr.IrCall.Primitive.UNARY is IrBinaryPrimitiveImpl -> KotlinIr.IrCall.Primitive.BINARY else diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIr.java b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIr.java index 7a310b431cf..eff44318d7e 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIr.java +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/serialization/KotlinIr.java @@ -18015,14 +18015,10 @@ public final class KotlinIr { * NULLARY = 2; */ NULLARY(1, 2), - /** - * UNARY = 3; - */ - UNARY(2, 3), /** * BINARY = 4; */ - BINARY(3, 4), + BINARY(2, 4), ; /** @@ -18033,10 +18029,6 @@ public final class KotlinIr { * NULLARY = 2; */ public static final int NULLARY_VALUE = 2; - /** - * UNARY = 3; - */ - public static final int UNARY_VALUE = 3; /** * BINARY = 4; */ @@ -18049,7 +18041,6 @@ public final class KotlinIr { switch (value) { case 1: return NOT_PRIMITIVE; case 2: return NULLARY; - case 3: return UNARY; case 4: return BINARY; default: return null; } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt index 1c91bb89bfe..d5f7c78ed9b 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/BlockDecomposerLowering.kt @@ -266,7 +266,7 @@ class BlockDecomposerTransformer(private val context: JsIrBackendContext) : IrEl val newLoopCondition = newCondition.statements.last() as IrExpression val breakCond = JsIrBuilder.buildCall(booleanNotSymbol).apply { - putValueArgument(0, newLoopCondition) + dispatchReceiver = newLoopCondition } newLoopBody.statements += JsIrBuilder.buildIfElse(unitType, breakCond, thenBlock) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt index 304761e0853..8da84f094d1 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/StateMachineBuilder.kt @@ -233,7 +233,7 @@ class StateMachineBuilder( l.condition.acceptVoid(this) transformLastExpression { - val exitCond = JsIrBuilder.buildCall(booleanNotSymbol).apply { putValueArgument(0, it) } + val exitCond = JsIrBuilder.buildCall(booleanNotSymbol).apply { dispatchReceiver = it } val irBreak = buildDispatchBlock(exit) JsIrBuilder.buildIfElse(unit, exitCond, irBreak) } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/IrUnboundSymbolReplacer.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/IrUnboundSymbolReplacer.kt index ab73c9aee53..7278943b515 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/IrUnboundSymbolReplacer.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/inline/IrUnboundSymbolReplacer.kt @@ -30,7 +30,7 @@ internal fun IrModuleFragment.replaceUnboundSymbols(context: JsIrBackendContext) val collector = DeclarationSymbolCollector() with(collector) { with(irBuiltins) { - for (op in arrayOf(eqeqeqFun, eqeqFun, throwNpeFun, booleanNotFun, noWhenBranchMatchedExceptionFun) + + for (op in arrayOf(eqeqeqFun, eqeqFun, throwNpeFun, noWhenBranchMatchedExceptionFun) + lessFunByOperandType.values + lessOrEqualFunByOperandType.values + greaterOrEqualFunByOperandType.values + diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt index 1be0a92bf72..6cb8c4eae22 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/FoldConstantLowering.kt @@ -35,17 +35,6 @@ internal val foldConstantLoweringPhase = makeIrFilePhase( * TODO: constant fields (e.g. Double.NaN) */ class FoldConstantLowering(private val context: JvmBackendContext) : IrElementTransformerVoid(), FileLoweringPass { - - /** - * ID of an unary operator / method. - * - * An unary operator / method can be identified by its operand type (in full qualified name) and its name. - */ - private data class UnaryOp( - val operandType: String, - val operatorName: String - ) - /** * ID of an binary operator / method. * @@ -70,14 +59,8 @@ class FoldConstantLowering(private val context: JvmBackendContext) : IrElementTr private val BOOLEAN = PrimitiveType("Boolean") private val STRING = PrimitiveType("String") - private val UNARY_OP_TO_EVALUATOR = HashMap>() private val BINARY_OP_TO_EVALUATOR = HashMap>() - @Suppress("UNCHECKED_CAST") - private fun registerBuiltinUnaryOp(operandType: PrimitiveType, operatorName: String, f: (T) -> Any) { - UNARY_OP_TO_EVALUATOR[UnaryOp(operandType.name, operatorName)] = f as Function1 - } - @Suppress("UNCHECKED_CAST") private fun registerBuiltinBinaryOp(operandType: PrimitiveType, operatorName: String, f: (T, T) -> Any) { BINARY_OP_TO_EVALUATOR[BinaryOp(operandType.name, operandType.name, operatorName)] = f as Function2 @@ -85,8 +68,6 @@ class FoldConstantLowering(private val context: JvmBackendContext) : IrElementTr init { // IrBuiltins - registerBuiltinUnaryOp(BOOLEAN, IrBuiltIns.OperatorNames.NOT) { !it } - registerBuiltinBinaryOp(DOUBLE, IrBuiltIns.OperatorNames.LESS) { a, b -> a < b } registerBuiltinBinaryOp(DOUBLE, IrBuiltIns.OperatorNames.LESS_OR_EQUAL) { a, b -> a <= b } registerBuiltinBinaryOp(DOUBLE, IrBuiltIns.OperatorNames.GREATER) { a, b -> a > b } @@ -138,16 +119,6 @@ class FoldConstantLowering(private val context: JvmBackendContext) : IrElementTr return buildIrConstant(call, evaluated) } - private fun tryFoldingBuiltinUnaryOps(call: IrCall): IrExpression { - if (call.symbol.owner.origin != IrDeclarationOrigin.IR_BUILTINS_STUB) - return call - - val operand = call.getValueArgument(0) as? IrConst<*> ?: return call - val evaluator = UNARY_OP_TO_EVALUATOR[UnaryOp(operand.kind.toString(), call.symbol.owner.name.toString())] ?: return call - - return buildIrConstant(call, evaluator(operand.value!!)) - } - private fun tryFoldingBinaryOps(call: IrCall): IrExpression { val lhs = call.dispatchReceiver as? IrConst<*> ?: return call val rhs = call.getValueArgument(0) as? IrConst<*> ?: return call @@ -201,7 +172,6 @@ class FoldConstantLowering(private val context: JvmBackendContext) : IrElementTr expression.extensionReceiver != null -> expression expression.dispatchReceiver != null && expression.valueArgumentsCount == 0 -> tryFoldingUnaryOps(expression) expression.dispatchReceiver != null && expression.valueArgumentsCount == 1 -> tryFoldingBinaryOps(expression) - expression.dispatchReceiver == null && expression.valueArgumentsCount == 1 -> tryFoldingBuiltinUnaryOps(expression) expression.dispatchReceiver == null && expression.valueArgumentsCount == 2 -> tryFoldingBuiltinBinaryOps(expression) else -> expression } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt index 25daefdd660..e3d3b9103d2 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.builders.buildStatement import org.jetbrains.kotlin.ir.builders.irIfThenMaybeElse +import org.jetbrains.kotlin.ir.builders.primitiveOp1 import org.jetbrains.kotlin.ir.builders.whenComma import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.* @@ -218,10 +219,11 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta irSubject.defaultLoad() ) return if (ktCondition.isNegated) - IrUnaryPrimitiveImpl( + primitiveOp1( ktCondition.startOffsetSkippingComments, ktCondition.endOffset, + context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, - IrStatementOrigin.EXCL, context.irBuiltIns.booleanNotSymbol, + IrStatementOrigin.EXCL, irInstanceOf ) else @@ -237,10 +239,11 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta IrStatementOrigin.IN -> irInCall IrStatementOrigin.NOT_IN -> - IrUnaryPrimitiveImpl( + primitiveOp1( ktCondition.startOffsetSkippingComments, ktCondition.endOffset, + context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, - IrStatementOrigin.EXCL, context.irBuiltIns.booleanNotSymbol, + IrStatementOrigin.EXCL, irInCall ) else -> throw AssertionError("Expected 'in' or '!in', got $inOperator") diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt index 89d00dac42e..52588cfe271 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt @@ -241,11 +241,11 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat IrStatementOrigin.IN -> irContainsCall IrStatementOrigin.NOT_IN -> - IrUnaryPrimitiveImpl( + primitiveOp1( expression.startOffsetSkippingComments, expression.endOffset, + context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, IrStatementOrigin.NOT_IN, - context.irBuiltIns.booleanNotSymbol, irContainsCall ) else -> @@ -272,11 +272,11 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat IrStatementOrigin.EQEQEQ -> irIdentityEquals IrStatementOrigin.EXCLEQEQ -> - IrUnaryPrimitiveImpl( + primitiveOp1( expression.startOffsetSkippingComments, expression.endOffset, + context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, IrStatementOrigin.EXCLEQEQ, - context.irBuiltIns.booleanNotSymbol, irIdentityEquals ) else -> @@ -314,11 +314,11 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat IrStatementOrigin.EQEQ -> irEquals IrStatementOrigin.EXCLEQ -> - IrUnaryPrimitiveImpl( + primitiveOp1( expression.startOffsetSkippingComments, expression.endOffset, + context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, IrStatementOrigin.EXCLEQ, - context.irBuiltIns.booleanNotSymbol, irEquals ) else -> diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt index 5b85b0ffa1c..1556876594c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt @@ -195,7 +195,7 @@ fun IrBuilderWithScope.irEquals(arg1: IrExpression, arg2: IrExpression, origin: fun IrBuilderWithScope.irNotEquals(arg1: IrExpression, arg2: IrExpression) = primitiveOp1( - startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, IrStatementOrigin.EXCLEQ, + startOffset, endOffset, context.irBuiltIns.booleanNotSymbol, context.irBuiltIns.booleanType, IrStatementOrigin.EXCLEQ, irEquals(arg1, arg2, origin = IrStatementOrigin.EXCLEQ) ) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt index f734a3d8b90..4c0ee9a6759 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt @@ -22,16 +22,20 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.expressions.IrWhen import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType // TODO rewrite using IR Builders fun primitiveOp1( startOffset: Int, endOffset: Int, primitiveOpSymbol: IrSimpleFunctionSymbol, + primitiveOpReturnType: IrType, origin: IrStatementOrigin, - argument: IrExpression + dispatchReceiver: IrExpression ): IrExpression = - IrUnaryPrimitiveImpl(startOffset, endOffset, primitiveOpSymbol.owner.returnType, origin, primitiveOpSymbol, argument) + IrCallImpl(startOffset, endOffset, primitiveOpReturnType, primitiveOpSymbol, primitiveOpSymbol.descriptor, origin = origin).also { + it.dispatchReceiver = dispatchReceiver + } fun primitiveOp2( startOffset: Int, endOffset: Int, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt index 0b6da1a1d79..4bddfc46be5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl +import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl @@ -195,7 +196,6 @@ class IrBuiltIns( val throwNpeFun = defineOperator(OperatorNames.THROW_NPE, nothing, listOf()) val throwCceFun = defineOperator(OperatorNames.THROW_CCE, nothing, listOf()) val throwIseFun = defineOperator(OperatorNames.THROW_ISE, nothing, listOf()) - val booleanNotFun = defineOperator(OperatorNames.NOT, bool, listOf(bool)) val noWhenBranchMatchedExceptionFun = defineOperator(OperatorNames.NO_WHEN_BRANCH_MATCHED_EXCEPTION, nothing, listOf()) val illegalArgumentExceptionFun = defineOperator(OperatorNames.ILLEGAL_ARGUMENT_EXCEPTION, nothing, listOf(string)) @@ -203,7 +203,7 @@ class IrBuiltIns( val eqeq = eqeqFun.descriptor val throwNpe = throwNpeFun.descriptor val throwCce = throwCceFun.descriptor - val booleanNot = booleanNotFun.descriptor + val booleanNot = builtIns.boolean.unsubstitutedMemberScope.getContributedFunctions(Name.identifier("not"), NoLookupLocation.FROM_BACKEND).single() val noWhenBranchMatchedException = noWhenBranchMatchedExceptionFun.descriptor val illegalArgumentException = illegalArgumentExceptionFun.descriptor @@ -212,7 +212,7 @@ class IrBuiltIns( val throwNpeSymbol = throwNpeFun.symbol val throwCceSymbol = throwCceFun.symbol val throwIseSymbol = throwIseFun.symbol - val booleanNotSymbol = booleanNotFun.symbol + val booleanNotSymbol = symbolTable.referenceSimpleFunction(booleanNot) val noWhenBranchMatchedExceptionSymbol = noWhenBranchMatchedExceptionFun.symbol val illegalArgumentExceptionSymbol = illegalArgumentExceptionFun.symbol @@ -262,7 +262,6 @@ class IrBuiltIns( const val EQEQ = "EQEQ" const val EQEQEQ = "EQEQEQ" const val IEEE754_EQUALS = "ieee754equals" - const val NOT = "NOT" const val THROW_NPE = "THROW_NPE" const val THROW_CCE = "THROW_CCE" const val THROW_ISE = "THROW_ISE" diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt index cb7d7055358..4cd7e160fc2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt @@ -107,54 +107,6 @@ class IrNullaryPrimitiveImpl( IrNullaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) } -class IrUnaryPrimitiveImpl( - startOffset: Int, - endOffset: Int, - type: IrType, - origin: IrStatementOrigin?, - symbol: IrFunctionSymbol -) : IrPrimitiveCallBase(startOffset, endOffset, type, origin, symbol, 1), - IrCallWithShallowCopy { - - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - origin: IrStatementOrigin?, - symbol: IrFunctionSymbol, - argument: IrExpression - ) : this(startOffset, endOffset, type, origin, symbol) { - this.argument = argument - } - - lateinit var argument: IrExpression - - override fun getValueArgument(index: Int): IrExpression? { - return when (index) { - ARGUMENT0 -> argument - else -> null - } - } - - override fun putValueArgument(index: Int, valueArgument: IrExpression?) { - when (index) { - ARGUMENT0 -> argument = valueArgument ?: throw AssertionError("Primitive call $descriptor argument is null") - else -> throw AssertionError("Primitive call $descriptor: no such argument index $index") - } - } - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - argument.accept(visitor, data) - } - - override fun transformChildren(transformer: IrElementTransformer, data: D) { - argument = argument.transform(transformer, data) - } - - override fun shallowCopy(newOrigin: IrStatementOrigin?, newCallee: IrFunctionSymbol, newSuperQualifier: IrClassSymbol?): IrCall = - IrUnaryPrimitiveImpl(startOffset, endOffset, type, newOrigin, newCallee) -} - class IrBinaryPrimitiveImpl( startOffset: Int, endOffset: Int,