Update IR Runtime

This commit is contained in:
romanart
2018-10-12 15:43:33 +03:00
parent eb2a33ebee
commit 6a66663739
4 changed files with 39 additions and 112 deletions
+24 -1
View File
@@ -85,4 +85,27 @@ fun getNumberHashCode(obj: dynamic) = js("""
}
""").unsafeCast<Int>()
fun identityHashCode(obj: dynamic): Int = getObjectHashCode(obj)
fun identityHashCode(obj: dynamic): Int = getObjectHashCode(obj)
@JsName("captureStack")
internal fun captureStack(instance: Throwable) {
if (js("Error").captureStackTrace) {
js("Error").captureStackTrace(instance, instance::class.js);
} else {
instance.asDynamic().stack = js("new Error()").stack;
}
}
@JsName("newThrowable")
internal fun newThrowable(message: String?, cause: Throwable?): Throwable {
val throwable = js("new Error()")
throwable.message = if (message == null) {
if (cause != null) js("cause.toString()") else null
} else {
message
}
throwable.cause = cause
throwable.name = "Throwable"
return throwable
}