[JS IR BE] Support exceptions in IR BE runtime
This commit is contained in:
committed by
Roman Artemev
parent
b65443dd25
commit
02628e8de3
@@ -45,6 +45,7 @@ abstract class BasicIrBoxTest(
|
|||||||
) {
|
) {
|
||||||
val runtime = listOf(
|
val runtime = listOf(
|
||||||
"libraries/stdlib/js/src/kotlin/core.kt",
|
"libraries/stdlib/js/src/kotlin/core.kt",
|
||||||
|
"libraries/stdlib/js/irRuntime/exceptions.kt",
|
||||||
"libraries/stdlib/js/irRuntime/annotations.kt",
|
"libraries/stdlib/js/irRuntime/annotations.kt",
|
||||||
"libraries/stdlib/js/irRuntime/internalAnnotations.kt",
|
"libraries/stdlib/js/irRuntime/internalAnnotations.kt",
|
||||||
"libraries/stdlib/js/irRuntime/typeCheckUtils.kt"
|
"libraries/stdlib/js/irRuntime/typeCheckUtils.kt"
|
||||||
|
|||||||
+1
-2
@@ -3,6 +3,5 @@ package kotlin
|
|||||||
// see StdLibTestBase.removeAdHocAssertions
|
// see StdLibTestBase.removeAdHocAssertions
|
||||||
|
|
||||||
fun fail(message: String? = null): Nothing {
|
fun fail(message: String? = null): Nothing {
|
||||||
js("throw new Error(message)")
|
throw Exception(message)
|
||||||
null!!
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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
|
||||||
|
|
||||||
|
open class Exception(override val message: String?, override val cause: Throwable?) : Throwable() {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(_message: String?) : this(_message, null)
|
||||||
|
constructor(_cause: Throwable?) : this(null, _cause)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class RuntimeException(message: String?, cause: Throwable?) : Exception(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: String?) : this(message, null)
|
||||||
|
constructor(cause: Throwable?) : this(null, cause)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IllegalArgumentException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: String?) : this(message, null)
|
||||||
|
constructor(cause: Throwable?) : this(null, cause)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IllegalStateException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: String?) : this(message, null)
|
||||||
|
constructor(cause: Throwable?) : this(null, cause)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class ClassCastException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: String?) : this(message, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class NullPointerException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: String?) : this(message, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class IndexOutOfBoundsException(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: String?) : this(message, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
open class AssertionError(message: String?, cause: Throwable?) : Exception(message, cause) {
|
||||||
|
constructor() : this(null, null)
|
||||||
|
constructor(message: Any?) : this(message?.toString(), message as? Throwable)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: fix function names to satisfy style convention (depends on built-in names)
|
||||||
|
fun THROW_CCE() {
|
||||||
|
throw ClassCastException()
|
||||||
|
}
|
||||||
|
fun THROW_NPE() {
|
||||||
|
throw NullPointerException()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user