[JS BE] add runtime-function and intrinsics for es6-classes

This commit is contained in:
Vitaly
2020-05-09 13:53:13 +03:00
committed by romanart
parent 18bd80eb29
commit 9ede8445e7
4 changed files with 60 additions and 0 deletions
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2020 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
/**
* @param CT is return type of calling constructor (uses in DCE)
*/
fun <CT> construct(constructorType: dynamic, resultType: dynamic, vararg args: Any?): Any {
return js("Reflect").construct(constructorType, args, resultType)
}
@@ -99,6 +99,10 @@ internal fun newThrowable(message: String?, cause: Throwable?): Throwable {
internal fun extendThrowable(this_: dynamic, message: String?, cause: Throwable?) {
js("Error").call(this_)
setPropertiesToThrowableInstance(this_, message, cause)
}
internal fun setPropertiesToThrowableInstance(this_: dynamic, message: String?, cause: Throwable?) {
if (!hasOwnPrototypeProperty(this_, "message")) {
this_.message = message ?: cause?.toString() ?: undefined
}