[WASM] Replace deprecated Char.toInt() with Char.code
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,22 +21,22 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
*/
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun compareTo(other: Char): Int =
|
||||
wasm_i32_compareTo(this.toInt(), other.toInt())
|
||||
wasm_i32_compareTo(this.code, other.code)
|
||||
|
||||
/** Adds the other Int value to this value resulting a Char. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline operator fun plus(other: Int): Char =
|
||||
(this.toInt() + other).toChar()
|
||||
(this.code + other).toChar()
|
||||
|
||||
/** Subtracts the other Char value from this value resulting an Int. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline operator fun minus(other: Char): Int =
|
||||
(this.toInt() - other.toInt())
|
||||
(this.code - other.code)
|
||||
|
||||
/** Subtracts the other Int value from this value resulting a Char. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline operator fun minus(other: Int): Char =
|
||||
(this.toInt() - other).toChar()
|
||||
(this.code - other).toChar()
|
||||
|
||||
/**
|
||||
* Returns this value incremented by one.
|
||||
@@ -44,7 +44,7 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
* @sample samples.misc.Builtins.inc
|
||||
*/
|
||||
public inline operator fun inc(): Char =
|
||||
(this.toInt() + 1).toChar()
|
||||
(this.code + 1).toChar()
|
||||
|
||||
/**
|
||||
* Returns this value decremented by one.
|
||||
@@ -52,7 +52,7 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
* @sample samples.misc.Builtins.dec
|
||||
*/
|
||||
public inline operator fun dec(): Char =
|
||||
(this.toInt() - 1).toChar()
|
||||
(this.code - 1).toChar()
|
||||
|
||||
/** Creates a range from this value to the specified [other] value. */
|
||||
public operator fun rangeTo(other: Char): CharRange =
|
||||
@@ -73,7 +73,7 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline fun toByte(): Byte =
|
||||
this.toInt().toByte()
|
||||
this.code.toByte()
|
||||
|
||||
/** Returns the value of this character as a `Char`. */
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
@@ -85,7 +85,7 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline fun toShort(): Short =
|
||||
this.toInt().toShort()
|
||||
this.code.toShort()
|
||||
|
||||
/** Returns the value of this character as a `Int`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code"))
|
||||
@@ -100,21 +100,21 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline fun toLong(): Long =
|
||||
this.toInt().toLong()
|
||||
this.code.toLong()
|
||||
|
||||
/** Returns the value of this character as a `Float`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toFloat()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline fun toFloat(): Float =
|
||||
this.toInt().toFloat()
|
||||
this.code.toFloat()
|
||||
|
||||
/** Returns the value of this character as a `Double`. */
|
||||
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toDouble()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public inline fun toDouble(): Double =
|
||||
this.toInt().toDouble()
|
||||
this.code.toDouble()
|
||||
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
override fun toString(): String {
|
||||
@@ -126,12 +126,12 @@ public class Char private constructor(private val value: Char) : Comparable<Char
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun equals(other: Any?): Boolean {
|
||||
if (other is Char)
|
||||
return wasm_i32_eq(this.toInt(), other.toInt())
|
||||
return wasm_i32_eq(this.code, other.code)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun hashCode(): Int =
|
||||
this.toInt().hashCode()
|
||||
this.code.hashCode()
|
||||
|
||||
public companion object {
|
||||
/**
|
||||
|
||||
@@ -126,7 +126,7 @@ public class String internal @WasmPrimitiveConstructor constructor(
|
||||
val thisChars = chars
|
||||
var hash = 0
|
||||
repeat(thisLength) {
|
||||
hash = (hash shl 5) - hash + thisChars.get(it).toInt()
|
||||
hash = (hash shl 5) - hash + thisChars.get(it).code
|
||||
}
|
||||
_hashCode = hash
|
||||
return _hashCode
|
||||
|
||||
@@ -351,7 +351,7 @@ internal fun kotlinShortToExternRefAdapter(x: Short): ExternalInterfaceType =
|
||||
intToExternref(x.toInt())
|
||||
|
||||
internal fun kotlinCharToExternRefAdapter(x: Char): ExternalInterfaceType =
|
||||
intToExternref(x.toInt())
|
||||
intToExternref(x.code)
|
||||
|
||||
internal fun newJsArray(): ExternalInterfaceType =
|
||||
js("[]")
|
||||
|
||||
Reference in New Issue
Block a user