[Wasm] Handle unsigned arrays in the vararg lowering

This commit is contained in:
Igor Laevsky
2021-11-03 17:57:21 +03:00
parent d1d2bd246b
commit 0915dac1f9
15 changed files with 10 additions and 21 deletions
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.backend.common.lower.irComposite import org.jetbrains.kotlin.backend.common.lower.irComposite
import org.jetbrains.kotlin.backend.wasm.WasmBackendContext import org.jetbrains.kotlin.backend.wasm.WasmBackendContext
import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.declarations.IrVariable
@@ -40,8 +41,15 @@ internal class WasmVarargExpressionLowering(
check(arrayClass.symbol in context.wasmSymbols.arrays) { "Argument ${ir2string(arrayClass)} must be an array" } check(arrayClass.symbol in context.wasmSymbols.arrays) { "Argument ${ir2string(arrayClass)} must be an array" }
} }
val primaryConstructor val isUnsigned
get() = arrayClass.primaryConstructor!! get() = arrayClass.symbol in context.wasmSymbols.unsignedTypesToUnsignedArrays.values
val primaryConstructor: IrConstructor
get() {
if (isUnsigned)
return arrayClass.constructors.find { it.valueParameters.singleOrNull()?.type == context.irBuiltIns.intType }!!
return arrayClass.primaryConstructor!!
}
val constructors val constructors
get() = arrayClass.constructors get() = arrayClass.constructors
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun test(uis: UIntArray): String { fun test(uis: UIntArray): String {
var s = "" var s = ""
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: UNSIGNED_ARRAYS
// !LANGUAGE: +InlineClasses // !LANGUAGE: +InlineClasses
// WITH_RUNTIME // WITH_RUNTIME
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: UNSIGNED_ARRAYS
// WITH_RUNTIME // WITH_RUNTIME
class C<T>(val x: T, vararg ys: UInt) { class C<T>(val x: T, vararg ys: UInt) {
@@ -1,5 +1,4 @@
// WITH_RUNTIME // WITH_RUNTIME
// IGNORE_BACKEND: WASM
fun box(): String { fun box(): String {
val uia = uintArrayOf() val uia = uintArrayOf()
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: UNSIGNED_ARRAYS
// WITH_RUNTIME // WITH_RUNTIME
fun box(): String { fun box(): String {
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: UNSIGNED_ARRAYS
// WITH_RUNTIME // WITH_RUNTIME
fun test() = uintArrayOf(1u).size fun test() = uintArrayOf(1u).size
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: UNSIGNED_ARRAYS
// WITH_RUNTIME // WITH_RUNTIME
fun uint(vararg us: UInt): UIntArray = us fun uint(vararg us: UInt): UIntArray = us