Add a common JVM/JS lowering for Array(size, function)
and remove the hack from JVM_IR codegen that replaces this call with
hardcoded inline function bytecode.
(cherry picked from commit 4a29e3cfcf)
This commit is contained in:
@@ -41,6 +41,12 @@ public class ByteArray(size: Int) {
|
||||
* @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 [init] function returns 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. */
|
||||
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. */
|
||||
@@ -53,17 +59,6 @@ public class CharArray(size: Int) {
|
||||
public operator fun iterator(): CharIterator
|
||||
}
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun CharArray(size: Int, init: (Int) -> Char): CharArray {
|
||||
val result = CharArray(size)
|
||||
var i = 0
|
||||
while (i != result.size) {
|
||||
result[i] = init(i)
|
||||
++i
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user