From 986f5220dfe473feb4cd4f0c03cf26d4863435a8 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Fri, 29 Jun 2018 12:21:53 +0300 Subject: [PATCH] Added possibility of debug output from lowerings --- .../src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt | 8 ++++++++ .../backend/konan/lower/SuspendFunctionsLowering.kt | 7 +++++++ 2 files changed, 15 insertions(+) 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 {