diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt index 2c3c618e059..53cf6c8d77f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt @@ -318,6 +318,14 @@ internal class KonanSymbols(context: Context, val symbolTable: SymbolTable): Sym val freeze = symbolTable.referenceSimpleFunction( builtInsPackage("konan", "worker").getContributedFunctions(Name.identifier("freeze"), NoLookupLocation.FROM_BACKEND).single()) + val println = symbolTable.referenceSimpleFunction( + builtInsPackage("kotlin", "io").getContributedFunctions(Name.identifier("println"), NoLookupLocation.FROM_BACKEND) + .single { it.valueParameters.singleOrNull()?.type == builtIns.stringType }) + + val anyNToString = symbolTable.referenceSimpleFunction( + builtInsPackage("kotlin").getContributedFunctions(Name.identifier("toString"), NoLookupLocation.FROM_BACKEND) + .single { it.extensionReceiverParameter?.type == builtIns.nullableAnyType}) + val getContinuation = symbolTable.referenceSimpleFunction( context.getInternalFunctions("getContinuation").single()) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt index c4f924da309..6f5ed7fbbce 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/SuspendFunctionsLowering.kt @@ -1194,6 +1194,13 @@ internal class SuspendFunctionsLowering(val context: Context): FileLoweringPass private fun IrBuilderWithScope.irThrowIfNotNull(exception: IrValueDeclaration) = irIfThen(irNot(irEqeqeq(irGet(exception), irNull())), irThrow(irImplicitCast(irGet(exception), exception.type.makeNotNull()))) + + fun IrBuilderWithScope.irDebugOutput(value: IrExpression) = + irCall(symbols.println).apply { + putValueArgument(0, irCall(symbols.anyNToString).apply { + extensionReceiver = value + }) + } } private open class VariablesScopeTracker: IrElementVisitorVoid {