[K/JS] Use only single variant of default arguments function wrapper for exported and not-exported functions
This commit is contained in:
@@ -90,8 +90,8 @@ internal fun captureStack(instance: Throwable, constructorFunction: Any) {
|
||||
internal fun newThrowable(message: String?, cause: Throwable?): Throwable {
|
||||
val throwable = js("new Error()")
|
||||
throwable.message = if (isUndefined(message)) {
|
||||
if (isUndefined(cause)) message else cause?.toString() ?: undefined
|
||||
} else message ?: undefined
|
||||
if (isUndefined(cause)) message else cause?.toString() ?: VOID
|
||||
} else message ?: VOID
|
||||
throwable.cause = cause
|
||||
throwable.name = "Throwable"
|
||||
return throwable.unsafeCast<Throwable>()
|
||||
@@ -109,10 +109,10 @@ internal fun setPropertiesToThrowableInstance(this_: dynamic, message: String?,
|
||||
@Suppress("SENSELESS_COMPARISON")
|
||||
if (message !== null) {
|
||||
// undefined
|
||||
cause?.toString() ?: undefined
|
||||
cause?.toString() ?: VOID
|
||||
} else {
|
||||
// real null
|
||||
undefined
|
||||
VOID
|
||||
}
|
||||
} else message
|
||||
}
|
||||
@@ -135,7 +135,19 @@ internal fun errorCode(description: String): Nothing {
|
||||
}
|
||||
|
||||
@Suppress("SENSELESS_COMPARISON")
|
||||
internal fun isUndefined(value: dynamic): Boolean = value === undefined
|
||||
internal fun isUndefined(value: dynamic): Boolean = value === VOID
|
||||
|
||||
internal fun <T, R> boxIntrinsic(@Suppress("UNUSED_PARAMETER") x: T): R = error("Should be lowered")
|
||||
internal fun <T, R> unboxIntrinsic(@Suppress("UNUSED_PARAMETER") x: T): R = error("Should be lowered")
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
internal fun protoOf(constructor: Any) =
|
||||
js("constructor.prototype")
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
internal fun <T> objectCreate(proto: T?) =
|
||||
js("Object.create(proto)")
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
internal fun defineProp(obj: Any, name: String, getter: Any?, setter: Any?) =
|
||||
js("Object.defineProperty(obj, name, { configurable: true, get: getter, set: setter })")
|
||||
|
||||
@@ -18,6 +18,9 @@ internal fun jsEqeq(a: Any?, b: Any?): Boolean
|
||||
@JsIntrinsic
|
||||
internal fun jsNotEq(a: Any?, b: Any?): Boolean
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsUndefined(): Nothing?
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsEqeqeq(a: Any?, b: Any?): Boolean
|
||||
|
||||
@@ -172,9 +175,6 @@ internal fun float32ArrayOf(a: Any?): Any?
|
||||
@JsIntrinsic
|
||||
internal fun float64ArrayOf(a: Any?): Any?
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun <T> objectCreate(): T
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun <T> sharedBoxCreate(v: T?): dynamic
|
||||
|
||||
@@ -184,15 +184,15 @@ internal fun <T> sharedBoxRead(box: dynamic): T?
|
||||
@JsIntrinsic
|
||||
internal fun <T> sharedBoxWrite(box: dynamic, nv: T?)
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsUndefined(): Nothing?
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun <T> DefaultType(): T
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsBind(receiver: Any?, target: Any?): Any?
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsCall(receiver: Any?, target: Any?, vararg args: Any?): Any?
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun <A> slice(a: A): A
|
||||
|
||||
@@ -220,4 +220,7 @@ internal fun <reified T : Any> jsClassIntrinsic(): JsClass<T>
|
||||
internal fun jsInIntrinsic(lhs: Any?, rhs: Any): Boolean
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsDelete(e: Any?)
|
||||
internal fun jsDelete(e: Any?)
|
||||
|
||||
@JsIntrinsic
|
||||
internal fun jsContextfulRef(context: dynamic, fn: dynamic): dynamic
|
||||
@@ -44,8 +44,7 @@ private fun getKPropMetadata(paramCount: Int, setter: Any?): dynamic {
|
||||
}
|
||||
|
||||
private fun metadataObject(): Metadata {
|
||||
val undef = js("undefined")
|
||||
return classMeta(undef, undef, undef, undef)
|
||||
return classMeta(VOID, VOID, VOID, VOID)
|
||||
}
|
||||
|
||||
private val propertyRefClassMetadataCache: Array<Array<dynamic>> = arrayOf<Array<dynamic>>(
|
||||
|
||||
@@ -44,7 +44,7 @@ internal fun classMeta(name: String?, associatedObjectKey: Number?, associatedOb
|
||||
}
|
||||
|
||||
// Seems like we need to disable this check if variables are used inside js annotation
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
|
||||
private fun createMetadata(
|
||||
kind: String,
|
||||
name: String?,
|
||||
@@ -53,13 +53,14 @@ private fun createMetadata(
|
||||
suspendArity: Array<Int>?,
|
||||
iid: Int?
|
||||
): Metadata {
|
||||
val undef = VOID
|
||||
return js("""({
|
||||
kind: kind,
|
||||
simpleName: name,
|
||||
associatedObjectKey: associatedObjectKey,
|
||||
associatedObjects: associatedObjects,
|
||||
suspendArity: suspendArity,
|
||||
${'$'}kClass$: undefined,
|
||||
${'$'}kClass$: undef,
|
||||
iid: iid
|
||||
})""")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package kotlin.js
|
||||
|
||||
internal val VOID: Nothing? = js("void 0")
|
||||
Reference in New Issue
Block a user