Skip to content

Commit 9890635

Browse files
alex28shSpace Team
authored andcommitted
[Wasm] change casts to reinterpreters (KT-78998)
1 parent d25e411 commit 9890635

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

libraries/stdlib/wasm/builtins/kotlin/String.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ internal fun stringLiteralLatin1(poolId: Int): String {
186186
val bytes = array_new_data0<WasmByteArray>(startAddress, length)
187187
val chars = WasmCharArray(length)
188188
for (i in 0..<length) {
189-
val chr = bytes.get(i).toUByte().toInt().toChar()
189+
val chr = bytes.getU(i).toByte().reinterpretAsInt().reinterpretAsChar()
190190
chars.set(i, chr)
191191
}
192192

libraries/stdlib/wasm/src/generated/wasm/internal/_WasmArrays.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ internal class WasmByteArray(size: Int) {
4545
fun get(index: Int): Byte =
4646
implementedAsIntrinsic
4747

48+
@WasmOp(WasmOp.ARRAY_GET_U)
49+
fun getU(index: Int): UByte =
50+
implementedAsIntrinsic
51+
4852
@WasmOp(WasmOp.ARRAY_SET)
4953
fun set(index: Int, value: Byte): Unit =
5054
implementedAsIntrinsic

0 commit comments

Comments
 (0)