[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
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)
}
}