[JS IR] Introduce jsArguments() intrinsic function
`jsArguments()` is lowered into a reference of the `arguments` object. This is useful for extracting varargs, when calling Kotlin code from JavaScript. For a concrete example, see KT-15223.
This commit is contained in:
@@ -215,6 +215,8 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
|
|||||||
|
|
||||||
val unreachable = getInternalFunction("unreachable")
|
val unreachable = getInternalFunction("unreachable")
|
||||||
|
|
||||||
|
val jsArguments = getInternalFunction("jsArguments")
|
||||||
|
|
||||||
val returnIfSuspended = getInternalFunction("returnIfSuspended")
|
val returnIfSuspended = getInternalFunction("returnIfSuspended")
|
||||||
val getContinuation = getInternalFunction("getContinuation")
|
val getContinuation = getInternalFunction("getContinuation")
|
||||||
|
|
||||||
|
|||||||
+2
@@ -236,6 +236,8 @@ class JsIntrinsicTransformers(backendContext: JsIrBackendContext) {
|
|||||||
add(intrinsics.jsInvokeSuspendSuperType, suspendInvokeTransform)
|
add(intrinsics.jsInvokeSuspendSuperType, suspendInvokeTransform)
|
||||||
add(intrinsics.jsInvokeSuspendSuperTypeWithReceiver, suspendInvokeTransform)
|
add(intrinsics.jsInvokeSuspendSuperTypeWithReceiver, suspendInvokeTransform)
|
||||||
add(intrinsics.jsInvokeSuspendSuperTypeWithReceiverAndParam, suspendInvokeTransform)
|
add(intrinsics.jsInvokeSuspendSuperTypeWithReceiverAndParam, suspendInvokeTransform)
|
||||||
|
|
||||||
|
add(intrinsics.jsArguments) { _, _ -> Namer.ARGUMENTS }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ object Namer {
|
|||||||
|
|
||||||
val IMPLICIT_RECEIVER_NAME = "this"
|
val IMPLICIT_RECEIVER_NAME = "this"
|
||||||
|
|
||||||
|
val ARGUMENTS = JsNameRef("arguments")
|
||||||
|
|
||||||
val PROTOTYPE_NAME = "prototype"
|
val PROTOTYPE_NAME = "prototype"
|
||||||
val CONSTRUCTOR_NAME = "constructor"
|
val CONSTRUCTOR_NAME = "constructor"
|
||||||
|
|
||||||
|
|||||||
@@ -195,6 +195,9 @@ internal fun <A> slice(a: A): A
|
|||||||
@JsIntrinsic
|
@JsIntrinsic
|
||||||
internal fun unreachable(): Nothing
|
internal fun unreachable(): Nothing
|
||||||
|
|
||||||
|
@JsIntrinsic
|
||||||
|
internal fun jsArguments(): Any?
|
||||||
|
|
||||||
@JsIntrinsic
|
@JsIntrinsic
|
||||||
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE") // TODO: mark `inline` and skip in inliner
|
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE") // TODO: mark `inline` and skip in inliner
|
||||||
internal fun <reified T : Any> jsClassIntrinsic(): JsClass<T>
|
internal fun <reified T : Any> jsClassIntrinsic(): JsClass<T>
|
||||||
|
|||||||
Reference in New Issue
Block a user