[Wasm] Major compiler and stdlib update

This commit is contained in:
Svyatoslav Kuzmich
2020-04-27 14:39:20 +03:00
parent 3be38d1796
commit bfd0f21e9d
196 changed files with 12635 additions and 4774 deletions
+54 -5
View File
@@ -1,19 +1,65 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
plugins {
kotlin("multiplatform")
}
val unimplementedNativeBuiltIns =
(file("$rootDir/core/builtins/native/kotlin/").list().toSortedSet() - file("$rootDir/libraries/stdlib/wasm/builtins/kotlin/").list())
.map { "core/builtins/native/kotlin/$it" }
val builtInsSources by task<Sync> {
val sources = listOf(
"core/builtins/src/kotlin/"
) + unimplementedNativeBuiltIns
val excluded = listOf(
// JS-specific optimized version of emptyArray() already defined
"core/builtins/src/kotlin/ArrayIntrinsics.kt"
)
sources.forEach { path ->
from("$rootDir/$path") {
into(path.dropLastWhile { it != '/' })
excluded.filter { it.startsWith(path) }.forEach {
exclude(it.substring(path.length))
}
}
}
into("$buildDir/builtInsSources")
}
val commonMainSources by task<Sync> {
val sources = listOf(
"libraries/stdlib/common/src/",
"libraries/stdlib/src/kotlin/",
"libraries/stdlib/unsigned/"
)
sources.forEach { path ->
from("$rootDir/$path") {
into(path.dropLastWhile { it != '/' })
}
}
into("$buildDir/commonMainSources")
}
kotlin {
js(IR) {
nodejs()
}
sourceSets {
val jsMain by getting {
kotlin.srcDirs("builtins", "internal", "runtime")
kotlin.srcDirs("builtins", "internal", "runtime", "src", "stubs")
kotlin.srcDirs(files(builtInsSources.map { it.destinationDir }))
}
val commonMain by getting {
kotlin.srcDirs(files(commonMainSources.map { it.destinationDir }))
}
}
}
@@ -28,10 +74,13 @@ tasks.withType<KotlinCompile<*>>().configureEach {
"-Xinline-classes",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.ExperimentalUnsignedTypes",
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-Xopt-in=kotlin.ExperimentalStdlibApi",
"-Xexplicit-api=warning"
)
}
tasks.named("compileKotlinJs") {
(this as KotlinCompile<*>).kotlinOptions.freeCompilerArgs += "-Xir-module-name=kotlin"
dependsOn(commonMainSources)
dependsOn(builtInsSources)
}
-6
View File
@@ -1,6 +0,0 @@
This directory is a modified copy of `core/builtins` adapted for current
needs of WASM backend.
This is a temporary solution for a development convenience. Most of files
from `core/builtins` will be reused once compiler implementation and
stdlib become stable.
@@ -3,20 +3,19 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
import kotlin.wasm.internal.*
/**
* The root of the Kotlin class hierarchy. Every Kotlin class has [Any] as a superclass.
*/
public open class Any {
// Pointer to runtime type info
// Initialized by a compiler
@Suppress("MUST_BE_INITIALIZED_OR_BE_ABSTRACT")
internal var typeInfo: Int
/**
* Indicates whether some other object is "equal to" this one. Implementations must fulfil the following
* requirements:
@@ -29,7 +28,8 @@ public open class Any {
*
* Read more about [equality](https://kotlinlang.org/docs/reference/equality.html) in Kotlin.
*/
public open operator fun equals(other: Any?): Boolean
public open operator fun equals(other: Any?): Boolean =
wasm_ref_eq(this, other)
/**
* Returns a hash code value for the object. The general contract of `hashCode` is:
@@ -37,10 +37,12 @@ public open class Any {
* * Whenever it is invoked on the same object more than once, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified.
* * If two objects are equal according to the `equals()` method, then calling the `hashCode` method on each of the two objects must produce the same integer result.
*/
public open fun hashCode(): Int
// TODO: Implement
public open fun hashCode(): Int = 100
/**
* Returns a string representation of the object.
*/
public open fun toString(): String
// TODO: Implement
public open fun toString(): String = "[Object object]"
}
@@ -3,16 +3,10 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
import kotlin.wasm.internal.*
/**
* Represents an array (specifically, a Java array when targeting the JVM platform).
* Array instances can be created using the [arrayOf], [arrayOfNulls] and [emptyArray]
@@ -20,7 +14,9 @@ package kotlin
* See [Kotlin language documentation](https://kotlinlang.org/docs/reference/basic-types.html#arrays)
* for more information on arrays.
*/
public class Array<T> {
public class Array<T> constructor(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
/**
* Creates a new array with the specified [size], where each element is calculated by calling the specified
* [init] function.
@@ -28,7 +24,10 @@ public class Array<T> {
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> T)
@Suppress("TYPE_PARAMETER_AS_REIFIED")
public constructor(size: Int, init: (Int) -> T) : this(size) {
JsArray_fill_T(jsArray, size, init)
}
/**
* Returns the array element at the specified [index]. This method can be called using the
@@ -40,7 +39,9 @@ public class Array<T> {
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): T
@Suppress("UNCHECKED_CAST")
public operator fun get(index: Int): T =
WasmExternRefToAny(JsArray_get_WasmExternRef(jsArray, index)) as T
/**
* Sets the array element at the specified [index] to the specified [value]. This method can
@@ -52,15 +53,25 @@ public class Array<T> {
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: T): Unit
public operator fun set(index: Int, value: T) {
JsArray_set_WasmExternRef(jsArray, index, value.toWasmExternRef())
}
/**
* Returns the number of elements in the array.
*/
public val size: Int
get() = JsArray_getSize(jsArray)
/**
* Creates an iterator for iterating over the elements of the array.
*/
public operator fun iterator(): Iterator<T>
public operator fun iterator(): Iterator<T> = arrayIterator(this)
}
internal fun <T> arrayIterator(array: Array<T>) = object : Iterator<T> {
var index = 0
override fun hasNext() = index != array.size
override fun next() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
@@ -0,0 +1,265 @@
/*
* Copyright 2010-2019 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
import kotlin.wasm.internal.*
public class ByteArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Byte(jsArray, size) { 0 }
}
public constructor(size: Int, init: (Int) -> Byte) : this(size) {
jsArray = JsArray_new(size)
JsArray_fill_Byte(jsArray, size, init)
}
public operator fun get(index: Int): Byte =
JsArray_get_Byte(jsArray, index)
public operator fun set(index: Int, value: Byte) {
JsArray_set_Byte(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): ByteIterator = byteArrayIterator(this)
}
internal fun byteArrayIterator(array: ByteArray) = object : ByteIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextByte() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class CharArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Char(jsArray, size) { 0.toChar() }
}
public constructor(size: Int, init: (Int) -> Char) : this(size) {
jsArray = JsArray_new(size)
JsArray_fill_Char(jsArray, size, init)
}
public operator fun get(index: Int): Char =
JsArray_get_Char(jsArray, index)
public operator fun set(index: Int, value: Char) {
JsArray_set_Char(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): CharIterator = charArrayIterator(this)
}
internal fun charArrayIterator(array: CharArray) = object : CharIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextChar() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class ShortArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Short(jsArray, size) { 0 }
}
public constructor(size: Int, init: (Int) -> Short) : this(size) {
JsArray_fill_Short(jsArray, size, init)
}
public operator fun get(index: Int): Short =
JsArray_get_Short(jsArray, index)
public operator fun set(index: Int, value: Short) {
JsArray_set_Short(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): ShortIterator = shortArrayIterator(this)
}
internal fun shortArrayIterator(array: ShortArray) = object : ShortIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextShort() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class IntArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Int(jsArray, size) { 0 }
}
public constructor(size: Int, init: (Int) -> Int) : this(size) {
JsArray_fill_Int(jsArray, size, init)
}
public operator fun get(index: Int): Int =
JsArray_get_Int(jsArray, index)
public operator fun set(index: Int, value: Int) {
JsArray_set_Int(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): IntIterator = intArrayIterator(this)
}
internal fun intArrayIterator(array: IntArray) = object : IntIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextInt() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class LongArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Long(jsArray, size) { 0L }
}
public constructor(size: Int, init: (Int) -> Long) : this(size) {
JsArray_fill_Long(jsArray, size, init)
}
public operator fun get(index: Int): Long =
JsArray_get_Long(jsArray, index)
public operator fun set(index: Int, value: Long) {
JsArray_set_Long(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): LongIterator = longArrayIterator(this)
}
internal fun longArrayIterator(array: LongArray) = object : LongIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextLong() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class FloatArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Float(jsArray, size) { 0.0f }
}
public constructor(size: Int, init: (Int) -> Float) : this(size) {
JsArray_fill_Float(jsArray, size, init)
}
public operator fun get(index: Int): Float =
JsArray_get_Float(jsArray, index)
public operator fun set(index: Int, value: Float) {
JsArray_set_Float(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): FloatIterator = floatArrayIterator(this)
}
internal fun floatArrayIterator(array: FloatArray) = object : FloatIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextFloat() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class DoubleArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Double(jsArray, size) { 0.0 }
}
public constructor(size: Int, init: (Int) -> Double) : this(size) {
JsArray_fill_Double(jsArray, size, init)
}
public operator fun get(index: Int): Double =
JsArray_get_Double(jsArray, index)
public operator fun set(index: Int, value: Double) {
JsArray_set_Double(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): DoubleIterator = doubleArrayIterator(this)
}
internal fun doubleArrayIterator(array: DoubleArray) = object : DoubleIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextDouble() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
public class BooleanArray(size: Int) {
private var jsArray: WasmExternRef = JsArray_new(size)
init {
JsArray_fill_Boolean(jsArray, size) { false }
}
public constructor(size: Int, init: (Int) -> Boolean) : this(size) {
JsArray_fill_Boolean(jsArray, size, init)
}
public operator fun get(index: Int): Boolean =
JsArray_get_Boolean(jsArray, index)
public operator fun set(index: Int, value: Boolean) {
JsArray_set_Boolean(jsArray, index, value)
}
public val size: Int
get() = JsArray_getSize(jsArray)
public operator fun iterator(): BooleanIterator = booleanArrayIterator(this)
}
internal fun booleanArrayIterator(array: BooleanArray) = object : BooleanIterator() {
var index = 0
override fun hasNext() = index != array.size
override fun nextBoolean() = if (index != array.size) array[index++] else throw NoSuchElementException("$index")
}
@@ -3,56 +3,67 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
import kotlin.wasm.internal.WasmInstruction
import kotlin.wasm.internal.wasm_i32_compareTo
import kotlin.wasm.internal.*
/**
* Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are
* represented as values of the primitive type `boolean`.
*/
public class Boolean private constructor() : Comparable<Boolean> {
@WasmPrimitive
public class Boolean private constructor(private val value: Boolean) : Comparable<Boolean> {
/**
* Returns the inverse of this boolean.
*/
@WasmInstruction(WasmInstruction.I32_EQZ)
public operator fun not(): Boolean
@WasmOp(WasmOp.I32_EQZ)
public operator fun not(): Boolean =
implementedAsIntrinsic
/**
* Performs a logical `and` operation between this Boolean and the [other] one. Unlike the `&&` operator,
* this function does not perform short-circuit evaluation. Both `this` and [other] will always be evaluated.
*/
@WasmInstruction(WasmInstruction.I32_AND)
public infix fun and(other: Boolean): Boolean
@WasmOp(WasmOp.I32_AND)
public infix fun and(other: Boolean): Boolean =
implementedAsIntrinsic
/**
* Performs a logical `or` operation between this Boolean and the [other] one. Unlike the `||` operator,
* this function does not perform short-circuit evaluation. Both `this` and [other] will always be evaluated.
*/
@WasmInstruction(WasmInstruction.I32_OR)
public infix fun or(other: Boolean): Boolean
@WasmOp(WasmOp.I32_OR)
public infix fun or(other: Boolean): Boolean =
implementedAsIntrinsic
/**
* Performs a logical `xor` operation between this Boolean and the [other] one.
*/
@WasmInstruction(WasmInstruction.I32_XOR)
public infix fun xor(other: Boolean): Boolean
@WasmOp(WasmOp.I32_XOR)
public infix fun xor(other: Boolean): Boolean =
implementedAsIntrinsic
public override fun compareTo(other: Boolean): Int =
wasm_i32_compareTo(this.asInt(), other.asInt())
wasm_i32_compareTo(this.toInt(), other.toInt())
@WasmInstruction(WasmInstruction.NOP)
internal fun asInt(): Int
override fun toString(): String =
if (this) "true" else "false"
override fun hashCode(): Int =
toInt()
override fun equals(other: Any?): Boolean {
return if (other !is Boolean) {
false
} else {
this === (other as Boolean)
}
}
@WasmReinterpret
internal fun toInt(): Int =
implementedAsIntrinsic
@SinceKotlin("1.3")
companion object {}
public companion object
}
@@ -3,30 +3,34 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
package kotlin
import kotlin.wasm.internal.ExcludedFromCodegen
import kotlin.wasm.internal.WasmInstruction
import kotlin.wasm.internal.implementedAsIntrinsic
import kotlin.wasm.internal.wasm_i32_compareTo
import kotlin.wasm.internal.*
/**
* Represents a 16-bit Unicode character.
*
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/
public class Char private constructor() : Comparable<Char> {
@WasmPrimitive
@Suppress("NOTHING_TO_INLINE")
public class Char private constructor(public val value: Char) : Comparable<Char> {
/**
* Compares this value with the specified value for order.
*
* Returns zero if this value is equal to the specified other value, a negative number if it's less than other,
* or a positive number if it's greater than other.
*/
public override inline fun compareTo(other: Char): Int =
public override fun compareTo(other: Char): Int =
wasm_i32_compareTo(this.toInt(), other.toInt())
public override fun equals(other: Any?): Boolean {
if (other is Char)
return this === (other as Char)
return false
}
/** Adds the other Int value to this value resulting a Char. */
public inline operator fun plus(other: Int): Char =
(this.toInt() + other).toChar()
@@ -47,34 +51,46 @@ public class Char private constructor() : Comparable<Char> {
public inline operator fun dec(): Char =
(this.toInt() - 1).toChar()
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Char): CharRange
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Char): CharRange =
CharRange(this, other)
/** Returns the value of this character as a `Byte`. */
public inline fun toByte(): Byte =
this.toInt().toByte()
/** Returns the value of this character as a `Char`. */
public inline fun toChar(): Char =
this
/** Returns the value of this character as a `Short`. */
public inline fun toShort(): Short =
this.toInt().toShort()
/** Returns the value of this character as a `Int`. */
@WasmInstruction(WasmInstruction.NOP)
@WasmReinterpret
public fun toInt(): Int =
implementedAsIntrinsic
/** Returns the value of this character as a `Long`. */
public inline fun toLong(): Long =
this.toInt().toLong()
/** Returns the value of this character as a `Float`. */
public inline fun toFloat(): Float =
this.toInt().toFloat()
/** Returns the value of this character as a `Double`. */
public inline fun toDouble(): Double =
this.toInt().toDouble()
@ExcludedFromCodegen
companion object {
override fun toString(): String =
charToString(this)
override fun hashCode(): Int =
this.toInt().hashCode()
public companion object {
/**
* The minimum value of a character code unit.
*/
@@ -129,6 +145,8 @@ public class Char private constructor() : Comparable<Char> {
@SinceKotlin("1.3")
public const val SIZE_BITS: Int = 16
}
}
@WasmImport("runtime", "Char_toString")
private fun charToString(c: Char): String = implementedAsIntrinsic
@@ -0,0 +1,20 @@
/*
* 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
public abstract class Enum<E : Enum<E>>(
public val name: String,
public val ordinal: Int
) : Comparable<E> {
override fun compareTo(other: E): Int =
ordinal.compareTo(other.ordinal)
override fun toString(): String =
name
public companion object
}
@@ -2,86 +2,90 @@
* Copyright 2010-2019 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.
*/
@file:Suppress(
"NON_MEMBER_FUNCTION_NO_BODY",
"REIFIED_TYPE_PARAMETER_NO_INLINE"
)
@file:kotlin.wasm.internal.ExcludedFromCodegen
@file:Suppress("NOTHING_TO_INLINE")
package kotlin
import kotlin.internal.PureReifiable
public inline fun <T> emptyArray(): Array<T> = arrayOf()
/**
* Returns a string representation of the object. Can be called with a null receiver, in which case
* it returns the string "null".
*/
public fun Any?.toString(): String
public fun Any?.toString(): String = this?.toString() ?: "null"
/**
* Concatenates this string with the string representation of the given [other] object. If either the receiver
* or the [other] object are null, they are represented as the string "null".
*/
public operator fun String?.plus(other: Any?): String
public operator fun String?.plus(other: Any?): String = (this ?: "null") + other.toString()
/**
* Returns an array of objects of the given type with the given [size], initialized with null values.
*/
public fun <reified @PureReifiable T> arrayOfNulls(size: Int): Array<T?>
// TODO: Should T be reified?
@Suppress("REIFIED_TYPE_PARAMETER_NO_INLINE")
public fun <@PureReifiable reified T> arrayOfNulls(size: Int): Array<T?> = Array(size) { null }
/**
* Returns an array containing the specified elements.
*/
public inline fun <reified @PureReifiable T> arrayOf(vararg elements: T): Array<T>
@Suppress("UNCHECKED_CAST")
public inline fun <T> arrayOf(vararg elements: T): Array<T> = elements as Array<T>
/**
* Returns an array containing the specified [Double] numbers.
*/
public fun doubleArrayOf(vararg elements: Double): DoubleArray
public inline fun doubleArrayOf(vararg elements: Double): DoubleArray = elements
/**
* Returns an array containing the specified [Float] numbers.
*/
public fun floatArrayOf(vararg elements: Float): FloatArray
public inline fun floatArrayOf(vararg elements: Float): FloatArray = elements
/**
* Returns an array containing the specified [Long] numbers.
*/
public fun longArrayOf(vararg elements: Long): LongArray
public inline fun longArrayOf(vararg elements: Long): LongArray = elements
/**
* Returns an array containing the specified [Int] numbers.
*/
public fun intArrayOf(vararg elements: Int): IntArray
public inline fun intArrayOf(vararg elements: Int): IntArray = elements
/**
* Returns an array containing the specified characters.
*/
public fun charArrayOf(vararg elements: Char): CharArray
public inline fun charArrayOf(vararg elements: Char): CharArray = elements
/**
* Returns an array containing the specified [Short] numbers.
*/
public fun shortArrayOf(vararg elements: Short): ShortArray
public inline fun shortArrayOf(vararg elements: Short): ShortArray = elements
/**
* Returns an array containing the specified [Byte] numbers.
*/
public fun byteArrayOf(vararg elements: Byte): ByteArray
public inline fun byteArrayOf(vararg elements: Byte): ByteArray = elements
/**
* Returns an array containing the specified boolean values.
*/
public fun booleanArrayOf(vararg elements: Boolean): BooleanArray
public inline fun booleanArrayOf(vararg elements: Boolean): BooleanArray = elements
/**
* Returns an array containing enum T entries.
*/
@SinceKotlin("1.1")
@Suppress("NON_MEMBER_FUNCTION_NO_BODY")
public inline fun <reified T : Enum<T>> enumValues(): Array<T>
/**
* Returns an enum entry with specified name.
*/
@SinceKotlin("1.1")
@Suppress("NON_MEMBER_FUNCTION_NO_BODY")
public inline fun <reified T : Enum<T>> enumValueOf(name: String): T
@@ -16,8 +16,11 @@
package kotlin
import kotlin.wasm.internal.ExcludedFromCodegen
/**
* Nothing has no instances. You can use Nothing to represent "a value that never exists": for example,
* if a function has the return type of Nothing, it means that it never returns (always throws an exception).
*/
@ExcludedFromCodegen
public class Nothing private constructor()
@@ -2,7 +2,11 @@
* Copyright 2010-2019 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.
*/
@file:Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
@file:Suppress(
"OVERRIDE_BY_INLINE",
"NOTHING_TO_INLINE",
"unused"
)
package kotlin
@@ -11,9 +15,9 @@ import kotlin.wasm.internal.*
/**
* Represents a 8-bit signed integer.
*/
public class Byte private constructor() : Number(), Comparable<Byte> {
@ExcludedFromCodegen
companion object {
@WasmPrimitive
public class Byte private constructor(public val value: Byte) : Number(), Comparable<Byte> {
public companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
*/
@@ -233,8 +237,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
* The least significant 8 bits of the resulting `Char` code are the same as the bits of this `Byte` value,
* whereas the most significant 8 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.NOP)
public override fun toChar(): Char = implementedAsIntrinsic
public override fun toChar(): Char = reinterpretAsInt().reinterpretAsChar()
/**
* Converts this [Byte] value to [Short].
@@ -244,8 +247,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
* The least significant 8 bits of the resulting `Short` value are the same as the bits of this `Byte` value,
* whereas the most significant 8 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.NOP)
public override fun toShort(): Short = implementedAsIntrinsic
public override fun toShort(): Short = reinterpretAsInt().reinterpretAsShort()
/**
* Converts this [Byte] value to [Int].
@@ -255,8 +257,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
* The least significant 8 bits of the resulting `Int` value are the same as the bits of this `Byte` value,
* whereas the most significant 24 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.NOP)
public override fun toInt(): Int = implementedAsIntrinsic
public override fun toInt(): Int = reinterpretAsInt()
/**
* Converts this [Byte] value to [Long].
@@ -266,62 +267,93 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
* The least significant 8 bits of the resulting `Long` value are the same as the bits of this `Byte` value,
* whereas the most significant 56 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.I64_EXTEND_I32_S)
public override fun toLong(): Long = implementedAsIntrinsic
public override fun toLong(): Long = wasm_i64_extend_i32_s(this.toInt())
/**
* Converts this [Byte] value to [Float].
*
* The resulting `Float` value represents the same numerical value as this `Byte`.
*/
@WasmInstruction(WasmInstruction.F32_CONVERT_I32_S)
public override fun toFloat(): Float = implementedAsIntrinsic
public override fun toFloat(): Float = wasm_f32_convert_i32_s(this.toInt())
/**
* Converts this [Byte] value to [Double].
*
* The resulting `Double` value represents the same numerical value as this `Byte`.
*/
@WasmInstruction(WasmInstruction.F64_CONVERT_I32_S)
public override fun toDouble(): Double = implementedAsIntrinsic
public override fun toDouble(): Double = wasm_f64_convert_i32_s(this.toInt())
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Byte): IntRange {
// return IntRange(this.toInt(), other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Short): IntRange {
// return IntRange(this.toInt(), other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Int): IntRange {
// return IntRange(this.toInt(), other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Long): LongRange {
// return LongRange(this.toLong(), other.toLong())
// }
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this.toInt(), other.toInt())
}
// TODO: Support Any? and type operators
// public override fun equals(other: Any?): Boolean =
// other is Byte && wasm_i32_eq(this.toInt(), other.toInt()).reinterpretAsBoolean()
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other.toLong())
}
/** Performs a bitwise AND operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_AND)
public infix fun and(other: Byte): Byte =
implementedAsIntrinsic
/** Performs a bitwise OR operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_OR)
public infix fun or(other: Byte): Byte =
implementedAsIntrinsic
/** Performs a bitwise XOR operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_XOR)
public infix fun xor(other: Byte): Byte =
implementedAsIntrinsic
/** Inverts the bits in this value/ */
@SinceKotlin("1.1")
public inline fun inv(): Byte = this.xor(-1)
public override fun equals(other: Any?): Boolean =
other is Byte && wasm_i32_eq(this.toInt(), other.toInt())
public inline fun equals(other: Byte): Boolean =
wasm_i32_eq(this.toInt(), other.toInt()).reinterpretAsBoolean()
wasm_i32_eq(this.toInt(), other.toInt())
// TODO: Implement Byte.toString()
// public override fun toString(): String
public override fun toString(): String =
byteToStringImpl(this)
public override inline fun hashCode(): Int =
this.toInt()
@WasmReinterpret
@PublishedApi
internal fun reinterpretAsInt(): Int =
implementedAsIntrinsic
}
@WasmImport("runtime", "coerceToString")
private fun byteToStringImpl(byte: Byte): String =
implementedAsIntrinsic
/**
* Represents a 16-bit signed integer.
*/
public class Short private constructor() : Number(), Comparable<Short> {
@ExcludedFromCodegen
companion object {
@WasmPrimitive
public class Short private constructor(public val value: Short) : Number(), Comparable<Short> {
public companion object {
/**
* A constant holding the minimum value an instance of Short can have.
*/
@@ -529,22 +561,48 @@ public class Short private constructor() : Number(), Comparable<Short> {
public inline operator fun unaryMinus(): Int =
-this.toInt()
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Byte): IntRange {
// return IntRange(this.toInt(), other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Short): IntRange {
// return IntRange(this.toInt(), other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Int): IntRange {
// return IntRange(this.toInt(), other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Long): LongRange {
// return LongRange(this.toLong(), other.toLong())
// }
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this.toInt(), other)
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other)
}
/** Performs a bitwise AND operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_AND)
public infix fun and(other: Short): Short =
implementedAsIntrinsic
/** Performs a bitwise OR operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_OR)
public infix fun or(other: Short): Short =
implementedAsIntrinsic
/** Performs a bitwise XOR operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_XOR)
public infix fun xor(other: Short): Short =
implementedAsIntrinsic
/** Inverts the bits in this value */
@SinceKotlin("1.1")
public fun inv(): Short =
this.xor(-1)
/**
* Converts this [Short] value to [Byte].
@@ -563,9 +621,7 @@ public class Short private constructor() : Number(), Comparable<Short> {
* The resulting `Char` code is equal to this value reinterpreted as an unsigned number,
* i.e. it has the same binary representation as this `Short`.
*/
@WasmInstruction(WasmInstruction.NOP)
public override fun toChar(): Char =
implementedAsIntrinsic
public override fun toChar(): Char = reinterpretAsInt().reinterpretAsChar()
/** Returns this value. */
public override inline fun toShort(): Short =
@@ -579,9 +635,7 @@ public class Short private constructor() : Number(), Comparable<Short> {
* The least significant 16 bits of the resulting `Int` value are the same as the bits of this `Short` value,
* whereas the most significant 16 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.NOP)
public override fun toInt(): Int =
implementedAsIntrinsic
public override fun toInt(): Int = reinterpretAsInt()
/**
* Converts this [Short] value to [Long].
@@ -591,49 +645,50 @@ public class Short private constructor() : Number(), Comparable<Short> {
* The least significant 16 bits of the resulting `Long` value are the same as the bits of this `Short` value,
* whereas the most significant 48 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.I64_EXTEND_I32_S)
public override fun toLong(): Long =
implementedAsIntrinsic
public override fun toLong(): Long = wasm_i64_extend_i32_s(this.toInt())
/**
* Converts this [Short] value to [Float].
*
* The resulting `Float` value represents the same numerical value as this `Short`.
*/
@WasmInstruction(WasmInstruction.F32_CONVERT_I32_S)
public override fun toFloat(): Float =
implementedAsIntrinsic
public override fun toFloat(): Float = wasm_f32_convert_i32_s(this.toInt())
/**
* Converts this [Short] value to [Double].
*
* The resulting `Double` value represents the same numerical value as this `Short`.
*/
@WasmInstruction(WasmInstruction.F64_CONVERT_I32_S)
public override fun toDouble(): Double =
implementedAsIntrinsic
wasm_f64_convert_i32_s(this.toInt())
public inline fun equals(other: Short): Boolean =
wasm_i32_eq(this.toInt(), other.toInt()).reinterpretAsBoolean()
wasm_i32_eq(this.toInt(), other.toInt())
// TODO: Support Any? and type operators
// public override fun equals(other: Any?): Boolean =
// other is Short && wasm_i32_eq(this.toInt(), other.toInt()).reinterpretAsBoolean()
public override fun equals(other: Any?): Boolean =
other is Short && wasm_i32_eq(this.toInt(), other.toInt())
// TODO: Implement Short.toString()
// public override fun toString(): String
public override fun toString(): String = shortToStringImpl(this)
public override inline fun hashCode(): Int =
this.toInt()
@WasmReinterpret
@PublishedApi
internal fun reinterpretAsInt(): Int =
implementedAsIntrinsic
}
@WasmImport("runtime", "coerceToString")
private fun shortToStringImpl(x: Short): String = implementedAsIntrinsic
/**
* Represents a 32-bit signed integer.
*/
public class Int private constructor() : Number(), Comparable<Int> {
@WasmPrimitive
public class Int private constructor(val value: Int) : Number(), Comparable<Int> {
@ExcludedFromCodegen
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Int can have.
*/
@@ -714,7 +769,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
this + other.toInt()
/** Adds the other value to this value. */
@WasmInstruction(WasmInstruction.I32_ADD)
@WasmOp(WasmOp.I32_ADD)
public operator fun plus(other: Int): Int =
implementedAsIntrinsic
@@ -739,7 +794,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
this - other.toInt()
/** Subtracts the other value from this value. */
@WasmInstruction(WasmInstruction.I32_SUB)
@WasmOp(WasmOp.I32_SUB)
public operator fun minus(other: Int): Int =
implementedAsIntrinsic
@@ -764,7 +819,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
this * other.toInt()
/** Multiplies this value by the other value. */
@WasmInstruction(WasmInstruction.I32_MUL)
@WasmOp(WasmOp.I32_MUL)
public operator fun times(other: Int): Int =
implementedAsIntrinsic
@@ -789,7 +844,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
this / other.toInt()
/** Divides this value by the other value. */
@WasmInstruction(WasmInstruction.I32_DIV_S)
@WasmOp(WasmOp.I32_DIV_S)
public operator fun div(other: Int): Int =
implementedAsIntrinsic
@@ -814,7 +869,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
this % other.toInt()
/** Calculates the remainder of dividing this value by the other value. */
@WasmInstruction(WasmInstruction.I32_REM_S)
@WasmOp(WasmOp.I32_REM_S)
public operator fun rem(other: Int): Int =
implementedAsIntrinsic
@@ -835,7 +890,8 @@ public class Int private constructor() : Number(), Comparable<Int> {
this + 1
/** Decrements this value. */
public inline operator fun dec(): Int =
// TODO: Fix test compiler/testData/codegen/box/functions/invoke/invoke.kt with inline dec
public operator fun dec(): Int =
this - 1
/** Returns this value. */
@@ -850,7 +906,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
* Note that only the five lowest-order bits of the [bitCount] are used as the shift distance.
* The shift distance actually used is therefore always in the range `0..31`.
*/
@WasmInstruction(WasmInstruction.I32_SHL)
@WasmOp(WasmOp.I32_SHL)
public infix fun shl(bitCount: Int): Int =
implementedAsIntrinsic
@@ -860,7 +916,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
* Note that only the five lowest-order bits of the [bitCount] are used as the shift distance.
* The shift distance actually used is therefore always in the range `0..31`.
*/
@WasmInstruction(WasmInstruction.I32_SHR_S)
@WasmOp(WasmOp.I32_SHR_S)
public infix fun shr(bitCount: Int): Int =
implementedAsIntrinsic
@@ -870,22 +926,22 @@ public class Int private constructor() : Number(), Comparable<Int> {
* Note that only the five lowest-order bits of the [bitCount] are used as the shift distance.
* The shift distance actually used is therefore always in the range `0..31`.
*/
@WasmInstruction(WasmInstruction.I32_SHR_U)
@WasmOp(WasmOp.I32_SHR_U)
public infix fun ushr(bitCount: Int): Int =
implementedAsIntrinsic
/** Performs a bitwise AND operation between the two values. */
@WasmInstruction(WasmInstruction.I32_AND)
@WasmOp(WasmOp.I32_AND)
public infix fun and(other: Int): Int =
implementedAsIntrinsic
/** Performs a bitwise OR operation between the two values. */
@WasmInstruction(WasmInstruction.I32_OR)
@WasmOp(WasmOp.I32_OR)
public infix fun or(other: Int): Int =
implementedAsIntrinsic
/** Performs a bitwise XOR operation between the two values. */
@WasmInstruction(WasmInstruction.I32_XOR)
@WasmOp(WasmOp.I32_XOR)
public infix fun xor(other: Int): Int =
implementedAsIntrinsic
@@ -893,22 +949,25 @@ public class Int private constructor() : Number(), Comparable<Int> {
public inline fun inv(): Int =
this.xor(-1)
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Byte): IntRange {
// return IntRange(this, other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Short): IntRange {
// return IntRange(this, other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Int): IntRange {
// return IntRange(this, other.toInt())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Long): LongRange {
// return LongRange(this.toLong(), other.toLong())
// }
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other.toLong())
}
/**
* Converts this [Int] value to [Byte].
@@ -955,9 +1014,8 @@ public class Int private constructor() : Number(), Comparable<Int> {
* The least significant 32 bits of the resulting `Long` value are the same as the bits of this `Int` value,
* whereas the most significant 32 bits are filled with the sign bit of this value.
*/
@WasmInstruction(WasmInstruction.I64_EXTEND_I32_S)
public override fun toLong(): Long =
implementedAsIntrinsic
wasm_i64_extend_i32_s(this)
/**
* Converts this [Int] value to [Float].
@@ -966,60 +1024,61 @@ public class Int private constructor() : Number(), Comparable<Int> {
* In case when this `Int` value is exactly between two `Float`s,
* the one with zero at least significant bit of mantissa is selected.
*/
@WasmInstruction(WasmInstruction.F32_CONVERT_I32_S)
public override fun toFloat(): Float =
implementedAsIntrinsic
wasm_f32_convert_i32_s(this)
/**
* Converts this [Int] value to [Double].
*
* The resulting `Double` value represents the same numerical value as this `Int`.
*/
@WasmInstruction(WasmInstruction.F64_CONVERT_I32_S)
public override fun toDouble(): Double =
implementedAsIntrinsic
wasm_f64_convert_i32_s(this)
public inline fun equals(other: Int): Boolean =
wasm_i32_eq(this, other).reinterpretAsBoolean()
wasm_i32_eq(this, other)
// TODO: Support Any? and type operators
// public override fun equals(other: Any?): Boolean =
// other is Int && wasm_i32_eq(this, other).reinterpretAsBoolean()
public override fun equals(other: Any?): Boolean =
other is Int && wasm_i32_eq(this, other)
// TODO: Implement Int.toString()
// public override fun toString(): String
public override fun toString(): String =
intToStringImpl(this)
public override inline fun hashCode(): Int =
this
@WasmInstruction(WasmInstruction.NOP)
@WasmReinterpret
@PublishedApi
internal fun reinterpretAsBoolean(): Boolean =
implementedAsIntrinsic
@PublishedApi
@WasmInstruction(WasmInstruction.NOP)
@WasmReinterpret
internal fun reinterpretAsByte(): Byte =
implementedAsIntrinsic
@PublishedApi
@WasmInstruction(WasmInstruction.NOP)
@WasmReinterpret
internal fun reinterpretAsShort(): Short =
implementedAsIntrinsic
@PublishedApi
@WasmInstruction(WasmInstruction.NOP)
@WasmReinterpret
internal fun reinterpretAsChar(): Char =
implementedAsIntrinsic
}
@WasmImport("runtime", "coerceToString")
private fun intToStringImpl(x: Int): String =
implementedAsIntrinsic
/**
* Represents a 64-bit signed integer.
*/
public class Long private constructor() : Number(), Comparable<Long> {
@WasmPrimitive
public class Long private constructor(val value: Long) : Number(), Comparable<Long> {
@ExcludedFromCodegen
companion object {
public companion object {
/**
* A constant holding the minimum value an instance of Long can have.
*/
@@ -1104,7 +1163,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
this + other.toLong()
/** Adds the other value to this value. */
@WasmInstruction(WasmInstruction.I64_ADD)
@WasmOp(WasmOp.I64_ADD)
public operator fun plus(other: Long): Long =
implementedAsIntrinsic
@@ -1129,7 +1188,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
this - other.toLong()
/** Subtracts the other value from this value. */
@WasmInstruction(WasmInstruction.I64_SUB)
@WasmOp(WasmOp.I64_SUB)
public operator fun minus(other: Long): Long =
implementedAsIntrinsic
@@ -1154,7 +1213,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
this * other.toLong()
/** Multiplies this value by the other value. */
@WasmInstruction(WasmInstruction.I64_MUL)
@WasmOp(WasmOp.I64_MUL)
public operator fun times(other: Long): Long =
implementedAsIntrinsic
@@ -1179,7 +1238,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
this / other.toLong()
/** Divides this value by the other value. */
@WasmInstruction(WasmInstruction.I64_DIV_S)
@WasmOp(WasmOp.I64_DIV_S)
public operator fun div(other: Long): Long =
implementedAsIntrinsic
@@ -1204,7 +1263,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
this % other.toLong()
/** Calculates the remainder of dividing this value by the other value. */
@WasmInstruction(WasmInstruction.I64_REM_S)
@WasmOp(WasmOp.I64_REM_S)
public operator fun rem(other: Long): Long =
implementedAsIntrinsic
@@ -1231,22 +1290,25 @@ public class Long private constructor() : Number(), Comparable<Long> {
/** Returns the negative of this value. */
public inline operator fun unaryMinus(): Long = 0L - this
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Byte): LongRange {
// return LongRange(this, other.toLong())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Short): LongRange {
// return LongRange(this, other.toLong())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Int): LongRange {
// return LongRange(this, other.toLong())
// }
// /** Creates a range from this value to the specified [other] value. */
// public operator fun rangeTo(other: Long): LongRange {
// return LongRange(this, other.toLong())
// }
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): LongRange {
return LongRange(this, other.toLong())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): LongRange {
return LongRange(this, other.toLong())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): LongRange {
return LongRange(this, other.toLong())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this, other.toLong())
}
/**
* Shifts this value left by the [bitCount] number of bits.
@@ -1276,17 +1338,17 @@ public class Long private constructor() : Number(), Comparable<Long> {
wasm_i64_shr_u(this, bitCount.toLong())
/** Performs a bitwise AND operation between the two values. */
@WasmInstruction(WasmInstruction.I64_AND)
@WasmOp(WasmOp.I64_AND)
public infix fun and(other: Long): Long =
implementedAsIntrinsic
/** Performs a bitwise OR operation between the two values. */
@WasmInstruction(WasmInstruction.I64_OR)
@WasmOp(WasmOp.I64_OR)
public infix fun or(other: Long): Long =
implementedAsIntrinsic
/** Performs a bitwise XOR operation between the two values. */
@WasmInstruction(WasmInstruction.I64_XOR)
@WasmOp(WasmOp.I64_XOR)
public infix fun xor(other: Long): Long =
implementedAsIntrinsic
@@ -1335,9 +1397,8 @@ public class Long private constructor() : Number(), Comparable<Long> {
*
* The resulting `Int` value is represented by the least significant 32 bits of this `Long` value.
*/
@WasmInstruction(WasmInstruction.I32_WRAP_I64)
public override fun toInt(): Int =
implementedAsIntrinsic
wasm_i32_wrap_i64(this)
/** Returns this value. */
public override inline fun toLong(): Long =
@@ -1350,9 +1411,8 @@ public class Long private constructor() : Number(), Comparable<Long> {
* In case when this `Long` value is exactly between two `Float`s,
* the one with zero at least significant bit of mantissa is selected.
*/
@WasmInstruction(WasmInstruction.F32_CONVERT_I64_S)
public override fun toFloat(): Float =
implementedAsIntrinsic
wasm_f32_convert_i64_s(this)
/**
* Converts this [Long] value to [Double].
@@ -1361,19 +1421,18 @@ public class Long private constructor() : Number(), Comparable<Long> {
* In case when this `Long` value is exactly between two `Double`s,
* the one with zero at least significant bit of mantissa is selected.
*/
@WasmInstruction(WasmInstruction.F64_CONVERT_I64_S)
public override fun toDouble(): Double =
implementedAsIntrinsic
wasm_f64_convert_i64_s(this)
public inline fun equals(other: Long): Boolean =
wasm_i64_eq(this, other).reinterpretAsBoolean()
wasm_i64_eq(this, other)
// TODO: Support Any? and type operators
// public override fun equals(other: Any?): Boolean =
// other is Long && wasm_i64_eq(this, other).reinterpretAsBoolean()
public override fun equals(other: Any?): Boolean =
other is Long && wasm_i64_eq(this, other)
// TODO: Implement Long.toString()
// public override fun toString(): String
// TODO: Implement proper Long.toString
public override fun toString(): String =
toDouble().toString()
public override fun hashCode(): Int =
((this ushr 32) xor this).toInt()
@@ -1382,10 +1441,10 @@ public class Long private constructor() : Number(), Comparable<Long> {
/**
* Represents a single-precision 32-bit IEEE 754 floating point number.
*/
public class Float private constructor() : Number(), Comparable<Float> {
@WasmPrimitive
public class Float private constructor(public val value: Float) : Number(), Comparable<Float> {
@ExcludedFromCodegen
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
@@ -1411,7 +1470,9 @@ public class Float private constructor() : Number(), Comparable<Float> {
/**
* A constant holding the "not a number" value of Float.
*/
public val NaN: Float = wasm_f32_const_nan()
public val NaN: Float
get() =
wasm_float_nan()
}
/**
@@ -1483,7 +1544,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
this + other.toFloat()
/** Adds the other value to this value. */
@WasmInstruction(WasmInstruction.F32_ADD)
@WasmOp(WasmOp.F32_ADD)
public operator fun plus(other: Float): Float =
implementedAsIntrinsic
@@ -1508,7 +1569,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
this - other.toFloat()
/** Subtracts the other value from this value. */
@WasmInstruction(WasmInstruction.F32_SUB)
@WasmOp(WasmOp.F32_SUB)
public operator fun minus(other: Float): Float =
implementedAsIntrinsic
@@ -1533,7 +1594,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
this * other.toFloat()
/** Multiplies this value by the other value. */
@WasmInstruction(WasmInstruction.F32_MUL)
@WasmOp(WasmOp.F32_MUL)
public operator fun times(other: Float): Float =
implementedAsIntrinsic
@@ -1558,7 +1619,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
this / other.toFloat()
/** Divides this value by the other value. */
@WasmInstruction(WasmInstruction.F32_DIV)
@WasmOp(WasmOp.F32_DIV)
public operator fun div(other: Float): Float =
implementedAsIntrinsic
@@ -1602,7 +1663,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
public inline operator fun unaryPlus(): Float = this
/** Returns the negative of this value. */
@WasmInstruction(WasmInstruction.F32_NEG)
@WasmOp(WasmOp.F32_NEG)
public operator fun unaryMinus(): Float =
implementedAsIntrinsic
@@ -1634,10 +1695,8 @@ public class Float private constructor() : Number(), Comparable<Float> {
* Returns zero if this `Float` value is `NaN`, [Int.MIN_VALUE] if it's less than `Int.MIN_VALUE`,
* [Int.MAX_VALUE] if it's bigger than `Int.MAX_VALUE`.
*/
// TODO: Implement Float.toInt()
public override fun toInt(): Int {
wasm_unreachable()
return 0
return wasm_i32_trunc_sat_f32_s(this)
}
/**
@@ -1647,10 +1706,8 @@ public class Float private constructor() : Number(), Comparable<Float> {
* Returns zero if this `Float` value is `NaN`, [Long.MIN_VALUE] if it's less than `Long.MIN_VALUE`,
* [Long.MAX_VALUE] if it's bigger than `Long.MAX_VALUE`.
*/
// TODO: Implement Float.toLong()
public override fun toLong(): Long {
wasm_unreachable()
return 0
return wasm_i64_trunc_sat_f32_s(this)
}
/** Returns this value. */
@@ -1662,35 +1719,37 @@ public class Float private constructor() : Number(), Comparable<Float> {
*
* The resulting `Double` value represents the same numerical value as this `Float`.
*/
@WasmInstruction(WasmInstruction.F64_PROMOTE_F32)
public override fun toDouble(): Double =
implementedAsIntrinsic
wasm_f64_promote_f32(this)
public inline fun equals(other: Float): Boolean =
bits() == other.bits()
// TODO: Support Any? and type operators
// public override fun equals(other: Any?): Boolean =
// other is Float && this.equals(other)
public override fun equals(other: Any?): Boolean =
other is Float && this.equals(other)
// TODO: Implement Float.toString()
// public override fun toString(): String
public override fun toString(): String =
floatToStringImpl(this)
public override inline fun hashCode(): Int =
bits()
@PublishedApi
@WasmInstruction(WasmInstruction.I32_REINTERPRET_F32)
@WasmOp(WasmOp.I32_REINTERPRET_F32)
internal fun bits(): Int = implementedAsIntrinsic
}
@WasmImport("runtime", "coerceToString")
private fun floatToStringImpl(x: Float): String =
implementedAsIntrinsic
/**
* Represents a double-precision 64-bit IEEE 754 floating point number.
*/
public class Double private constructor() : Number(), Comparable<Double> {
@WasmPrimitive
public class Double private constructor(public val value: Double) : Number(), Comparable<Double> {
@ExcludedFromCodegen
companion object {
public companion object {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/
@@ -1716,7 +1775,10 @@ public class Double private constructor() : Number(), Comparable<Double> {
/**
* A constant holding the "not a number" value of Double.
*/
public val NaN: Double = wasm_f64_const_nan()
public val NaN: Double
get() =
wasm_double_nan()
}
/**
@@ -1792,7 +1854,7 @@ public class Double private constructor() : Number(), Comparable<Double> {
this + other.toDouble()
/** Adds the other value to this value. */
@WasmInstruction(WasmInstruction.F64_ADD)
@WasmOp(WasmOp.F64_ADD)
public operator fun plus(other: Double): Double =
implementedAsIntrinsic
@@ -1817,7 +1879,7 @@ public class Double private constructor() : Number(), Comparable<Double> {
this - other.toDouble()
/** Subtracts the other value from this value. */
@WasmInstruction(WasmInstruction.F64_SUB)
@WasmOp(WasmOp.F64_SUB)
public operator fun minus(other: Double): Double =
implementedAsIntrinsic
@@ -1842,7 +1904,7 @@ public class Double private constructor() : Number(), Comparable<Double> {
this * other.toDouble()
/** Multiplies this value by the other value. */
@WasmInstruction(WasmInstruction.F64_MUL)
@WasmOp(WasmOp.F64_MUL)
public operator fun times(other: Double): Double =
implementedAsIntrinsic
@@ -1867,7 +1929,7 @@ public class Double private constructor() : Number(), Comparable<Double> {
this / other.toDouble()
/** Divides this value by the other value. */
@WasmInstruction(WasmInstruction.F64_DIV)
@WasmOp(WasmOp.F64_DIV)
public operator fun div(other: Double): Double =
implementedAsIntrinsic
@@ -1908,7 +1970,7 @@ public class Double private constructor() : Number(), Comparable<Double> {
this
/** Returns the negative of this value. */
@WasmInstruction(WasmInstruction.F64_NEG)
@WasmOp(WasmOp.F64_NEG)
public operator fun unaryMinus(): Double =
implementedAsIntrinsic
@@ -1940,10 +2002,8 @@ public class Double private constructor() : Number(), Comparable<Double> {
* Returns zero if this `Double` value is `NaN`, [Int.MIN_VALUE] if it's less than `Int.MIN_VALUE`,
* [Int.MAX_VALUE] if it's bigger than `Int.MAX_VALUE`.
*/
// TODO: Implement Double.toInt()
public override fun toInt(): Int {
wasm_unreachable()
return 0
return wasm_i32_trunc_sat_f64_s(this)
}
/**
@@ -1953,10 +2013,8 @@ public class Double private constructor() : Number(), Comparable<Double> {
* Returns zero if this `Double` value is `NaN`, [Long.MIN_VALUE] if it's less than `Long.MIN_VALUE`,
* [Long.MAX_VALUE] if it's bigger than `Long.MAX_VALUE`.
*/
// TODO: Implement Double.toLong()
public override fun toLong(): Long {
wasm_unreachable()
return 0
return wasm_i64_trunc_sat_f64_s(this)
}
/**
@@ -1966,9 +2024,8 @@ public class Double private constructor() : Number(), Comparable<Double> {
* In case when this `Double` value is exactly between two `Float`s,
* the one with zero at least significant bit of mantissa is selected.
*/
@WasmInstruction(WasmInstruction.F32_DEMOTE_F64)
public override fun toFloat(): Float =
implementedAsIntrinsic
wasm_f32_demote_f64(this)
/** Returns this value. */
public override inline fun toDouble(): Double =
@@ -1977,17 +2034,20 @@ public class Double private constructor() : Number(), Comparable<Double> {
public inline fun equals(other: Double): Boolean =
this.bits() == other.bits()
// TODO: Support Any? and type operators
// public override fun equals(other: Any?): Boolean =
// other is Double && this.bits() == other.bits()
public override fun equals(other: Any?): Boolean =
other is Double && this.bits() == other.bits()
// TODO: Implement Double.toString()
// public override fun toString(): String
public override fun toString(): String =
doubleToStringImpl(this)
public override inline fun hashCode(): Int = bits().hashCode()
@PublishedApi
@WasmInstruction(WasmInstruction.I64_REINTERPRET_F64)
@WasmOp(WasmOp.I64_REINTERPRET_F64)
internal fun bits(): Long =
implementedAsIntrinsic
}
@WasmImport("runtime", "coerceToString")
private fun doubleToStringImpl(x: Double): String =
implementedAsIntrinsic
@@ -0,0 +1,72 @@
/*
* Copyright 2010-2019 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
import kotlin.wasm.internal.*
/**
* The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are
* implemented as instances of this class.
*/
@WasmPrimitive
public class String constructor(public val string: String) : Comparable<String>, CharSequence {
public companion object;
/**
* Returns a string obtained by concatenating this string with the string representation of the given [other] object.
*/
public operator fun plus(other: Any?): String =
stringPlusImpl(this, other.toString())
public override val length: Int
get() = stringLengthImpl(this)
/**
* Returns the character of this string at the specified [index].
*
* If the [index] is out of bounds of this string, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public override fun get(index: Int): Char =
stringGetCharImpl(this, index)
public override fun subSequence(startIndex: Int, endIndex: Int): CharSequence =
stringSubSequenceImpl(this, startIndex, endIndex)
public override fun compareTo(other: String): Int =
stringCompareToImpl(this, other)
public override fun equals(other: Any?): Boolean {
if (other is String)
return this.compareTo(other) == 0
return false
}
public override fun toString(): String = this
// TODO: Implement
public override fun hashCode(): Int = 10
}
@WasmImport("runtime", "String_plus")
private fun stringPlusImpl(it: String, other: String): String =
implementedAsIntrinsic
@WasmImport("runtime", "String_getLength")
private fun stringLengthImpl(it: String): Int =
implementedAsIntrinsic
@WasmImport("runtime", "String_getChar")
private fun stringGetCharImpl(it: String, index: Int): Char =
implementedAsIntrinsic
@WasmImport("runtime", "String_compareTo")
private fun stringCompareToImpl(it: String, other: String): Int =
implementedAsIntrinsic
@WasmImport("runtime", "String_subsequence")
private fun stringSubSequenceImpl(string: String, startIndex: Int, endIndex: Int): String =
implementedAsIntrinsic
@@ -1,13 +0,0 @@
/*
* Copyright 2010-2018 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
/**
* Base interface implicitly implemented by all annotation interfaces.
* See [Kotlin language documentation](https://kotlinlang.org/docs/reference/annotations.html) for more information
* on annotations.
*/
public interface Annotation
@@ -1,313 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
// Auto-generated file. DO NOT EDIT!
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
/**
* An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
*/
public class ByteArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Byte)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Byte
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Byte): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): ByteIterator
}
/**
* An array of chars. When targeting the JVM, instances of this class are represented as `char[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to null char (`\u0000').
*/
public class CharArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Char)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Char
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Char): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): CharIterator
}
/**
* An array of shorts. When targeting the JVM, instances of this class are represented as `short[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
*/
public class ShortArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Short)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Short
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Short): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): ShortIterator
}
/**
* An array of ints. When targeting the JVM, instances of this class are represented as `int[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
*/
public class IntArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Int)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Int
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Int): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): IntIterator
}
/**
* An array of longs. When targeting the JVM, instances of this class are represented as `long[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
*/
public class LongArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Long)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Long
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Long): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): LongIterator
}
/**
* An array of floats. When targeting the JVM, instances of this class are represented as `float[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
*/
public class FloatArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Float)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Float
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Float): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): FloatIterator
}
/**
* An array of doubles. When targeting the JVM, instances of this class are represented as `double[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
*/
public class DoubleArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Double)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Double
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Double): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): DoubleIterator
}
/**
* An array of booleans. When targeting the JVM, instances of this class are represented as `boolean[]`.
* @constructor Creates a new array of the specified [size], with all elements initialized to `false`.
*/
public class BooleanArray(size: Int) {
/**
* Creates a new array of the specified [size], where each element is calculated by calling the specified
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
* It should return the value for an array element given its index.
*/
public inline constructor(size: Int, init: (Int) -> Boolean)
/**
* Returns the array element at the given [index]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun get(index: Int): Boolean
/**
* Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
*
* If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
public operator fun set(index: Int, value: Boolean): Unit
/** Returns the number of elements in the array. */
public val size: Int
/** Creates an iterator over the elements of the array. */
public operator fun iterator(): BooleanIterator
}
@@ -1,46 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin
/**
* Represents a readable sequence of [Char] values.
*/
public interface CharSequence {
/**
* Returns the length of this character sequence.
*/
public val length: Int
/**
* Returns the character at the specified [index] in this character sequence.
*
* @throws [IndexOutOfBoundsException] if the [index] is out of bounds of this character sequence.
*
* Note that the [String] implementation of this interface in Kotlin/JS has unspecified behavior
* if the [index] is out of its bounds.
*/
public operator fun get(index: Int): Char
/**
* Returns a new character sequence that is a subsequence of this character sequence,
* starting at the specified [startIndex] and ending right before the specified [endIndex].
*
* @param startIndex the start index (inclusive).
* @param endIndex the end index (exclusive).
*/
public fun subSequence(startIndex: Int, endIndex: Int): CharSequence
}
@@ -1,438 +0,0 @@
/*
* 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.collections
import kotlin.internal.PlatformDependent
/**
* Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over.
* @param T the type of element being iterated over. The iterator is covariant in its element type.
*/
public interface Iterable<out T> {
/**
* Returns an iterator over the elements of this object.
*/
public operator fun iterator(): Iterator<T>
}
/**
* Classes that inherit from this interface can be represented as a sequence of elements that can
* be iterated over and that supports removing elements during iteration.
* @param T the type of element being iterated over. The mutable iterator is invariant in its element type.
*/
public interface MutableIterable<out T> : Iterable<T> {
/**
* Returns an iterator over the elements of this sequence that supports removing elements during iteration.
*/
override fun iterator(): MutableIterator<T>
}
/**
* A generic collection of elements. Methods in this interface support only read-only access to the collection;
* read/write access is supported through the [MutableCollection] interface.
* @param E the type of elements contained in the collection. The collection is covariant in its element type.
*/
public interface Collection<out E> : Iterable<E> {
// Query Operations
/**
* Returns the size of the collection.
*/
public val size: Int
/**
* Returns `true` if the collection is empty (contains no elements), `false` otherwise.
*/
public fun isEmpty(): Boolean
/**
* Checks if the specified element is contained in this collection.
*/
public operator fun contains(element: @UnsafeVariance E): Boolean
override fun iterator(): Iterator<E>
// Bulk Operations
/**
* Checks if all elements in the specified collection are contained in this collection.
*/
public fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
}
/**
* A generic collection of elements that supports adding and removing elements.
*
* @param E the type of elements contained in the collection. The mutable collection is invariant in its element type.
*/
public interface MutableCollection<E> : Collection<E>, MutableIterable<E> {
// Query Operations
override fun iterator(): MutableIterator<E>
// Modification Operations
/**
* Adds the specified element to the collection.
*
* @return `true` if the element has been added, `false` if the collection does not support duplicates
* and the element is already contained in the collection.
*/
public fun add(element: E): Boolean
/**
* Removes a single instance of the specified element from this
* collection, if it is present.
*
* @return `true` if the element has been successfully removed; `false` if it was not present in the collection.
*/
public fun remove(element: E): Boolean
// Bulk Modification Operations
/**
* Adds all of the elements of the specified collection to this collection.
*
* @return `true` if any of the specified elements was added to the collection, `false` if the collection was not modified.
*/
public fun addAll(elements: Collection<E>): Boolean
/**
* Removes all of this collection's elements that are also contained in the specified collection.
*
* @return `true` if any of the specified elements was removed from the collection, `false` if the collection was not modified.
*/
public fun removeAll(elements: Collection<E>): Boolean
/**
* Retains only the elements in this collection that are contained in the specified collection.
*
* @return `true` if any element was removed from the collection, `false` if the collection was not modified.
*/
public fun retainAll(elements: Collection<E>): Boolean
/**
* Removes all elements from this collection.
*/
public fun clear(): Unit
}
/**
* A generic ordered collection of elements. Methods in this interface support only read-only access to the list;
* read/write access is supported through the [MutableList] interface.
* @param E the type of elements contained in the list. The list is covariant in its element type.
*/
public interface List<out E> : Collection<E> {
// Query Operations
override val size: Int
override fun isEmpty(): Boolean
override fun contains(element: @UnsafeVariance E): Boolean
override fun iterator(): Iterator<E>
// Bulk Operations
override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
// Positional Access Operations
/**
* Returns the element at the specified index in the list.
*/
public operator fun get(index: Int): E
// Search Operations
/**
* Returns the index of the first occurrence of the specified element in the list, or -1 if the specified
* element is not contained in the list.
*/
public fun indexOf(element: @UnsafeVariance E): Int
/**
* Returns the index of the last occurrence of the specified element in the list, or -1 if the specified
* element is not contained in the list.
*/
public fun lastIndexOf(element: @UnsafeVariance E): Int
// List Iterators
/**
* Returns a list iterator over the elements in this list (in proper sequence).
*/
public fun listIterator(): ListIterator<E>
/**
* Returns a list iterator over the elements in this list (in proper sequence), starting at the specified [index].
*/
public fun listIterator(index: Int): ListIterator<E>
// View
/**
* Returns a view of the portion of this list between the specified [fromIndex] (inclusive) and [toIndex] (exclusive).
* The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa.
*
* Structural changes in the base list make the behavior of the view undefined.
*/
public fun subList(fromIndex: Int, toIndex: Int): List<E>
}
/**
* A generic ordered collection of elements that supports adding and removing elements.
* @param E the type of elements contained in the list. The mutable list is invariant in its element type.
*/
public interface MutableList<E> : List<E>, MutableCollection<E> {
// Modification Operations
/**
* Adds the specified element to the end of this list.
*
* @return `true` because the list is always modified as the result of this operation.
*/
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
// Bulk Modification Operations
/**
* Adds all of the elements of the specified collection to the end of this list.
*
* The elements are appended in the order they appear in the [elements] collection.
*
* @return `true` if the list was changed as the result of the operation.
*/
override fun addAll(elements: Collection<E>): Boolean
/**
* Inserts all of the elements of the specified collection [elements] into this list at the specified [index].
*
* @return `true` if the list was changed as the result of the operation.
*/
public fun addAll(index: Int, elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear(): Unit
// Positional Access Operations
/**
* Replaces the element at the specified position in this list with the specified element.
*
* @return the element previously at the specified position.
*/
public operator fun set(index: Int, element: E): E
/**
* Inserts an element into the list at the specified [index].
*/
public fun add(index: Int, element: E): Unit
/**
* Removes an element at the specified [index] from the list.
*
* @return the element that has been removed.
*/
public fun removeAt(index: Int): E
// List Iterators
override fun listIterator(): MutableListIterator<E>
override fun listIterator(index: Int): MutableListIterator<E>
// View
override fun subList(fromIndex: Int, toIndex: Int): MutableList<E>
}
/**
* A generic unordered collection of elements that does not support duplicate elements.
* Methods in this interface support only read-only access to the set;
* read/write access is supported through the [MutableSet] interface.
* @param E the type of elements contained in the set. The set is covariant in its element type.
*/
public interface Set<out E> : Collection<E> {
// Query Operations
override val size: Int
override fun isEmpty(): Boolean
override fun contains(element: @UnsafeVariance E): Boolean
override fun iterator(): Iterator<E>
// Bulk Operations
override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean
}
/**
* A generic unordered collection of elements that does not support duplicate elements, and supports
* adding and removing elements.
* @param E the type of elements contained in the set. The mutable set is invariant in its element type.
*/
public interface MutableSet<E> : Set<E>, MutableCollection<E> {
// Query Operations
override fun iterator(): MutableIterator<E>
// Modification Operations
/**
* Adds the specified element to the set.
*
* @return `true` if the element has been added, `false` if the element is already contained in the set.
*/
override fun add(element: E): Boolean
override fun remove(element: E): Boolean
// Bulk Modification Operations
override fun addAll(elements: Collection<E>): Boolean
override fun removeAll(elements: Collection<E>): Boolean
override fun retainAll(elements: Collection<E>): Boolean
override fun clear(): Unit
}
/**
* A collection that holds pairs of objects (keys and values) and supports efficiently retrieving
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* Methods in this interface support only read-only access to the map; read-write access is supported through
* the [MutableMap] interface.
* @param K the type of map keys. The map is invariant in its key type, as it
* can accept key as a parameter (of [containsKey] for example) and return it in [keys] set.
* @param V the type of map values. The map is covariant in its value type.
*/
public interface Map<K, out V> {
// Query Operations
/**
* Returns the number of key/value pairs in the map.
*/
public val size: Int
/**
* Returns `true` if the map is empty (contains no elements), `false` otherwise.
*/
public fun isEmpty(): Boolean
/**
* Returns `true` if the map contains the specified [key].
*/
public fun containsKey(key: K): Boolean
/**
* Returns `true` if the map maps one or more keys to the specified [value].
*/
public fun containsValue(value: @UnsafeVariance V): Boolean
/**
* Returns the value corresponding to the given [key], or `null` if such a key is not present in the map.
*/
public operator fun get(key: K): V?
/**
* Returns the value corresponding to the given [key], or [defaultValue] if such a key is not present in the map.
*
* @since JDK 1.8
*/
@SinceKotlin("1.1")
@PlatformDependent
public fun getOrDefault(key: K, defaultValue: @UnsafeVariance V): V {
// See default implementation in JDK sources
return null as V
}
// Views
/**
* Returns a read-only [Set] of all keys in this map.
*/
public val keys: Set<K>
/**
* Returns a read-only [Collection] of all values in this map. Note that this collection may contain duplicate values.
*/
public val values: Collection<V>
/**
* Returns a read-only [Set] of all key/value pairs in this map.
*/
public val entries: Set<Map.Entry<K, V>>
/**
* Represents a key/value pair held by a [Map].
*/
public interface Entry<out K, out V> {
/**
* Returns the key of this key/value pair.
*/
public val key: K
/**
* Returns the value of this key/value pair.
*/
public val value: V
}
}
/**
* A modifiable collection that holds pairs of objects (keys and values) and supports efficiently retrieving
* the value corresponding to each key. Map keys are unique; the map holds only one value for each key.
* @param K the type of map keys. The map is invariant in its key type.
* @param V the type of map values. The mutable map is invariant in its value type.
*/
public interface MutableMap<K, V> : Map<K, V> {
// Modification Operations
/**
* Associates the specified [value] with the specified [key] in the map.
*
* @return the previous value associated with the key, or `null` if the key was not present in the map.
*/
public fun put(key: K, value: V): V?
/**
* Removes the specified key and its corresponding value from this map.
*
* @return the previous value associated with the key, or `null` if the key was not present in the map.
*/
public fun remove(key: K): V?
/**
* Removes the entry for the specified key only if it is mapped to the specified value.
*
* @return true if entry was removed
*/
@SinceKotlin("1.1")
@PlatformDependent
public fun remove(key: K, value: V): Boolean {
// See default implementation in JDK sources
return true
}
// Bulk Modification Operations
/**
* Updates this map with key/value pairs from the specified map [from].
*/
public fun putAll(from: Map<out K, V>): Unit
/**
* Removes all elements from this map.
*/
public fun clear(): Unit
// Views
/**
* Returns a [MutableSet] of all keys in this map.
*/
override val keys: MutableSet<K>
/**
* Returns a [MutableCollection] of all values in this map. Note that this collection may contain duplicate values.
*/
override val values: MutableCollection<V>
/**
* Returns a [MutableSet] of all key/value pairs in this map.
*/
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
/**
* Represents a key/value pair held by a [MutableMap].
*/
public interface MutableEntry<K, V> : Map.Entry<K, V> {
/**
* Changes the value associated with the key of this entry.
*
* @return the previous value corresponding to the key.
*/
public fun setValue(newValue: V): V
}
}
@@ -1,29 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin
/**
* Classes which inherit from this interface have a defined total ordering between their instances.
*/
public interface Comparable<in T> {
/**
* Compares this object with the specified object for order. Returns zero if this object is equal
* to the specified [other] object, a negative number if it's less than [other], or a positive number
* if it's greater than [other].
*/
public operator fun compareTo(other: T): Int
}
@@ -1,58 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
/**
* The common base class of all enum classes.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/enum-classes.html) for more
* information on enum classes.
*/
public abstract class Enum<E : Enum<E>>(name: String, ordinal: Int): Comparable<E> {
companion object {}
/**
* Returns the name of this enum constant, exactly as declared in its enum declaration.
*/
public final val name: String
/**
* Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant
* is assigned an ordinal of zero).
*/
public final val ordinal: Int
public override final fun compareTo(other: E): Int
/**
* Throws an exception since enum constants cannot be cloned.
* This method prevents enum classes from inheriting from `Cloneable`.
*/
protected final fun clone(): Any
public override final fun equals(other: Any?): Boolean
public override final fun hashCode(): Int
public override fun toString(): String
/**
* Returns an array containing the constants of this enum type, in the order they're declared.
* This method may be used to iterate over the constants.
* @values
*/
/**
* Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
* @throws IllegalArgumentException if this enum type has no constant with the specified name
* @valueOf
*/
}
@@ -1,102 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.collections
/**
* An iterator over a collection or another entity that can be represented as a sequence of elements.
* Allows to sequentially access the elements.
*/
public interface Iterator<out T> {
/**
* Returns the next element in the iteration.
*/
public operator fun next(): T
/**
* Returns `true` if the iteration has more elements.
*/
public operator fun hasNext(): Boolean
}
/**
* An iterator over a mutable collection. Provides the ability to remove elements while iterating.
* @see MutableCollection.iterator
*/
public interface MutableIterator<out T> : Iterator<T> {
/**
* Removes from the underlying collection the last element returned by this iterator.
*/
public fun remove(): Unit
}
/**
* An iterator over a collection that supports indexed access.
* @see List.listIterator
*/
public interface ListIterator<out T> : Iterator<T> {
// Query Operations
override fun next(): T
override fun hasNext(): Boolean
/**
* Returns `true` if there are elements in the iteration before the current element.
*/
public fun hasPrevious(): Boolean
/**
* Returns the previous element in the iteration and moves the cursor position backwards.
*/
public fun previous(): T
/**
* Returns the index of the element that would be returned by a subsequent call to [next].
*/
public fun nextIndex(): Int
/**
* Returns the index of the element that would be returned by a subsequent call to [previous].
*/
public fun previousIndex(): Int
}
/**
* An iterator over a mutable collection that supports indexed access. Provides the ability
* to add, modify and remove elements while iterating.
*/
public interface MutableListIterator<T> : ListIterator<T>, MutableIterator<T> {
// Query Operations
override fun next(): T
override fun hasNext(): Boolean
// Modification Operations
override fun remove(): Unit
/**
* Replaces the last element returned by [next] or [previous] with the specified element [element].
*/
public fun set(element: T): Unit
/**
* Adds the specified element [element] into the underlying collection immediately before the element that would be
* returned by [next], if any, and after the element that would be returned by [previous], if any.
* (If the collection contains no elements, the new element becomes the sole element in the collection.)
* The new element is inserted before the implicit cursor: a subsequent call to [next] would be unaffected,
* and a subsequent call to [previous] would return the new element. (This call increases by one the value \
* that would be returned by a call to [nextIndex] or [previousIndex].)
*/
public fun add(element: T): Unit
}
@@ -1,58 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin
/**
* Superclass for all platform classes representing numeric values.
*/
public abstract class Number {
/**
* Returns the value of this number as a [Double], which may involve rounding.
*/
public abstract fun toDouble(): Double
/**
* Returns the value of this number as a [Float], which may involve rounding.
*/
public abstract fun toFloat(): Float
/**
* Returns the value of this number as a [Long], which may involve rounding or truncation.
*/
public abstract fun toLong(): Long
/**
* Returns the value of this number as an [Int], which may involve rounding or truncation.
*/
public abstract fun toInt(): Int
/**
* Returns the [Char] with the numeric value equal to this number, truncated to 16 bits if appropriate.
*/
public abstract fun toChar(): Char
/**
* Returns the value of this number as a [Short], which may involve rounding or truncation.
*/
public abstract fun toShort(): Short
/**
* Returns the value of this number as a [Byte], which may involve rounding or truncation.
*/
public abstract fun toByte(): Byte
}
@@ -1,58 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
import kotlin.wasm.internal.ExcludedFromCodegen
import kotlin.wasm.internal.WasmImport
/**
* The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are
* implemented as instances of this class.
*/
public class String : Comparable<String>, CharSequence {
@ExcludedFromCodegen
companion object {}
/**
* Returns a string obtained by concatenating this string with the string representation of the given [other] object.
*/
@WasmImport("runtime", "String_plus")
public operator fun plus(other: Any?): String
public override val length: Int
@WasmImport("runtime", "String_getLength") get
/**
* Returns the character of this string at the specified [index].
*
* If the [index] is out of bounds of this string, throws an [IndexOutOfBoundsException] except in Kotlin/JS
* where the behavior is unspecified.
*/
@WasmImport("runtime", "String_getChar")
public override fun get(index: Int): Char
@ExcludedFromCodegen
public override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
@WasmImport("runtime", "String_compareTo")
public override fun compareTo(other: String): Int
@ExcludedFromCodegen
public override fun equals(other: Any?): Boolean
public override fun toString(): String = this
@ExcludedFromCodegen
public override fun hashCode(): Int
}
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
@file:Suppress(
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"MUST_BE_INITIALIZED_OR_BE_ABSTRACT",
"EXTERNAL_TYPE_EXTENDS_NON_EXTERNAL_TYPE",
"PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED",
"WRONG_MODIFIER_TARGET"
)
package kotlin
/**
* The base class for all errors and exceptions. Only instances of this class can be thrown or caught.
*
* @param message the detail message string.
* @param cause the cause of this throwable.
*/
public open class Throwable(open val message: String?, open val cause: Throwable?) {
constructor(message: String?) : this(message, null)
constructor(cause: Throwable?) : this(cause?.toString(), cause)
constructor() : this(null, null)
}
@@ -1,152 +0,0 @@
/*
* Copyright 2010-2019 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
import kotlin.annotation.AnnotationRetention.BINARY
import kotlin.annotation.AnnotationRetention.SOURCE
import kotlin.annotation.AnnotationTarget.*
/**
* Marks the annotated declaration as deprecated.
*
* A deprecated API element is not recommended to use, typically because it's being phased out or a better alternative exists.
*
* To help removing deprecated API gradually, the property [level] could be used.
* Usually a gradual phase-out goes through the "warning", then "error", then "hidden" or "removed" stages:
* - First and by default, [DeprecationLevel.WARNING] is used to notify API consumers, but not to break their compilation or runtime usages.
* - Then, some time later the deprecation level is raised to [DeprecationLevel.ERROR], so that no new Kotlin code can be compiled
* using the deprecated API.
* - Finally, the API is either removed entirely, or hidden ([DeprecationLevel.HIDDEN]) from code,
* so its usages look like unresolved references, while the API remains in the compiled code
* preserving binary compatibility with previously compiled code.
*
* @property message The message explaining the deprecation and recommending an alternative API to use.
* @property replaceWith If present, specifies a code fragment which should be used as a replacement for
* the deprecated API usage.
* @property level Specifies how the deprecated element usages are reported in code.
* See the [DeprecationLevel] enum for the possible values.
*/
@Target(CLASS, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER, TYPEALIAS)
@MustBeDocumented
public annotation class Deprecated(
val message: String,
val replaceWith: ReplaceWith = ReplaceWith(""),
val level: DeprecationLevel = DeprecationLevel.WARNING
)
/**
* Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such
* as IDEs can automatically apply the replacements specified through this annotation.
*
* @property expression the replacement expression. The replacement expression is interpreted in the context
* of the symbol being used, and can reference members of enclosing classes etc.
* For function calls, the replacement expression may contain argument names of the deprecated function,
* which will be substituted with actual parameters used in the call being updated. The imports used in the file
* containing the deprecated function or property are NOT accessible; if the replacement expression refers
* on any of those imports, they need to be specified explicitly in the [imports] parameter.
* @property imports the qualified names that need to be imported in order for the references in the
* replacement expression to be resolved correctly.
*/
@Target()
@Retention(BINARY)
@MustBeDocumented
public annotation class ReplaceWith(val expression: String, vararg val imports: String)
/**
* Possible levels of a deprecation. The level specifies how the deprecated element usages are reported in code.
*
* @see Deprecated
*/
public enum class DeprecationLevel {
/** Usage of the deprecated element will be reported as a warning. */
WARNING,
/** Usage of the deprecated element will be reported as an error. */
ERROR,
/** Deprecated element will not be accessible from code. */
HIDDEN
}
/**
* Signifies that the annotated functional type represents an extension function.
*/
@Target(TYPE)
@MustBeDocumented
public annotation class ExtensionFunctionType
/**
* Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any).
*/
@Target(TYPE)
@MustBeDocumented
@SinceKotlin("1.1")
public annotation class ParameterName(val name: String)
/**
* Suppresses the given compilation warnings in the annotated element.
* @property names names of the compiler diagnostics to suppress.
*/
@Target(CLASS, ANNOTATION_CLASS, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER,
CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPE, EXPRESSION, FILE, TYPEALIAS)
@Retention(SOURCE)
public annotation class Suppress(vararg val names: String)
/**
* Suppresses errors about variance conflict
*/
@Target(TYPE)
@Retention(SOURCE)
@MustBeDocumented
public annotation class UnsafeVariance
/**
* Specifies the first version of Kotlin where a declaration has appeared.
* Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error.
*
* @property version the version in the following formats: `<major>.<minor>` or `<major>.<minor>.<patch>`, where major, minor and patch
* are non-negative integer numbers without leading zeros.
*/
@Target(CLASS, PROPERTY, FIELD, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPEALIAS)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
public annotation class SinceKotlin(val version: String)
/**
* When applied to annotation class X specifies that X defines a DSL language
*
* The general rule:
* - an implicit receiver may *belong to a DSL @X* if marked with a corresponding DSL marker annotation
* - two implicit receivers of the same DSL are not accessible in the same scope
* - the closest one wins
* - other available receivers are resolved as usual, but if the resulting resolved call binds to such a receiver, it's a compilation error
*
* Marking rules: an implicit receiver is considered marked with @Ann if
* - its type is marked, or
* - its type's classifier is marked
* - or any of its superclasses/superinterfaces
*/
@Target(ANNOTATION_CLASS)
@Retention(BINARY)
@MustBeDocumented
@SinceKotlin("1.1")
public annotation class DslMarker
/**
* When applied to a class or a member with internal visibility allows to use it from public inline functions and
* makes it effectively public.
*
* Public inline functions cannot use non-public API, since if they are inlined, those non-public API references
* would violate access restrictions at a call site (https://kotlinlang.org/docs/reference/inline-functions.html#public-inline-restrictions).
*
* To overcome this restriction an `internal` declaration can be annotated with the `@PublishedApi` annotation:
* - this allows to call that declaration from public inline functions;
* - the declaration becomes effectively public, and this should be considered with respect to binary compatibility maintaining.
*/
@Target(AnnotationTarget.CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
@SinceKotlin("1.1")
public annotation class PublishedApi
@@ -1,24 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin
/**
* Represents a value of a functional type, such as a lambda, an anonymous function or a function reference.
*
* @param R return type of the function.
*/
public interface Function<out R>
@@ -1,73 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
// Auto-generated file. DO NOT EDIT!
package kotlin.collections
/** An iterator over a sequence of values of type `Byte`. */
public abstract class ByteIterator : Iterator<Byte> {
override final fun next() = nextByte()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextByte(): Byte
}
/** An iterator over a sequence of values of type `Char`. */
public abstract class CharIterator : Iterator<Char> {
override final fun next() = nextChar()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextChar(): Char
}
/** An iterator over a sequence of values of type `Short`. */
public abstract class ShortIterator : Iterator<Short> {
override final fun next() = nextShort()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextShort(): Short
}
/** An iterator over a sequence of values of type `Int`. */
public abstract class IntIterator : Iterator<Int> {
override final fun next() = nextInt()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextInt(): Int
}
/** An iterator over a sequence of values of type `Long`. */
public abstract class LongIterator : Iterator<Long> {
override final fun next() = nextLong()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextLong(): Long
}
/** An iterator over a sequence of values of type `Float`. */
public abstract class FloatIterator : Iterator<Float> {
override final fun next() = nextFloat()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextFloat(): Float
}
/** An iterator over a sequence of values of type `Double`. */
public abstract class DoubleIterator : Iterator<Double> {
override final fun next() = nextDouble()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextDouble(): Double
}
/** An iterator over a sequence of values of type `Boolean`. */
public abstract class BooleanIterator : Iterator<Boolean> {
override final fun next() = nextBoolean()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextBoolean(): Boolean
}
@@ -1,24 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin
/**
* The type with only one value: the `Unit` object. This type corresponds to the `void` type in Java.
*/
public object Unit {
override fun toString() = "kotlin.Unit"
}
@@ -1,103 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.annotation
import kotlin.annotation.AnnotationTarget.*
/**
* Contains the list of code elements which are the possible annotation targets
*/
public enum class AnnotationTarget {
/** Class, interface or object, annotation class is also included */
CLASS,
/** Annotation class only */
ANNOTATION_CLASS,
/** Generic type parameter (unsupported yet) */
TYPE_PARAMETER,
/** Property */
PROPERTY,
/** Field, including property's backing field */
FIELD,
/** Local variable */
LOCAL_VARIABLE,
/** Value parameter of a function or a constructor */
VALUE_PARAMETER,
/** Constructor only (primary or secondary) */
CONSTRUCTOR,
/** Function (constructors are not included) */
FUNCTION,
/** Property getter only */
PROPERTY_GETTER,
/** Property setter only */
PROPERTY_SETTER,
/** Type usage */
TYPE,
/** Any expression */
EXPRESSION,
/** File */
FILE,
/** Type alias */
@SinceKotlin("1.1")
TYPEALIAS
}
/**
* Contains the list of possible annotation's retentions.
*
* Determines how an annotation is stored in binary output.
*/
public enum class AnnotationRetention {
/** Annotation isn't stored in binary output */
SOURCE,
/** Annotation is stored in binary output, but invisible for reflection */
BINARY,
/** Annotation is stored in binary output and visible for reflection (default retention) */
RUNTIME
}
/**
* This meta-annotation indicates the kinds of code elements which are possible targets of an annotation.
*
* If the target meta-annotation is not present on an annotation declaration, the annotation is applicable to the following elements:
* [CLASS], [PROPERTY], [FIELD], [LOCAL_VARIABLE], [VALUE_PARAMETER], [CONSTRUCTOR], [FUNCTION], [PROPERTY_GETTER], [PROPERTY_SETTER].
*
* @property allowedTargets list of allowed annotation targets
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
@MustBeDocumented
public annotation class Target(vararg val allowedTargets: AnnotationTarget)
/**
* This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true.
*
* @property value necessary annotation retention (RUNTIME, BINARY or SOURCE)
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
public annotation class Retention(val value: AnnotationRetention = AnnotationRetention.RUNTIME)
/**
* This meta-annotation determines that an annotation is applicable twice or more on a single code element
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
public annotation class Repeatable
/**
* This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated
* documentation for the element to which the annotation is applied.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
public annotation class MustBeDocumented
@@ -1,35 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.internal
/**
* Specifies that the corresponding type parameter is not used for unsafe operations such as casts or 'is' checks
* That means it's completely safe to use generic types as argument for such parameter.
*/
@Target(AnnotationTarget.TYPE_PARAMETER)
@Retention(AnnotationRetention.BINARY)
internal annotation class PureReifiable
/**
* Specifies that the corresponding built-in method exists depending on platform.
* Current implementation for JVM looks whether method with same JVM descriptor exists in the module JDK.
* For example MutableMap.remove(K, V) available only if corresponding
* method 'java/util/Map.remove(Ljava/lang/Object;Ljava/lang/Object;)Z' is defined in JDK (i.e. for major versions >= 8)
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
internal annotation class PlatformDependent
@@ -1,18 +0,0 @@
/*
* Copyright 2010-2019 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.reflect
/**
* Represents an annotated element and allows to obtain its annotations.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/annotations.html)
* for more information.
*/
public interface KAnnotatedElement {
/**
* Annotations which are present on this element.
*/
public val annotations: List<Annotation>
}
@@ -1,85 +0,0 @@
/*
* Copyright 2010-2019 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.reflect
/**
* Represents a callable entity, such as a function or a property.
*
* @param R return type of the callable.
*/
public interface KCallable<out R> : KAnnotatedElement {
/**
* The name of this callable as it was declared in the source code.
* If the callable has no name, a special invented name is created.
* Nameless callables include:
* - constructors have the name "<init>",
* - property accessors: the getter for a property named "foo" will have the name "<get-foo>",
* the setter, similarly, will have the name "<set-foo>".
*/
public val name: String
/**
* Parameters required to make a call to this callable.
* If this callable requires a `this` instance or an extension receiver parameter,
* they come first in the list in that order.
*/
public val parameters: List<KParameter>
/**
* The type of values returned by this callable.
*/
public val returnType: KType
/**
* The list of type parameters of this callable.
*/
@SinceKotlin("1.1")
public val typeParameters: List<KTypeParameter>
/**
* Calls this callable with the specified list of arguments and returns the result.
* Throws an exception if the number of specified arguments is not equal to the size of [parameters],
* or if their types do not match the types of the parameters.
*/
public fun call(vararg args: Any?): R
/**
* Calls this callable with the specified mapping of parameters to arguments and returns the result.
* If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional]),
* or its type does not match the type of the provided value, an exception is thrown.
*/
public fun callBy(args: Map<KParameter, Any?>): R
/**
* Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin.
*/
@SinceKotlin("1.1")
public val visibility: KVisibility?
/**
* `true` if this callable is `final`.
*/
@SinceKotlin("1.1")
public val isFinal: Boolean
/**
* `true` if this callable is `open`.
*/
@SinceKotlin("1.1")
public val isOpen: Boolean
/**
* `true` if this callable is `abstract`.
*/
@SinceKotlin("1.1")
public val isAbstract: Boolean
/**
* `true` if this is a suspending function.
*/
@SinceKotlin("1.3")
public val isSuspend: Boolean
}
@@ -1,144 +0,0 @@
/*
* Copyright 2010-2019 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.reflect
/**
* Represents a class and provides introspection capabilities.
* Instances of this class are obtainable by the `::class` syntax.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html#class-references)
* for more information.
*
* @param T the type of the class.
*/
public interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KClassifier {
/**
* The simple name of the class as it was declared in the source code,
* or `null` if the class has no name (if, for example, it is an anonymous object literal).
*/
public val simpleName: String?
/**
* The fully qualified dot-separated name of the class,
* or `null` if the class is local or it is an anonymous object literal.
*/
public val qualifiedName: String?
/**
* All functions and properties accessible in this class, including those declared in this class
* and all of its superclasses. Does not include constructors.
*/
override val members: Collection<KCallable<*>>
/**
* All constructors declared in this class.
*/
public val constructors: Collection<KFunction<T>>
/**
* All classes declared inside this class. This includes both inner and static nested classes.
*/
public val nestedClasses: Collection<KClass<*>>
/**
* The instance of the object declaration, or `null` if this class is not an object declaration.
*/
public val objectInstance: T?
/**
* Returns `true` if [value] is an instance of this class on a given platform.
*/
@SinceKotlin("1.1")
public fun isInstance(value: Any?): Boolean
/**
* The list of type parameters of this class. This list does *not* include type parameters of outer classes.
*/
@SinceKotlin("1.1")
public val typeParameters: List<KTypeParameter>
/**
* The list of immediate supertypes of this class, in the order they are listed in the source code.
*/
@SinceKotlin("1.1")
public val supertypes: List<KType>
/**
* The list of the immediate subclasses if this class is a sealed class, or an empty list otherwise.
*/
@SinceKotlin("1.3")
public val sealedSubclasses: List<KClass<out T>>
/**
* Visibility of this class, or `null` if its visibility cannot be represented in Kotlin.
*/
@SinceKotlin("1.1")
public val visibility: KVisibility?
/**
* `true` if this class is `final`.
*/
@SinceKotlin("1.1")
public val isFinal: Boolean
/**
* `true` if this class is `open`.
*/
@SinceKotlin("1.1")
public val isOpen: Boolean
/**
* `true` if this class is `abstract`.
*/
@SinceKotlin("1.1")
public val isAbstract: Boolean
/**
* `true` if this class is `sealed`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/sealed-classes.html)
* for more information.
*/
@SinceKotlin("1.1")
public val isSealed: Boolean
/**
* `true` if this class is a data class.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/data-classes.html)
* for more information.
*/
@SinceKotlin("1.1")
public val isData: Boolean
/**
* `true` if this class is an inner class.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/nested-classes.html#inner-classes)
* for more information.
*/
@SinceKotlin("1.1")
public val isInner: Boolean
/**
* `true` if this class is a companion object.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects)
* for more information.
*/
@SinceKotlin("1.1")
public val isCompanion: Boolean
/**
* Returns `true` if this [KClass] instance represents the same Kotlin class as the class represented by [other].
* On JVM this means that all of the following conditions are satisfied:
*
* 1. [other] has the same (fully qualified) Kotlin class name as this instance.
* 2. [other]'s backing [Class] object is loaded with the same class loader as the [Class] object of this instance.
* 3. If the classes represent [Array], then [Class] objects of their element types are equal.
*
* For example, on JVM, [KClass] instances for a primitive type (`int`) and the corresponding wrapper type (`java.lang.Integer`)
* are considered equal, because they have the same fully qualified name "kotlin.Int".
*/
override fun equals(other: Any?): Boolean
override fun hashCode(): Int
}
@@ -1,26 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect
/**
* A classifier is either a class or a type parameter.
*
* @see [KClass]
* @see [KTypeParameter]
*/
@SinceKotlin("1.1")
public interface KClassifier
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect
/**
* Represents an entity which may contain declarations of any other entities,
* such as a class or a package.
*/
public interface KDeclarationContainer {
/**
* All functions and properties accessible in this container.
*/
public val members: Collection<KCallable<*>>
}
@@ -1,49 +0,0 @@
/*
* Copyright 2010-2018 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.reflect
/**
* Represents a function with introspection capabilities.
*/
public interface KFunction<out R> : KCallable<R>, Function<R> {
/**
* `true` if this function is `inline`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/inline-functions.html)
* for more information.
*/
@SinceKotlin("1.1")
public val isInline: Boolean
/**
* `true` if this function is `external`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/java-interop.html#using-jni-with-kotlin)
* for more information.
*/
@SinceKotlin("1.1")
public val isExternal: Boolean
/**
* `true` if this function is `operator`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/operator-overloading.html)
* for more information.
*/
@SinceKotlin("1.1")
public val isOperator: Boolean
/**
* `true` if this function is `infix`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/functions.html#infix-notation)
* for more information.
*/
@SinceKotlin("1.1")
public val isInfix: Boolean
/**
* `true` if this is a suspending function.
*/
@SinceKotlin("1.1")
public override val isSuspend: Boolean
}
@@ -1,80 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect
/**
* Represents a parameter passed to a function or a property getter/setter,
* including `this` and extension receiver parameters.
*/
public interface KParameter : KAnnotatedElement {
/**
* 0-based index of this parameter in the parameter list of its containing callable.
*/
public val index: Int
/**
* Name of this parameter as it was declared in the source code,
* or `null` if the parameter has no name or its name is not available at runtime.
* Examples of nameless parameters include `this` instance for member functions,
* extension receiver for extension functions or properties, parameters of Java methods
* compiled without the debug information, and others.
*/
public val name: String?
/**
* Type of this parameter. For a `vararg` parameter, this is the type of the corresponding array,
* not the individual element.
*/
public val type: KType
/**
* Kind of this parameter.
*/
public val kind: Kind
/**
* Kind represents a particular position of the parameter declaration in the source code,
* such as an instance, an extension receiver parameter or a value parameter.
*/
public enum class Kind {
/** Instance required to make a call to the member, or an outer class instance for an inner class constructor. */
INSTANCE,
/** Extension receiver of an extension function or property. */
EXTENSION_RECEIVER,
/** Ordinary named value parameter. */
VALUE,
}
/**
* `true` if this parameter is optional and can be omitted when making a call via [KCallable.callBy], or `false` otherwise.
*
* A parameter is optional in any of the two cases:
* 1. The default value is provided at the declaration of this parameter.
* 2. The parameter is declared in a member function and one of the corresponding parameters in the super functions is optional.
*/
public val isOptional: Boolean
/**
* `true` if this parameter is `vararg`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/functions.html#variable-number-of-arguments-varargs)
* for more information.
*/
@SinceKotlin("1.1")
public val isVararg: Boolean
}
@@ -1,258 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
@file:Suppress("IMPLEMENTING_FUNCTION_INTERFACE")
package kotlin.reflect
/**
* Represents a property, such as a named `val` or `var` declaration.
* Instances of this class are obtainable by the `::` operator.
*
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html)
* for more information.
*
* @param R the type of the property.
*/
public interface KProperty<out R> : KCallable<R> {
/**
* `true` if this property is `lateinit`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties)
* for more information.
*/
@SinceKotlin("1.1")
public val isLateinit: Boolean
/**
* `true` if this property is `const`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#compile-time-constants)
* for more information.
*/
@SinceKotlin("1.1")
public val isConst: Boolean
/** The getter of this property, used to obtain the value of the property. */
public val getter: Getter<R>
/**
* Represents a property accessor, which is a `get` or `set` method declared alongside the property.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#getters-and-setters)
* for more information.
*
* @param R the type of the property, which it is an accessor of.
*/
public interface Accessor<out R> {
/** The property which this accessor is originated from. */
public val property: KProperty<R>
}
/**
* Getter of the property is a `get` method declared alongside the property.
*/
public interface Getter<out R> : Accessor<R>, KFunction<R>
}
/**
* Represents a property declared as a `var`.
*/
public interface KMutableProperty<R> : KProperty<R> {
/** The setter of this mutable property, used to change the value of the property. */
public val setter: Setter<R>
/**
* Setter of the property is a `set` method declared alongside the property.
*/
public interface Setter<R> : KProperty.Accessor<R>, KFunction<Unit>
}
/**
* Represents a property without any kind of receiver.
* Such property is either originally declared in a receiverless context such as a package,
* or has the receiver bound to it.
*/
public interface KProperty0<out R> : KProperty<R>, () -> R {
/**
* Returns the current value of the property.
*/
public fun get(): R
/**
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
* for more information.
*/
@SinceKotlin("1.1")
public fun getDelegate(): Any?
override val getter: Getter<R>
/**
* Getter of the property is a `get` method declared alongside the property.
*
* Can be used as a function that takes 0 arguments and returns the value of the property type [R].
*/
public interface Getter<out R> : KProperty.Getter<R>, () -> R
}
/**
* Represents a `var`-property without any kind of receiver.
*/
public interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
/**
* Modifies the value of the property.
*
* @param value the new value to be assigned to this property.
*/
public fun set(value: R)
override val setter: Setter<R>
/**
* Setter of the property is a `set` method declared alongside the property.
*
* Can be used as a function that takes new property value as an argument and returns [Unit].
*/
public interface Setter<R> : KMutableProperty.Setter<R>, (R) -> Unit
}
/**
* Represents a property, operations on which take one receiver as a parameter.
*
* @param T the type of the receiver which should be used to obtain the value of the property.
* @param R the type of the property.
*/
public interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
/**
* Returns the current value of the property.
*
* @param receiver the receiver which is used to obtain the value of the property.
* For example, it should be a class instance if this is a member property of that class,
* or an extension receiver if this is a top level extension property.
*/
public fun get(receiver: T): R
/**
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
* for more information.
*
* Note that for a top level **extension** property, the delegate is the same for all extension receivers,
* so the [receiver] instance passed in is not going to make any difference, it must only be a value of [T].
*
* @param receiver the receiver which is used to obtain the value of the property delegate.
* For example, it should be a class instance if this is a member property of that class,
* or an extension receiver if this is a top level extension property.
*
* @see [kotlin.reflect.full.getExtensionDelegate] // [KProperty1.getExtensionDelegate]
*/
@SinceKotlin("1.1")
public fun getDelegate(receiver: T): Any?
override val getter: Getter<T, R>
/**
* Getter of the property is a `get` method declared alongside the property.
*
* Can be used as a function that takes an argument of type [T] (the receiver) and returns the value of the property type [R].
*/
public interface Getter<T, out R> : KProperty.Getter<R>, (T) -> R
}
/**
* Represents a `var`-property, operations on which take one receiver as a parameter.
*/
public interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R> {
/**
* Modifies the value of the property.
*
* @param receiver the receiver which is used to modify the value of the property.
* For example, it should be a class instance if this is a member property of that class,
* or an extension receiver if this is a top level extension property.
* @param value the new value to be assigned to this property.
*/
public fun set(receiver: T, value: R)
override val setter: Setter<T, R>
/**
* Setter of the property is a `set` method declared alongside the property.
*
* Can be used as a function that takes the receiver and the new property value as arguments and returns [Unit].
*/
public interface Setter<T, R> : KMutableProperty.Setter<R>, (T, R) -> Unit
}
/**
* Represents a property, operations on which take two receivers as parameters,
* such as an extension property declared in a class.
*
* @param D the type of the first receiver. In case of the extension property in a class this is
* the type of the declaring class of the property, or any subclass of that class.
* @param E the type of the second receiver. In case of the extension property in a class this is
* the type of the extension receiver.
* @param R the type of the property.
*/
public interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
/**
* Returns the current value of the property. In case of the extension property in a class,
* the instance of the class should be passed first and the instance of the extension receiver second.
*
* @param receiver1 the instance of the first receiver.
* @param receiver2 the instance of the second receiver.
*/
public fun get(receiver1: D, receiver2: E): R
/**
* Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/delegated-properties.html)
* for more information.
*
* In case of the extension property in a class, the instance of the class should be passed first
* and the instance of the extension receiver second.
*
* @param receiver1 the instance of the first receiver.
* @param receiver2 the instance of the second receiver.
*
* @see [kotlin.reflect.full.getExtensionDelegate] // [KProperty2.getExtensionDelegate]
*/
@SinceKotlin("1.1")
public fun getDelegate(receiver1: D, receiver2: E): Any?
override val getter: Getter<D, E, R>
/**
* Getter of the property is a `get` method declared alongside the property.
*
* Can be used as a function that takes an argument of type [D] (the first receiver), an argument of type [E] (the second receiver)
* and returns the value of the property type [R].
*/
public interface Getter<D, E, out R> : KProperty.Getter<R>, (D, E) -> R
}
/**
* Represents a `var`-property, operations on which take two receivers as parameters.
*/
public interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
/**
* Modifies the value of the property.
*
* @param receiver1 the instance of the first receiver.
* @param receiver2 the instance of the second receiver.
* @param value the new value to be assigned to this property.
*/
public fun set(receiver1: D, receiver2: E, value: R)
override val setter: Setter<D, E, R>
/**
* Setter of the property is a `set` method declared alongside the property.
*
* Can be used as a function that takes an argument of type [D] (the first receiver), an argument of type [E] (the second receiver),
* and the new property value and returns [Unit].
*/
public interface Setter<D, E, R> : KMutableProperty.Setter<R>, (D, E, R) -> Unit
}
@@ -1,104 +0,0 @@
/*
* Copyright 2010-2019 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.reflect
/**
* Represents a type. Type is usually either a class with optional type arguments,
* or a type parameter of some declaration, plus nullability.
*/
public interface KType : KAnnotatedElement {
/**
* The declaration of the classifier used in this type.
* For example, in the type `List<String>` the classifier would be the [KClass] instance for [List].
*
* Returns `null` if this type is not denotable in Kotlin, for example if it is an intersection type.
*/
@SinceKotlin("1.1")
public val classifier: KClassifier?
/**
* Type arguments passed for the parameters of the classifier in this type.
* For example, in the type `Array<out Number>` the only type argument is `out Number`.
*
* In case this type is based on an inner class, the returned list contains the type arguments provided for the innermost class first,
* then its outer class, and so on.
* For example, in the type `Outer<A, B>.Inner<C, D>` the returned list is `[C, D, A, B]`.
*/
@SinceKotlin("1.1")
public val arguments: List<KTypeProjection>
/**
* `true` if this type was marked nullable in the source code.
*
* For Kotlin types, it means that `null` value is allowed to be represented by this type.
* In practice it means that the type was declared with a question mark at the end.
* For non-Kotlin types, it means the type or the symbol which was declared with this type
* is annotated with a runtime-retained nullability annotation such as [javax.annotation.Nullable].
*
* Note that even if [isMarkedNullable] is false, values of the type can still be `null`.
* This may happen if it is a type of the type parameter with a nullable upper bound:
*
* ```
* fun <T> foo(t: T) {
* // isMarkedNullable == false for t's type, but t can be null here when T = "Any?"
* }
* ```
*/
public val isMarkedNullable: Boolean
}
/**
* Represents a type projection. Type projection is usually the argument to another type in a type usage.
* For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`.
*
* Type projection is either the star projection, or an entity consisting of a specific type plus optional variance.
*
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#type-projections)
* for more information.
*/
@SinceKotlin("1.1")
public data class KTypeProjection constructor(
/**
* The use-site variance specified in the projection, or `null` if this is a star projection.
*/
public val variance: KVariance?,
/**
* The type specified in the projection, or `null` if this is a star projection.
*/
public val type: KType?
) {
public companion object {
/**
* Star projection, denoted by the `*` character.
* For example, in the type `KClass<*>`, `*` is the star projection.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#star-projections)
* for more information.
*/
public val STAR: KTypeProjection = KTypeProjection(null, null)
/**
* Creates an invariant projection of a given type. Invariant projection is just the type itself,
* without any use-site variance modifiers applied to it.
* For example, in the type `Set<String>`, `String` is an invariant projection of the type represented by the class `String`.
*/
public fun invariant(type: KType): KTypeProjection =
KTypeProjection(KVariance.INVARIANT, type)
/**
* Creates a contravariant projection of a given type, denoted by the `in` modifier applied to a type.
* For example, in the type `MutableList<in Number>`, `in Number` is a contravariant projection of the type of class `Number`.
*/
public fun contravariant(type: KType): KTypeProjection =
KTypeProjection(KVariance.IN, type)
/**
* Creates a covariant projection of a given type, denoted by the `out` modifier applied to a type.
* For example, in the type `Array<out Number>`, `out Number` is a covariant projection of the type of class `Number`.
*/
public fun covariant(type: KType): KTypeProjection =
KTypeProjection(KVariance.OUT, type)
}
}
@@ -1,40 +0,0 @@
/*
* Copyright 2010-2019 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.reflect
/**
* Represents a declaration of a type parameter of a class or a callable.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#generics)
* for more information.
*/
@SinceKotlin("1.1")
public interface KTypeParameter : KClassifier {
/**
* The name of this type parameter as it was declared in the source code.
*/
public val name: String
/**
* Upper bounds, or generic constraints imposed on this type parameter.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#upper-bounds)
* for more information.
*/
public val upperBounds: List<KType>
/**
* Declaration-site variance of this type parameter.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#declaration-site-variance)
* for more information.
*/
public val variance: KVariance
/**
* `true` if this type parameter is `reified`.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/inline-functions.html#reified-type-parameters)
* for more information.
*/
public val isReified: Boolean
}
@@ -1,45 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect
/**
* Represents variance applied to a type parameter on the declaration site (*declaration-site variance*),
* or to a type in a projection (*use-site variance*).
*
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/generics.html#variance)
* for more information.
*
* @see [KTypeParameter.variance]
* @see [KTypeProjection]
*/
@SinceKotlin("1.1")
enum class KVariance {
/**
* The affected type parameter or type is *invariant*, which means it has no variance applied to it.
*/
INVARIANT,
/**
* The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code.
*/
IN,
/**
* The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code.
*/
OUT,
}
@@ -1,50 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect
/**
* Visibility is an aspect of a Kotlin declaration regulating where that declaration is accessible in the source code.
* Visibility can be changed with one of the following modifiers: `public`, `protected`, `internal`, `private`.
*
* Note that some Java visibilities such as package-private and protected (which also gives access to items from the same package)
* cannot be represented in Kotlin, so there's no [KVisibility] value corresponding to them.
*
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/visibility-modifiers.html)
* for more information.
*/
@SinceKotlin("1.1")
enum class KVisibility {
/**
* Visibility of declarations marked with the `public` modifier, or with no modifier at all.
*/
PUBLIC,
/**
* Visibility of declarations marked with the `protected` modifier.
*/
PROTECTED,
/**
* Visibility of declarations marked with the `internal` modifier.
*/
INTERNAL,
/**
* Visibility of declarations marked with the `private` modifier.
*/
PRIVATE,
}
@@ -1,397 +0,0 @@
/*
* Copyright 2010-2019 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.
*/
@file:ExcludedFromCodegen
@file:Suppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY", "unused")
package kotlin.wasm.internal
@WasmInstruction(WasmInstruction.UNREACHABLE)
external fun wasm_unreachable(): Nothing
@WasmInstruction(WasmInstruction.I32_EQZ)
external fun wasm_i32_eqz(a: Int): Int
@WasmInstruction(WasmInstruction.I32_EQ)
external fun wasm_i32_eq(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_NE)
external fun wasm_i32_ne(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_LT_S)
external fun wasm_i32_lt_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_LT_U)
external fun wasm_i32_lt_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_GT_S)
external fun wasm_i32_gt_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_GT_U)
external fun wasm_i32_gt_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_LE_S)
external fun wasm_i32_le_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_LE_U)
external fun wasm_i32_le_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_GE_S)
external fun wasm_i32_ge_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_GE_U)
external fun wasm_i32_ge_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I64_EQZ)
external fun wasm_i64_eqz(a: Long): Int
@WasmInstruction(WasmInstruction.I64_EQ)
external fun wasm_i64_eq(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_NE)
external fun wasm_i64_ne(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_LT_S)
external fun wasm_i64_lt_s(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_LT_U)
external fun wasm_i64_lt_u(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_GT_S)
external fun wasm_i64_gt_s(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_GT_U)
external fun wasm_i64_gt_u(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_LE_S)
external fun wasm_i64_le_s(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_LE_U)
external fun wasm_i64_le_u(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_GE_S)
external fun wasm_i64_ge_s(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.I64_GE_U)
external fun wasm_i64_ge_u(a: Long, b: Long): Int
@WasmInstruction(WasmInstruction.F32_EQ)
external fun wasm_f32_eq(a: Float, b: Float): Int
@WasmInstruction(WasmInstruction.F32_NE)
external fun wasm_f32_ne(a: Float, b: Float): Int
@WasmInstruction(WasmInstruction.F32_LT)
external fun wasm_f32_lt(a: Float, b: Float): Int
@WasmInstruction(WasmInstruction.F32_GT)
external fun wasm_f32_gt(a: Float, b: Float): Int
@WasmInstruction(WasmInstruction.F32_LE)
external fun wasm_f32_le(a: Float, b: Float): Int
@WasmInstruction(WasmInstruction.F32_GE)
external fun wasm_f32_ge(a: Float, b: Float): Int
@WasmInstruction(WasmInstruction.F64_EQ)
external fun wasm_f64_eq(a: Double, b: Double): Int
@WasmInstruction(WasmInstruction.F64_NE)
external fun wasm_f64_ne(a: Double, b: Double): Int
@WasmInstruction(WasmInstruction.F64_LT)
external fun wasm_f64_lt(a: Double, b: Double): Int
@WasmInstruction(WasmInstruction.F64_GT)
external fun wasm_f64_gt(a: Double, b: Double): Int
@WasmInstruction(WasmInstruction.F64_LE)
external fun wasm_f64_le(a: Double, b: Double): Int
@WasmInstruction(WasmInstruction.F64_GE)
external fun wasm_f64_ge(a: Double, b: Double): Int
@WasmInstruction(WasmInstruction.I32_CLZ)
external fun wasm_i32_clz(a: Int): Int
@WasmInstruction(WasmInstruction.I32_CTZ)
external fun wasm_i32_ctz(a: Int): Int
@WasmInstruction(WasmInstruction.I32_POPCNT)
external fun wasm_i32_popcnt(a: Int): Int
@WasmInstruction(WasmInstruction.I32_ADD)
external fun wasm_i32_add(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_SUB)
external fun wasm_i32_sub(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_MUL)
external fun wasm_i32_mul(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_DIV_S)
external fun wasm_i32_div_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_DIV_U)
external fun wasm_i32_div_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_REM_S)
external fun wasm_i32_rem_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_REM_U)
external fun wasm_i32_rem_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_AND)
external fun wasm_i32_and(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_OR)
external fun wasm_i32_or(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_XOR)
external fun wasm_i32_xor(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_SHL)
external fun wasm_i32_shl(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_SHR_S)
external fun wasm_i32_shr_s(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_SHR_U)
external fun wasm_i32_shr_u(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_ROTL)
external fun wasm_i32_rotl(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I32_ROTR)
external fun wasm_i32_rotr(a: Int, b: Int): Int
@WasmInstruction(WasmInstruction.I64_CLZ)
external fun wasm_i64_clz(a: Long): Long
@WasmInstruction(WasmInstruction.I64_CTZ)
external fun wasm_i64_ctz(a: Long): Long
@WasmInstruction(WasmInstruction.I64_POPCNT)
external fun wasm_i64_popcnt(a: Long): Long
@WasmInstruction(WasmInstruction.I64_ADD)
external fun wasm_i64_add(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_SUB)
external fun wasm_i64_sub(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_MUL)
external fun wasm_i64_mul(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_DIV_S)
external fun wasm_i64_div_s(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_DIV_U)
external fun wasm_i64_div_u(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_REM_S)
external fun wasm_i64_rem_s(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_REM_U)
external fun wasm_i64_rem_u(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_AND)
external fun wasm_i64_and(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_OR)
external fun wasm_i64_or(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_XOR)
external fun wasm_i64_xor(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_SHL)
external fun wasm_i64_shl(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_SHR_S)
external fun wasm_i64_shr_s(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_SHR_U)
external fun wasm_i64_shr_u(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_ROTL)
external fun wasm_i64_rotl(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.I64_ROTR)
external fun wasm_i64_rotr(a: Long, b: Long): Long
@WasmInstruction(WasmInstruction.F32_ABS)
external fun wasm_f32_abs(a: Float): Float
@WasmInstruction(WasmInstruction.F32_NEG)
external fun wasm_f32_neg(a: Float): Float
@WasmInstruction(WasmInstruction.F32_CEIL)
external fun wasm_f32_ceil(a: Float): Float
@WasmInstruction(WasmInstruction.F32_FLOOR)
external fun wasm_f32_floor(a: Float): Float
@WasmInstruction(WasmInstruction.F32_TRUNC)
external fun wasm_f32_trunc(a: Float): Float
@WasmInstruction(WasmInstruction.F32_NEAREST)
external fun wasm_f32_nearest(a: Float): Float
@WasmInstruction(WasmInstruction.F32_SQRT)
external fun wasm_f32_sqrt(a: Float): Float
@WasmInstruction(WasmInstruction.F32_ADD)
external fun wasm_f32_add(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F32_SUB)
external fun wasm_f32_sub(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F32_MUL)
external fun wasm_f32_mul(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F32_DIV)
external fun wasm_f32_div(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F32_FMIN)
external fun wasm_f32_fmin(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F32_FMAX)
external fun wasm_f32_fmax(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F32_COPYSIGN)
external fun wasm_f32_copysign(a: Float, b: Float): Float
@WasmInstruction(WasmInstruction.F64_ABS)
external fun wasm_f64_abs(a: Double): Double
@WasmInstruction(WasmInstruction.F64_NEG)
external fun wasm_f64_neg(a: Double): Double
@WasmInstruction(WasmInstruction.F64_CEIL)
external fun wasm_f64_ceil(a: Double): Double
@WasmInstruction(WasmInstruction.F64_FLOOR)
external fun wasm_f64_floor(a: Double): Double
@WasmInstruction(WasmInstruction.F64_TRUNC)
external fun wasm_f64_trunc(a: Double): Double
@WasmInstruction(WasmInstruction.F64_NEAREST)
external fun wasm_f64_nearest(a: Double): Double
@WasmInstruction(WasmInstruction.F64_SQRT)
external fun wasm_f64_sqrt(a: Double): Double
@WasmInstruction(WasmInstruction.F64_ADD)
external fun wasm_f64_add(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.F64_SUB)
external fun wasm_f64_sub(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.F64_MUL)
external fun wasm_f64_mul(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.F64_DIV)
external fun wasm_f64_div(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.F64_FMIN)
external fun wasm_f64_fmin(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.F64_FMAX)
external fun wasm_f64_fmax(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.F64_COPYSIGN)
external fun wasm_f64_copysign(a: Double, b: Double): Double
@WasmInstruction(WasmInstruction.I32_WRAP_I64)
external fun wasm_i32_wrap_i64(a: Long): Int
@WasmInstruction(WasmInstruction.I32_TRUNC_F32_S)
external fun wasm_i32_trunc_f32_s(a: Float): Int
@WasmInstruction(WasmInstruction.I32_TRUNC_F32_U)
external fun wasm_i32_trunc_f32_u(a: Float): Int
@WasmInstruction(WasmInstruction.I32_TRUNC_F64_S)
external fun wasm_i32_trunc_f64_s(a: Double): Int
@WasmInstruction(WasmInstruction.I32_TRUNC_F64_U)
external fun wasm_i32_trunc_f64_u(a: Double): Int
@WasmInstruction(WasmInstruction.I64_EXTEND_I32_S)
external fun wasm_i64_extend_i32_s(a: Int): Long
@WasmInstruction(WasmInstruction.I64_EXTEND_I32_U)
external fun wasm_i64_extend_i32_u(a: Int): Long
@WasmInstruction(WasmInstruction.I64_TRUNC_F32_S)
external fun wasm_i64_trunc_f32_s(a: Float): Long
@WasmInstruction(WasmInstruction.I64_TRUNC_F32_U)
external fun wasm_i64_trunc_f32_u(a: Float): Long
@WasmInstruction(WasmInstruction.I64_TRUNC_F64_S)
external fun wasm_i64_trunc_f64_s(a: Double): Long
@WasmInstruction(WasmInstruction.I64_TRUNC_F64_U)
external fun wasm_i64_trunc_f64_u(a: Double): Long
@WasmInstruction(WasmInstruction.F32_CONVERT_I32_S)
external fun wasm_f32_convert_i32_s(a: Int): Float
@WasmInstruction(WasmInstruction.F32_CONVERT_I32_U)
external fun wasm_f32_convert_i32_u(a: Int): Float
@WasmInstruction(WasmInstruction.F32_CONVERT_I64_S)
external fun wasm_f32_convert_i64_s(a: Long): Float
@WasmInstruction(WasmInstruction.F32_CONVERT_I64_U)
external fun wasm_f32_convert_i64_u(a: Long): Float
@WasmInstruction(WasmInstruction.F32_DEMOTE_F64)
external fun wasm_f32_demote_f64(a: Double): Float
@WasmInstruction(WasmInstruction.F64_CONVERT_I32_S)
external fun wasm_f64_convert_i32_s(a: Int): Double
@WasmInstruction(WasmInstruction.F64_CONVERT_I32_U)
external fun wasm_f64_convert_i32_u(a: Int): Double
@WasmInstruction(WasmInstruction.F64_CONVERT_I64_S)
external fun wasm_f64_convert_i64_s(a: Long): Double
@WasmInstruction(WasmInstruction.F64_CONVERT_I64_U)
external fun wasm_f64_convert_i64_u(a: Long): Double
@WasmInstruction(WasmInstruction.F64_PROMOTE_F32)
external fun wasm_f64_promote_f32(a: Float): Double
@WasmInstruction(WasmInstruction.I32_REINTERPRET_F32)
external fun wasm_i32_reinterpret_f32(a: Float): Int
@WasmInstruction(WasmInstruction.I64_REINTERPRET_F64)
external fun wasm_i64_reinterpret_f64(a: Double): Long
@WasmInstruction(WasmInstruction.F32_REINTERPRET_I32)
external fun wasm_f32_reinterpret_i32(a: Int): Float
@WasmInstruction(WasmInstruction.F32_CONST_NAN)
external fun wasm_f32_const_nan(): Float
@WasmInstruction(WasmInstruction.F32_CONST_PLUS_INF)
external fun wasm_f32_const_plus_inf(): Float
@WasmInstruction(WasmInstruction.F32_CONST_MINUS_INF)
external fun wasm_f32_const_minus_inf(): Float
@WasmInstruction(WasmInstruction.F64_CONST_NAN)
external fun wasm_f64_const_nan(): Double
@WasmInstruction(WasmInstruction.F64_CONST_PLUS_INF)
external fun wasm_f64_const_plus_inf(): Float
@WasmInstruction(WasmInstruction.F64_CONST_MINUS_INF)
external fun wasm_f64_const_minus_inf(): Float
@@ -1,20 +0,0 @@
/*
* Copyright 2010-2019 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.wasm.internal
// `compareTo(x, y)` implemented as `(x >= y) - (x <= y)`
fun wasm_i32_compareTo(x: Int, y: Int): Int =
wasm_i32_ge_s(x, y) - wasm_i32_le_s(x, y)
fun wasm_i64_compareTo(x: Long, y: Long): Int =
wasm_i64_ge_s(x, y) - wasm_i64_le_s(x, y)
fun wasm_f32_compareTo(x: Float, y: Float): Int =
wasm_f32_ge(x, y) - wasm_f32_le(x, y)
fun wasm_f64_compareTo(x: Double, y: Double): Int =
wasm_f64_ge(x, y) - wasm_f64_le(x, y)
@@ -3,12 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.wasm.internal.ExcludedFromCodegen
package kotlin.wasm.internal
package kotlin.ranges
// Stubs for unimplemented classes used by CommonBackendContext
class CharProgression
class IntProgression
class LongProgression
internal object DefaultConstructorMarker
@@ -0,0 +1,341 @@
/*
* 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.
*/
@file:Suppress("unused")
package kotlin.wasm.internal
/** A function that takes 0 arguments. */
public interface Function0<out R> : Function<R> {
/** Invokes the function. */
public operator fun invoke(): R
}
/** A function that takes 1 argument. */
public interface Function1<in P1, out R> : Function<R> {
/** Invokes the function with the specified argument. */
public operator fun invoke(p1: P1): R
}
/** A function that takes 2 arguments. */
public interface Function2<in P1, in P2, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2): R
}
/** A function that takes 3 arguments. */
public interface Function3<in P1, in P2, in P3, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3): R
}
/** A function that takes 4 arguments. */
public interface Function4<in P1, in P2, in P3, in P4, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R
}
/** A function that takes 5 arguments. */
public interface Function5<in P1, in P2, in P3, in P4, in P5, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R
}
/** A function that takes 6 arguments. */
public interface Function6<in P1, in P2, in P3, in P4, in P5, in P6, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R
}
/** A function that takes 7 arguments. */
public interface Function7<in P1, in P2, in P3, in P4, in P5, in P6, in P7, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R
}
/** A function that takes 8 arguments. */
public interface Function8<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R
}
/** A function that takes 9 arguments. */
public interface Function9<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R
}
/** A function that takes 10 arguments. */
public interface Function10<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R
}
/** A function that takes 11 arguments. */
public interface Function11<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R
}
/** A function that takes 12 arguments. */
public interface Function12<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, out R> : Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R
}
/** A function that takes 13 arguments. */
public interface Function13<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13
): R
}
/** A function that takes 14 arguments. */
public interface Function14<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14
): R
}
/** A function that takes 15 arguments. */
public interface Function15<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15
): R
}
/** A function that takes 16 arguments. */
public interface Function16<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16
): R
}
/** A function that takes 17 arguments. */
public interface Function17<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16,
p17: P17
): R
}
/** A function that takes 18 arguments. */
public interface Function18<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16,
p17: P17,
p18: P18
): R
}
/** A function that takes 19 arguments. */
public interface Function19<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16,
p17: P17,
p18: P18,
p19: P19
): R
}
/** A function that takes 20 arguments. */
public interface Function20<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16,
p17: P17,
p18: P18,
p19: P19,
p20: P20
): R
}
/** A function that takes 21 arguments. */
public interface Function21<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16,
p17: P17,
p18: P18,
p19: P19,
p20: P20,
p21: P21
): R
}
/** A function that takes 22 arguments. */
public interface Function22<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, in P22, out R> :
Function<R> {
/** Invokes the function with the specified arguments. */
public operator fun invoke(
p1: P1,
p2: P2,
p3: P3,
p4: P4,
p5: P5,
p6: P6,
p7: P7,
p8: P8,
p9: P9,
p10: P10,
p11: P11,
p12: P12,
p13: P13,
p14: P14,
p15: P15,
p16: P16,
p17: P17,
p18: P18,
p19: P19,
p20: P20,
p21: P21,
p22: P22
): R
}
@@ -0,0 +1,153 @@
/*
* 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.wasm.internal
@ExcludedFromCodegen
@WasmForeign
internal class WasmExternRef
@WasmImport("runtime", "JsArray_new")
internal fun JsArray_new(size: Int): WasmExternRef =
implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Byte(array: WasmExternRef, index: Int): Byte = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Byte(array: WasmExternRef, index: Int, value: Byte): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Char(array: WasmExternRef, index: Int): Char = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Char(array: WasmExternRef, index: Int, value: Char): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Short(array: WasmExternRef, index: Int): Short = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Short(array: WasmExternRef, index: Int, value: Short): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Int(array: WasmExternRef, index: Int): Int = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Int(array: WasmExternRef, index: Int, value: Int): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Long(array: WasmExternRef, index: Int): Long = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Long(array: WasmExternRef, index: Int, value: Long): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Float(array: WasmExternRef, index: Int): Float = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Float(array: WasmExternRef, index: Int, value: Float): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Double(array: WasmExternRef, index: Int): Double = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Double(array: WasmExternRef, index: Int, value: Double): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_Boolean(array: WasmExternRef, index: Int): Boolean = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_Boolean(array: WasmExternRef, index: Int, value: Boolean): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_get")
internal fun JsArray_get_WasmExternRef(array: WasmExternRef, index: Int): WasmExternRef = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_set")
internal fun JsArray_set_WasmExternRef(array: WasmExternRef, index: Int, value: WasmExternRef): Unit = implementedAsIntrinsic
@WasmImport("runtime", "JsArray_getSize")
internal fun JsArray_getSize(array: WasmExternRef): Int =
implementedAsIntrinsic
@WasmImport("runtime", "identity")
internal fun Any?.toWasmExternRef(): WasmExternRef =
implementedAsIntrinsic
@WasmImport("runtime", "identity")
internal fun WasmExternRefToAny(ref: WasmExternRef): Any? =
implementedAsIntrinsic
internal inline fun JsArray_fill_Byte(array: WasmExternRef, size: Int, init: (Int) -> Byte) {
var i = 0
while (i < size) {
JsArray_set_Byte(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Char(array: WasmExternRef, size: Int, init: (Int) -> Char) {
var i = 0
while (i < size) {
JsArray_set_Char(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Short(array: WasmExternRef, size: Int, init: (Int) -> Short) {
var i = 0
while (i < size) {
JsArray_set_Short(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Int(array: WasmExternRef, size: Int, init: (Int) -> Int) {
var i = 0
while (i < size) {
JsArray_set_Int(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Long(array: WasmExternRef, size: Int, init: (Int) -> Long) {
var i = 0
while (i < size) {
JsArray_set_Long(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Float(array: WasmExternRef, size: Int, init: (Int) -> Float) {
var i = 0
while (i < size) {
JsArray_set_Float(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Double(array: WasmExternRef, size: Int, init: (Int) -> Double) {
var i = 0
while (i < size) {
JsArray_set_Double(array, i, init(i))
i++
}
}
internal inline fun JsArray_fill_Boolean(array: WasmExternRef, size: Int, init: (Int) -> Boolean) {
var i = 0
while (i < size) {
JsArray_set_Boolean(array, i, init(i))
i++
}
}
internal inline fun <T> JsArray_fill_T(array: WasmExternRef, size: Int, init: (Int) -> T) {
var i = 0
while (i < size) {
JsArray_set_WasmExternRef(array, i, init(i).toWasmExternRef())
i++
}
}
@@ -0,0 +1,50 @@
/*
* 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.wasm.internal
@WasmImport("runtime", "String_getLiteral")
internal fun stringLiteral(index: Int): String =
implementedAsIntrinsic
@WasmReinterpret
internal fun unsafeNotNull(x: Any?): Any =
implementedAsIntrinsic
internal fun nullableEquals(lhs: Any?, rhs: Any?): Boolean {
if (wasm_ref_is_null(lhs))
return wasm_ref_is_null(rhs)
return unsafeNotNull(lhs).equals(rhs)
}
internal fun anyNtoString(x: Any?): String = x.toString()
internal fun nullableFloatIeee754Equals(lhs: Float?, rhs: Float?): Boolean {
if (lhs == null) return rhs == null
if (rhs == null) return false
return wasm_f32_eq(lhs, rhs)
}
internal fun nullableDoubleIeee754Equals(lhs: Double?, rhs: Double?): Boolean {
if (lhs == null) return rhs == null
if (rhs == null) return false
return wasm_f64_eq(lhs, rhs)
}
internal fun <T : Any> ensureNotNull(v: T?): T = if (v == null) THROW_NPE() else v
@ExcludedFromCodegen
internal fun <T, R> boxIntrinsic(x: T): R =
implementedAsIntrinsic
@ExcludedFromCodegen
internal fun <T, R> unboxIntrinsic(x: T): R =
implementedAsIntrinsic
internal fun wasmThrow(e: Throwable): Nothing {
println("Kotlin/Wasm exception wasm thrown: ${e.message}")
wasm_unreachable()
}
@@ -0,0 +1,27 @@
/*
* 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.wasm.internal
internal fun THROW_CCE(): Nothing {
throw ClassCastException()
}
internal fun THROW_NPE(): Nothing {
throw NullPointerException()
}
internal fun THROW_ISE(): Nothing {
throw IllegalStateException()
}
internal fun THROW_IAE(): Nothing {
throw IllegalArgumentException()
}
@PublishedApi
internal fun throwUninitializedPropertyAccessException(name: String): Nothing {
throw UninitializedPropertyAccessException("lateinit property $name has not been initialized")
}
@@ -0,0 +1,83 @@
/*
* 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.
*/
@file:Suppress("unused") // Used by compiler
package kotlin.wasm.internal
internal const val TYPE_INFO_ELEMENT_SIZE = 4
internal const val TYPE_INFO_VTABLE_OFFSET = 2 * TYPE_INFO_ELEMENT_SIZE
internal const val TYPE_INFO_VTABLE_LENGTH_OFFSET = TYPE_INFO_ELEMENT_SIZE
internal const val SUPER_CLASS_ID_OFFSET = 0
internal fun getVtablePtr(obj: Any): Int =
obj.typeInfo + TYPE_INFO_VTABLE_OFFSET
internal fun getVtableLength(obj: Any): Int =
wasm_i32_load(obj.typeInfo + TYPE_INFO_VTABLE_LENGTH_OFFSET)
internal fun getInterfaceListLength(obj: Any): Int =
wasm_i32_load(obj.typeInfo + TYPE_INFO_VTABLE_LENGTH_OFFSET)
internal fun getSuperClassId(obj: Any): Int =
wasm_i32_load(obj.typeInfo + SUPER_CLASS_ID_OFFSET)
internal fun getVirtualMethodId(obj: Any, virtualFunctionSlot: Int): Int {
val vtablePtr = getVtablePtr(obj)
val methodIdPtr = vtablePtr + virtualFunctionSlot * TYPE_INFO_ELEMENT_SIZE
return wasm_i32_load(methodIdPtr)
}
internal fun getInterfaceMethodId(obj: Any, methodSignatureId: Int): Int {
val vtableLength = getVtableLength(obj)
val vtableSignatures = getVtablePtr(obj) + vtableLength * TYPE_INFO_ELEMENT_SIZE
var virtualFunctionSlot = 0
while (virtualFunctionSlot < vtableLength) {
if (wasm_i32_load(vtableSignatures + virtualFunctionSlot * TYPE_INFO_ELEMENT_SIZE) == methodSignatureId) {
return getVirtualMethodId(obj, virtualFunctionSlot)
}
virtualFunctionSlot++
}
wasm_unreachable()
}
internal fun isSubClassOfImpl(currentClassId: Int, otherClassId: Int): Boolean {
if (currentClassId == otherClassId) return true
val anyClassId = wasmClassId<Any>()
if (currentClassId == anyClassId && otherClassId != anyClassId) return false
return isSubClassOfImpl(wasm_i32_load(currentClassId + SUPER_CLASS_ID_OFFSET), otherClassId)
}
internal fun isSubClass(obj: Any, classId: Int): Boolean {
return isSubClassOfImpl(obj.typeInfo, classId)
}
internal fun isInterface(obj: Any, interfaceId: Int): Boolean {
val vtableLength = getVtableLength(obj)
val interfaceListSizePtr = getVtablePtr(obj) + 2 * vtableLength * TYPE_INFO_ELEMENT_SIZE
val interfaceListPtr = interfaceListSizePtr + TYPE_INFO_ELEMENT_SIZE
val interfaceListSize = wasm_i32_load(interfaceListSizePtr)
var interfaceSlot = 0
while (interfaceSlot < interfaceListSize) {
val supportedInterface = wasm_i32_load(interfaceListPtr + interfaceSlot * TYPE_INFO_ELEMENT_SIZE)
if (supportedInterface == interfaceId) {
return true
}
interfaceSlot++
}
return false
}
@ExcludedFromCodegen
internal fun <T> wasmClassId(): Int =
implementedAsIntrinsic
@ExcludedFromCodegen
internal fun <T> wasmInterfaceId(): Int =
implementedAsIntrinsic
@@ -0,0 +1,46 @@
/*
* 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.wasm.internal
import kotlin.annotation.AnnotationTarget.*
// Exclude declaration or file from lowering and code generation
@Target(FILE, CLASS, FUNCTION, CONSTRUCTOR, PROPERTY)
@Retention(AnnotationRetention.BINARY)
internal annotation class ExcludedFromCodegen
@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmImport(val module: String, val name: String)
@Target(CLASS)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmForeign
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmReinterpret
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmPrimitive
/**
* Replace calls to this functions with specified Wasm instruction.
*
* Operands are passed in the following order:
* 1. Dispatch receiver (if present)
* 2. Extension receiver (if present)
* 3. Value arguments
*
* @mnemonic parameter is an instruction WAT name: "i32.add", "f64.trunc", etc.
*
* Immediate arguments (label, index, offest, align, etc.) are not supported yet.
*/
@ExcludedFromCodegen
internal val implementedAsIntrinsic: Nothing
get() = null!!
@@ -0,0 +1,22 @@
/*
* 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.
*/
@file:ExcludedFromCodegen
@file:Suppress("unused")
package kotlin.wasm.internal
@WasmOp(WasmOp.UNREACHABLE)
internal fun wasm_unreachable(): Nothing =
implementedAsIntrinsic
internal fun wasm_float_nan(): Float =
implementedAsIntrinsic
internal fun wasm_double_nan(): Double =
implementedAsIntrinsic
internal fun <From, To> wasm_ref_cast(a: From): To =
implementedAsIntrinsic
@@ -0,0 +1,18 @@
/*
* 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.wasm.internal
// `compareTo(x, y)` implemented as `(x >= y) - (x <= y)`
fun wasm_i32_compareTo(x: Int, y: Int): Int =
wasm_i32_ge_s(x, y).toInt() - wasm_i32_le_s(x, y).toInt()
fun wasm_i64_compareTo(x: Long, y: Long): Int =
wasm_i64_ge_s(x, y).toInt() - wasm_i64_le_s(x, y).toInt()
@WasmImport("runtime", "String_equals")
fun wasm_string_eq(x: String, y: String): Boolean =
implementedAsIntrinsic
@@ -0,0 +1,514 @@
/*
* 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.
*/
@file:ExcludedFromCodegen
@file:Suppress(
"INLINE_CLASS_IN_EXTERNAL_DECLARATION",
"NON_ABSTRACT_FUNCTION_WITH_NO_BODY",
"unused"
)
package kotlin.wasm.internal
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmOp(val name: String) {
companion object {
const val I32_EQZ = "I32_EQZ"
const val I64_EQZ = "I64_EQZ"
const val I32_CLZ = "I32_CLZ"
const val I32_CTZ = "I32_CTZ"
const val I32_POPCNT = "I32_POPCNT"
const val I64_CLZ = "I64_CLZ"
const val I64_CTZ = "I64_CTZ"
const val I64_POPCNT = "I64_POPCNT"
const val F32_ABS = "F32_ABS"
const val F32_NEG = "F32_NEG"
const val F32_CEIL = "F32_CEIL"
const val F32_FLOOR = "F32_FLOOR"
const val F32_TRUNC = "F32_TRUNC"
const val F32_NEAREST = "F32_NEAREST"
const val F32_SQRT = "F32_SQRT"
const val F64_ABS = "F64_ABS"
const val F64_NEG = "F64_NEG"
const val F64_CEIL = "F64_CEIL"
const val F64_FLOOR = "F64_FLOOR"
const val F64_TRUNC = "F64_TRUNC"
const val F64_NEAREST = "F64_NEAREST"
const val F64_SQRT = "F64_SQRT"
const val I32_WRAP_I64 = "I32_WRAP_I64"
const val I32_TRUNC_F32_S = "I32_TRUNC_F32_S"
const val I32_TRUNC_F32_U = "I32_TRUNC_F32_U"
const val I32_TRUNC_F64_S = "I32_TRUNC_F64_S"
const val I32_TRUNC_F64_U = "I32_TRUNC_F64_U"
const val I64_EXTEND_I32_S = "I64_EXTEND_I32_S"
const val I64_EXTEND_I32_U = "I64_EXTEND_I32_U"
const val I64_TRUNC_F32_S = "I64_TRUNC_F32_S"
const val I64_TRUNC_F32_U = "I64_TRUNC_F32_U"
const val I64_TRUNC_F64_S = "I64_TRUNC_F64_S"
const val I64_TRUNC_F64_U = "I64_TRUNC_F64_U"
const val F32_CONVERT_I32_S = "F32_CONVERT_I32_S"
const val F32_CONVERT_I32_U = "F32_CONVERT_I32_U"
const val F32_CONVERT_I64_S = "F32_CONVERT_I64_S"
const val F32_CONVERT_I64_U = "F32_CONVERT_I64_U"
const val F32_DEMOTE_F64 = "F32_DEMOTE_F64"
const val F64_CONVERT_I32_S = "F64_CONVERT_I32_S"
const val F64_CONVERT_I32_U = "F64_CONVERT_I32_U"
const val F64_CONVERT_I64_S = "F64_CONVERT_I64_S"
const val F64_CONVERT_I64_U = "F64_CONVERT_I64_U"
const val F64_PROMOTE_F32 = "F64_PROMOTE_F32"
const val I32_REINTERPRET_F32 = "I32_REINTERPRET_F32"
const val I64_REINTERPRET_F64 = "I64_REINTERPRET_F64"
const val F32_REINTERPRET_I32 = "F32_REINTERPRET_I32"
const val F64_REINTERPRET_I64 = "F64_REINTERPRET_I64"
const val I32_EXTEND8_S = "I32_EXTEND8_S"
const val I32_EXTEND16_S = "I32_EXTEND16_S"
const val I64_EXTEND8_S = "I64_EXTEND8_S"
const val I64_EXTEND16_S = "I64_EXTEND16_S"
const val I64_EXTEND32_S = "I64_EXTEND32_S"
const val I32_TRUNC_SAT_F32_S = "I32_TRUNC_SAT_F32_S"
const val I32_TRUNC_SAT_F32_U = "I32_TRUNC_SAT_F32_U"
const val I32_TRUNC_SAT_F64_S = "I32_TRUNC_SAT_F64_S"
const val I32_TRUNC_SAT_F64_U = "I32_TRUNC_SAT_F64_U"
const val I64_TRUNC_SAT_F32_S = "I64_TRUNC_SAT_F32_S"
const val I64_TRUNC_SAT_F32_U = "I64_TRUNC_SAT_F32_U"
const val I64_TRUNC_SAT_F64_S = "I64_TRUNC_SAT_F64_S"
const val I64_TRUNC_SAT_F64_U = "I64_TRUNC_SAT_F64_U"
const val I32_EQ = "I32_EQ"
const val I32_NE = "I32_NE"
const val I32_LT_S = "I32_LT_S"
const val I32_LT_U = "I32_LT_U"
const val I32_GT_S = "I32_GT_S"
const val I32_GT_U = "I32_GT_U"
const val I32_LE_S = "I32_LE_S"
const val I32_LE_U = "I32_LE_U"
const val I32_GE_S = "I32_GE_S"
const val I32_GE_U = "I32_GE_U"
const val I64_EQ = "I64_EQ"
const val I64_NE = "I64_NE"
const val I64_LT_S = "I64_LT_S"
const val I64_LT_U = "I64_LT_U"
const val I64_GT_S = "I64_GT_S"
const val I64_GT_U = "I64_GT_U"
const val I64_LE_S = "I64_LE_S"
const val I64_LE_U = "I64_LE_U"
const val I64_GE_S = "I64_GE_S"
const val I64_GE_U = "I64_GE_U"
const val F32_EQ = "F32_EQ"
const val F32_NE = "F32_NE"
const val F32_LT = "F32_LT"
const val F32_GT = "F32_GT"
const val F32_LE = "F32_LE"
const val F32_GE = "F32_GE"
const val F64_EQ = "F64_EQ"
const val F64_NE = "F64_NE"
const val F64_LT = "F64_LT"
const val F64_GT = "F64_GT"
const val F64_LE = "F64_LE"
const val F64_GE = "F64_GE"
const val I32_ADD = "I32_ADD"
const val I32_SUB = "I32_SUB"
const val I32_MUL = "I32_MUL"
const val I32_DIV_S = "I32_DIV_S"
const val I32_DIV_U = "I32_DIV_U"
const val I32_REM_S = "I32_REM_S"
const val I32_REM_U = "I32_REM_U"
const val I32_AND = "I32_AND"
const val I32_OR = "I32_OR"
const val I32_XOR = "I32_XOR"
const val I32_SHL = "I32_SHL"
const val I32_SHR_S = "I32_SHR_S"
const val I32_SHR_U = "I32_SHR_U"
const val I32_ROTL = "I32_ROTL"
const val I32_ROTR = "I32_ROTR"
const val I64_ADD = "I64_ADD"
const val I64_SUB = "I64_SUB"
const val I64_MUL = "I64_MUL"
const val I64_DIV_S = "I64_DIV_S"
const val I64_DIV_U = "I64_DIV_U"
const val I64_REM_S = "I64_REM_S"
const val I64_REM_U = "I64_REM_U"
const val I64_AND = "I64_AND"
const val I64_OR = "I64_OR"
const val I64_XOR = "I64_XOR"
const val I64_SHL = "I64_SHL"
const val I64_SHR_S = "I64_SHR_S"
const val I64_SHR_U = "I64_SHR_U"
const val I64_ROTL = "I64_ROTL"
const val I64_ROTR = "I64_ROTR"
const val F32_ADD = "F32_ADD"
const val F32_SUB = "F32_SUB"
const val F32_MUL = "F32_MUL"
const val F32_DIV = "F32_DIV"
const val F32_MIN = "F32_MIN"
const val F32_MAX = "F32_MAX"
const val F32_COPYSIGN = "F32_COPYSIGN"
const val F64_ADD = "F64_ADD"
const val F64_SUB = "F64_SUB"
const val F64_MUL = "F64_MUL"
const val F64_DIV = "F64_DIV"
const val F64_MIN = "F64_MIN"
const val F64_MAX = "F64_MAX"
const val F64_COPYSIGN = "F64_COPYSIGN"
const val I32_CONST = "I32_CONST"
const val I64_CONST = "I64_CONST"
const val F32_CONST = "F32_CONST"
const val F64_CONST = "F64_CONST"
const val I32_LOAD = "I32_LOAD"
const val I64_LOAD = "I64_LOAD"
const val F32_LOAD = "F32_LOAD"
const val F64_LOAD = "F64_LOAD"
const val I32_LOAD8_S = "I32_LOAD8_S"
const val I32_LOAD8_U = "I32_LOAD8_U"
const val I32_LOAD16_S = "I32_LOAD16_S"
const val I32_LOAD16_U = "I32_LOAD16_U"
const val I64_LOAD8_S = "I64_LOAD8_S"
const val I64_LOAD8_U = "I64_LOAD8_U"
const val I64_LOAD16_S = "I64_LOAD16_S"
const val I64_LOAD16_U = "I64_LOAD16_U"
const val I64_LOAD32_S = "I64_LOAD32_S"
const val I64_LOAD32_U = "I64_LOAD32_U"
const val I32_STORE = "I32_STORE"
const val I64_STORE = "I64_STORE"
const val F32_STORE = "F32_STORE"
const val F64_STORE = "F64_STORE"
const val I32_STORE8 = "I32_STORE8"
const val I32_STORE16 = "I32_STORE16"
const val I64_STORE8 = "I64_STORE8"
const val I64_STORE16 = "I64_STORE16"
const val I64_STORE32 = "I64_STORE32"
const val MEMORY_SIZE = "MEMORY_SIZE"
const val MEMORY_GROW = "MEMORY_GROW"
const val MEMORY_INIT = "MEMORY_INIT"
const val DATA_DROP = "DATA_DROP"
const val MEMORY_COPY = "MEMORY_COPY"
const val MEMORY_FILL = "MEMORY_FILL"
const val TABLE_GET = "TABLE_GET"
const val TABLE_SET = "TABLE_SET"
const val TABLE_GROW = "TABLE_GROW"
const val TABLE_SIZE = "TABLE_SIZE"
const val TABLE_FILL = "TABLE_FILL"
const val TABLE_INIT = "TABLE_INIT"
const val ELEM_DROP = "ELEM_DROP"
const val TABLE_COPY = "TABLE_COPY"
const val UNREACHABLE = "UNREACHABLE"
const val NOP = "NOP"
const val BLOCK = "BLOCK"
const val LOOP = "LOOP"
const val IF = "IF"
const val ELSE = "ELSE"
const val END = "END"
const val BR = "BR"
const val BR_IF = "BR_IF"
const val BR_TABLE = "BR_TABLE"
const val RETURN = "RETURN"
const val CALL = "CALL"
const val CALL_INDIRECT = "CALL_INDIRECT"
const val DROP = "DROP"
const val SELECT = "SELECT"
const val SELECT_TYPED = "SELECT_TYPED"
const val LOCAL_GET = "LOCAL_GET"
const val LOCAL_SET = "LOCAL_SET"
const val LOCAL_TEE = "LOCAL_TEE"
const val GLOBAL_GET = "GLOBAL_GET"
const val GLOBAL_SET = "GLOBAL_SET"
const val REF_NULL = "REF_NULL"
const val REF_IS_NULL = "REF_IS_NULL"
const val REF_EQ = "REF_EQ"
const val REF_FUNC = "REF_FUNC"
const val STRUCT_NEW_WITH_RTT = "STRUCT_NEW_WITH_RTT"
const val STRUCT_GET = "STRUCT_GET"
const val STRUCT_SET = "STRUCT_SET"
const val REF_CAST = "REF_CAST"
const val RTT_CANON = "RTT_CANON"
const val RTT_SUB = "RTT_SUB"
}
}
@WasmOp(WasmOp.I32_EQ)
public external fun wasm_i32_eq(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_NE)
public external fun wasm_i32_ne(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_LT_S)
public external fun wasm_i32_lt_s(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_LT_U)
public external fun wasm_i32_lt_u(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_GT_S)
public external fun wasm_i32_gt_s(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_GT_U)
public external fun wasm_i32_gt_u(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_LE_S)
public external fun wasm_i32_le_s(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_LE_U)
public external fun wasm_i32_le_u(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_GE_S)
public external fun wasm_i32_ge_s(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I32_GE_U)
public external fun wasm_i32_ge_u(a: Int, b: Int): Boolean
@WasmOp(WasmOp.I64_EQ)
public external fun wasm_i64_eq(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_NE)
public external fun wasm_i64_ne(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_LT_S)
public external fun wasm_i64_lt_s(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_LT_U)
public external fun wasm_i64_lt_u(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_GT_S)
public external fun wasm_i64_gt_s(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_GT_U)
public external fun wasm_i64_gt_u(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_LE_S)
public external fun wasm_i64_le_s(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_LE_U)
public external fun wasm_i64_le_u(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_GE_S)
public external fun wasm_i64_ge_s(a: Long, b: Long): Boolean
@WasmOp(WasmOp.I64_GE_U)
public external fun wasm_i64_ge_u(a: Long, b: Long): Boolean
@WasmOp(WasmOp.F32_EQ)
public external fun wasm_f32_eq(a: Float, b: Float): Boolean
@WasmOp(WasmOp.F32_NE)
public external fun wasm_f32_ne(a: Float, b: Float): Boolean
@WasmOp(WasmOp.F32_LT)
public external fun wasm_f32_lt(a: Float, b: Float): Boolean
@WasmOp(WasmOp.F32_GT)
public external fun wasm_f32_gt(a: Float, b: Float): Boolean
@WasmOp(WasmOp.F32_LE)
public external fun wasm_f32_le(a: Float, b: Float): Boolean
@WasmOp(WasmOp.F32_GE)
public external fun wasm_f32_ge(a: Float, b: Float): Boolean
@WasmOp(WasmOp.F64_EQ)
public external fun wasm_f64_eq(a: Double, b: Double): Boolean
@WasmOp(WasmOp.F64_NE)
public external fun wasm_f64_ne(a: Double, b: Double): Boolean
@WasmOp(WasmOp.F64_LT)
public external fun wasm_f64_lt(a: Double, b: Double): Boolean
@WasmOp(WasmOp.F64_GT)
public external fun wasm_f64_gt(a: Double, b: Double): Boolean
@WasmOp(WasmOp.F64_LE)
public external fun wasm_f64_le(a: Double, b: Double): Boolean
@WasmOp(WasmOp.F64_GE)
public external fun wasm_f64_ge(a: Double, b: Double): Boolean
@WasmOp(WasmOp.I32_ADD)
public external fun wasm_i32_add(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_SUB)
public external fun wasm_i32_sub(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_MUL)
public external fun wasm_i32_mul(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_DIV_S)
public external fun wasm_i32_div_s(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_DIV_U)
public external fun wasm_i32_div_u(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_REM_S)
public external fun wasm_i32_rem_s(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_REM_U)
public external fun wasm_i32_rem_u(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_AND)
public external fun wasm_i32_and(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_OR)
public external fun wasm_i32_or(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_XOR)
public external fun wasm_i32_xor(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_SHL)
public external fun wasm_i32_shl(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_SHR_S)
public external fun wasm_i32_shr_s(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_SHR_U)
public external fun wasm_i32_shr_u(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_ROTL)
public external fun wasm_i32_rotl(a: Int, b: Int): Int
@WasmOp(WasmOp.I32_ROTR)
public external fun wasm_i32_rotr(a: Int, b: Int): Int
@WasmOp(WasmOp.I64_ADD)
public external fun wasm_i64_add(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_SUB)
public external fun wasm_i64_sub(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_MUL)
public external fun wasm_i64_mul(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_DIV_S)
public external fun wasm_i64_div_s(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_DIV_U)
public external fun wasm_i64_div_u(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_REM_S)
public external fun wasm_i64_rem_s(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_REM_U)
public external fun wasm_i64_rem_u(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_AND)
public external fun wasm_i64_and(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_OR)
public external fun wasm_i64_or(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_XOR)
public external fun wasm_i64_xor(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_SHL)
public external fun wasm_i64_shl(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_SHR_S)
public external fun wasm_i64_shr_s(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_SHR_U)
public external fun wasm_i64_shr_u(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_ROTL)
public external fun wasm_i64_rotl(a: Long, b: Long): Long
@WasmOp(WasmOp.I64_ROTR)
public external fun wasm_i64_rotr(a: Long, b: Long): Long
@WasmOp(WasmOp.F32_ADD)
public external fun wasm_f32_add(a: Float, b: Float): Float
@WasmOp(WasmOp.F32_SUB)
public external fun wasm_f32_sub(a: Float, b: Float): Float
@WasmOp(WasmOp.F32_MUL)
public external fun wasm_f32_mul(a: Float, b: Float): Float
@WasmOp(WasmOp.F32_DIV)
public external fun wasm_f32_div(a: Float, b: Float): Float
@WasmOp(WasmOp.F32_MIN)
public external fun wasm_f32_min(a: Float, b: Float): Float
@WasmOp(WasmOp.F32_MAX)
public external fun wasm_f32_max(a: Float, b: Float): Float
@WasmOp(WasmOp.F32_COPYSIGN)
public external fun wasm_f32_copysign(a: Float, b: Float): Float
@WasmOp(WasmOp.F64_ADD)
public external fun wasm_f64_add(a: Double, b: Double): Double
@WasmOp(WasmOp.F64_SUB)
public external fun wasm_f64_sub(a: Double, b: Double): Double
@WasmOp(WasmOp.F64_MUL)
public external fun wasm_f64_mul(a: Double, b: Double): Double
@WasmOp(WasmOp.F64_DIV)
public external fun wasm_f64_div(a: Double, b: Double): Double
@WasmOp(WasmOp.F64_MIN)
public external fun wasm_f64_min(a: Double, b: Double): Double
@WasmOp(WasmOp.F64_MAX)
public external fun wasm_f64_max(a: Double, b: Double): Double
@WasmOp(WasmOp.REF_IS_NULL)
public external fun wasm_ref_is_null(a: Any?): Boolean
@WasmOp(WasmOp.REF_EQ)
public external fun wasm_ref_eq(a: Any?, b: Any?): Boolean
// ---
@WasmOp(WasmOp.F32_NEAREST)
public external fun wasm_f32_nearest(a: Float): Float
@WasmOp(WasmOp.F64_NEAREST)
public external fun wasm_f64_nearest(a: Double): Double
@WasmOp(WasmOp.I32_WRAP_I64)
public external fun wasm_i32_wrap_i64(a: Long): Int
@WasmOp(WasmOp.I64_EXTEND_I32_S)
public external fun wasm_i64_extend_i32_s(a: Int): Long
@WasmOp(WasmOp.F32_CONVERT_I32_S)
public external fun wasm_f32_convert_i32_s(a: Int): Float
@WasmOp(WasmOp.F32_CONVERT_I64_S)
public external fun wasm_f32_convert_i64_s(a: Long): Float
@WasmOp(WasmOp.F32_DEMOTE_F64)
public external fun wasm_f32_demote_f64(a: Double): Float
@WasmOp(WasmOp.F64_CONVERT_I32_S)
public external fun wasm_f64_convert_i32_s(a: Int): Double
@WasmOp(WasmOp.F64_CONVERT_I64_S)
public external fun wasm_f64_convert_i64_s(a: Long): Double
@WasmOp(WasmOp.F64_PROMOTE_F32)
public external fun wasm_f64_promote_f32(a: Float): Double
@WasmOp(WasmOp.I32_REINTERPRET_F32)
public external fun wasm_i32_reinterpret_f32(a: Float): Int
@WasmOp(WasmOp.F32_REINTERPRET_I32)
public external fun wasm_f32_reinterpret_i32(a: Int): Float
@WasmOp(WasmOp.I32_TRUNC_SAT_F32_S)
public external fun wasm_i32_trunc_sat_f32_s(a: Float): Int
@WasmOp(WasmOp.I32_TRUNC_SAT_F64_S)
public external fun wasm_i32_trunc_sat_f64_s(a: Double): Int
@WasmOp(WasmOp.I64_TRUNC_SAT_F32_S)
public external fun wasm_i64_trunc_sat_f32_s(a: Float): Long
@WasmOp(WasmOp.I64_TRUNC_SAT_F64_S)
public external fun wasm_i64_trunc_sat_f64_s(a: Double): Long
@WasmOp(WasmOp.I32_LOAD)
public external fun wasm_i32_load(x: Int): Int
+55
View File
@@ -39,7 +39,62 @@ const runtime = {
return 0;
},
/**
* @return {boolean}
*/
String_equals(str, other) {
// if (typeof str != "string") throw `Illegal argument str: ${str}`;
return str === other;
},
/**
* @return {string}
*/
String_subsequence(str, startIndex, endIndex) {
return str.substring(startIndex, endIndex);
},
String_getLiteral(index) {
return runtime.stringLiterals[index];
},
coerceToString(value) {
return String(value);
},
/**
* @return {string}
*/
Char_toString(char) {
return String.fromCharCode(char)
},
JsArray_new(size) {
if (typeof size != "number") throw `Illegal argument size: ${size}`;
return new Array(size);
},
JsArray_get(array, index) {
if (typeof index != "number") throw `Illegal argument index: ${index}`;
if (array.length <= index) throw `Index out of bounds: index=${index} length=${array.length}`;
return array[index];
},
JsArray_set(array, index, value) {
if (typeof index != "number") throw `Illegal argument index: ${index}`;
if (array.length <= index) throw `Index out of bounds: index=${index} length=${array.length}`;
array[index] = value;
},
JsArray_getSize(array) {
return array.length;
},
identity(x) {
return x;
},
println(value) {
console.log(">>> " + value)
}
};
-10
View File
@@ -1,10 +0,0 @@
/*
* Copyright 2010-2019 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.wasm.internal
@WasmImport("runtime", "String_getLiteral")
public fun stringLiteral(index: Int): String =
implementedAsIntrinsic
@@ -1,59 +0,0 @@
/*
* 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
import kotlin.wasm.internal.wasm_unreachable
fun assertEquals(x: Boolean, y: Boolean) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Byte, y: Byte) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Short, y: Short) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Char, y: Char) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Int, y: Int) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Long, y: Long) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Float, y: Float) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Double, y: Double) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Boolean, y: Boolean, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Byte, y: Byte, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Short, y: Short, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Char, y: Char, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Int, y: Int, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Long, y: Long, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Float, y: Float, s: String) {
if (x != y) wasm_unreachable()
}
fun assertEquals(x: Double, y: Double, s: String) {
if (x != y) wasm_unreachable()
}
@@ -1,173 +0,0 @@
/*
* 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.wasm.internal
import kotlin.annotation.AnnotationTarget.*
// Exclude declaration or file from lowerings and code generation
@Target(FILE, CLASS, FUNCTION, PROPERTY)
@Retention(AnnotationRetention.BINARY)
internal annotation class ExcludedFromCodegen
@ExcludedFromCodegen
@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER)
@Retention(AnnotationRetention.BINARY)
internal annotation class WasmImport(val module: String, val name: String)
/**
* Replace calls to this functions with specified Wasm instruction.
*
* Operands are passed in the following order:
* 1. Dispatch receiver (if present)
* 2. Extension receiver (if present)
* 3. Value arguments
*
* @mnemonic parameter is an instruction WAT name: "i32.add", "f64.trunc", etc.
*
* Immediate arguments (label, index, offest, align, etc.) are not supported yet.
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
@ExcludedFromCodegen
internal annotation class WasmInstruction(val mnemonic: String) {
companion object {
const val NOP = "nop"
const val UNREACHABLE = "unreachable"
const val I32_EQZ = "i32.eqz"
const val I32_EQ = "i32.eq"
const val I32_NE = "i32.ne"
const val I32_LT_S = "i32.lt_s"
const val I32_LT_U = "i32.lt_u"
const val I32_GT_S = "i32.gt_s"
const val I32_GT_U = "i32.gt_u"
const val I32_LE_S = "i32.le_s"
const val I32_LE_U = "i32.le_u"
const val I32_GE_S = "i32.ge_s"
const val I32_GE_U = "i32.ge_u"
const val I64_EQZ = "i64.eqz"
const val I64_EQ = "i64.eq"
const val I64_NE = "i64.ne"
const val I64_LT_S = "i64.lt_s"
const val I64_LT_U = "i64.lt_u"
const val I64_GT_S = "i64.gt_s"
const val I64_GT_U = "i64.gt_u"
const val I64_LE_S = "i64.le_s"
const val I64_LE_U = "i64.le_u"
const val I64_GE_S = "i64.ge_s"
const val I64_GE_U = "i64.ge_u"
const val F32_EQ = "f32.eq"
const val F32_NE = "f32.ne"
const val F32_LT = "f32.lt"
const val F32_GT = "f32.gt"
const val F32_LE = "f32.le"
const val F32_GE = "f32.ge"
const val F64_EQ = "f64.eq"
const val F64_NE = "f64.ne"
const val F64_LT = "f64.lt"
const val F64_GT = "f64.gt"
const val F64_LE = "f64.le"
const val F64_GE = "f64.ge"
const val I32_CLZ = "i32.clz"
const val I32_CTZ = "i32.ctz"
const val I32_POPCNT = "i32.popcnt"
const val I32_ADD = "i32.add"
const val I32_SUB = "i32.sub"
const val I32_MUL = "i32.mul"
const val I32_DIV_S = "i32.div_s"
const val I32_DIV_U = "i32.div_u"
const val I32_REM_S = "i32.rem_s"
const val I32_REM_U = "i32.rem_u"
const val I32_AND = "i32.and"
const val I32_OR = "i32.or"
const val I32_XOR = "i32.xor"
const val I32_SHL = "i32.shl"
const val I32_SHR_S = "i32.shr_s"
const val I32_SHR_U = "i32.shr_u"
const val I32_ROTL = "i32.rotl"
const val I32_ROTR = "i32.rotr"
const val I64_CLZ = "i64.clz"
const val I64_CTZ = "i64.ctz"
const val I64_POPCNT = "i64.popcnt"
const val I64_ADD = "i64.add"
const val I64_SUB = "i64.sub"
const val I64_MUL = "i64.mul"
const val I64_DIV_S = "i64.div_s"
const val I64_DIV_U = "i64.div_u"
const val I64_REM_S = "i64.rem_s"
const val I64_REM_U = "i64.rem_u"
const val I64_AND = "i64.and"
const val I64_OR = "i64.or"
const val I64_XOR = "i64.xor"
const val I64_SHL = "i64.shl"
const val I64_SHR_S = "i64.shr_s"
const val I64_SHR_U = "i64.shr_u"
const val I64_ROTL = "i64.rotl"
const val I64_ROTR = "i64.rotr"
const val F32_ABS = "f32.abs"
const val F32_NEG = "f32.neg"
const val F32_CEIL = "f32.ceil"
const val F32_FLOOR = "f32.floor"
const val F32_TRUNC = "f32.trunc"
const val F32_NEAREST = "f32.nearest"
const val F32_SQRT = "f32.sqrt"
const val F32_ADD = "f32.add"
const val F32_SUB = "f32.sub"
const val F32_MUL = "f32.mul"
const val F32_DIV = "f32.div"
const val F32_FMIN = "f32.fmin"
const val F32_FMAX = "f32.fmax"
const val F32_COPYSIGN = "f32.copysign"
const val F64_ABS = "f64.abs"
const val F64_NEG = "f64.neg"
const val F64_CEIL = "f64.ceil"
const val F64_FLOOR = "f64.floor"
const val F64_TRUNC = "f64.trunc"
const val F64_NEAREST = "f64.nearest"
const val F64_SQRT = "f64.sqrt"
const val F64_ADD = "f64.add"
const val F64_SUB = "f64.sub"
const val F64_MUL = "f64.mul"
const val F64_DIV = "f64.div"
const val F64_FMIN = "f64.fmin"
const val F64_FMAX = "f64.fmax"
const val F64_COPYSIGN = "f64.copysign"
const val I32_WRAP_I64 = "i32.wrap/i64"
const val I32_TRUNC_F32_S = "i32.trunc_s/f32"
const val I32_TRUNC_F32_U = "i32.trunc_u/f32"
const val I32_TRUNC_F64_S = "i32.trunc_s/f64"
const val I32_TRUNC_F64_U = "i32.trunc_u/f64"
const val I64_EXTEND_I32_S = "i64.extend_s/i32"
const val I64_EXTEND_I32_U = "i64.extend_u/i32"
const val I64_TRUNC_F32_S = "i64.trunc_s/f32"
const val I64_TRUNC_F32_U = "i64.trunc_u/f32"
const val I64_TRUNC_F64_S = "i64.trunc_s/f64"
const val I64_TRUNC_F64_U = "i64.trunc_u/f64"
const val F32_CONVERT_I32_S = "f32.convert_s/i32"
const val F32_CONVERT_I32_U = "f32.convert_u/i32"
const val F32_CONVERT_I64_S = "f32.convert_s/i64"
const val F32_CONVERT_I64_U = "f32.convert_u/i64"
const val F64_CONVERT_I32_S = "f64.convert_s/i32"
const val F64_CONVERT_I32_U = "f64.convert_u/i32"
const val F64_CONVERT_I64_S = "f64.convert_s/i64"
const val F64_CONVERT_I64_U = "f64.convert_u/i64"
const val F32_DEMOTE_F64 = "f32.demote/f64"
const val F64_PROMOTE_F32 = "f64.promote/f32"
const val I32_REINTERPRET_F32 = "i32.reinterpret/f32"
const val I64_REINTERPRET_F64 = "i64.reinterpret/f64"
const val F32_REINTERPRET_I32 = "f32.reinterpret/i32"
const val F32_CONST_NAN = "f32.const nan"
const val F64_CONST_NAN = "f64.const nan"
const val F32_CONST_PLUS_INF = "f32.const +inf"
const val F32_CONST_MINUS_INF = "f32.const -inf"
const val F64_CONST_PLUS_INF = "f64.const +inf"
const val F64_CONST_MINUS_INF = "f64.const -inf"
}
}
@ExcludedFromCodegen
internal val implementedAsIntrinsic: Nothing
get() = null!!
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
/*
* 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.collections
//
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Reverses elements in the list in-place.
*/
public actual fun <T> MutableList<T>.reverse(): Unit {
val midPoint = (size / 2) - 1
if (midPoint < 0) return
var reverseIndex = lastIndex
for (index in 0..midPoint) {
val tmp = this[index]
this[index] = this[reverseIndex]
this[reverseIndex] = tmp
reverseIndex--
}
}
@@ -0,0 +1,445 @@
/*
* 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.comparisons
//
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
/**
* Returns the greater of two values.
*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
public actual fun <T : Comparable<T>> maxOf(a: T, b: T): T {
return if (a >= b) a else b
}
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Byte, b: Byte): Byte {
return maxOf(a.toInt(), b.toInt()).toByte()
}
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Short, b: Short): Short {
return maxOf(a.toInt(), b.toInt()).toShort()
}
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Int, b: Int): Int {
return if (a >= b) a else b
}
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Long, b: Long): Long {
return if (a >= b) a else b
}
/**
* Returns the greater of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Float, b: Float): Float {
return if (a.compareTo(b) >= 0) a else b
}
/**
* Returns the greater of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Double, b: Double): Double {
return if (a.compareTo(b) >= 0) a else b
}
/**
* Returns the greater of three values.
*
* If there are multiple equal maximal values, returns the first of them.
*/
@SinceKotlin("1.1")
public actual fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T {
return maxOf(a, maxOf(b, c))
}
/**
* Returns the greater of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
return maxOf(a.toInt(), maxOf(b.toInt(), c.toInt())).toByte()
}
/**
* Returns the greater of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
return maxOf(a.toInt(), maxOf(b.toInt(), c.toInt())).toShort()
}
/**
* Returns the greater of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
return maxOf(a, maxOf(b, c))
}
/**
* Returns the greater of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Long, b: Long, c: Long): Long {
return maxOf(a, maxOf(b, c))
}
/**
* Returns the greater of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
return maxOf(a, maxOf(b, c))
}
/**
* Returns the greater of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
return maxOf(a, maxOf(b, c))
}
/**
* Returns the greater of the given values.
*
* If there are multiple equal maximal values, returns the first of them.
*/
@SinceKotlin("1.4")
public actual fun <T : Comparable<T>> maxOf(a: T, vararg other: T): T {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public actual fun maxOf(a: Byte, vararg other: Byte): Byte {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public actual fun maxOf(a: Short, vararg other: Short): Short {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public actual fun maxOf(a: Int, vararg other: Int): Int {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the greater of the given values.
*/
@SinceKotlin("1.4")
public actual fun maxOf(a: Long, vararg other: Long): Long {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the greater of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public actual fun maxOf(a: Float, vararg other: Float): Float {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the greater of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public actual fun maxOf(a: Double, vararg other: Double): Double {
var max = a
for (e in other) max = maxOf(max, e)
return max
}
/**
* Returns the smaller of two values.
*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
public actual fun <T : Comparable<T>> minOf(a: T, b: T): T {
return if (a <= b) a else b
}
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Byte, b: Byte): Byte {
return minOf(a.toInt(), b.toInt()).toByte()
}
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Short, b: Short): Short {
return minOf(a.toInt(), b.toInt()).toShort()
}
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Int, b: Int): Int {
return if (a <= b) a else b
}
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Long, b: Long): Long {
return if (a <= b) a else b
}
/**
* Returns the smaller of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Float, b: Float): Float {
return when {
a.isNaN() -> a
b.isNaN() -> b
else -> if (a.compareTo(b) <= 0) a else b
}
}
/**
* Returns the smaller of two values.
*
* If either value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Double, b: Double): Double {
return when {
a.isNaN() -> a
b.isNaN() -> b
else -> if (a.compareTo(b) <= 0) a else b
}
}
/**
* Returns the smaller of three values.
*
* If there are multiple equal minimal values, returns the first of them.
*/
@SinceKotlin("1.1")
public actual fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T {
return minOf(a, minOf(b, c))
}
/**
* Returns the smaller of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
return minOf(a.toInt(), minOf(b.toInt(), c.toInt())).toByte()
}
/**
* Returns the smaller of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
return minOf(a.toInt(), minOf(b.toInt(), c.toInt())).toShort()
}
/**
* Returns the smaller of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
return minOf(a, minOf(b, c))
}
/**
* Returns the smaller of three values.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Long, b: Long, c: Long): Long {
return minOf(a, minOf(b, c))
}
/**
* Returns the smaller of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
return minOf(a, minOf(b, c))
}
/**
* Returns the smaller of three values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public actual inline fun minOf(a: Double, b: Double, c: Double): Double {
return minOf(a, minOf(b, c))
}
/**
* Returns the smaller of the given values.
*
* If there are multiple equal minimal values, returns the first of them.
*/
@SinceKotlin("1.4")
public actual fun <T : Comparable<T>> minOf(a: T, vararg other: T): T {
var min = a
for (e in other) min = minOf(min, e)
return min
}
/**
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public actual fun minOf(a: Byte, vararg other: Byte): Byte {
var min = a
for (e in other) min = minOf(min, e)
return min
}
/**
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public actual fun minOf(a: Short, vararg other: Short): Short {
var min = a
for (e in other) min = minOf(min, e)
return min
}
/**
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public actual fun minOf(a: Int, vararg other: Int): Int {
var min = a
for (e in other) min = minOf(min, e)
return min
}
/**
* Returns the smaller of the given values.
*/
@SinceKotlin("1.4")
public actual fun minOf(a: Long, vararg other: Long): Long {
var min = a
for (e in other) min = minOf(min, e)
return min
}
/**
* Returns the smaller of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public actual fun minOf(a: Float, vararg other: Float): Float {
var min = a
for (e in other) min = minOf(min, e)
return min
}
/**
* Returns the smaller of the given values.
*
* If any value is `NaN`, returns `NaN`.
*/
@SinceKotlin("1.4")
public actual fun minOf(a: Double, vararg other: Double): Double {
var min = a
for (e in other) min = minOf(min, e)
return min
}
@@ -0,0 +1,23 @@
/*
* 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.text
//
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
/**
* Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this char sequence.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@kotlin.internal.InlineOnly
public actual inline fun CharSequence.elementAt(index: Int): Char {
return get(index)
}
@@ -0,0 +1,127 @@
/*
* 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.collections
//
// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
//
import kotlin.ranges.contains
import kotlin.ranges.reversed
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public actual inline fun UIntArray.elementAt(index: Int): UInt {
return get(index)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public actual inline fun ULongArray.elementAt(index: Int): ULong {
return get(index)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public actual inline fun UByteArray.elementAt(index: Int): UByte {
return get(index)
}
/**
* Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this array.
*
* @sample samples.collections.Collections.Elements.elementAt
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
@kotlin.internal.InlineOnly
public actual inline fun UShortArray.elementAt(index: Int): UShort {
return get(index)
}
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public actual fun UIntArray.asList(): List<UInt> {
return object : AbstractList<UInt>(), RandomAccess {
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(element: UInt): Boolean = this@asList.contains(element)
override fun get(index: Int): UInt = this@asList[index]
override fun indexOf(element: UInt): Int = this@asList.indexOf(element)
override fun lastIndexOf(element: UInt): Int = this@asList.lastIndexOf(element)
}
}
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public actual fun ULongArray.asList(): List<ULong> {
return object : AbstractList<ULong>(), RandomAccess {
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(element: ULong): Boolean = this@asList.contains(element)
override fun get(index: Int): ULong = this@asList[index]
override fun indexOf(element: ULong): Int = this@asList.indexOf(element)
override fun lastIndexOf(element: ULong): Int = this@asList.lastIndexOf(element)
}
}
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public actual fun UByteArray.asList(): List<UByte> {
return object : AbstractList<UByte>(), RandomAccess {
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(element: UByte): Boolean = this@asList.contains(element)
override fun get(index: Int): UByte = this@asList[index]
override fun indexOf(element: UByte): Int = this@asList.indexOf(element)
override fun lastIndexOf(element: UByte): Int = this@asList.lastIndexOf(element)
}
}
/**
* Returns a [List] that wraps the original array.
*/
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public actual fun UShortArray.asList(): List<UShort> {
return object : AbstractList<UShort>(), RandomAccess {
override val size: Int get() = this@asList.size
override fun isEmpty(): Boolean = this@asList.isEmpty()
override fun contains(element: UShort): Boolean = this@asList.contains(element)
override fun get(index: Int): UShort = this@asList[index]
override fun indexOf(element: UShort): Int = this@asList.indexOf(element)
override fun lastIndexOf(element: UShort): Int = this@asList.lastIndexOf(element)
}
}
@@ -0,0 +1,95 @@
/*
* 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
public actual open class Exception actual constructor(message: String?, cause: Throwable?) : Throwable(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class Error actual constructor(message: String?, cause: Throwable?) : Throwable(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class RuntimeException actual constructor(message: String?, cause: Throwable?) : Exception(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class IllegalArgumentException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class IllegalStateException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class IndexOutOfBoundsException actual constructor(message: String?) : RuntimeException(message) {
actual constructor() : this(null)
}
public actual open class ConcurrentModificationException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class UnsupportedOperationException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class NumberFormatException actual constructor(message: String?) : IllegalArgumentException(message) {
actual constructor() : this(null)
}
public actual open class NullPointerException actual constructor(message: String?) : RuntimeException(message) {
actual constructor() : this(null)
}
public actual open class ClassCastException actual constructor(message: String?) : RuntimeException(message) {
actual constructor() : this(null)
}
public actual open class AssertionError private constructor(message: String?, cause: Throwable?) : Error(message, cause) {
actual constructor() : this(null)
constructor(message: String?) : this(message, null)
actual constructor(message: Any?) : this(message.toString(), message as? Throwable)
}
public actual open class NoSuchElementException actual constructor(message: String?) : RuntimeException(message) {
actual constructor() : this(null)
}
@SinceKotlin("1.3")
public actual open class ArithmeticException actual constructor(message: String?) : RuntimeException(message) {
actual constructor() : this(null)
}
public actual open class NoWhenBranchMatchedException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
public actual open class UninitializedPropertyAccessException actual constructor(message: String?, cause: Throwable?) : RuntimeException(message, cause) {
actual constructor() : this(null, null)
actual constructor(message: String?) : this(message, null)
actual constructor(cause: Throwable?) : this(null, cause)
}
+107
View File
@@ -0,0 +1,107 @@
/*
* 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
import kotlin.annotation.AnnotationTarget.FIELD
import kotlin.annotation.AnnotationTarget.PROPERTY
/**
* Provides a comparison function for imposing a total ordering between instances of the type [T].
*/
public actual fun interface Comparator<T> {
/**
* Compares its two arguments for order. Returns zero if the arguments are equal,
* a negative number if the first argument is less than the second, or a positive number
* if the first argument is greater than the second.
*/
public actual fun compare(a: T, b: T): Int
}
// From kotlin.kt
// From numbers.kt
actual fun Double.isNaN(): Boolean = TODO("Wasm stdlib: Kotlin")
actual fun Float.isNaN(): Boolean = TODO("Wasm stdlib: Kotlin")
actual fun Double.isInfinite(): Boolean = TODO("Wasm stdlib: Kotlin")
actual fun Float.isInfinite(): Boolean = TODO("Wasm stdlib: Kotlin")
actual fun Double.isFinite(): Boolean = TODO("Wasm stdlib: Kotlin")
actual fun Float.isFinite(): Boolean = TODO("Wasm stdlib: Kotlin")
/**
* Returns a bit representation of the specified floating-point value as [Long]
* according to the IEEE 754 floating-point "double format" bit layout.
*/
@SinceKotlin("1.2")
public actual fun Double.toBits(): Long = TODO("Wasm stdlib: Kotlin")
/**
* Returns a bit representation of the specified floating-point value as [Long]
* according to the IEEE 754 floating-point "double format" bit layout,
* preserving `NaN` values exact layout.
*/
@SinceKotlin("1.2")
public actual fun Double.toRawBits(): Long = TODO("Wasm stdlib: Kotlin")
/**
* Returns the [Double] value corresponding to a given bit representation.
*/
@SinceKotlin("1.2")
public actual fun Double.Companion.fromBits(bits: Long): Double = TODO("Wasm stdlib: Kotlin")
/**
* Returns a bit representation of the specified floating-point value as [Int]
* according to the IEEE 754 floating-point "single format" bit layout.
*/
@SinceKotlin("1.2")
public actual fun Float.toBits(): Int = TODO("Wasm stdlib: Kotlin")
/**
* Returns a bit representation of the specified floating-point value as [Int]
* according to the IEEE 754 floating-point "single format" bit layout,
* preserving `NaN` values exact layout.
*/
@SinceKotlin("1.2")
public actual fun Float.toRawBits(): Int = TODO("Wasm stdlib: Kotlin")
/**
* Returns the [Float] value corresponding to a given bit representation.
*/
@SinceKotlin("1.2")
public actual fun Float.Companion.fromBits(bits: Int): Float = TODO("Wasm stdlib: Kotlin")
// From concurrent.kt
// TODO: promote to error? Otherwise it gets to JVM part
//@Deprecated("Use Volatile annotation from kotlin.jvm package", ReplaceWith("kotlin.jvm.Volatile"), level = DeprecationLevel.WARNING)
//public typealias Volatile = kotlin.jvm.Volatile
@Deprecated("Synchronization on any object is not supported on every platform and will be removed from the common standard library soon.")
public actual inline fun <R> synchronized(lock: Any, block: () -> R): R = TODO("Wasm stdlib: Kotlin")
// from lazy.kt
public actual fun <T> lazy(initializer: () -> T): Lazy<T> = TODO("Wasm stdlib: Kotlin")
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [mode] parameter is ignored. */
public actual fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> = TODO("Wasm stdlib: Kotlin")
/**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
*
* The [lock] parameter is ignored.
*/
public actual fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = TODO("Wasm stdlib: Kotlin")
+990
View File
@@ -0,0 +1,990 @@
/*
* 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.math
// region ================ Double Math ========================================
/** Computes the sine of the angle [x] given in radians.
*
* Special cases:
* - `sin(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun sin(x: Double): Double = TODO("Wasm stdlib: Math")
/** Computes the cosine of the angle [x] given in radians.
*
* Special cases:
* - `cos(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun cos(x: Double): Double = TODO("Wasm stdlib: Math")
/** Computes the tangent of the angle [x] given in radians.
*
* Special cases:
* - `tan(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun tan(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the arc sine of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
* - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
public actual fun asin(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the arc cosine of the value [x];
* the returned value is an angle in the range from `0.0` to `PI` radians.
*
* Special cases:
* - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
public actual fun acos(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the arc tangent of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
* - `atan(NaN)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun atan(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond
* to the rectangular coordinates `(x, y)` by computing the arc tangent of the value [y] / [x];
* the returned value is an angle in the range from `-PI` to `PI` radians.
*
* Special cases:
* - `atan2(0.0, 0.0)` is `0.0`
* - `atan2(0.0, x)` is `0.0` for `x > 0` and `PI` for `x < 0`
* - `atan2(-0.0, x)` is `-0.0` for 'x > 0` and `-PI` for `x < 0`
* - `atan2(y, +Inf)` is `0.0` for `0 < y < +Inf` and `-0.0` for '-Inf < y < 0`
* - `atan2(y, -Inf)` is `PI` for `0 < y < +Inf` and `-PI` for `-Inf < y < 0`
* - `atan2(y, 0.0)` is `PI/2` for `y > 0` and `-PI/2` for `y < 0`
* - `atan2(+Inf, x)` is `PI/2` for finite `x`y
* - `atan2(-Inf, x)` is `-PI/2` for finite `x`
* - `atan2(NaN, x)` and `atan2(y, NaN)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun atan2(y: Double, x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the hyperbolic sine of the value [x].
*
* Special cases:
* - `sinh(NaN)` is `NaN`
* - `sinh(+Inf)` is `+Inf`
* - `sinh(-Inf)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun sinh(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the hyperbolic cosine of the value [x].
*
* Special cases:
* - `cosh(NaN)` is `NaN`
* - `cosh(+Inf|-Inf)` is `+Inf`
*/
@SinceKotlin("1.2")
public actual fun cosh(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the hyperbolic tangent of the value [x].
*
* Special cases:
* - `tanh(NaN)` is `NaN`
* - `tanh(+Inf)` is `1.0`
* - `tanh(-Inf)` is `-1.0`
*/
@SinceKotlin("1.2")
public actual fun tanh(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the inverse hyperbolic sine of the value [x].
*
* The returned value is `y` such that `sinh(y) == x`.
*
* Special cases:
* - `asinh(NaN)` is `NaN`
* - `asinh(+Inf)` is `+Inf`
* - `asinh(-Inf)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun asinh(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the inverse hyperbolic cosine of the value [x].
*
* The returned value is positive `y` such that `cosh(y) == x`.
*
* Special cases:
* - `acosh(NaN)` is `NaN`
* - `acosh(x)` is `NaN` when `x < 1`
* - `acosh(+Inf)` is `+Inf`
*/
@SinceKotlin("1.2")
public actual fun acosh(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the inverse hyperbolic tangent of the value [x].
*
* The returned value is `y` such that `tanh(y) == x`.
*
* Special cases:
* - `tanh(NaN)` is `NaN`
* - `tanh(x)` is `NaN` when `x > 1` or `x < -1`
* - `tanh(1.0)` is `+Inf`
* - `tanh(-1.0)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun atanh(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.
*
* Special cases:
* - returns `+Inf` if any of arguments is infinite
* - returns `NaN` if any of arguments is `NaN` and the other is not infinite
*/
@SinceKotlin("1.2")
public actual fun hypot(x: Double, y: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the positive square root of the value [x].
*
* Special cases:
* - `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun sqrt(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes Euler's number `e` raised to the power of the value [x].
*
* Special cases:
* - `exp(NaN)` is `NaN`
* - `exp(+Inf)` is `+Inf`
* - `exp(-Inf)` is `0.0`
*/
@SinceKotlin("1.2")
public actual fun exp(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes `exp(x) - 1`.
*
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `expm1(NaN)` is `NaN`
* - `expm1(+Inf)` is `+Inf`
* - `expm1(-Inf)` is `-1.0`
*
* @see [exp] function.
*/
@SinceKotlin("1.2")
public actual fun expm1(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the logarithm of the value [x] to the given [base].
*
* Special cases:
* - `log(x, b)` is `NaN` if either `x` or `b` are `NaN`
* - `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0`
* - `log(+Inf, +Inf)` is `NaN`
* - `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1`
* - `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1`
*
* See also logarithm functions for common fixed bases: [ln], [log10] and [log2].
*/
@SinceKotlin("1.2")
public actual fun log(x: Double, base: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the natural logarithm (base `E`) of the value [x].
*
* Special cases:
* - `ln(NaN)` is `NaN`
* - `ln(x)` is `NaN` when `x < 0.0`
* - `ln(+Inf)` is `+Inf`
* - `ln(0.0)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun ln(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the common logarithm (base 10) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
public actual fun log10(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes the binary logarithm (base 2) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
public actual fun log2(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Computes `ln(x + 1)`.
*
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `ln1p(NaN)` is `NaN`
* - `ln1p(x)` is `NaN` where `x < -1.0`
* - `ln1p(-1.0)` is `-Inf`
* - `ln1p(+Inf)` is `+Inf`
*
* @see [ln] function
* @see [expm1] function
*/
@SinceKotlin("1.2")
public actual fun ln1p(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] to an integer towards positive infinity.
* @return the smallest double value that is greater than or equal to the given value [x] and is a mathematical integer.
*
* Special cases:
* - `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun ceil(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] to an integer towards negative infinity.
* @return the largest double value that is smaller than or equal to the given value [x] and is a mathematical integer.
*
* Special cases:
* - `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun floor(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] to an integer towards zero.
*
* @return the value [x] having its fractional part truncated.
*
* Special cases:
* - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun truncate(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] towards the closest integer with ties rounded towards even integer.
*
* Special cases:
* - `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun round(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of the given value [x].
*
* Special cases:
* - `abs(NaN)` is `NaN`
*
* @see absoluteValue extension property for [Double]
*/
@SinceKotlin("1.2")
public actual fun abs(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Returns the sign of the given value [x]:
* - `-1.0` if the value is negative,
* - zero if the value is zero,
* - `1.0` if the value is positive
*
* Special case:
* - `sign(NaN)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun sign(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Returns the smaller of two values.
*
* If either value is `NaN`, then the result is `NaN`.
*/
@SinceKotlin("1.2")
public actual fun min(a: Double, b: Double): Double = TODO("Wasm stdlib: Math")
/**
* Returns the greater of two values.
*
* If either value is `NaN`, then the result is `NaN`.
*/
@SinceKotlin("1.2")
public actual fun max(a: Double, b: Double): Double = TODO("Wasm stdlib: Math")
// extensions
/**
* Raises this value to the power [x].
*
* Special cases:
* - `b.pow(0.0)` is `1.0`
* - `b.pow(1.0) == b`
* - `b.pow(NaN)` is `NaN`
* - `NaN.pow(x)` is `NaN` for `x != 0.0`
* - `b.pow(Inf)` is `NaN` for `abs(b) == 1.0`
* - `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer
*/
@SinceKotlin("1.2")
public actual fun Double.pow(x: Double): Double = TODO("Wasm stdlib: Math")
/**
* Raises this value to the integer power [n].
*
* See the other overload of [pow] for details.
*/
@SinceKotlin("1.2")
public actual fun Double.pow(n: Int): Double = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of this value.
*
* Special cases:
* - `NaN.absoluteValue` is `NaN`
*
* @see abs function
*/
@SinceKotlin("1.2")
public actual val Double.absoluteValue: Double get() = TODO("Wasm stdlib: Math")
/**
* Returns the sign of this value:
* - `-1.0` if the value is negative,
* - zero if the value is zero,
* - `1.0` if the value is positive
*
* Special case:
* - `NaN.sign` is `NaN`
*/
@SinceKotlin("1.2")
public actual val Double.sign: Double get() = TODO("Wasm stdlib: Math")
/**
* Returns this value with the sign bit same as of the [sign] value.
*
* If [sign] is `NaN` the sign of the result is undefined.
*/
@SinceKotlin("1.2")
public actual fun Double.withSign(sign: Double): Double = TODO("Wasm stdlib: Math")
/**
* Returns this value with the sign bit same as of the [sign] value.
*/
@SinceKotlin("1.2")
public actual fun Double.withSign(sign: Int): Double = TODO("Wasm stdlib: Math")
/**
* Returns the ulp (unit in the last place) of this value.
*
* An ulp is a positive distance between this value and the next nearest [Double] value larger in magnitude.
*
* Special Cases:
* - `NaN.ulp` is `NaN`
* - `x.ulp` is `+Inf` when `x` is `+Inf` or `-Inf`
* - `0.0.ulp` is `Double.MIN_VALUE`
*/
@SinceKotlin("1.2")
public actual val Double.ulp: Double get() = TODO("Wasm stdlib: Math")
/**
* Returns the [Double] value nearest to this value in direction of positive infinity.
*/
@SinceKotlin("1.2")
public actual fun Double.nextUp(): Double = TODO("Wasm stdlib: Math")
/**
* Returns the [Double] value nearest to this value in direction of negative infinity.
*/
@SinceKotlin("1.2")
public actual fun Double.nextDown(): Double = TODO("Wasm stdlib: Math")
/**
* Returns the [Double] value nearest to this value in direction from this value towards the value [to].
*
* Special cases:
* - `x.nextTowards(y)` is `NaN` if either `x` or `y` are `NaN`
* - `x.nextTowards(x) == x`
*
*/
@SinceKotlin("1.2")
public actual fun Double.nextTowards(to: Double): Double = TODO("Wasm stdlib: Math")
/**
* Rounds this [Double] value to the nearest integer and converts the result to [Int].
* Ties are rounded towards positive infinity.
*
* Special cases:
* - `x.roundToInt() == Int.MAX_VALUE` when `x > Int.MAX_VALUE`
* - `x.roundToInt() == Int.MIN_VALUE` when `x < Int.MIN_VALUE`
*
* @throws IllegalArgumentException when this value is `NaN`
*/
@SinceKotlin("1.2")
public actual fun Double.roundToInt(): Int = TODO("Wasm stdlib: Math")
/**
* Rounds this [Double] value to the nearest integer and converts the result to [Long].
* Ties are rounded towards positive infinity.
*
* Special cases:
* - `x.roundToLong() == Long.MAX_VALUE` when `x > Long.MAX_VALUE`
* - `x.roundToLong() == Long.MIN_VALUE` when `x < Long.MIN_VALUE`
*
* @throws IllegalArgumentException when this value is `NaN`
*/
@SinceKotlin("1.2")
public actual fun Double.roundToLong(): Long = TODO("Wasm stdlib: Math")
// endregion
// region ================ Float Math ========================================
/** Computes the sine of the angle [x] given in radians.
*
* Special cases:
* - `sin(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun sin(x: Float): Float = TODO("Wasm stdlib: Math")
/** Computes the cosine of the angle [x] given in radians.
*
* Special cases:
* - `cos(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun cos(x: Float): Float = TODO("Wasm stdlib: Math")
/** Computes the tangent of the angle [x] given in radians.
*
* Special cases:
* - `tan(NaN|+Inf|-Inf)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun tan(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the arc sine of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
* - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
public actual fun asin(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the arc cosine of the value [x];
* the returned value is an angle in the range from `0.0` to `PI` radians.
*
* Special cases:
* - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN`
*/
@SinceKotlin("1.2")
public actual fun acos(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the arc tangent of the value [x];
* the returned value is an angle in the range from `-PI/2` to `PI/2` radians.
*
* Special cases:
* - `atan(NaN)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun atan(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond
* to the rectangular coordinates `(x, y)` by computing the arc tangent of the value [y] / [x];
* the returned value is an angle in the range from `-PI` to `PI` radians.
*
* Special cases:
* - `atan2(0.0, 0.0)` is `0.0`
* - `atan2(0.0, x)` is `0.0` for `x > 0` and `PI` for `x < 0`
* - `atan2(-0.0, x)` is `-0.0` for 'x > 0` and `-PI` for `x < 0`
* - `atan2(y, +Inf)` is `0.0` for `0 < y < +Inf` and `-0.0` for '-Inf < y < 0`
* - `atan2(y, -Inf)` is `PI` for `0 < y < +Inf` and `-PI` for `-Inf < y < 0`
* - `atan2(y, 0.0)` is `PI/2` for `y > 0` and `-PI/2` for `y < 0`
* - `atan2(+Inf, x)` is `PI/2` for finite `x`y
* - `atan2(-Inf, x)` is `-PI/2` for finite `x`
* - `atan2(NaN, x)` and `atan2(y, NaN)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun atan2(y: Float, x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the hyperbolic sine of the value [x].
*
* Special cases:
* - `sinh(NaN)` is `NaN`
* - `sinh(+Inf)` is `+Inf`
* - `sinh(-Inf)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun sinh(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the hyperbolic cosine of the value [x].
*
* Special cases:
* - `cosh(NaN)` is `NaN`
* - `cosh(+Inf|-Inf)` is `+Inf`
*/
@SinceKotlin("1.2")
public actual fun cosh(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the hyperbolic tangent of the value [x].
*
* Special cases:
* - `tanh(NaN)` is `NaN`
* - `tanh(+Inf)` is `1.0`
* - `tanh(-Inf)` is `-1.0`
*/
@SinceKotlin("1.2")
public actual fun tanh(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the inverse hyperbolic sine of the value [x].
*
* The returned value is `y` such that `sinh(y) == x`.
*
* Special cases:
* - `asinh(NaN)` is `NaN`
* - `asinh(+Inf)` is `+Inf`
* - `asinh(-Inf)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun asinh(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the inverse hyperbolic cosine of the value [x].
*
* The returned value is positive `y` such that `cosh(y) == x`.
*
* Special cases:
* - `acosh(NaN)` is `NaN`
* - `acosh(x)` is `NaN` when `x < 1`
* - `acosh(+Inf)` is `+Inf`
*/
@SinceKotlin("1.2")
public actual fun acosh(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the inverse hyperbolic tangent of the value [x].
*
* The returned value is `y` such that `tanh(y) == x`.
*
* Special cases:
* - `tanh(NaN)` is `NaN`
* - `tanh(x)` is `NaN` when `x > 1` or `x < -1`
* - `tanh(1.0)` is `+Inf`
* - `tanh(-1.0)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun atanh(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.
*
* Special cases:
* - returns `+Inf` if any of arguments is infinite
* - returns `NaN` if any of arguments is `NaN` and the other is not infinite
*/
@SinceKotlin("1.2")
public actual fun hypot(x: Float, y: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the positive square root of the value [x].
*
* Special cases:
* - `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun sqrt(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes Euler's number `e` raised to the power of the value [x].
*
* Special cases:
* - `exp(NaN)` is `NaN`
* - `exp(+Inf)` is `+Inf`
* - `exp(-Inf)` is `0.0`
*/
@SinceKotlin("1.2")
public actual fun exp(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes `exp(x) - 1`.
*
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `expm1(NaN)` is `NaN`
* - `expm1(+Inf)` is `+Inf`
* - `expm1(-Inf)` is `-1.0`
*
* @see [exp] function.
*/
@SinceKotlin("1.2")
public actual fun expm1(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the logarithm of the value [x] to the given [base].
*
* Special cases:
* - `log(x, b)` is `NaN` if either `x` or `b` are `NaN`
* - `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0`
* - `log(+Inf, +Inf)` is `NaN`
* - `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1`
* - `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1`
*
* See also logarithm functions for common fixed bases: [ln], [log10] and [log2].
*/
@SinceKotlin("1.2")
public actual fun log(x: Float, base: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the natural logarithm (base `E`) of the value [x].
*
* Special cases:
* - `ln(NaN)` is `NaN`
* - `ln(x)` is `NaN` when `x < 0.0`
* - `ln(+Inf)` is `+Inf`
* - `ln(0.0)` is `-Inf`
*/
@SinceKotlin("1.2")
public actual fun ln(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the common logarithm (base 10) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
public actual fun log10(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes the binary logarithm (base 2) of the value [x].
*
* @see [ln] function for special cases.
*/
@SinceKotlin("1.2")
public actual fun log2(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Computes `ln(a + 1)`.
*
* This function can be implemented to produce more precise result for [x] near zero.
*
* Special cases:
* - `ln1p(NaN)` is `NaN`
* - `ln1p(x)` is `NaN` where `x < -1.0`
* - `ln1p(-1.0)` is `-Inf`
* - `ln1p(+Inf)` is `+Inf`
*
* @see [ln] function
* @see [expm1] function
*/
@SinceKotlin("1.2")
public actual fun ln1p(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] to an integer towards positive infinity.
* @return the smallest Float value that is greater than or equal to the given value [x] and is a mathematical integer.
*
* Special cases:
* - `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun ceil(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] to an integer towards negative infinity.
* @return the largest Float value that is smaller than or equal to the given value [x] and is a mathematical integer.
*
* Special cases:
* - `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun floor(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] to an integer towards zero.
*
* @return the value [x] having its fractional part truncated.
*
* Special cases:
* - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun truncate(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Rounds the given value [x] towards the closest integer with ties rounded towards even integer.
*
* Special cases:
* - `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/
@SinceKotlin("1.2")
public actual fun round(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of the given value [x].
*
* Special cases:
* - `abs(NaN)` is `NaN`
*
* @see absoluteValue extension property for [Float]
*/
@SinceKotlin("1.2")
public actual fun abs(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Returns the sign of the given value [x]:
* - `-1.0` if the value is negative,
* - zero if the value is zero,
* - `1.0` if the value is positive
*
* Special case:
* - `sign(NaN)` is `NaN`
*/
@SinceKotlin("1.2")
public actual fun sign(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Returns the smaller of two values.
*
* If either value is `NaN`, then the result is `NaN`.
*/
@SinceKotlin("1.2")
public actual fun min(a: Float, b: Float): Float = TODO("Wasm stdlib: Math")
/**
* Returns the greater of two values.
*
* If either value is `NaN`, then the result is `NaN`.
*/
@SinceKotlin("1.2")
public actual fun max(a: Float, b: Float): Float = TODO("Wasm stdlib: Math")
// extensions
/**
* Raises this value to the power [x].
*
* Special cases:
* - `b.pow(0.0)` is `1.0`
* - `b.pow(1.0) == b`
* - `b.pow(NaN)` is `NaN`
* - `NaN.pow(x)` is `NaN` for `x != 0.0`
* - `b.pow(Inf)` is `NaN` for `abs(b) == 1.0`
* - `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer
*/
@SinceKotlin("1.2")
public actual fun Float.pow(x: Float): Float = TODO("Wasm stdlib: Math")
/**
* Raises this value to the integer power [n].
*
* See the other overload of [pow] for details.
*/
@SinceKotlin("1.2")
public actual fun Float.pow(n: Int): Float = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of this value.
*
* Special cases:
* - `NaN.absoluteValue` is `NaN`
*
* @see abs function
*/
@SinceKotlin("1.2")
public actual val Float.absoluteValue: Float get() = TODO("Wasm stdlib: Math")
/**
* Returns the sign of this value:
* - `-1.0` if the value is negative,
* - zero if the value is zero,
* - `1.0` if the value is positive
*
* Special case:
* - `NaN.sign` is `NaN`
*/
@SinceKotlin("1.2")
public actual val Float.sign: Float get() = TODO("Wasm stdlib: Math")
/**
* Returns this value with the sign bit same as of the [sign] value.
*
* If [sign] is `NaN` the sign of the result is undefined.
*/
@SinceKotlin("1.2")
public actual fun Float.withSign(sign: Float): Float = TODO("Wasm stdlib: Math")
/**
* Returns this value with the sign bit same as of the [sign] value.
*/
@SinceKotlin("1.2")
public actual fun Float.withSign(sign: Int): Float = TODO("Wasm stdlib: Math")
/**
* Rounds this [Float] value to the nearest integer and converts the result to [Int].
* Ties are rounded towards positive infinity.
*
* Special cases:
* - `x.roundToInt() == Int.MAX_VALUE` when `x > Int.MAX_VALUE`
* - `x.roundToInt() == Int.MIN_VALUE` when `x < Int.MIN_VALUE`
*
* @throws IllegalArgumentException when this value is `NaN`
*/
@SinceKotlin("1.2")
public actual fun Float.roundToInt(): Int = TODO("Wasm stdlib: Math")
/**
* Rounds this [Float] value to the nearest integer and converts the result to [Long].
* Ties are rounded towards positive infinity.
*
* Special cases:
* - `x.roundToLong() == Long.MAX_VALUE` when `x > Long.MAX_VALUE`
* - `x.roundToLong() == Long.MIN_VALUE` when `x < Long.MIN_VALUE`
*
* @throws IllegalArgumentException when this value is `NaN`
*/
@SinceKotlin("1.2")
public actual fun Float.roundToLong(): Long = TODO("Wasm stdlib: Math")
// endregion
// region ================ Integer Math ========================================
/**
* Returns the absolute value of the given value [n].
*
* Special cases:
* - `abs(Int.MIN_VALUE)` is `Int.MIN_VALUE` due to an overflow
*
* @see absoluteValue extension property for [Int]
*/
@SinceKotlin("1.2")
public actual fun abs(n: Int): Int = TODO("Wasm stdlib: Math")
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.2")
public actual fun min(a: Int, b: Int): Int = TODO("Wasm stdlib: Math")
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.2")
public actual fun max(a: Int, b: Int): Int = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of this value.
*
* Special cases:
* - `Int.MIN_VALUE.absoluteValue` is `Int.MIN_VALUE` due to an overflow
*
* @see abs function
*/
@SinceKotlin("1.2")
public actual val Int.absoluteValue: Int get() = TODO("Wasm stdlib: Math")
/**
* Returns the sign of this value:
* - `-1` if the value is negative,
* - `0` if the value is zero,
* - `1` if the value is positive
*/
@SinceKotlin("1.2")
public actual val Int.sign: Int get() = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of the given value [n].
*
* Special cases:
* - `abs(Long.MIN_VALUE)` is `Long.MIN_VALUE` due to an overflow
*
* @see absoluteValue extension property for [Long]
*/
@SinceKotlin("1.2")
public actual fun abs(n: Long): Long = TODO("Wasm stdlib: Math")
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.2")
public actual fun min(a: Long, b: Long): Long = TODO("Wasm stdlib: Math")
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.2")
public actual fun max(a: Long, b: Long): Long = TODO("Wasm stdlib: Math")
/**
* Returns the absolute value of this value.
*
* Special cases:
* - `Long.MIN_VALUE.absoluteValue` is `Long.MIN_VALUE` due to an overflow
*
* @see abs function
*/
@SinceKotlin("1.2")
public actual val Long.absoluteValue: Long get() = TODO("Wasm stdlib: Math")
/**
* Returns the sign of this value:
* - `-1` if the value is negative,
* - `0` if the value is zero,
* - `1` if the value is positive
*/
@SinceKotlin("1.2")
public actual val Long.sign: Int get() = TODO("Wasm stdlib: Math")
// endregion
@@ -0,0 +1,12 @@
/*
* 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.sequences
internal actual class ConstrainedOnceSequence<T> : Sequence<T> {
actual constructor(sequence: Sequence<T>) { TODO("Wasm stdlib: ConstrainedOnceSequence") }
actual override fun iterator(): Iterator<T> = TODO("Wasm stdlib: ConstrainedOnceSequence")
}
+402
View File
@@ -0,0 +1,402 @@
/*
* 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.text
actual class Regex {
actual constructor(pattern: String) { TODO("Wasm stdlib: Text") }
actual constructor(pattern: String, option: RegexOption) { TODO("Wasm stdlib: Text") }
actual constructor(pattern: String, options: Set<RegexOption>) { TODO("Wasm stdlib: Text") }
actual val pattern: String = TODO("Wasm stdlib: Text")
actual val options: Set<RegexOption> = TODO("Wasm stdlib: Text")
actual fun matchEntire(input: CharSequence): MatchResult? = TODO("Wasm stdlib: Text")
actual infix fun matches(input: CharSequence): Boolean = TODO("Wasm stdlib: Text")
actual fun containsMatchIn(input: CharSequence): Boolean = TODO("Wasm stdlib: Text")
actual fun replace(input: CharSequence, replacement: String): String = TODO("Wasm stdlib: Text")
actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String = TODO("Wasm stdlib: Text")
actual fun replaceFirst(input: CharSequence, replacement: String): String = TODO("Wasm stdlib: Text")
/**
* Returns the first match of a regular expression in the [input], beginning at the specified [startIndex].
*
* @param startIndex An index to start search with, by default 0. Must be not less than zero and not greater than `input.length()`
* @return An instance of [MatchResult] if match was found or `null` otherwise.
* @sample samples.text.Regexps.find
*/
actual fun find(input: CharSequence, startIndex: Int): MatchResult? = TODO("Wasm stdlib: Text")
/**
* Returns a sequence of all occurrences of a regular expression within the [input] string, beginning at the specified [startIndex].
*
* @sample samples.text.Regexps.findAll
*/
actual fun findAll(input: CharSequence, startIndex: Int): Sequence<MatchResult> = TODO("Wasm stdlib: Text")
/**
* Splits the [input] CharSequence around matches of this regular expression.
*
* @param limit Non-negative value specifying the maximum number of substrings the string can be split to.
* Zero by default means no limit is set.
*/
actual fun split(input: CharSequence, limit: Int): List<String> = TODO("Wasm stdlib: Text")
actual companion object {
actual fun fromLiteral(literal: String): Regex = TODO("Wasm stdlib: Text")
actual fun escape(literal: String): String = TODO("Wasm stdlib: Text")
actual fun escapeReplacement(literal: String): String = TODO("Wasm stdlib: Text")
}
}
actual class MatchGroup {
actual val value: String = TODO("Wasm stdlib: Text")
}
actual enum class RegexOption {
IGNORE_CASE,
MULTILINE
}
// From char.kt
actual fun Char.isWhitespace(): Boolean = TODO("Wasm stdlib: Text")
actual fun Char.toLowerCase(): Char = TODO("Wasm stdlib: Text")
actual fun Char.toUpperCase(): Char = TODO("Wasm stdlib: Text")
actual fun Char.isHighSurrogate(): Boolean = TODO("Wasm stdlib: Text")
actual fun Char.isLowSurrogate(): Boolean = TODO("Wasm stdlib: Text")
// From string.kt
/**
* Converts the characters in the specified array to a string.
*/
@SinceKotlin("1.2")
public actual fun String(chars: CharArray): String = TODO("Wasm stdlib: Text")
/**
* Converts the characters from a portion of the specified array to a string.
*
* @throws IndexOutOfBoundsException if either [offset] or [length] are less than zero
* or `offset + length` is out of [chars] array bounds.
*/
@SinceKotlin("1.2")
public actual fun String(chars: CharArray, offset: Int, length: Int): String = TODO("Wasm stdlib: Text")
/**
* Concatenates characters in this [CharArray] into a String.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun CharArray.concatToString(): String = TODO("Wasm stdlib: Text")
/**
* Concatenates characters in this [CharArray] or its subrange into a String.
*
* @param startIndex the beginning (inclusive) of the subrange of characters, 0 by default.
* @param endIndex the end (exclusive) of the subrange of characters, size of this array by default.
*
* @throws IndexOutOfBoundsException if [startIndex] is less than zero or [endIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [startIndex] is greater than [endIndex].
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun CharArray.concatToString(startIndex: Int, endIndex: Int): String = TODO("Wasm stdlib: Text")
/**
* Returns a [CharArray] containing characters of this string.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun String.toCharArray(): CharArray = TODO("Wasm stdlib: Text")
/**
* Returns a [CharArray] containing characters of this string or its substring.
*
* @param startIndex the beginning (inclusive) of the substring, 0 by default.
* @param endIndex the end (exclusive) of the substring, length of this string by default.
*
* @throws IndexOutOfBoundsException if [startIndex] is less than zero or [endIndex] is greater than the length of this string.
* @throws IllegalArgumentException if [startIndex] is greater than [endIndex].
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun String.toCharArray(startIndex: Int, endIndex: Int): CharArray = TODO("Wasm stdlib: Text")
/**
* Decodes a string from the bytes in UTF-8 encoding in this array.
*
* Malformed byte sequences are replaced by the replacement char `\uFFFD`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun ByteArray.decodeToString(): String = TODO("Wasm stdlib: Text")
/**
* Decodes a string from the bytes in UTF-8 encoding in this array or its subrange.
*
* @param startIndex the beginning (inclusive) of the subrange to decode, 0 by default.
* @param endIndex the end (exclusive) of the subrange to decode, size of this array by default.
* @param throwOnInvalidSequence specifies whether to throw an exception on malformed byte sequence or replace it by the replacement char `\uFFFD`.
*
* @throws IndexOutOfBoundsException if [startIndex] is less than zero or [endIndex] is greater than the size of this array.
* @throws IllegalArgumentException if [startIndex] is greater than [endIndex].
* @throws CharacterCodingException if the byte array contains malformed UTF-8 byte sequence and [throwOnInvalidSequence] is true.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun ByteArray.decodeToString(
startIndex: Int,
endIndex: Int,
throwOnInvalidSequence: Boolean
): String = TODO("Wasm stdlib: Text")
/**
* Encodes this string to an array of bytes in UTF-8 encoding.
*
* Any malformed char sequence is replaced by the replacement byte sequence.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun String.encodeToByteArray(): ByteArray = TODO("Wasm stdlib: Text")
/**
* Encodes this string or its substring to an array of bytes in UTF-8 encoding.
*
* @param startIndex the beginning (inclusive) of the substring to encode, 0 by default.
* @param endIndex the end (exclusive) of the substring to encode, length of this string by default.
* @param throwOnInvalidSequence specifies whether to throw an exception on malformed char sequence or replace.
*
* @throws IndexOutOfBoundsException if [startIndex] is less than zero or [endIndex] is greater than the length of this string.
* @throws IllegalArgumentException if [startIndex] is greater than [endIndex].
* @throws CharacterCodingException if this string contains malformed char sequence and [throwOnInvalidSequence] is true.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun String.encodeToByteArray(
startIndex: Int,
endIndex: Int,
throwOnInvalidSequence: Boolean
): ByteArray = TODO("Wasm stdlib: Text")
internal actual fun String.nativeIndexOf(str: String, fromIndex: Int): Int = TODO("Wasm stdlib: Text")
internal actual fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = TODO("Wasm stdlib: Text")
public actual fun String.substring(startIndex: Int): String = TODO("Wasm stdlib: Text")
public actual fun String.substring(startIndex: Int, endIndex: Int): String = TODO("Wasm stdlib: Text")
/**
* Returns a copy of this string converted to upper case using the rules of the default locale.
*
* @sample samples.text.Strings.toUpperCase
*/
public actual fun String.toUpperCase(): String = TODO("Wasm stdlib: Text")
/**
* Returns a copy of this string converted to lower case using the rules of the default locale.
*
* @sample samples.text.Strings.toLowerCase
*/
public actual fun String.toLowerCase(): String = TODO("Wasm stdlib: Text")
public actual fun String.capitalize(): String = TODO("Wasm stdlib: Text")
public actual fun String.decapitalize(): String = TODO("Wasm stdlib: Text")
public actual fun CharSequence.repeat(n: Int): String = TODO("Wasm stdlib: Text")
/**
* Returns a new string with all occurrences of [oldChar] replaced with [newChar].
*/
actual fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean): String = TODO("Wasm stdlib: Text")
/**
* Returns a new string obtained by replacing all occurrences of the [oldValue] substring in this string
* with the specified [newValue] string.
*/
actual fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean): String = TODO("Wasm stdlib: Text")
/**
* Returns a new string with the first occurrence of [oldChar] replaced with [newChar].
*/
actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean): String = TODO("Wasm stdlib: Text")
/**
* Returns a new string obtained by replacing the first occurrence of the [oldValue] substring in this string
* with the specified [newValue] string.
*/
actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean): String = TODO("Wasm stdlib: Text")
/**
* Returns `true` if this string is equal to [other], optionally ignoring character case.
*
* @param ignoreCase `true` to ignore character case when comparing strings. By default `false`.
*/
actual fun String?.equals(other: String?, ignoreCase: Boolean): Boolean = TODO("Wasm stdlib: Text")
/**
* Compares two strings lexicographically, optionally ignoring case differences.
*/
@SinceKotlin("1.2")
actual fun String.compareTo(other: String, ignoreCase: Boolean): Int = TODO("Wasm stdlib: Text")
public actual fun String.startsWith(prefix: String, ignoreCase: Boolean): Boolean = TODO("Wasm stdlib: Text")
public actual fun String.startsWith(prefix: String, startIndex: Int, ignoreCase: Boolean): Boolean = TODO("Wasm stdlib: Text")
public actual fun String.endsWith(suffix: String, ignoreCase: Boolean): Boolean = TODO("Wasm stdlib: Text")
// From stringsCode.kt
internal actual fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = TODO("Wasm stdlib: Text")
internal actual fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = TODO("Wasm stdlib: Text")
actual fun CharSequence.isBlank(): Boolean = TODO("Wasm stdlib: Text")
/**
* Returns `true` if the specified range in this char sequence is equal to the specified range in another char sequence.
* @param thisOffset the start offset in this char sequence of the substring to compare.
* @param other the string against a substring of which the comparison is performed.
* @param otherOffset the start offset in the other char sequence of the substring to compare.
* @param length the length of the substring to compare.
*/
actual fun CharSequence.regionMatches(
thisOffset: Int,
other: CharSequence,
otherOffset: Int,
length: Int,
ignoreCase: Boolean
): Boolean = TODO("Wasm stdlib: Text")
/**
* A Comparator that orders strings ignoring character case.
*
* Note that this Comparator does not take locale into account,
* and will result in an unsatisfactory ordering for certain locales.
*/
@SinceKotlin("1.2")
public actual val String.Companion.CASE_INSENSITIVE_ORDER: Comparator<String> get() = TODO("Wasm stdlib: Text")
actual fun String.toBoolean(): Boolean = TODO("Wasm stdlib: Text")
/**
* Returns `true` if the contents of this string is equal to the word "true", ignoring case, and `false` otherwise.
*/
actual fun String?.toBoolean(): Boolean = TODO("Wasm stdlib: Text")
/**
* Parses the string as a signed [Byte] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
*/
actual fun String.toByte(): Byte = TODO("Wasm stdlib: Text")
/**
* Parses the string as a signed [Byte] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
* @throws IllegalArgumentException when [radix] is not a valid radix for string to number conversion.
*/
actual fun String.toByte(radix: Int): Byte = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Short] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
*/
actual fun String.toShort(): Short = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Short] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
* @throws IllegalArgumentException when [radix] is not a valid radix for string to number conversion.
*/
actual fun String.toShort(radix: Int): Short = TODO("Wasm stdlib: Text")
/**
* Parses the string as an [Int] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
*/
actual fun String.toInt(): Int = TODO("Wasm stdlib: Text")
/**
* Parses the string as an [Int] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
* @throws IllegalArgumentException when [radix] is not a valid radix for string to number conversion.
*/
actual fun String.toInt(radix: Int): Int = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Long] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
*/
actual fun String.toLong(): Long = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Long] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
* @throws IllegalArgumentException when [radix] is not a valid radix for string to number conversion.
*/
actual fun String.toLong(radix: Int): Long = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Double] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
*/
actual fun String.toDouble(): Double = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Float] number and returns the result.
* @throws NumberFormatException if the string is not a valid representation of a number.
*/
actual fun String.toFloat(): Float = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Double] number and returns the result
* or `null` if the string is not a valid representation of a number.
*/
actual fun String.toDoubleOrNull(): Double? = TODO("Wasm stdlib: Text")
/**
* Parses the string as a [Float] number and returns the result
* or `null` if the string is not a valid representation of a number.
*/
actual fun String.toFloatOrNull(): Float? = TODO("Wasm stdlib: Text")
/**
* Returns a string representation of this [Byte] value in the specified [radix].
*
* @throws IllegalArgumentException when [radix] is not a valid radix for number to string conversion.
*/
@SinceKotlin("1.2")
actual fun Byte.toString(radix: Int): String = TODO("Wasm stdlib: Text")
/**
* Returns a string representation of this [Short] value in the specified [radix].
*
* @throws IllegalArgumentException when [radix] is not a valid radix for number to string conversion.
*/
@SinceKotlin("1.2")
actual fun Short.toString(radix: Int): String = TODO("Wasm stdlib: Text")
/**
* Returns a string representation of this [Int] value in the specified [radix].
*
* @throws IllegalArgumentException when [radix] is not a valid radix for number to string conversion.
*/
@SinceKotlin("1.2")
actual fun Int.toString(radix: Int): String = TODO("Wasm stdlib: Text")
/**
* Returns a string representation of this [Long] value in the specified [radix].
*
* @throws IllegalArgumentException when [radix] is not a valid radix for number to string conversion.
*/
@SinceKotlin("1.2")
actual fun Long.toString(radix: Int): String = TODO("Wasm stdlib: Text")
@PublishedApi
internal actual fun checkRadix(radix: Int): Int = TODO("Wasm stdlib: Text")
internal actual fun digitOf(char: Char, radix: Int): Int = TODO("Wasm stdlib: Text")
@@ -0,0 +1,32 @@
/*
* 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.collections
/**
* Provides a skeletal implementation of the [MutableCollection] interface.
*
* @param E the type of elements contained in the collection. The collection is invariant on its element type.
*/
@SinceKotlin("1.3")
public actual abstract class AbstractMutableCollection<E> : MutableCollection<E> {
actual protected constructor()
actual abstract override val size: Int
actual abstract override fun iterator(): MutableIterator<E>
actual abstract override fun add(element: E): Boolean
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun contains(element: @UnsafeVariance E): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun addAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun remove(element: E): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun removeAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun retainAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableCollection")
actual override fun clear(): Unit = TODO("Wasm stdlib: AbstractMutableCollection")
}
@@ -0,0 +1,45 @@
/*
* 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.collections
/**
* Provides a skeletal implementation of the [MutableList] interface.
*
* @param E the type of elements contained in the list. The list is invariant on its element type.
*/
public actual abstract class AbstractMutableList<E> : MutableList<E> {
actual protected constructor()
// From List
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun contains(element: @UnsafeVariance E): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun indexOf(element: @UnsafeVariance E): Int = TODO("Wasm stdlib: AbstractMutableList")
actual override fun lastIndexOf(element: @UnsafeVariance E): Int = TODO("Wasm stdlib: AbstractMutableList")
// From MutableCollection
actual override fun iterator(): MutableIterator<E> = TODO("Wasm stdlib: AbstractMutableList")
// From MutableList
/**
* Adds the specified element to the end of this list.
*
* @return `true` because the list is always modified as the result of this operation.
*/
actual override fun add(element: E): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun remove(element: E): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun addAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun addAll(index: Int, elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun removeAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun retainAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableList")
actual override fun clear() { TODO("Wasm stdlib: AbstractMutableList") }
actual override fun listIterator(): MutableListIterator<E> = TODO("Wasm stdlib: AbstractMutableList")
actual override fun listIterator(index: Int): MutableListIterator<E> = TODO("Wasm stdlib: AbstractMutableList")
actual override fun subList(fromIndex: Int, toIndex: Int): MutableList<E> = TODO("Wasm stdlib: AbstractMutableList")
}
@@ -0,0 +1,42 @@
/*
* 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.collections
/**
* Provides a skeletal implementation of the [MutableMap] interface.
*
* The implementor is required to implement [entries] property, which should return mutable set of map entries, and [put] function.
*
* @param K the type of map keys. The map is invariant on its key type.
* @param V the type of map values. The map is invariant on its value type.
*/
@SinceKotlin("1.3")
public actual abstract class AbstractMutableMap<K, V> : MutableMap<K, V> {
actual protected constructor()
/**
* Associates the specified [value] with the specified [key] in the map.
*
* This method is redeclared as abstract, because it's not implemented in the base class,
* so it must be always overridden in the concrete mutable collection implementation.
*
* @return the previous value associated with the key, or `null` if the key was not present in the map.
*/
abstract actual override fun put(key: K, value: V): V?
abstract actual override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
actual override val keys: MutableSet<K> = TODO("Wasm stdlib: AbstractMutableMap")
actual override val size: Int = TODO("Wasm stdlib: AbstractMutableMap")
actual override val values: MutableCollection<V> = TODO("Wasm stdlib: AbstractMutableMap")
actual override fun clear() { TODO("Wasm stdlib: AbstractMutableMap") }
actual override fun containsKey(key: K): Boolean = TODO("Wasm stdlib: AbstractMutableMap")
actual override fun containsValue(value: V): Boolean = TODO("Wasm stdlib: AbstractMutableMap")
actual override fun get(key: K): V? = TODO("Wasm stdlib: AbstractMutableMap")
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: AbstractMutableMap")
actual override fun putAll(from: Map<out K, V>) { TODO("Wasm stdlib: AbstractMutableMap") }
actual override fun remove(key: K): V? = TODO("Wasm stdlib: AbstractMutableMap")
}
@@ -0,0 +1,31 @@
/*
* 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.collections
/**
* Provides a skeletal implementation of the [MutableSet] interface.
*
* @param E the type of elements contained in the set. The set is invariant on its element type.
*/
@SinceKotlin("1.3")
public actual abstract class AbstractMutableSet<E> : MutableSet<E> {
actual protected constructor()
actual abstract override val size: Int
actual abstract override fun iterator(): MutableIterator<E>
actual abstract override fun add(element: E): Boolean
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun contains(element: @UnsafeVariance E): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun addAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun remove(element: E): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun removeAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun retainAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: AbstractMutableSet")
actual override fun clear() { TODO("Wasm stdlib: AbstractMutableSet") }
}
@@ -0,0 +1,45 @@
/*
* 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.collections
actual open class ArrayList<E> : MutableList<E>, RandomAccess {
actual constructor() { TODO("Wasm stdlib: ArrayList") }
actual constructor(initialCapacity: Int) { TODO("Wasm stdlib: ArrayList") }
actual constructor(elements: Collection<E>) { TODO("Wasm stdlib: ArrayList") }
actual fun trimToSize() { TODO("Wasm stdlib: ArrayList") }
actual fun ensureCapacity(minCapacity: Int) { TODO("Wasm stdlib: ArrayList") }
// From List
actual override val size: Int = TODO("Wasm stdlib: ArrayList")
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun contains(element: @UnsafeVariance E): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean = TODO("Wasm stdlib: ArrayList")
actual override operator fun get(index: Int): E = TODO("Wasm stdlib: ArrayList")
actual override fun indexOf(element: @UnsafeVariance E): Int = TODO("Wasm stdlib: ArrayList")
actual override fun lastIndexOf(element: @UnsafeVariance E): Int = TODO("Wasm stdlib: ArrayList")
// From MutableCollection
actual override fun iterator(): MutableIterator<E> = TODO("Wasm stdlib: ArrayList")
// From MutableList
actual override fun add(element: E): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun remove(element: E): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun addAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun addAll(index: Int, elements: Collection<E>): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun removeAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun retainAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: ArrayList")
actual override fun clear() { TODO("Wasm stdlib: ArrayList") }
actual override operator fun set(index: Int, element: E): E = TODO("Wasm stdlib: ArrayList")
actual override fun add(index: Int, element: E) { TODO("Wasm stdlib: ArrayList") }
actual override fun removeAt(index: Int): E = TODO("Wasm stdlib: ArrayList")
actual override fun listIterator(): MutableListIterator<E> = TODO("Wasm stdlib: ArrayList")
actual override fun listIterator(index: Int): MutableListIterator<E> = TODO("Wasm stdlib: ArrayList")
actual override fun subList(fromIndex: Int, toIndex: Int): MutableList<E> = TODO("Wasm stdlib: ArrayList")
}
@@ -0,0 +1,105 @@
/*
* 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.collections
import kotlin.internal.PureReifiable
// Array Utils copied from K/N
internal fun checkCopyOfRangeArguments(fromIndex: Int, toIndex: Int, size: Int) {
if (toIndex > size)
throw IndexOutOfBoundsException("toIndex ($toIndex) is greater than size ($size).")
if (fromIndex > toIndex)
throw IllegalArgumentException("fromIndex ($fromIndex) is greater than toIndex ($toIndex).")
}
// TODO: internal
/**
* Returns a string representation of the contents of the subarray of the specified array as if it is [List].
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public inline fun <T> Array<out T>.subarrayContentToString(offset: Int, length: Int): String {
val sb = StringBuilder(2 + length * 3)
sb.append("[")
var i = 0
while (i < length) {
if (i > 0) sb.append(", ")
sb.append(this[offset + i])
i++
}
sb.append("]")
return sb.toString()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
* Nested arrays are treated as lists too.
*
* If any of arrays contains itself on any nesting level the behavior is undefined.
*/
@SinceKotlin("1.1")
@UseExperimental(ExperimentalUnsignedTypes::class)
internal fun <T> Array<out T>?.contentDeepHashCodeImpl(): Int {
if (this == null) return 0
var result = 1
for (element in this) {
val elementHash = when (element) {
null -> 0
is Array<*> -> element.contentDeepHashCode()
is ByteArray -> element.contentHashCode()
is ShortArray -> element.contentHashCode()
is IntArray -> element.contentHashCode()
is LongArray -> element.contentHashCode()
is FloatArray -> element.contentHashCode()
is DoubleArray -> element.contentHashCode()
is CharArray -> element.contentHashCode()
is BooleanArray -> element.contentHashCode()
is UByteArray -> element.contentHashCode()
is UShortArray -> element.contentHashCode()
is UIntArray -> element.contentHashCode()
is ULongArray -> element.contentHashCode()
else -> element.hashCode()
}
result = 31 * result + elementHash
}
return result
}
@Suppress("UNCHECKED_CAST")
internal actual fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T> = arrayOfNulls<Any>(size) as Array<T>
internal actual fun copyToArrayImpl(collection: Collection<*>): Array<Any?> {
val array = Array<Any?>(collection.size)
val iterator = collection.iterator()
var index = 0
while (iterator.hasNext())
array[index++] = iterator.next()
return array
}
@Suppress("UNCHECKED_CAST")
internal actual fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> {
if (array.size < collection.size)
return copyToArrayImpl(collection) as Array<T>
val iterator = collection.iterator()
var index = 0
while (iterator.hasNext()) {
array[index++] = iterator.next() as T
}
if (index < array.size) {
return array.copyOf(index) as Array<T>
}
return array
}
@@ -0,0 +1,111 @@
/*
* 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.collections
actual interface RandomAccess
/** Returns the array if it's not `null`, or an empty array otherwise. */
actual inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()
public actual inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
val result = arrayOfNulls<T>(size)
var index = 0
for (element in this) result[index++] = element
@Suppress("UNCHECKED_CAST")
return result as Array<T>
}
@SinceKotlin("1.2")
actual fun <T> MutableList<T>.fill(value: T): Unit = TODO("Wasm stdlib: Collections")
@SinceKotlin("1.2")
actual fun <T> MutableList<T>.shuffle(): Unit = TODO("Wasm stdlib: Collections")
@SinceKotlin("1.2")
actual fun <T> Iterable<T>.shuffled(): List<T> = TODO("Wasm stdlib: Collections")
actual fun <T : Comparable<T>> MutableList<T>.sort(): Unit = TODO("Wasm stdlib: Collections")
actual fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit = TODO("Wasm stdlib: Collections")
// from Grouping.kt
public actual fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int> = TODO("Wasm stdlib: Collections")
// public actual inline fun <T, K> Grouping<T, K>.eachSumOf(valueSelector: (T) -> Int): Map<K, Int>
internal actual fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = TODO("Wasm stdlib: Collections")
internal actual fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> = TODO("Wasm stdlib: Collections")
internal actual fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> = TODO("Wasm stdlib: Collections")
@PublishedApi
@SinceKotlin("1.3")
internal actual fun checkIndexOverflow(index: Int): Int = TODO("Wasm stdlib: Collections")
@PublishedApi
@SinceKotlin("1.3")
internal actual fun checkCountOverflow(count: Int): Int = TODO("Wasm stdlib: Collections")
@PublishedApi
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun <E> buildListInternal(builderAction: MutableList<E>.() -> Unit): List<E> {
return TODO("Wasm stdlib: Collections")
}
@PublishedApi
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun <E> buildListInternal(capacity: Int, builderAction: MutableList<E>.() -> Unit): List<E> {
checkBuilderCapacity(capacity)
return TODO("Wasm stdlib: Collections")
}
/**
* Returns an immutable set containing only the specified object [element].
*/
public fun <T> setOf(element: T): Set<T> = hashSetOf(element)
@PublishedApi
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun <E> buildSetInternal(builderAction: MutableSet<E>.() -> Unit): Set<E> {
return TODO("Wasm stdlib: Collections")
}
@PublishedApi
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun <E> buildSetInternal(capacity: Int, builderAction: MutableSet<E>.() -> Unit): Set<E> {
return TODO("Wasm stdlib: Collections")
}
/**
* Returns an immutable map, mapping only the specified key to the
* specified value.
*/
public fun <K, V> mapOf(pair: Pair<K, V>): Map<K, V> = hashMapOf(pair)
@PublishedApi
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun <K, V> buildMapInternal(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {
return TODO("Wasm stdlib: Collections")
}
@PublishedApi
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
internal actual inline fun <K, V> buildMapInternal(capacity: Int, builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> {
return TODO("Wasm stdlib: Collections")
}
@@ -0,0 +1,31 @@
/*
* 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.collections
actual open class HashMap<K, V> : MutableMap<K, V> {
actual constructor() { TODO("Wasm stdlib: HashMap") }
actual constructor(initialCapacity: Int) { TODO("Wasm stdlib: HashMap") }
actual constructor(initialCapacity: Int, loadFactor: Float) { TODO("Wasm stdlib: HashMap") }
actual constructor(original: Map<out K, V>) { TODO("Wasm stdlib: HashMap") }
// From Map
actual override val size: Int = TODO("Wasm stdlib: HashMap")
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: HashMap")
actual override fun containsKey(key: K): Boolean = TODO("Wasm stdlib: HashMap")
actual override fun containsValue(value: @UnsafeVariance V): Boolean = TODO("Wasm stdlib: HashMap")
actual override operator fun get(key: K): V? = TODO("Wasm stdlib: HashMap")
// From MutableMap
actual override fun put(key: K, value: V): V? = TODO("Wasm stdlib: HashMap")
actual override fun remove(key: K): V? = TODO("Wasm stdlib: HashMap")
actual override fun putAll(from: Map<out K, V>) { TODO("Wasm stdlib: HashMap") }
actual override fun clear() { TODO("Wasm stdlib: HashMap") }
actual override val keys: MutableSet<K> = TODO("Wasm stdlib: HashMap")
actual override val values: MutableCollection<V> = TODO("Wasm stdlib: HashMap")
actual override val entries: MutableSet<MutableMap.MutableEntry<K, V>> = TODO("Wasm stdlib: HashMap")
}
@@ -0,0 +1,30 @@
/*
* 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.collections
actual open class HashSet<E> : MutableSet<E> {
actual constructor() { TODO("Wasm stdlib: HashSet") }
actual constructor(initialCapacity: Int) { TODO("Wasm stdlib: HashSet") }
actual constructor(initialCapacity: Int, loadFactor: Float) { TODO("Wasm stdlib: HashSet") }
actual constructor(elements: Collection<E>) { TODO("Wasm stdlib: HashSet") }
// From Set
actual override val size: Int = TODO("Wasm stdlib: HashSet")
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun contains(element: @UnsafeVariance E): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean = TODO("Wasm stdlib: HashSet")
// From MutableSet
actual override fun iterator(): MutableIterator<E> = TODO("Wasm stdlib: HashSet")
actual override fun add(element: E): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun remove(element: E): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun addAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun removeAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun retainAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: HashSet")
actual override fun clear() { TODO("Wasm stdlib: HashSet") }
}
@@ -0,0 +1,31 @@
/*
* 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.collections
actual open class LinkedHashMap<K, V> : MutableMap<K, V> {
actual constructor() { TODO("Wasm stdlib: LinkedHashMap") }
actual constructor(initialCapacity: Int) { TODO("Wasm stdlib: LinkedHashMap") }
actual constructor(initialCapacity: Int, loadFactor: Float) { TODO("Wasm stdlib: LinkedHashMap") }
actual constructor(original: Map<out K, V>) { TODO("Wasm stdlib: LinkedHashMap") }
// From Map
actual override val size: Int = TODO("Wasm stdlib: LinkedHashMap")
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: LinkedHashMap")
actual override fun containsKey(key: K): Boolean = TODO("Wasm stdlib: LinkedHashMap")
actual override fun containsValue(value: V): Boolean = TODO("Wasm stdlib: LinkedHashMap")
actual override fun get(key: K): V? = TODO("Wasm stdlib: LinkedHashMap")
// From MutableMap
actual override fun put(key: K, value: V): V? = TODO("Wasm stdlib: LinkedHashMap")
actual override fun remove(key: K): V? = TODO("Wasm stdlib: LinkedHashMap")
actual override fun putAll(from: Map<out K, V>) { TODO("Wasm stdlib: LinkedHashMap") }
actual override fun clear() { TODO("Wasm stdlib: LinkedHashMap") }
actual override val keys: MutableSet<K> = TODO("Wasm stdlib: LinkedHashMap")
actual override val values: MutableCollection<V> = TODO("Wasm stdlib: LinkedHashMap")
actual override val entries: MutableSet<MutableMap.MutableEntry<K, V>> = TODO("Wasm stdlib: LinkedHashMap")
}
@@ -0,0 +1,30 @@
/*
* 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.collections
actual open class LinkedHashSet<E> : MutableSet<E> {
actual constructor() { TODO("Wasm stdlib: LinkedHashSet") }
actual constructor(initialCapacity: Int) { TODO("Wasm stdlib: LinkedHashSet") }
actual constructor(initialCapacity: Int, loadFactor: Float) { TODO("Wasm stdlib: LinkedHashSet") }
actual constructor(elements: Collection<E>) { TODO("Wasm stdlib: LinkedHashSet") }
// From Set
actual override val size: Int = TODO("Wasm stdlib: LinkedHashSet")
actual override fun isEmpty(): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun contains(element: @UnsafeVariance E): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun containsAll(elements: Collection<@UnsafeVariance E>): Boolean = TODO("Wasm stdlib: LinkedHashSet")
// From MutableSet
actual override fun iterator(): MutableIterator<E> = TODO("Wasm stdlib: LinkedHashSet")
actual override fun add(element: E): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun remove(element: E): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun addAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun removeAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun retainAll(elements: Collection<E>): Boolean = TODO("Wasm stdlib: LinkedHashSet")
actual override fun clear() { TODO("Wasm stdlib: LinkedHashSet") }
}
@@ -0,0 +1,20 @@
/*
* 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.collections
/**
* Calculate the initial capacity of a map.
*/
@PublishedApi
internal actual fun mapCapacity(expectedSize: Int): Int = TODO("Wasm stdlib: Maps")
/**
* Checks a collection builder function capacity argument.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
@PublishedApi
internal fun checkBuilderCapacity(capacity: Int) { TODO("Wasm stdlib: Maps") }
@@ -0,0 +1,21 @@
/*
* 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.coroutines
@PublishedApi
@SinceKotlin("1.3")
internal actual class SafeContinuation<in T> : Continuation<T> {
actual internal constructor(delegate: Continuation<T>, initialResult: Any?) { TODO("Wasm stdlib: Coroutines") }
@PublishedApi
actual internal constructor(delegate: Continuation<T>) { TODO("Wasm stdlib: Coroutines") }
@PublishedApi
actual internal fun getOrThrow(): Any? = TODO("Wasm stdlib: Coroutines")
actual override val context: CoroutineContext = TODO("Wasm stdlib: Coroutines")
actual override fun resumeWith(result: Result<T>): Unit { TODO("Wasm stdlib: Coroutines") }
}
@@ -0,0 +1,76 @@
/*
* 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.coroutines.intrinsics
import kotlin.coroutines.Continuation
import kotlin.coroutines.ContinuationInterceptor
import kotlin.coroutines.CoroutineContext
import kotlin.internal.InlineOnly
/**
* Starts an unintercepted coroutine without a receiver and with result type [T] and executes it until its first suspension.
* Returns the result of the coroutine or throws its exception if it does not suspend or [COROUTINE_SUSPENDED] if it suspends.
* In the latter case, the [completion] continuation is invoked when the coroutine completes with a result or an exception.
*
* The coroutine is started directly in the invoker's thread without going through the [ContinuationInterceptor] that might
* be present in the completion's [CoroutineContext]. It is the invoker's responsibility to ensure that a proper invocation
* context is established.
*
* This function is designed to be used from inside of [suspendCoroutineUninterceptedOrReturn] to resume the execution of the suspended
* coroutine using a reference to the suspending function.
*/
@SinceKotlin("1.3")
public actual inline fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn(
completion: Continuation<T>
): Any? = TODO("Wasm stdlib: Coroutines intrinsics")
/**
* Starts an unintercepted coroutine with receiver type [R] and result type [T] and executes it until its first suspension.
* Returns the result of the coroutine or throws its exception if it does not suspend or [COROUTINE_SUSPENDED] if it suspends.
* In the latter case, the [completion] continuation is invoked when the coroutine completes with a result or an exception.
*
* The coroutine is started directly in the invoker's thread without going through the [ContinuationInterceptor] that might
* be present in the completion's [CoroutineContext]. It is the invoker's responsibility to ensure that a proper invocation
* context is established.
*
* This function is designed to be used from inside of [suspendCoroutineUninterceptedOrReturn] to resume the execution of the suspended
* coroutine using a reference to the suspending function.
*/
@SinceKotlin("1.3")
public actual inline fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn(
receiver: R,
completion: Continuation<T>
): Any? = TODO("Wasm stdlib: Coroutines intrinsics")
@InlineOnly
internal actual inline fun <R, P, T> (suspend R.(P) -> T).startCoroutineUninterceptedOrReturn(
receiver: R,
param: P,
completion: Continuation<T>
): Any? = TODO("Wasm stdlib: Coroutines intrinsics")
@SinceKotlin("1.3")
public actual fun <T> (suspend () -> T).createCoroutineUnintercepted(
completion: Continuation<T>
): Continuation<Unit> = TODO("Wasm stdlib: Coroutines intrinsics")
@SinceKotlin("1.3")
public actual fun <R, T> (suspend R.() -> T).createCoroutineUnintercepted(
receiver: R,
completion: Continuation<T>
): Continuation<Unit> = TODO("Wasm stdlib: Coroutines intrinsics")
/**
* Intercepts this continuation with [ContinuationInterceptor].
*
* This function shall be used on the immediate result of [createCoroutineUnintercepted] or [suspendCoroutineUninterceptedOrReturn],
* in which case it checks for [ContinuationInterceptor] in the continuation's [context][Continuation.context],
* invokes [ContinuationInterceptor.interceptContinuation], caches and returns the result.
*
* If this function is invoked on other [Continuation] instances it returns `this` continuation unchanged.
*/
@SinceKotlin("1.3")
public actual fun <T> Continuation<T>.intercepted(): Continuation<T> = TODO("Wasm stdlib: Coroutines intrinsics")
@@ -0,0 +1,15 @@
/*
* 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.coroutines.cancellation
@ExperimentalStdlibApi
@SinceKotlin("1.4")
public actual open class CancellationException : IllegalStateException {
actual constructor() : super()
actual constructor(message: String?) : super(message)
constructor(message: String?, cause: Throwable?) : super(message, cause)
constructor(cause: Throwable?) : super(cause)
}
+31
View File
@@ -0,0 +1,31 @@
/*
* 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.io
import kotlin.wasm.internal.*
/** Prints the line separator to the standard output stream. */
public actual fun println() {
println("")
}
/** Prints the given [message] and the line separator to the standard output stream. */
public actual fun println(message: Any?) {
printlnImpl(message.toString())
}
/** Prints the given [message] to the standard output stream. */
public actual fun print(message: Any?) {
// TODO: Support print without newline
println(message)
}
internal actual interface Serializable
@WasmImport("runtime", "println")
private fun printlnImpl(message: String): Unit =
implementedAsIntrinsic
@@ -0,0 +1,9 @@
/*
* 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.random
internal actual fun defaultPlatformRandom(): Random = TODO("Wasm stdlib: Random")
internal actual fun doubleFromParts(hi26: Int, low27: Int): Double = TODO("Wasm stdlib: Random")
@@ -0,0 +1,23 @@
/*
* 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.reflect
/**
* Represents a callable entity, such as a function or a property.
*
* @param R return type of the callable.
*/
public actual interface KCallable<out R> {
/**
* The name of this callable as it was declared in the source code.
* If the callable has no name, a special invented name is created.
* Nameless callables include:
* - constructors have the name "<init>",
* - property accessors: the getter for a property named "foo" will have the name "<get-foo>",
* the setter, similarly, will have the name "<set-foo>".
*/
actual public val name: String
}
@@ -0,0 +1,35 @@
/*
* 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.reflect
/**
* Represents a class and provides introspection capabilities.
* Instances of this class are obtainable by the `::class` syntax.
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html#class-references)
* for more information.
*
* @param T the type of the class.
*/
public actual interface KClass<T : Any> : KClassifier {
/**
* The simple name of the class as it was declared in the source code,
* or `null` if the class has no name (if, for example, it is a class of an anonymous object).
*/
public actual val simpleName: String?
/**
* The fully qualified dot-separated name of the class,
* or `null` if the class is local or a class of an anonymous object.
*/
public actual val qualifiedName: String?
/**
* Returns `true` if [value] is an instance of this class on a given platform.
*/
@SinceKotlin("1.1")
public actual fun isInstance(value: Any?): Boolean
}
@@ -0,0 +1,8 @@
/*
* 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.reflect
internal actual val KClass<*>.qualifiedOrSimpleName: String? get() = TODO("Wasm stdlib: KClass<*>.qualifiedOrSimpleName")
@@ -0,0 +1,11 @@
/*
* 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.reflect
/**
* Represents a function with introspection capabilities.
*/
public actual interface KFunction<out R> : KCallable<R>, Function<R>
@@ -0,0 +1,119 @@
/*
* 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.
*/
@file:Suppress("IMPLEMENTING_FUNCTION_INTERFACE")
package kotlin.reflect
/**
* Represents a property, such as a named `val` or `var` declaration.
* Instances of this class are obtainable by the `::` operator.
*
* See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/reflection.html)
* for more information.
*
* @param R the type of the property.
*/
public actual interface KProperty<out R> : KCallable<R> {
}
/**
* Represents a property declared as a `var`.
*/
public actual interface KMutableProperty<R> : KProperty<R> {
}
/**
* Represents a property without any kind of receiver.
* Such property is either originally declared in a receiverless context such as a package,
* or has the receiver bound to it.
*/
public actual interface KProperty0<out R> : KProperty<R>, () -> R {
/**
* Returns the current value of the property.
*/
public actual fun get(): R
}
/**
* Represents a `var`-property without any kind of receiver.
*/
public actual interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
/**
* Modifies the value of the property.
*
* @param value the new value to be assigned to this property.
*/
public actual fun set(value: R)
}
/**
* Represents a property, operations on which take one receiver as a parameter.
*
* @param T the type of the receiver which should be used to obtain the value of the property.
* @param R the type of the property.
*/
public actual interface KProperty1<T, out R> : KProperty<R>, (T) -> R {
/**
* Returns the current value of the property.
*
* @param receiver the receiver which is used to obtain the value of the property.
* For example, it should be a class instance if this is a member property of that class,
* or an extension receiver if this is a top level extension property.
*/
public actual fun get(receiver: T): R
}
/**
* Represents a `var`-property, operations on which take one receiver as a parameter.
*/
public actual interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R> {
/**
* Modifies the value of the property.
*
* @param receiver the receiver which is used to modify the value of the property.
* For example, it should be a class instance if this is a member property of that class,
* or an extension receiver if this is a top level extension property.
* @param value the new value to be assigned to this property.
*/
public actual fun set(receiver: T, value: R)
}
/**
* Represents a property, operations on which take two receivers as parameters,
* such as an extension property declared in a class.
*
* @param D the type of the first receiver. In case of the extension property in a class this is
* the type of the declaring class of the property, or any subclass of that class.
* @param E the type of the second receiver. In case of the extension property in a class this is
* the type of the extension receiver.
* @param R the type of the property.
*/
public actual interface KProperty2<D, E, out R> : KProperty<R>, (D, E) -> R {
/**
* Returns the current value of the property. In case of the extension property in a class,
* the instance of the class should be passed first and the instance of the extension receiver second.
*
* @param receiver1 the instance of the first receiver.
* @param receiver2 the instance of the second receiver.
*/
public actual fun get(receiver1: D, receiver2: E): R
}
/**
* Represents a `var`-property, operations on which take two receivers as parameters.
*/
public actual interface KMutableProperty2<D, E, R> : KProperty2<D, E, R>, KMutableProperty<R> {
/**
* Modifies the value of the property.
*
* @param receiver1 the instance of the first receiver.
* @param receiver2 the instance of the second receiver.
* @param value the new value to be assigned to this property.
*/
public actual fun set(receiver1: D, receiver2: E, value: R)
}
@@ -0,0 +1,51 @@
/*
* 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.reflect
/**
* Represents a type. Type is usually either a class with optional type arguments,
* or a type parameter of some declaration, plus nullability.
*/
public actual interface KType {
/**
* The declaration of the classifier used in this type.
* For example, in the type `List<String>` the classifier would be the [KClass] instance for [List].
*
* Returns `null` if this type is not denotable in Kotlin, for example if it is an intersection type.
*/
@SinceKotlin("1.1")
public actual val classifier: KClassifier?
/**
* Type arguments passed for the parameters of the classifier in this type.
* For example, in the type `Array<out Number>` the only type argument is `out Number`.
*
* In case this type is based on an inner class, the returned list contains the type arguments provided for the innermost class first,
* then its outer class, and so on.
* For example, in the type `Outer<A, B>.Inner<C, D>` the returned list is `[C, D, A, B]`.
*/
@SinceKotlin("1.1")
public actual val arguments: List<KTypeProjection>
/**
* `true` if this type was marked nullable in the source code.
*
* For Kotlin types, it means that `null` value is allowed to be represented by this type.
* In practice it means that the type was declared with a question mark at the end.
* For non-Kotlin types, it means the type or the symbol which was declared with this type
* is annotated with a runtime-retained nullability annotation such as [javax.annotation.Nullable].
*
* Note that even if [isMarkedNullable] is false, values of the type can still be `null`.
* This may happen if it is a type of the type parameter with a nullable upper bound:
*
* ```
* fun <T> foo(t: T) {
* // isMarkedNullable == false for t's type, but t can be null here when T = "Any?"
* }
* ```
*/
public actual val isMarkedNullable: Boolean
}
@@ -0,0 +1,37 @@
/*
* 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.text
/**
* An object to which char sequences and values can be appended.
*/
actual interface Appendable {
/**
* Appends the specified character [value] to this Appendable and returns this instance.
*
* @param value the character to append.
*/
actual fun append(value: Char): Appendable
/**
* Appends the specified character sequence [value] to this Appendable and returns this instance.
*
* @param value the character sequence to append. If [value] is `null`, then the four characters `"null"` are appended to this Appendable.
*/
actual fun append(value: CharSequence?): Appendable
/**
* Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance.
*
* @param value the character sequence from which a subsequence is appended. If [value] is `null`,
* then characters are appended as if [value] contained the four characters `"null"`.
* @param startIndex the beginning (inclusive) of the subsequence to append.
* @param endIndex the end (exclusive) of the subsequence to append.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
*/
actual fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable
}
@@ -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.text
/**
* The exception thrown when a character encoding or decoding error occurs.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual open class CharacterCodingException actual constructor() : Exception()
@@ -0,0 +1,387 @@
/*
* 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.text
/**
* A mutable sequence of characters.
*
* String builder can be used to efficiently perform multiple string manipulation operations.
*/
actual class StringBuilder : Appendable, CharSequence {
/** Constructs an empty string builder. */
actual constructor() { TODO("Wasm stdlib: StringBuilder") }
/** Constructs an empty string builder with the specified initial [capacity]. */
actual constructor(capacity: Int) { TODO("Wasm stdlib: StringBuilder") }
/** Constructs a string builder that contains the same characters as the specified [content] char sequence. */
actual constructor(content: CharSequence) { TODO("Wasm stdlib: StringBuilder") }
/** Constructs a string builder that contains the same characters as the specified [content] string. */
@SinceKotlin("1.3")
// @ExperimentalStdlibApi
actual constructor(content: String) { TODO("Wasm stdlib: StringBuilder") }
actual override val length: Int = TODO("Wasm stdlib: StringBuilder")
actual override operator fun get(index: Int): Char = TODO("Wasm stdlib: StringBuilder")
actual override fun subSequence(startIndex: Int, endIndex: Int): CharSequence = TODO("Wasm stdlib: StringBuilder")
actual override fun append(value: Char): StringBuilder = TODO("Wasm stdlib: StringBuilder")
actual override fun append(value: CharSequence?): StringBuilder = TODO("Wasm stdlib: StringBuilder")
actual override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Reverses the contents of this string builder and returns this instance.
*
* Surrogate pairs included in this string builder are treated as single characters.
* Therefore, the order of the high-low surrogates is never reversed.
*
* Note that the reverse operation may produce new surrogate pairs that were unpaired low-surrogates and high-surrogates before the operation.
* For example, reversing `"\uDC00\uD800"` produces `"\uD800\uDC00"` which is a valid surrogate pair.
*/
actual fun reverse(): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Appends the string representation of the specified object [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
actual fun append(value: Any?): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Appends the string representation of the specified boolean [value] to this string builder and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was appended to this string builder.
*/
@SinceKotlin("1.3")
// @ExperimentalStdlibApi
actual fun append(value: Boolean): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Appends characters in the specified character array [value] to this string builder and returns this instance.
*
* Characters are appended in order, starting at the index 0.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun append(value: CharArray): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Appends the specified string [value] to this string builder and returns this instance.
*/
@SinceKotlin("1.3")
// @ExperimentalStdlibApi
actual fun append(value: String?): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Returns the current capacity of this string builder.
*
* The capacity is the maximum length this string builder can have before an allocation occurs.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun capacity(): Int = TODO("Wasm stdlib: StringBuilder")
/**
* Ensures that the capacity of this string builder is at least equal to the specified [minimumCapacity].
*
* If the current capacity is less than the [minimumCapacity], a new backing storage is allocated with greater capacity.
* Otherwise, this method takes no action and simply returns.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun ensureCapacity(minimumCapacity: Int) { TODO("Wasm stdlib: StringBuilder") }
/**
* Returns the index within this string builder of the first occurrence of the specified [string].
*
* Returns `-1` if the specified [string] does not occur in this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun indexOf(string: String): Int = TODO("Wasm stdlib: StringBuilder")
/**
* Returns the index within this string builder of the first occurrence of the specified [string],
* starting at the specified [startIndex].
*
* Returns `-1` if the specified [string] does not occur in this string builder starting at the specified [startIndex].
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun indexOf(string: String, startIndex: Int): Int = TODO("Wasm stdlib: StringBuilder")
/**
* Returns the index within this string builder of the last occurrence of the specified [string].
* The last occurrence of empty string `""` is considered to be at the index equal to `this.length`.
*
* Returns `-1` if the specified [string] does not occur in this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun lastIndexOf(string: String): Int = TODO("Wasm stdlib: StringBuilder")
/**
* Returns the index within this string builder of the last occurrence of the specified [string],
* starting from the specified [startIndex] toward the beginning.
*
* Returns `-1` if the specified [string] does not occur in this string builder starting at the specified [startIndex].
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun lastIndexOf(string: String, startIndex: Int): Int = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts the string representation of the specified boolean [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun insert(index: Int, value: Boolean): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts the specified character [value] into this string builder at the specified [index] and returns this instance.
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun insert(index: Int, value: Char): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts characters in the specified character array [value] into this string builder at the specified [index] and returns this instance.
*
* The inserted characters go in same order as in the [value] character array, starting at [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun insert(index: Int, value: CharArray): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts characters in the specified character sequence [value] into this string builder at the specified [index] and returns this instance.
*
* The inserted characters go in the same order as in the [value] character sequence, starting at [index].
*
* @param index the position in this string builder to insert at.
* @param value the character sequence from which characters are inserted. If [value] is `null`, then the four characters `"null"` are inserted.
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun insert(index: Int, value: CharSequence?): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts the string representation of the specified object [value] into this string builder at the specified [index] and returns this instance.
*
* The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
* and then that string was inserted into this string builder at the specified [index].
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun insert(index: Int, value: Any?): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts the string [value] into this string builder at the specified [index] and returns this instance.
*
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun insert(index: Int, value: String?): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Sets the length of this string builder to the specified [newLength].
*
* If the [newLength] is less than the current length, it is changed to the specified [newLength].
* Otherwise, null characters '\u0000' are appended to this string builder until its length is less than the [newLength].
*
* Note that in Kotlin/JS [set] operator function has non-constant execution time complexity.
* Therefore, increasing length of this string builder and then updating each character by index may slow down your program.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] if [newLength] is less than zero.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun setLength(newLength: Int) { TODO("Wasm stdlib: StringBuilder") }
/**
* Returns a new [String] that contains characters in this string builder at [startIndex] (inclusive) and up to the [length] (exclusive).
*
* @throws IndexOutOfBoundsException if [startIndex] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun substring(startIndex: Int): String = TODO("Wasm stdlib: StringBuilder")
/**
* Returns a new [String] that contains characters in this string builder at [startIndex] (inclusive) and up to the [endIndex] (exclusive).
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun substring(startIndex: Int, endIndex: Int): String = TODO("Wasm stdlib: StringBuilder")
/**
* Attempts to reduce storage used for this string builder.
*
* If the backing storage of this string builder is larger than necessary to hold its current contents,
* then it may be resized to become more space efficient.
* Calling this method may, but is not required to, affect the value of the [capacity] property.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
actual fun trimToSize() { TODO("Wasm stdlib: StringBuilder") }
}
/**
* Clears the content of this string builder making it empty and returns this instance.
*
* @sample samples.text.Strings.clearStringBuilder
*/
@SinceKotlin("1.3")
public actual fun StringBuilder.clear(): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Sets the character at the specified [index] to the specified [value].
*
* @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual operator fun StringBuilder.set(index: Int, value: Char) { TODO("Wasm stdlib: StringBuilder") }
/**
* Replaces characters in the specified range of this string builder with characters in the specified string [value] and returns this instance.
*
* @param startIndex the beginning (inclusive) of the range to replace.
* @param endIndex the end (exclusive) of the range to replace.
* @param value the string to replace with.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] if [startIndex] is less than zero, greater than the length of this string builder, or `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Removes the character at the specified [index] from this string builder and returns this instance.
*
* If the `Char` at the specified [index] is part of a supplementary code point, this method does not remove the entire supplementary character.
*
* @param index the index of `Char` to remove.
*
* @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.deleteAt(index: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Removes characters in the specified range from this string builder and returns this instance.
*
* @param startIndex the beginning (inclusive) of the range to remove.
* @param endIndex the end (exclusive) of the range to remove.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.deleteRange(startIndex: Int, endIndex: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Copies characters from this string builder into the [destination] character array.
*
* @param destination the array to copy to.
* @param destinationOffset the position in the array to copy to, 0 by default.
* @param startIndex the beginning (inclusive) of the range to copy, 0 by default.
* @param endIndex the end (exclusive) of the range to copy, length of this string builder by default.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
* or when that index is out of the [destination] array indices range.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int, startIndex: Int, endIndex: Int) { TODO("Wasm stdlib: StringBuilder") }
/**
* Appends characters in a subarray of the specified character array [value] to this string builder and returns this instance.
*
* Characters are appended in order, starting at specified [startIndex].
*
* @param value the array from which characters are appended.
* @param startIndex the beginning (inclusive) of the subarray to append.
* @param endIndex the end (exclusive) of the subarray to append.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] array indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Appends a subsequence of the specified character sequence [value] to this string builder and returns this instance.
*
* @param value the character sequence from which a subsequence is appended. If [value] is `null`,
* then characters are appended as if [value] contained the four characters `"null"`.
* @param startIndex the beginning (inclusive) of the subsequence to append.
* @param endIndex the end (exclusive) of the subsequence to append.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts characters in a subarray of the specified character array [value] into this string builder at the specified [index] and returns this instance.
*
* The inserted characters go in same order as in the [value] array, starting at [index].
*
* @param index the position in this string builder to insert at.
* @param value the array from which characters are inserted.
* @param startIndex the beginning (inclusive) of the subarray to insert.
* @param endIndex the end (exclusive) of the subarray to insert.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] array indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
/**
* Inserts characters in a subsequence of the specified character sequence [value] into this string builder at the specified [index] and returns this instance.
*
* The inserted characters go in the same order as in the [value] character sequence, starting at [index].
*
* @param index the position in this string builder to insert at.
* @param value the character sequence from which a subsequence is inserted. If [value] is `null`,
* then characters will be inserted as if [value] contained the four characters `"null"`.
* @param startIndex the beginning (inclusive) of the subsequence to insert.
* @param endIndex the end (exclusive) of the subsequence to insert.
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
* @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder = TODO("Wasm stdlib: StringBuilder")
@@ -0,0 +1,45 @@
/*
* 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
/**
* Returns the detailed description of this throwable with its stack trace.
*
* The detailed description includes:
* - the short description (see [Throwable.toString]) of this throwable;
* - the complete stack trace;
* - detailed descriptions of the exceptions that were [suppressed][suppressedExceptions] in order to deliver this exception;
* - the detailed description of each throwable in the [Throwable.cause] chain.
*/
@SinceKotlin("1.4")
public actual fun Throwable.stackTraceToString(): String =
TODO("Implement stackTraceToString")
/**
* Prints the [detailed description][Throwable.stackTraceToString] of this throwable to console error output.
*/
@SinceKotlin("1.4")
public actual fun Throwable.printStackTrace() {
TODO("Implement printStackTrace")
}
/**
* Adds the specified exception to the list of exceptions that were
* suppressed in order to deliver this exception.
*/
@SinceKotlin("1.4")
public actual fun Throwable.addSuppressed(exception: Throwable) {
TODO("Implement Throwable.addSuppressed")
}
/**
* Returns a list of all exceptions that were suppressed in order to deliver this exception.
*/
@SinceKotlin("1.4")
public actual val Throwable.suppressedExceptions: List<Throwable>
get() {
TODO("Implement Throwable.suppressedExceptions")
}
@@ -0,0 +1,9 @@
/*
* 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.time
internal actual fun formatToExactDecimals(value: Double, decimals: Int): String = TODO("Wasm stdlib: Duration")
internal actual fun formatUpToDecimals(value: Double, decimals: Int): String = TODO("Wasm stdlib: Duration")
internal actual fun formatScientific(value: Double): String = TODO("Wasm stdlib: Duration")
@@ -0,0 +1,50 @@
/*
* 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.time
/**
* The list of possible time measurement units, in which a duration can be expressed.
*
* The smallest time unit is [NANOSECONDS] and the largest is [DAYS], which corresponds to exactly 24 [HOURS].
*/
@SinceKotlin("1.3")
@ExperimentalTime
public actual enum class DurationUnit {
/**
* Time unit representing one nanosecond, which is 1/1000 of a microsecond.
*/
NANOSECONDS,
/**
* Time unit representing one microsecond, which is 1/1000 of a millisecond.
*/
MICROSECONDS,
/**
* Time unit representing one millisecond, which is 1/1000 of a second.
*/
MILLISECONDS,
/**
* Time unit representing one second.
*/
SECONDS,
/**
* Time unit representing one minute.
*/
MINUTES,
/**
* Time unit representing one hour.
*/
HOURS,
/**
* Time unit representing one day, which is always equal to 24 hours.
*/
DAYS;
}
/** Converts the given time duration [value] expressed in the specified [sourceUnit] into the specified [targetUnit]. */
@SinceKotlin("1.3")
@ExperimentalTime
internal actual fun convertDurationUnit(value: Double, sourceUnit: DurationUnit, targetUnit: DurationUnit): Double = TODO("Wasm stdlib: convertDurationUnit")
@@ -0,0 +1,11 @@
/*
* 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.time
@SinceKotlin("1.3")
@ExperimentalTime
internal actual object MonotonicTimeSource : TimeSource {
override fun markNow(): TimeMark = TODO("Wasm stdlib: MonotonicTimeSource::markNow")
}
@@ -0,0 +1,138 @@
/*
* 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
/**
* Counts the number of set bits in the binary representation of this [Int] number.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.countOneBits(): Int = TODO("Wasm stdlib: Numbers")
/**
* Counts the number of consecutive most significant bits that are zero in the binary representation of this [Int] number.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.countLeadingZeroBits(): Int = TODO("Wasm stdlib: Numbers")
/**
* Counts the number of consecutive least significant bits that are zero in the binary representation of this [Int] number.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.countTrailingZeroBits(): Int = TODO("Wasm stdlib: Numbers")
/**
* Returns a number having a single bit set in the position of the most significant set bit of this [Int] number,
* or zero, if this number is zero.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.takeHighestOneBit(): Int = TODO("Wasm stdlib: Numbers")
/**
* Returns a number having a single bit set in the position of the least significant set bit of this [Int] number,
* or zero, if this number is zero.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.takeLowestOneBit(): Int = TODO("Wasm stdlib: Numbers")
/**
* Rotates the binary representation of this [Int] number left by the specified [bitCount] number of bits.
* The most significant bits pushed out from the left side reenter the number as the least significant bits on the right side.
*
* Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count:
* `number.rotateLeft(-n) == number.rotateRight(n)`
*
* Rotating by a multiple of [Int.SIZE_BITS] (32) returns the same number, or more generally
* `number.rotateLeft(n) == number.rotateLeft(n % 32)`
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.rotateLeft(bitCount: Int): Int = TODO("Wasm stdlib: Numbers")
/**
* Rotates the binary representation of this [Int] number right by the specified [bitCount] number of bits.
* The least significant bits pushed out from the right side reenter the number as the most significant bits on the left side.
*
* Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count:
* `number.rotateRight(-n) == number.rotateLeft(n)`
*
* Rotating by a multiple of [Int.SIZE_BITS] (32) returns the same number, or more generally
* `number.rotateRight(n) == number.rotateRight(n % 32)`
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Int.rotateRight(bitCount: Int): Int = TODO("Wasm stdlib: Numbers")
/**
* Counts the number of set bits in the binary representation of this [Long] number.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.countOneBits(): Int = TODO("Wasm stdlib: Numbers")
/**
* Counts the number of consecutive most significant bits that are zero in the binary representation of this [Long] number.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.countLeadingZeroBits(): Int = TODO("Wasm stdlib: Numbers")
/**
* Counts the number of consecutive least significant bits that are zero in the binary representation of this [Long] number.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.countTrailingZeroBits(): Int = TODO("Wasm stdlib: Numbers")
/**
* Returns a number having a single bit set in the position of the most significant set bit of this [Long] number,
* or zero, if this number is zero.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.takeHighestOneBit(): Long = TODO("Wasm stdlib: Numbers")
/**
* Returns a number having a single bit set in the position of the least significant set bit of this [Long] number,
* or zero, if this number is zero.
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.takeLowestOneBit(): Long = TODO("Wasm stdlib: Numbers")
/**
* Rotates the binary representation of this [Long] number left by the specified [bitCount] number of bits.
* The most significant bits pushed out from the left side reenter the number as the least significant bits on the right side.
*
* Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count:
* `number.rotateLeft(-n) == number.rotateRight(n)`
*
* Rotating by a multiple of [Long.SIZE_BITS] (64) returns the same number, or more generally
* `number.rotateLeft(n) == number.rotateLeft(n % 64)`
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.rotateLeft(bitCount: Int): Long = TODO("Wasm stdlib: Numbers")
/**
* Rotates the binary representation of this [Long] number right by the specified [bitCount] number of bits.
* The least significant bits pushed out from the right side reenter the number as the most significant bits on the left side.
*
* Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count:
* `number.rotateRight(-n) == number.rotateLeft(n)`
*
* Rotating by a multiple of [Long.SIZE_BITS] (64) returns the same number, or more generally
* `number.rotateRight(n) == number.rotateRight(n % 64)`
*/
@SinceKotlin("1.3")
@ExperimentalStdlibApi
public actual fun Long.rotateRight(bitCount: Int): Long = TODO("Wasm stdlib: Numbers")
@@ -0,0 +1,8 @@
/*
* 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.experimental
// In some tests `import kotlin.experimental*` is used without actually importing anything
@@ -0,0 +1,22 @@
/*
* 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.test
import kotlin.internal.OnlyInputTypes
public fun assert(x: Boolean) {
if (!x) throw AssertionError("Assertion failed")
}
/** Asserts that the [expected] value is equal to the [actual] value, with an optional [message]. */
public fun <@OnlyInputTypes T> assertEquals(expected: T, actual: T, message: String? = null) {
if (expected != actual) throw AssertionError("assertEquals failed: expected:$expected, actual:$actual, message=$message")
}
/** Asserts that the [actual] value is not equal to the illegal value, with an optional [message]. */
public fun <@OnlyInputTypes T> assertNotEquals(illegal: T, actual: T, message: String? = null) {
if (illegal == actual) throw AssertionError("assertNotEquals failed: illegal:$illegal, actual:$actual, message=$message")
}
@@ -0,0 +1,17 @@
/*
* 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
import kotlin.internal.OnlyInputTypes
public fun assert(x: Boolean) {
if (!x) throw AssertionError("Assertion failed")
}
/** Asserts that the [expected] value is equal to the [actual] value, with an optional [message]. */
public fun <@OnlyInputTypes T> assertEquals(expected: T, actual: T, message: String? = null) {
if (expected != actual) throw AssertionError("assertEquals failed: expected:$expected, actual:$actual, message=$message")
}