[IR, Native] Support partial linkage in backend

^KT-50775
This commit is contained in:
Dmitriy Dolovov
2022-01-14 16:06:20 +03:00
parent 4726b14c4b
commit 15e6101608
3 changed files with 17 additions and 0 deletions
@@ -232,6 +232,7 @@ internal class KonanSymbols(
override val throwNullPointerException = internalFunction("ThrowNullPointerException")
val throwNoWhenBranchMatchedException = internalFunction("ThrowNoWhenBranchMatchedException")
val throwIrLinkageError = internalFunction("ThrowIrLinkageError")
override val throwTypeCastException = internalFunction("ThrowTypeCastException")
@@ -57,6 +57,15 @@ internal class BuiltinOperatorLowering(val context: Context) : FileLoweringPass,
context.ir.symbols.throwNoWhenBranchMatchedException.owner.typeParameters.size,
context.ir.symbols.throwNoWhenBranchMatchedException.owner.valueParameters.size)
irBuiltins.linkageErrorSymbol -> {
val newExpression = IrCallImpl.fromSymbolOwner(
expression.startOffset, expression.endOffset,
context.ir.symbols.throwIrLinkageError
)
newExpression.putValueArgument(0, expression.getValueArgument(0)) // error message
newExpression
}
else -> expression
}
}
@@ -112,6 +112,13 @@ internal fun ThrowFileFailedToInitializeException() {
throw FileFailedToInitializeException("There was an error during file initialization")
}
internal class IrLinkageError(message: String?) : Error(message)
@PublishedApi
internal fun ThrowIrLinkageError(message: String?): Nothing {
throw IrLinkageError(message)
}
@ExportForCppRuntime
internal fun PrintThrowable(throwable: Throwable) {
println(throwable)