From adce2c9a78fdf54eafeca6e82c0aa335bca09e6a Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Mon, 24 Jul 2023 11:33:05 +0200 Subject: [PATCH] [WASM] Replace deprecated `Char.toInt()` with `Char.code` --- .../builtins/primitives/CharGenerator.kt | 18 ++++++------- libraries/stdlib/wasm/builtins/kotlin/Char.kt | 26 +++++++++---------- .../stdlib/wasm/builtins/kotlin/String.kt | 2 +- .../wasm/js/internal/ExternalWrapper.kt | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/generators/builtins/primitives/CharGenerator.kt b/generators/builtins/primitives/CharGenerator.kt index 3d6572d8531..501b9a0273c 100644 --- a/generators/builtins/primitives/CharGenerator.kt +++ b/generators/builtins/primitives/CharGenerator.kt @@ -490,32 +490,32 @@ class WasmCharGenerator(writer: PrintWriter) : CharGenerator(writer) { } override fun MethodBuilder.modifyGeneratedCompareTo() { - "wasm_i32_compareTo(this.toInt(), other.toInt())".addAsSingleLineBody(bodyOnNewLine = true) + "wasm_i32_compareTo(this.code, other.code)".addAsSingleLineBody(bodyOnNewLine = true) } override fun MethodBuilder.modifyGeneratedPlus() { modifySignature { isInline = true } - "(this.toInt() + other).toChar()".addAsSingleLineBody(bodyOnNewLine = true) + "(this.code + other).toChar()".addAsSingleLineBody(bodyOnNewLine = true) } override fun MethodBuilder.modifyGeneratedMinusChar() { modifySignature { isInline = true } - "(this.toInt() - other.toInt())".addAsSingleLineBody(bodyOnNewLine = true) + "(this.code - other.code)".addAsSingleLineBody(bodyOnNewLine = true) } override fun MethodBuilder.modifyGeneratedMinusInt() { modifySignature { isInline = true } - "(this.toInt() - other).toChar()".addAsSingleLineBody(bodyOnNewLine = true) + "(this.code - other).toChar()".addAsSingleLineBody(bodyOnNewLine = true) } override fun MethodBuilder.modifyGeneratedInc() { modifySignature { isInline = true } - "(this.toInt() + 1).toChar()".addAsSingleLineBody(bodyOnNewLine = true) + "(this.code + 1).toChar()".addAsSingleLineBody(bodyOnNewLine = true) } override fun MethodBuilder.modifyGeneratedDec() { modifySignature { isInline = true } - "(this.toInt() - 1).toChar()".addAsSingleLineBody(bodyOnNewLine = true) + "(this.code - 1).toChar()".addAsSingleLineBody(bodyOnNewLine = true) } override fun MethodBuilder.modifyGeneratedRangeTo() { @@ -534,7 +534,7 @@ class WasmCharGenerator(writer: PrintWriter) : CharGenerator(writer) { annotations += "WasmNoOpCast" "implementedAsIntrinsic" } - else -> "this.toInt().$methodName()" + else -> "this.code.$methodName()" } body.addAsSingleLineBody(bodyOnNewLine = true) } @@ -542,7 +542,7 @@ class WasmCharGenerator(writer: PrintWriter) : CharGenerator(writer) { override fun MethodBuilder.modifyGeneratedEquals() { """ if (other is Char) - return wasm_i32_eq(this.toInt(), other.toInt()) + return wasm_i32_eq(this.code, other.code) return false """.trimIndent().addAsMultiLineBody() } @@ -558,7 +558,7 @@ class WasmCharGenerator(writer: PrintWriter) : CharGenerator(writer) { override fun MethodBuilder.modifyGeneratedHashCode() { modifySignature { visibility = null } - "this.toInt().hashCode()".addAsSingleLineBody(bodyOnNewLine = true) + "this.code.hashCode()".addAsSingleLineBody(bodyOnNewLine = true) } } diff --git a/libraries/stdlib/wasm/builtins/kotlin/Char.kt b/libraries/stdlib/wasm/builtins/kotlin/Char.kt index a1961ade3f1..6690736a682 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Char.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Char.kt @@ -21,22 +21,22 @@ public class Char private constructor(private val value: Char) : Comparable