6
6
package kotlin.js
7
7
8
8
import withType
9
+ import kotlin.internal.UsedFromCompilerGeneratedCode
9
10
10
11
@PublishedApi
11
12
internal external fun <T > Array (size : Int ): Array <T >
@@ -30,68 +31,83 @@ internal inline fun <T> fillArrayFun(array: dynamic, init: (Int) -> T): Array<T>
30
31
return result
31
32
}
32
33
34
+ @UsedFromCompilerGeneratedCode
33
35
internal fun booleanArray (size : Int ): BooleanArray = withType(" BooleanArray" , fillArrayVal(Array <Boolean >(size), false )).unsafeCast<BooleanArray >()
34
36
37
+ @UsedFromCompilerGeneratedCode
35
38
internal fun booleanArrayOf (arr : Array <Boolean >): BooleanArray = withType(" BooleanArray" , arr.asDynamic().slice()).unsafeCast<BooleanArray >()
36
39
37
40
@Suppress(" UNUSED_PARAMETER" )
41
+ @UsedFromCompilerGeneratedCode
38
42
internal fun charArray (size : Int ): CharArray = withType(" CharArray" , js(" new Uint16Array(size)" )).unsafeCast<CharArray >()
39
43
40
44
@Suppress(" UNUSED_PARAMETER" )
45
+ @UsedFromCompilerGeneratedCode
41
46
internal fun charArrayOf (arr : Array <Char >): CharArray = withType(" CharArray" , js(" new Uint16Array(arr)" )).unsafeCast<CharArray >()
42
47
48
+ @UsedFromCompilerGeneratedCode
43
49
internal fun longArray (size : Int ): LongArray = withType(" LongArray" , fillArrayVal(Array <Long >(size), 0L )).unsafeCast<LongArray >()
44
50
51
+ @UsedFromCompilerGeneratedCode
45
52
internal fun longArrayOf (arr : Array <Long >): LongArray = withType(" LongArray" , arr.asDynamic().slice()).unsafeCast<LongArray >()
46
53
54
+ @UsedFromCompilerGeneratedCode
47
55
internal fun <T > arrayIterator (array : Array <T >) = object : Iterator <T > {
48
56
var index = 0
49
57
override fun hasNext () = index != array.size
50
58
override fun next () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
51
59
}
52
60
61
+ @UsedFromCompilerGeneratedCode
53
62
internal fun booleanArrayIterator (array : BooleanArray ) = object : BooleanIterator () {
54
63
var index = 0
55
64
override fun hasNext () = index != array.size
56
65
override fun nextBoolean () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
57
66
}
58
67
68
+ @UsedFromCompilerGeneratedCode
59
69
internal fun byteArrayIterator (array : ByteArray ) = object : ByteIterator () {
60
70
var index = 0
61
71
override fun hasNext () = index != array.size
62
72
override fun nextByte () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
63
73
}
64
74
75
+ @UsedFromCompilerGeneratedCode
65
76
internal fun shortArrayIterator (array : ShortArray ) = object : ShortIterator () {
66
77
var index = 0
67
78
override fun hasNext () = index != array.size
68
79
override fun nextShort () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
69
80
}
70
81
82
+ @UsedFromCompilerGeneratedCode
71
83
internal fun charArrayIterator (array : CharArray ) = object : CharIterator () {
72
84
var index = 0
73
85
override fun hasNext () = index != array.size
74
86
override fun nextChar () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
75
87
}
76
88
89
+ @UsedFromCompilerGeneratedCode
77
90
internal fun intArrayIterator (array : IntArray ) = object : IntIterator () {
78
91
var index = 0
79
92
override fun hasNext () = index != array.size
80
93
override fun nextInt () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
81
94
}
82
95
96
+ @UsedFromCompilerGeneratedCode
83
97
internal fun floatArrayIterator (array : FloatArray ) = object : FloatIterator () {
84
98
var index = 0
85
99
override fun hasNext () = index != array.size
86
100
override fun nextFloat () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
87
101
}
88
102
103
+ @UsedFromCompilerGeneratedCode
89
104
internal fun doubleArrayIterator (array : DoubleArray ) = object : DoubleIterator () {
90
105
var index = 0
91
106
override fun hasNext () = index != array.size
92
107
override fun nextDouble () = if (index != array.size) array[index++ ] else throw NoSuchElementException (" $index " )
93
108
}
94
109
110
+ @UsedFromCompilerGeneratedCode
95
111
internal fun longArrayIterator (array : LongArray ) = object : LongIterator () {
96
112
var index = 0
97
113
override fun hasNext () = index != array.size
0 commit comments