[WASM] Refactoring wasm array copy functions
This commit is contained in:
@@ -1017,8 +1017,10 @@ public actual fun CharArray?.contentToString(): String {
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): Array<T> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
arrayCopy(this as Array<Any?>, startIndex, destination as Array<Any?>, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1041,7 +1043,10 @@ public actual fun <T> Array<out T>.copyInto(destination: Array<T>, destinationOf
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1064,7 +1069,10 @@ public actual fun ByteArray.copyInto(destination: ByteArray, destinationOffset:
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun ShortArray.copyInto(destination: ShortArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ShortArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1087,7 +1095,10 @@ public actual fun ShortArray.copyInto(destination: ShortArray, destinationOffset
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun IntArray.copyInto(destination: IntArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): IntArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1110,7 +1121,10 @@ public actual fun IntArray.copyInto(destination: IntArray, destinationOffset: In
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun LongArray.copyInto(destination: LongArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): LongArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1133,7 +1147,10 @@ public actual fun LongArray.copyInto(destination: LongArray, destinationOffset:
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun FloatArray.copyInto(destination: FloatArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): FloatArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1156,7 +1173,10 @@ public actual fun FloatArray.copyInto(destination: FloatArray, destinationOffset
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun DoubleArray.copyInto(destination: DoubleArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): DoubleArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1179,7 +1199,10 @@ public actual fun DoubleArray.copyInto(destination: DoubleArray, destinationOffs
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun BooleanArray.copyInto(destination: BooleanArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): BooleanArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
@@ -1202,7 +1225,10 @@ public actual fun BooleanArray.copyInto(destination: BooleanArray, destinationOf
|
||||
@SinceKotlin("1.3")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun CharArray.copyInto(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): CharArray {
|
||||
arrayCopy(this, startIndex, destination, destinationOffset, endIndex - startIndex)
|
||||
AbstractList.checkRangeIndexes(startIndex, endIndex, this.size)
|
||||
val rangeSize = endIndex - startIndex
|
||||
AbstractList.checkRangeIndexes(destinationOffset, destinationOffset + rangeSize, destination.size)
|
||||
kotlin.wasm.internal.copyWasmArray(this.storage, destination.storage, startIndex, destinationOffset, rangeSize)
|
||||
return destination
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ internal class WasmAnyArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmAnyArray.copyTo(destination: WasmAnyArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmAnyArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmAnyArray, destination: WasmAnyArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmAnyArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmAnyArray.fill(size: Int, init: (Int) -> Any?) {
|
||||
@@ -58,11 +58,11 @@ internal class WasmByteArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmByteArray.copyTo(destination: WasmByteArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmByteArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmByteArray, destination: WasmByteArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmByteArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmByteArray.fill(size: Int, init: (Int) -> Byte) {
|
||||
@@ -84,11 +84,11 @@ internal class WasmCharArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmCharArray.copyTo(destination: WasmCharArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmCharArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmCharArray, destination: WasmCharArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmCharArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmCharArray.fill(size: Int, init: (Int) -> Char) {
|
||||
@@ -110,11 +110,11 @@ internal class WasmShortArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmShortArray.copyTo(destination: WasmShortArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmShortArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmShortArray, destination: WasmShortArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmShortArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmShortArray.fill(size: Int, init: (Int) -> Short) {
|
||||
@@ -136,11 +136,11 @@ internal class WasmIntArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmIntArray.copyTo(destination: WasmIntArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmIntArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmIntArray, destination: WasmIntArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmIntArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmIntArray.fill(size: Int, init: (Int) -> Int) {
|
||||
@@ -162,11 +162,11 @@ internal class WasmLongArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmLongArray.copyTo(destination: WasmLongArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmLongArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmLongArray, destination: WasmLongArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmLongArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmLongArray.fill(size: Int, init: (Int) -> Long) {
|
||||
@@ -188,11 +188,11 @@ internal class WasmFloatArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmFloatArray.copyTo(destination: WasmFloatArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmFloatArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmFloatArray, destination: WasmFloatArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmFloatArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmFloatArray.fill(size: Int, init: (Int) -> Float) {
|
||||
@@ -214,11 +214,11 @@ internal class WasmDoubleArray(size: Int) {
|
||||
|
||||
@WasmOp(WasmOp.ARRAY_LEN)
|
||||
fun len(): Int =
|
||||
implementedAsIntrinsic
|
||||
implementedAsIntrinsic
|
||||
}
|
||||
|
||||
internal inline fun WasmDoubleArray.copyTo(destination: WasmDoubleArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmDoubleArray>(destination, destinationIndex, this, sourceIndex, length)
|
||||
internal inline fun copyWasmArray(source: WasmDoubleArray, destination: WasmDoubleArray, sourceIndex: Int, destinationIndex: Int, length: Int) {
|
||||
wasm_array_copy<WasmDoubleArray>(destination, destinationIndex, source, sourceIndex, length)
|
||||
}
|
||||
|
||||
internal inline fun WasmDoubleArray.fill(size: Int, init: (Int) -> Double) {
|
||||
|
||||
Reference in New Issue
Block a user