[JS IR] Support throwing linkage error in JS IR BE
- lower it into runtime API call
This commit is contained in:
committed by
TeamCityServer
parent
7f27ebc589
commit
a0d67cb2e3
@@ -322,6 +322,10 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
|||||||
|
|
||||||
val jsUndefined = getInternalFunction("jsUndefined")
|
val jsUndefined = getInternalFunction("jsUndefined")
|
||||||
|
|
||||||
|
val linkageErrorSymbol = getInternalFunction("throwLinkageError")
|
||||||
|
|
||||||
|
// Helpers:
|
||||||
|
|
||||||
private fun getInternalFunction(name: String) =
|
private fun getInternalFunction(name: String) =
|
||||||
context.symbolTable.referenceSimpleFunction(context.getJsInternalFunction(name))
|
context.symbolTable.referenceSimpleFunction(context.getJsInternalFunction(name))
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -6,14 +6,15 @@
|
|||||||
package org.jetbrains.kotlin.ir.backend.js.lower.calls
|
package org.jetbrains.kotlin.ir.backend.js.lower.calls
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||||
import org.jetbrains.kotlin.ir.util.irCall
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
|
||||||
|
import org.jetbrains.kotlin.ir.util.irCall
|
||||||
import org.jetbrains.kotlin.ir.util.kotlinPackageFqn
|
import org.jetbrains.kotlin.ir.util.kotlinPackageFqn
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class ExceptionHelperCallsTransformer(private val context: JsIrBackendContext) : CallsTransformer {
|
class ExceptionHelperCallsTransformer(private val context: JsIrBackendContext) : CallsTransformer {
|
||||||
|
|
||||||
|
// TODO: move symbol resolve into context
|
||||||
private fun referenceFunction(fqn: FqName) =
|
private fun referenceFunction(fqn: FqName) =
|
||||||
context.getFunctions(fqn).singleOrNull()?.let {
|
context.getFunctions(fqn).singleOrNull()?.let {
|
||||||
context.symbolTable.referenceSimpleFunction(it)
|
context.symbolTable.referenceSimpleFunction(it)
|
||||||
@@ -24,7 +25,8 @@ class ExceptionHelperCallsTransformer(private val context: JsIrBackendContext) :
|
|||||||
context.irBuiltIns.throwCceSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_CCE"))),
|
context.irBuiltIns.throwCceSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_CCE"))),
|
||||||
context.irBuiltIns.throwIseSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))),
|
context.irBuiltIns.throwIseSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_ISE"))),
|
||||||
context.irBuiltIns.illegalArgumentExceptionSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_IAE"))),
|
context.irBuiltIns.illegalArgumentExceptionSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("THROW_IAE"))),
|
||||||
context.irBuiltIns.noWhenBranchMatchedExceptionSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("noWhenBranchMatchedException")))
|
context.irBuiltIns.noWhenBranchMatchedExceptionSymbol to referenceFunction(kotlinPackageFqn.child(Name.identifier("noWhenBranchMatchedException"))),
|
||||||
|
context.irBuiltIns.linkageErrorSymbol to context.intrinsics.linkageErrorSymbol
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun transformFunctionAccess(call: IrFunctionAccessExpression, doNotIntrinsify: Boolean) =
|
override fun transformFunctionAccess(call: IrFunctionAccessExpression, doNotIntrinsify: Boolean) =
|
||||||
|
|||||||
Reference in New Issue
Block a user