[JS IR BE] Enum class lowering

This commit is contained in:
Svyatoslav Kuzmich
2018-07-19 14:57:27 +03:00
parent 668708170f
commit 625983b28a
98 changed files with 397 additions and 108 deletions
+19
View File
@@ -0,0 +1,19 @@
/*
* 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
public class Enum<T : Enum<T>>(val name: String, val ordinal: Int) : Comparable<Enum<T>> {
override fun compareTo(other: Enum<T>) = ordinal.compareTo(other.ordinal)
override fun equals(other: Any?) = this === other
override fun hashCode(): Int = identityHashCode(this)
override fun toString() = name
companion object
}
+3
View File
@@ -102,3 +102,6 @@ fun hashCode(obj: dynamic): Int {
"""
).unsafeCast<Int>()
}
// TODO: Use getObjectHashCode instead
fun identityHashCode(obj: dynamic): Int = hashCode(obj)
@@ -61,6 +61,9 @@ open class NoSuchElementException(message: String?, cause: Throwable?) : Runtime
}
// TODO: fix function names to satisfy style convention (depends on built-in names)
fun THROW_ISE() {
throw IllegalStateException()
}
fun THROW_CCE() {
throw ClassCastException()
}