Added possibility of debug output from lowerings

This commit is contained in:
Igor Chevdar
2018-06-29 12:21:53 +03:00
parent 11c4a2518d
commit 986f5220df
2 changed files with 15 additions and 0 deletions
@@ -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())
@@ -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 {