From 2e836494f54d19bb7b4274d1c79b5a4c171bc6f9 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Thu, 2 Mar 2023 16:27:27 +0100 Subject: [PATCH] Rewrite primitives' generation using simple DSL --- core/builtins/native/kotlin/Primitives.kt | 24 +- .../primitives/BasePrimitivesGenerator.kt | 664 +++++++++--------- .../primitives/JsPrimitivesGenerator.kt | 31 +- .../primitives/JvmPrimitivesGenerator.kt | 4 +- .../primitives/NativePrimitivesGenerator.kt | 204 +++--- .../primitives/WasmPrimitivesGenerator.kt | 228 +++--- generators/builtins/primitives/builders.kt | 301 ++++++++ .../builtins/primitives/declarations.kt | 214 ------ generators/builtins/primitives/utils.kt | 12 +- .../src/main/kotlin/kotlin/Primitives.kt | 472 ++++++------- libraries/stdlib/js-ir/builtins/Primitives.kt | 44 +- .../stdlib/wasm/builtins/kotlin/Primitives.kt | 616 ++++++++-------- 12 files changed, 1455 insertions(+), 1359 deletions(-) create mode 100644 generators/builtins/primitives/builders.kt delete mode 100644 generators/builtins/primitives/declarations.kt diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index bdd150143f4..85740a33678 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -371,10 +371,10 @@ public class Byte private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean } /** @@ -739,10 +739,10 @@ public class Short private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean } /** @@ -1153,10 +1153,10 @@ public class Int private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean } /** @@ -1570,10 +1570,10 @@ public class Long private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean } /** @@ -1903,10 +1903,10 @@ public class Float private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean } /** @@ -2238,8 +2238,8 @@ public class Double private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean } diff --git a/generators/builtins/primitives/BasePrimitivesGenerator.kt b/generators/builtins/primitives/BasePrimitivesGenerator.kt index 040d803b9b1..9d1b30f23f3 100644 --- a/generators/builtins/primitives/BasePrimitivesGenerator.kt +++ b/generators/builtins/primitives/BasePrimitivesGenerator.kt @@ -18,18 +18,23 @@ abstract class BasePrimitivesGenerator(private val writer: PrintWriter) : BuiltI "div", "rem", ) + internal val unaryPlusMinusOperators: Map = mapOf( "unaryPlus" to "Returns this value.", "unaryMinus" to "Returns the negative of this value." ) + internal val shiftOperators: Map = mapOf( "shl" to "Shifts this value left by the [bitCount] number of bits.", "shr" to "Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with copies of the sign bit.", - "ushr" to "Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with zeros.") + "ushr" to "Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with zeros." + ) + internal val bitwiseOperators: Map = mapOf( "and" to "Performs a bitwise AND operation between the two values.", "or" to "Performs a bitwise OR operation between the two values.", - "xor" to "Performs a bitwise XOR operation between the two values.") + "xor" to "Performs a bitwise XOR operation between the two values." + ) internal fun shiftOperatorsDocDetail(kind: PrimitiveType): String { val bitsUsed = when (kind) { @@ -136,25 +141,23 @@ abstract class BasePrimitivesGenerator(private val writer: PrintWriter) : BuiltI val otherName = toIntegral.capitalized return if (toIntegral == PrimitiveType.CHAR) { - if (fromIntegral == PrimitiveType.SHORT) { - """ - The resulting `Char` code is equal to this value reinterpreted as an unsigned number, - i.e. it has the same binary representation as this `Short`. - """.trimIndent() - } else if (fromIntegral == PrimitiveType.BYTE) { - """ - If this value is non-negative, the resulting `Char` code is equal to this value. - - The least significant 8 bits of the resulting `Char` code are the same as the bits of this `Byte` value, - whereas the most significant 8 bits are filled with the sign bit of this value. - """.trimIndent() - } else { - """ - If this value is in the range of `Char` codes `Char.MIN_VALUE..Char.MAX_VALUE`, - the resulting `Char` code is equal to this value. - - The resulting `Char` code is represented by the least significant 16 bits of this `$thisName` value. - """.trimIndent() + when (fromIntegral) { + PrimitiveType.SHORT -> """ + The resulting `Char` code is equal to this value reinterpreted as an unsigned number, + i.e. it has the same binary representation as this `Short`. + """.trimIndent() + PrimitiveType.BYTE -> """ + If this value is non-negative, the resulting `Char` code is equal to this value. + + The least significant 8 bits of the resulting `Char` code are the same as the bits of this `Byte` value, + whereas the most significant 8 bits are filled with the sign bit of this value. + """.trimIndent() + else -> """ + If this value is in the range of `Char` codes `Char.MIN_VALUE..Char.MAX_VALUE`, + the resulting `Char` code is equal to this value. + + The resulting `Char` code is represented by the least significant 16 bits of this `$thisName` value. + """.trimIndent() } } else if (compareByDomainCapacity(toIntegral, fromIntegral) < 0) { """ @@ -227,301 +230,306 @@ abstract class BasePrimitivesGenerator(private val writer: PrintWriter) : BuiltI open fun PrimitiveType.shouldGenerate(): Boolean = true override fun generate() { - writer.print(FileDescription(classes = generateClasses()).apply { this.modifyGeneratedFile() }.toString()) + writer.print(generateFile().build()) } - private fun generateClasses(): List { - return buildList { - for (thisKind in PrimitiveType.onlyNumeric.filter { it.shouldGenerate() }) { - val className = thisKind.capitalized - val doc = "Represents a ${typeDescriptions[thisKind]}." + private fun generateFile(): FileBuilder { + return file { generateClasses() }.apply { this.modifyGeneratedFile() } + } - val methods = buildList { - this.addAll(generateCompareTo(thisKind)) - this.addAll(generateBinaryOperators(thisKind)) - this.addAll(generateUnaryOperators(thisKind)) - this.addAll(generateRangeTo(thisKind)) - this.addAll(generateRangeUntil(thisKind)) + private fun FileBuilder.generateClasses() { + for (thisKind in PrimitiveType.onlyNumeric.filter { it.shouldGenerate() }) { + val className = thisKind.capitalized - if (thisKind == PrimitiveType.INT || thisKind == PrimitiveType.LONG) { - this.addAll(generateBitShiftOperators(thisKind)) - this.addAll(generateBitwiseOperators(thisKind)) - } + klass { + appendDoc("Represents a ${typeDescriptions[thisKind]}.") + name = className + generateCompanionObject(thisKind) - this.addAll(generateConversions(thisKind)) - this += generateEquals(thisKind) - this += generateToString(thisKind) - this.addAll(generateAdditionalMethods(thisKind)) + generateCompareTo(thisKind) + generateBinaryOperators(thisKind) + generateUnaryOperators(thisKind) + generateRangeTo(thisKind) + generateRangeUntil(thisKind) + + if (thisKind == PrimitiveType.INT || thisKind == PrimitiveType.LONG) { + generateBitShiftOperators(thisKind) + generateBitwiseOperators(thisKind) } - this += ClassDescription( - doc, - annotations = mutableListOf(), - name = className, - companionObject = generateCompanionObject(thisKind), - methods = methods - ).apply { this.modifyGeneratedClass(thisKind) } - } + generateConversions(thisKind) + generateToString(thisKind) + generateEquals(thisKind) + generateAdditionalMethods(thisKind) + }.modifyGeneratedClass(thisKind) } } - private fun generateCompanionObject(thisKind: PrimitiveType): CompanionObjectDescription { - val properties = buildList { + private fun ClassBuilder.generateCompanionObject(thisKind: PrimitiveType) { + companionObject { val className = thisKind.capitalized if (thisKind == PrimitiveType.FLOAT || thisKind == PrimitiveType.DOUBLE) { val (minValue, maxValue, posInf, negInf, nan) = primitiveConstants(thisKind) - this += PropertyDescription( - doc = "A constant holding the smallest *positive* nonzero value of $className.", - name = "MIN_VALUE", - type = className, + property { + appendDoc("A constant holding the smallest *positive* nonzero value of $className.") + name = "MIN_VALUE" + type = className value = minValue.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) - this += PropertyDescription( - doc = "A constant holding the largest positive finite value of $className.", - name = "MAX_VALUE", - type = className, + property { + appendDoc("A constant holding the largest positive finite value of $className.") + name = "MAX_VALUE" + type = className value = maxValue.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) - this += PropertyDescription( - doc = "A constant holding the positive infinity value of $className.", - name = "POSITIVE_INFINITY", - type = className, + property { + appendDoc("A constant holding the positive infinity value of $className.") + name = "POSITIVE_INFINITY" + type = className value = posInf.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) - this += PropertyDescription( - doc = "A constant holding the negative infinity value of $className.", - name = "NEGATIVE_INFINITY", - type = className, + property { + appendDoc("A constant holding the negative infinity value of $className.") + name = "NEGATIVE_INFINITY" + type = className value = negInf.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) - this += PropertyDescription( - doc = "A constant holding the \"not a number\" value of $className.", - name = "NaN", - type = className, + property { + appendDoc("A constant holding the \"not a number\" value of $className.") + name = "NaN" + type = className value = nan.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) } if (thisKind == PrimitiveType.INT || thisKind == PrimitiveType.LONG || thisKind == PrimitiveType.SHORT || thisKind == PrimitiveType.BYTE) { val (minValue, maxValue) = primitiveConstants(thisKind) - this += PropertyDescription( - doc = "A constant holding the minimum value an instance of $className can have.", - name = "MIN_VALUE", - type = className, + property { + appendDoc("A constant holding the minimum value an instance of $className can have.") + name = "MIN_VALUE" + type = className value = minValue.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) - this += PropertyDescription( - doc = "A constant holding the maximum value an instance of $className can have.", - name = "MAX_VALUE", - type = className, + property { + appendDoc("A constant holding the maximum value an instance of $className can have.") + name = "MAX_VALUE" + type = className value = maxValue.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) } val sizeSince = if (thisKind.isFloatingPoint) "1.4" else "1.3" - this += PropertyDescription( - doc = "The number of bytes used to represent an instance of $className in a binary form.", - annotations = mutableListOf("SinceKotlin(\"$sizeSince\")"), - name = "SIZE_BYTES", - type = "Int", + property { + appendDoc("The number of bytes used to represent an instance of $className in a binary form.") + annotations += mutableListOf("SinceKotlin(\"$sizeSince\")") + name = "SIZE_BYTES" + type = "Int" value = thisKind.byteSize.toString() - ) + }.modifyGeneratedCompanionObjectProperty(thisKind) - this += PropertyDescription( - doc = "The number of bits used to represent an instance of $className in a binary form.", - annotations = mutableListOf("SinceKotlin(\"$sizeSince\")"), - name = "SIZE_BITS", - type = "Int", + property { + appendDoc("The number of bits used to represent an instance of $className in a binary form.") + annotations += mutableListOf("SinceKotlin(\"$sizeSince\")") + name = "SIZE_BITS" + type = "Int" value = thisKind.bitSize.toString() - ) - } - - properties.forEach { it.modifyGeneratedCompanionObjectProperty(thisKind) } - return CompanionObjectDescription(properties = properties).apply { this.modifyGeneratedCompanionObject(thisKind) } + }.modifyGeneratedCompanionObjectProperty(thisKind) + }.modifyGeneratedCompanionObject(thisKind) } - private fun generateCompareTo(thisKind: PrimitiveType): List { - return buildList { - for (otherKind in PrimitiveType.onlyNumeric) { - val doc = """ + private fun ClassBuilder.generateCompareTo(thisKind: PrimitiveType) { + for (otherKind in PrimitiveType.onlyNumeric) { + val doc = """ Compares this value with the specified value for order. Returns zero if this value is equal to the specified other value, a negative number if it's less than other, or a positive number if it's greater than other. """.trimIndent() - val signature = MethodSignature( - isOverride = otherKind == thisKind, - isOperator = true, - name = "compareTo", - arg = MethodParameter("other", otherKind.capitalized), + method { + appendDoc(doc) + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isOverride = otherKind == thisKind + isOperator = true + methodName = "compareTo" + parameter { + name = "other" + type = otherKind.capitalized + } returnType = PrimitiveType.INT.capitalized - ) - - this += MethodDescription( - doc = doc, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = signature - ).apply { this.modifyGeneratedCompareTo(thisKind, otherKind) } - } - } - } - - private fun generateBinaryOperators(thisKind: PrimitiveType): List { - return buildList { - for (name in binaryOperators) { - this += generateOperator(name, thisKind) - } - } - } - - private fun generateOperator(name: String, thisKind: PrimitiveType): List { - return buildList { - for (otherKind in PrimitiveType.onlyNumeric) { - val returnType = getOperatorReturnType(thisKind, otherKind) - - val annotations = buildList { - if (name == "rem") add("SinceKotlin(\"1.1\")") - add("kotlin.internal.IntrinsicConstEvaluation") } - - this += MethodDescription( - doc = binaryOperatorDoc(name, thisKind, otherKind), - annotations = annotations.toMutableList(), - signature = MethodSignature( - isOperator = true, - name = name, - arg = MethodParameter("other", otherKind.capitalized), - returnType = returnType.capitalized - ) - ).apply { this.modifyGeneratedBinaryOperation(thisKind, otherKind) } - } + }.modifyGeneratedCompareTo(thisKind, otherKind) } } - private fun generateUnaryOperators(thisKind: PrimitiveType): List { - return buildList { - for (name in listOf("inc", "dec")) { - this += MethodDescription( - doc = incDecOperatorsDoc(name), - signature = MethodSignature(isOperator = true, name = name, arg = null, returnType = thisKind.capitalized) - ).apply { this.modifyGeneratedUnaryOperation(thisKind) } - } - - for ((name, doc) in unaryPlusMinusOperators) { - val returnType = when (thisKind) { - in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) -> PrimitiveType.INT.capitalized - else -> thisKind.capitalized - } - this += MethodDescription( - doc = doc, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature(isOperator = true, name = name, arg = null, returnType = returnType) - ).apply { this.modifyGeneratedUnaryOperation(thisKind) } - } + private fun ClassBuilder.generateBinaryOperators(thisKind: PrimitiveType) { + for (name in binaryOperators) { + generateOperator(name, thisKind) } } - private fun generateRangeTo(thisKind: PrimitiveType): List { - return buildList { - for (otherKind in PrimitiveType.onlyNumeric) { - val returnType = maxByDomainCapacity(maxByDomainCapacity(thisKind, otherKind), PrimitiveType.INT) + private fun ClassBuilder.generateOperator(operatorName: String, thisKind: PrimitiveType) { + for (otherKind in PrimitiveType.onlyNumeric) { + val opReturnType = getOperatorReturnType(thisKind, otherKind) - if (returnType == PrimitiveType.DOUBLE || returnType == PrimitiveType.FLOAT) { - continue - } - - this += MethodDescription( - doc = "Creates a range from this value to the specified [other] value.", - signature = MethodSignature( - isOperator = true, - name = "rangeTo", - arg = MethodParameter("other", otherKind.capitalized), - returnType = "${returnType.capitalized}Range" - ) - ).apply { this.modifyGeneratedRangeTo(thisKind) } + val annotationsToAdd = buildList { + if (operatorName == "rem") add("SinceKotlin(\"1.1\")") + add("kotlin.internal.IntrinsicConstEvaluation") } + + method { + appendDoc(binaryOperatorDoc(operatorName, thisKind, otherKind)) + annotations += annotationsToAdd + signature { + isOperator = true + methodName = operatorName + parameter { + name = "other" + type = otherKind.capitalized + } + returnType = opReturnType.capitalized + } + }.modifyGeneratedBinaryOperation(thisKind, otherKind) } } - private fun generateRangeUntil(thisKind: PrimitiveType): List { - return buildList { - for (otherKind in PrimitiveType.onlyNumeric) { - val returnType = maxByDomainCapacity(maxByDomainCapacity(thisKind, otherKind), PrimitiveType.INT) - - if (returnType == PrimitiveType.DOUBLE || returnType == PrimitiveType.FLOAT) { - continue + private fun ClassBuilder.generateUnaryOperators(thisKind: PrimitiveType) { + for (operatorName in listOf("inc", "dec")) { + method { + appendDoc(incDecOperatorsDoc(operatorName)) + signature { + isOperator = true + methodName = operatorName + returnType = thisKind.capitalized } + }.modifyGeneratedUnaryOperation(thisKind) + } - this += MethodDescription( - doc = """ + for ((operatorName, doc) in unaryPlusMinusOperators) { + val opReturnType = when (thisKind) { + in listOf(PrimitiveType.SHORT, PrimitiveType.BYTE, PrimitiveType.CHAR) -> PrimitiveType.INT.capitalized + else -> thisKind.capitalized + } + + method { + appendDoc(doc) + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isOperator = true + methodName = operatorName + returnType = opReturnType + } + }.modifyGeneratedUnaryOperation(thisKind) + } + } + + private fun ClassBuilder.generateRangeTo(thisKind: PrimitiveType) { + for (otherKind in PrimitiveType.onlyNumeric) { + val opReturnType = maxByDomainCapacity(maxByDomainCapacity(thisKind, otherKind), PrimitiveType.INT) + + if (opReturnType == PrimitiveType.DOUBLE || opReturnType == PrimitiveType.FLOAT) { + continue + } + + method { + appendDoc("Creates a range from this value to the specified [other] value.") + signature { + isOperator = true + methodName = "rangeTo" + parameter { + name = "other" + type = otherKind.capitalized + } + returnType = "${opReturnType.capitalized}Range" + } + }.modifyGeneratedRangeTo(thisKind) + } + } + + private fun ClassBuilder.generateRangeUntil(thisKind: PrimitiveType) { + for (otherKind in PrimitiveType.onlyNumeric) { + val opReturnType = maxByDomainCapacity(maxByDomainCapacity(thisKind, otherKind), PrimitiveType.INT) + + if (opReturnType == PrimitiveType.DOUBLE || opReturnType == PrimitiveType.FLOAT) { + continue + } + + method { + appendDoc( + """ Creates a range from this value up to but excluding the specified [other] value. If the [other] value is less than or equal to `this` value, then the returned range is empty. - """.trimIndent(), - annotations = mutableListOf("SinceKotlin(\"1.7\")", "ExperimentalStdlibApi"), - signature = MethodSignature( - isOperator = true, - name = "rangeUntil", - arg = MethodParameter("other", otherKind.capitalized), - returnType = "${returnType.capitalized}Range" - ) - ).apply { this.modifyGeneratedRangeUntil(thisKind) } - } - } - } - - private fun generateBitShiftOperators(thisKind: PrimitiveType): List { - return buildList { - val className = thisKind.capitalized - val detail = shiftOperatorsDocDetail(thisKind) - for ((name, doc) in shiftOperators) { - this += MethodDescription( - doc = doc + END_LINE + END_LINE + detail, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - isInfix = true, - name = name, - arg = MethodParameter("bitCount", PrimitiveType.INT.capitalized), - returnType = className - ) - ).apply { this.modifyGeneratedBitShiftOperators(thisKind) } - } - } - } - - private fun generateBitwiseOperators(thisKind: PrimitiveType): List { - return buildList { - for ((name, doc) in bitwiseOperators) { - this += MethodDescription( - doc = doc, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - isInfix = true, - name = name, - arg = MethodParameter("other", thisKind.capitalized), - returnType = thisKind.capitalized - ) - ).apply { this.modifyGeneratedBitwiseOperators(thisKind) } - } - - this += MethodDescription( - doc = "Inverts the bits in this value.", - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - name = "inv", - arg = null, - returnType = thisKind.capitalized + """.trimIndent() ) - ).apply { this.modifyGeneratedBitwiseOperators(thisKind) } + annotations += mutableListOf("SinceKotlin(\"1.7\")", "ExperimentalStdlibApi") + signature { + isOperator = true + methodName = "rangeUntil" + parameter { + name = "other" + type = otherKind.capitalized + } + returnType = "${opReturnType.capitalized}Range" + } + }.modifyGeneratedRangeUntil(thisKind) } } - private fun generateConversions(thisKind: PrimitiveType): List { + private fun ClassBuilder.generateBitShiftOperators(thisKind: PrimitiveType) { + val className = thisKind.capitalized + val detail = shiftOperatorsDocDetail(thisKind) + for ((operatorName, doc) in shiftOperators) { + method { + appendDoc(doc + END_LINE + END_LINE + detail) + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isInfix = true + methodName = operatorName + parameter { + name = "bitCount" + type = PrimitiveType.INT.capitalized + } + returnType = className + } + }.modifyGeneratedBitShiftOperators(thisKind) + } + } + + private fun ClassBuilder.generateBitwiseOperators(thisKind: PrimitiveType) { + for ((operatorName, doc) in bitwiseOperators) { + method { + appendDoc(doc) + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isInfix = true + methodName = operatorName + parameter { + name = "other" + type = thisKind.capitalized + } + returnType = thisKind.capitalized + } + + }.modifyGeneratedBitwiseOperators(thisKind) + } + + method { + appendDoc("Inverts the bits in this value.") + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + methodName = "inv" + returnType = thisKind.capitalized + } + }.modifyGeneratedBitwiseOperators(thisKind) + } + + private fun ClassBuilder.generateConversions(thisKind: PrimitiveType) { fun isFpToIntConversionDeprecated(otherKind: PrimitiveType): Boolean { return thisKind in PrimitiveType.floatingPoint && otherKind in listOf(PrimitiveType.BYTE, PrimitiveType.SHORT) } @@ -530,94 +538,94 @@ abstract class BasePrimitivesGenerator(private val writer: PrintWriter) : BuiltI return thisKind != PrimitiveType.INT && otherKind == PrimitiveType.CHAR } - return buildList { - val thisName = thisKind.capitalized - for (otherKind in PrimitiveType.exceptBoolean) { - val otherName = otherKind.capitalized - val doc = if (thisKind == otherKind) { - "Returns this value." - } else { - val detail = if (thisKind in PrimitiveType.integral) { - if (otherKind.isIntegral) { - docForConversionFromIntegralToIntegral(thisKind, otherKind) - } else { - docForConversionFromIntegralToFloating(thisKind, otherKind) - } + val thisName = thisKind.capitalized + for (otherKind in PrimitiveType.exceptBoolean) { + val otherName = otherKind.capitalized + val doc = if (thisKind == otherKind) { + "Returns this value." + } else { + val detail = if (thisKind in PrimitiveType.integral) { + if (otherKind.isIntegral) { + docForConversionFromIntegralToIntegral(thisKind, otherKind) } else { - if (otherKind.isIntegral) { - docForConversionFromFloatingToIntegral(thisKind, otherKind) - } else { - docForConversionFromFloatingToFloating(thisKind, otherKind) - } + docForConversionFromIntegralToFloating(thisKind, otherKind) + } + } else { + if (otherKind.isIntegral) { + docForConversionFromFloatingToIntegral(thisKind, otherKind) + } else { + docForConversionFromFloatingToFloating(thisKind, otherKind) } - - "Converts this [$thisName] value to [$otherName].$END_LINE$END_LINE" + detail } - val annotations = mutableListOf() - if (isFpToIntConversionDeprecated(otherKind)) { - annotations += "Deprecated(\"Unclear conversion. To achieve the same result convert to Int explicitly and then to $otherName.\", ReplaceWith(\"toInt().to$otherName()\"))" - annotations += "DeprecatedSinceKotlin(warningSince = \"1.3\", errorSince = \"1.5\")" - } - if (isCharConversionDeprecated(otherKind)) { - annotations += "Deprecated(\"Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\", ReplaceWith(\"this.toInt().toChar()\"))" - annotations += "DeprecatedSinceKotlin(warningSince = \"1.5\")" - } - - annotations += "kotlin.internal.IntrinsicConstEvaluation" - this += MethodDescription( - doc = doc, - annotations = annotations, - signature = MethodSignature( - isOverride = true, - name = "to$otherName", - arg = null, - returnType = otherName - ) - ).apply { this.modifyGeneratedConversions(thisKind) } + "Converts this [$thisName] value to [$otherName].$END_LINE$END_LINE$detail" } + + val annotationsToAdd = mutableListOf() + if (isFpToIntConversionDeprecated(otherKind)) { + annotationsToAdd += "Deprecated(\"Unclear conversion. To achieve the same result convert to Int explicitly and then to $otherName.\", ReplaceWith(\"toInt().to$otherName()\"))" + annotationsToAdd += "DeprecatedSinceKotlin(warningSince = \"1.3\", errorSince = \"1.5\")" + } + if (isCharConversionDeprecated(otherKind)) { + annotationsToAdd += "Deprecated(\"Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\", ReplaceWith(\"this.toInt().toChar()\"))" + annotationsToAdd += "DeprecatedSinceKotlin(warningSince = \"1.5\", errorSince = \"2.3\")" + } + if (thisKind == PrimitiveType.INT && otherKind == PrimitiveType.CHAR) { + annotationsToAdd += "Suppress(\"OVERRIDE_DEPRECATION\")" + } + + annotationsToAdd += "kotlin.internal.IntrinsicConstEvaluation" + method { + appendDoc(doc) + annotations += annotationsToAdd + signature { + isOverride = true + methodName = "to$otherName" + returnType = otherName + } + }.modifyGeneratedConversions(thisKind) } } - private fun generateEquals(thisKind: PrimitiveType): MethodDescription { - return MethodDescription( - doc = null, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - isOverride = true, - name = "equals", - arg = MethodParameter("other", "Any?"), + private fun ClassBuilder.generateEquals(thisKind: PrimitiveType) { + method { + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isOverride = true + methodName = "equals" + parameter { + name = "other" + type = "Any?" + } returnType = "Boolean" - ) - ).apply { this.modifyGeneratedEquals(thisKind) } + } + }.modifyGeneratedEquals(thisKind) } - private fun generateToString(thisKind: PrimitiveType): MethodDescription { - return MethodDescription( - doc = null, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - isOverride = true, - name = "toString", - arg = null, + private fun ClassBuilder.generateToString(thisKind: PrimitiveType) { + method { + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isOverride = true + methodName = "toString" returnType = "String" - ) - ).apply { modifyGeneratedToString(thisKind) } + } + }.modifyGeneratedToString(thisKind) } - internal open fun FileDescription.modifyGeneratedFile() {} - internal open fun ClassDescription.modifyGeneratedClass(thisKind: PrimitiveType) {} - internal open fun CompanionObjectDescription.modifyGeneratedCompanionObject(thisKind: PrimitiveType) {} - internal open fun PropertyDescription.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedCompareTo(thisKind: PrimitiveType, otherKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedBinaryOperation(thisKind: PrimitiveType, otherKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedRangeTo(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedRangeUntil(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedBitShiftOperators(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedBitwiseOperators(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedConversions(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedEquals(thisKind: PrimitiveType) {} - internal open fun MethodDescription.modifyGeneratedToString(thisKind: PrimitiveType) {} - internal open fun generateAdditionalMethods(thisKind: PrimitiveType): List = emptyList() + internal open fun FileBuilder.modifyGeneratedFile() {} + internal open fun ClassBuilder.modifyGeneratedClass(thisKind: PrimitiveType) {} + internal open fun CompanionObjectBuilder.modifyGeneratedCompanionObject(thisKind: PrimitiveType) {} + internal open fun PropertyBuilder.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedCompareTo(thisKind: PrimitiveType, otherKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedBinaryOperation(thisKind: PrimitiveType, otherKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedRangeTo(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedRangeUntil(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedBitShiftOperators(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedBitwiseOperators(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedConversions(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) {} + internal open fun MethodBuilder.modifyGeneratedToString(thisKind: PrimitiveType) {} + internal open fun ClassBuilder.generateAdditionalMethods(thisKind: PrimitiveType) {} } diff --git a/generators/builtins/primitives/JsPrimitivesGenerator.kt b/generators/builtins/primitives/JsPrimitivesGenerator.kt index d6b287dc1c5..c2a2da56dc7 100644 --- a/generators/builtins/primitives/JsPrimitivesGenerator.kt +++ b/generators/builtins/primitives/JsPrimitivesGenerator.kt @@ -13,27 +13,28 @@ class JsPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(write return this != PrimitiveType.LONG } - override fun FileDescription.modifyGeneratedFile() { - addSuppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY") - addSuppress("UNUSED_PARAMETER") + override fun FileBuilder.modifyGeneratedFile() { + suppress("NON_ABSTRACT_FUNCTION_WITH_NO_BODY") + suppress("UNUSED_PARAMETER") } - override fun PropertyDescription.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) { + override fun PropertyBuilder.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) { if (this.name in setOf("POSITIVE_INFINITY", "NEGATIVE_INFINITY", "NaN")) { - this.addAnnotation("Suppress(\"DIVISION_BY_ZERO\")") + annotations += "Suppress(\"DIVISION_BY_ZERO\")" } } - override fun generateAdditionalMethods(thisKind: PrimitiveType): List { - val hashCode = MethodDescription( - doc = null, - signature = MethodSignature( - isOverride = true, - name = "hashCode", - arg = null, + override fun ClassBuilder.generateAdditionalMethods(thisKind: PrimitiveType) { + method { + signature { + isOverride = true + methodName = "hashCode" returnType = PrimitiveType.INT.capitalized - ) - ) - return listOf(hashCode) + } + } + } + + override fun MethodBuilder.modifyGeneratedRangeUntil(thisKind: PrimitiveType) { + "this until $parameterName".addAsSingleLineBody(bodyOnNewLine = false) } } \ No newline at end of file diff --git a/generators/builtins/primitives/JvmPrimitivesGenerator.kt b/generators/builtins/primitives/JvmPrimitivesGenerator.kt index face653789d..6e42f613145 100644 --- a/generators/builtins/primitives/JvmPrimitivesGenerator.kt +++ b/generators/builtins/primitives/JvmPrimitivesGenerator.kt @@ -9,7 +9,7 @@ import org.jetbrains.kotlin.generators.builtins.PrimitiveType import java.io.PrintWriter class JvmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(writer) { - override fun ClassDescription.modifyGeneratedClass(thisKind: PrimitiveType) { - this.addDoc("On the JVM, non-nullable values of this type are represented as values of the primitive type `${thisKind.name.lowercase()}`.") + override fun ClassBuilder.modifyGeneratedClass(thisKind: PrimitiveType) { + appendDoc("On the JVM, non-nullable values of this type are represented as values of the primitive type `${thisKind.name.lowercase()}`.") } } \ No newline at end of file diff --git a/generators/builtins/primitives/NativePrimitivesGenerator.kt b/generators/builtins/primitives/NativePrimitivesGenerator.kt index 9af135848a1..a7bc4139151 100644 --- a/generators/builtins/primitives/NativePrimitivesGenerator.kt +++ b/generators/builtins/primitives/NativePrimitivesGenerator.kt @@ -10,19 +10,19 @@ import java.io.PrintWriter import java.util.* class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(writer) { - override fun FileDescription.modifyGeneratedFile() { - this.addSuppress("OVERRIDE_BY_INLINE") - this.addSuppress("NOTHING_TO_INLINE") - this.addImport("kotlin.native.internal.*") + override fun FileBuilder.modifyGeneratedFile() { + suppress("OVERRIDE_BY_INLINE") + suppress("NOTHING_TO_INLINE") + import("kotlin.native.internal.*") } - override fun ClassDescription.modifyGeneratedClass(thisKind: PrimitiveType) { + override fun ClassBuilder.modifyGeneratedClass(thisKind: PrimitiveType) { this.isFinal = true } - override fun CompanionObjectDescription.modifyGeneratedCompanionObject(thisKind: PrimitiveType) { + override fun CompanionObjectBuilder.modifyGeneratedCompanionObject(thisKind: PrimitiveType) { if (thisKind !in PrimitiveType.floatingPoint) { - this.addAnnotation("CanBePrecreated") + annotations += "CanBePrecreated" } } @@ -37,25 +37,24 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w } } - override fun PropertyDescription.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) { + override fun PropertyBuilder.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) { if (this.name in setOf("POSITIVE_INFINITY", "NEGATIVE_INFINITY", "NaN")) { - this.addAnnotation("Suppress(\"DIVISION_BY_ZERO\")") + annotations += "Suppress(\"DIVISION_BY_ZERO\")" } } - override fun MethodDescription.modifyGeneratedCompareTo(thisKind: PrimitiveType, otherKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedCompareTo(thisKind: PrimitiveType, otherKind: PrimitiveType) { if (otherKind == thisKind) { if (thisKind in PrimitiveType.floatingPoint) { - val argName = this.signature.arg!!.name """ // if any of values in NaN both comparisons return false - if (this > $argName) return 1 - if (this < $argName) return -1 + if (this > $parameterName) return 1 + if (this < $parameterName) return -1 val thisBits = this.toBits() - val otherBits = $argName.toBits() + val otherBits = $parameterName.toBits() - // Canonical NaN bits representation higher than any other bit represent value + // Canonical NaN bit representation is higher than any other value's bit representation return thisBits.compareTo(otherBits) """.trimIndent().addAsMultiLineBody() } else { @@ -64,172 +63,183 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w return } - this.signature.isInline = thisKind !in PrimitiveType.floatingPoint + modifySignature { isInline = thisKind !in PrimitiveType.floatingPoint } val thisCasted = "this" + thisKind.castToIfNecessary(otherKind) - val otherCasted = this.signature.arg!!.name + otherKind.castToIfNecessary(thisKind) + val otherCasted = parameterName + otherKind.castToIfNecessary(thisKind) if (thisKind == PrimitiveType.FLOAT && otherKind == PrimitiveType.DOUBLE) { - "- ${otherCasted}.compareTo(this)" + "-${otherCasted}.compareTo(this)" } else { "$thisCasted.compareTo($otherCasted)" }.addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedBinaryOperation(thisKind: PrimitiveType, otherKind: PrimitiveType) { - val sign = this.signature.name.asSign() + override fun MethodBuilder.modifyGeneratedBinaryOperation(thisKind: PrimitiveType, otherKind: PrimitiveType) { + val sign = operatorSign(this.methodName) if (thisKind != PrimitiveType.BYTE && thisKind != PrimitiveType.SHORT && thisKind == otherKind) { return setAsExternal() } - this.signature.isInline = true - val returnTypeAsPrimitive = PrimitiveType.valueOf(this.signature.returnType.uppercase()) + modifySignature { isInline = true } + val returnTypeAsPrimitive = PrimitiveType.valueOf(returnType.uppercase()) val thisCasted = "this" + thisKind.castToIfNecessary(returnTypeAsPrimitive) - val otherCasted = this.signature.arg!!.name + this.signature.arg.getTypeAsPrimitive().castToIfNecessary(returnTypeAsPrimitive) + val otherCasted = parameterName + parameterType.toPrimitiveType().castToIfNecessary(returnTypeAsPrimitive) "$thisCasted $sign $otherCasted".addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) { - if (this.signature.name in setOf("inc", "dec") || thisKind == PrimitiveType.INT || - thisKind in PrimitiveType.floatingPoint || (this.signature.name == "unaryMinus" && thisKind == PrimitiveType.LONG) + override fun MethodBuilder.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) { + if (methodName in setOf("inc", "dec") || thisKind == PrimitiveType.INT || + thisKind in PrimitiveType.floatingPoint || (methodName == "unaryMinus" && thisKind == PrimitiveType.LONG) ) { return setAsExternal() } - this.signature.isInline = true - val returnTypeAsPrimitive = PrimitiveType.valueOf(this.signature.returnType.uppercase()) + modifySignature { isInline = true } + val returnTypeAsPrimitive = PrimitiveType.valueOf(returnType.uppercase()) val thisCasted = "this" + thisKind.castToIfNecessary(returnTypeAsPrimitive) - val sign = if (this.signature.name == "unaryMinus") "-" else "" + val sign = if (methodName == "unaryMinus") "-" else "" "$sign$thisCasted".addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedRangeTo(thisKind: PrimitiveType) { - val rangeType = PrimitiveType.valueOf(this.signature.returnType.replace("Range", "").uppercase()) + override fun MethodBuilder.modifyGeneratedRangeTo(thisKind: PrimitiveType) { + val rangeType = PrimitiveType.valueOf(returnType.replace("Range", "").uppercase()) val thisCasted = "this" + thisKind.castToIfNecessary(rangeType) - val otherCasted = this.signature.arg!!.name + this.signature.arg.getTypeAsPrimitive().castToIfNecessary(rangeType) - "return ${this.signature.returnType}($thisCasted, $otherCasted)".addAsMultiLineBody() + val otherCasted = parameterName + parameterType.toPrimitiveType().castToIfNecessary(rangeType) + "return ${returnType}($thisCasted, $otherCasted)".addAsMultiLineBody() } - override fun MethodDescription.modifyGeneratedRangeUntil(thisKind: PrimitiveType) { - "this until ${this.signature.arg!!.name}".addAsSingleLineBody(bodyOnNewLine = false) + override fun MethodBuilder.modifyGeneratedRangeUntil(thisKind: PrimitiveType) { + "this until $parameterName".addAsSingleLineBody(bodyOnNewLine = false) } - override fun MethodDescription.modifyGeneratedBitShiftOperators(thisKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedBitShiftOperators(thisKind: PrimitiveType) { setAsExternal() } - override fun MethodDescription.modifyGeneratedBitwiseOperators(thisKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedBitwiseOperators(thisKind: PrimitiveType) { setAsExternal() } - override fun MethodDescription.modifyGeneratedConversions(thisKind: PrimitiveType) { - val returnTypeAsPrimitive = PrimitiveType.valueOf(this.signature.returnType.uppercase()) + override fun MethodBuilder.modifyGeneratedConversions(thisKind: PrimitiveType) { + val returnTypeAsPrimitive = PrimitiveType.valueOf(returnType.uppercase()) when { returnTypeAsPrimitive == thisKind -> { - this.signature.isInline = true + modifySignature { isInline = true } "this".addAsSingleLineBody(bodyOnNewLine = true) } thisKind !in PrimitiveType.floatingPoint -> { - this.signature.isExternal = true + modifySignature { isExternal = true } val intrinsicType = when { returnTypeAsPrimitive in PrimitiveType.floatingPoint -> "SIGNED_TO_FLOAT" returnTypeAsPrimitive.byteSize < thisKind.byteSize -> "INT_TRUNCATE" returnTypeAsPrimitive.byteSize > thisKind.byteSize -> "SIGN_EXTEND" else -> "ZERO_EXTEND" } - this.addAnnotation("TypedIntrinsic(IntrinsicType.$intrinsicType)") + annotations += "TypedIntrinsic(IntrinsicType.$intrinsicType)" } else -> { if (returnTypeAsPrimitive in setOf(PrimitiveType.BYTE, PrimitiveType.SHORT, PrimitiveType.CHAR)) { - "this.toInt().to${this.signature.returnType}()".addAsSingleLineBody(bodyOnNewLine = false) + "this.toInt().to${returnType}()".addAsSingleLineBody(bodyOnNewLine = false) return } - this.signature.isExternal = true + modifySignature { isExternal = true } when { returnTypeAsPrimitive in setOf(PrimitiveType.INT, PrimitiveType.LONG) -> { - this.addAnnotation("GCUnsafeCall(\"Kotlin_${thisKind.capitalized}_to${this.signature.returnType}\")") + annotations += "GCUnsafeCall(\"Kotlin_${thisKind.capitalized}_to${returnType}\")" } thisKind.byteSize > returnTypeAsPrimitive.byteSize -> { - this.addAnnotation("TypedIntrinsic(IntrinsicType.FLOAT_TRUNCATE)") + annotations += "TypedIntrinsic(IntrinsicType.FLOAT_TRUNCATE)" } thisKind.byteSize < returnTypeAsPrimitive.byteSize -> { - this.addAnnotation("TypedIntrinsic(IntrinsicType.FLOAT_EXTEND)") + annotations += "TypedIntrinsic(IntrinsicType.FLOAT_EXTEND)" } } } } } - override fun MethodDescription.modifyGeneratedEquals(thisKind: PrimitiveType) { - val argName = this.signature.arg!!.name + override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) { val additionalCheck = if (thisKind in PrimitiveType.floatingPoint) { "this.equals(other)" } else { - "kotlin.native.internal.areEqualByValue(this, $argName)" + "kotlin.native.internal.areEqualByValue(this, $parameterName)" } - " $argName is ${thisKind.capitalized} && $additionalCheck".addAsSingleLineBody(bodyOnNewLine = true) + "$parameterName is ${thisKind.capitalized} && $additionalCheck".addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedToString(thisKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedToString(thisKind: PrimitiveType) { if (thisKind in PrimitiveType.floatingPoint) { + appendDoc("Returns the string representation of this [${thisKind.capitalized}] value.\n") + """ + Note that the representation format is unstable and may change in a future release. + However, it is guaranteed that the returned string is valid for converting back to [${thisKind.capitalized}] + using [String.to${thisKind.capitalized}], and will result in the same numeric value. + The exact bit pattern of a `NaN` ${thisKind.name.lowercase()} is not guaranteed to be preserved though. + """.trimIndent().let { appendDoc(it) } + "NumberConverter.convert(this)".addAsSingleLineBody(bodyOnNewLine = false) } else { - this.signature.isExternal = true - this.addAnnotation("GCUnsafeCall(\"Kotlin_${thisKind.capitalized}_toString\")") + modifySignature { isExternal = true } + annotations += "GCUnsafeCall(\"Kotlin_${thisKind.capitalized}_toString\")" } } - override fun generateAdditionalMethods(thisKind: PrimitiveType): List { - val hashCode = MethodDescription( - doc = null, - signature = MethodSignature( - isOverride = true, - name = "hashCode", - arg = null, - returnType = PrimitiveType.INT.capitalized - ) - ).apply { - when (thisKind) { - PrimitiveType.LONG -> "return ((this ushr 32) xor this).toInt()".addAsMultiLineBody() - PrimitiveType.FLOAT -> "toBits()".addAsSingleLineBody() - PrimitiveType.DOUBLE -> "toBits().hashCode()".addAsSingleLineBody() - else -> "return this${thisKind.castToIfNecessary(PrimitiveType.INT)}".addAsMultiLineBody() - } + override fun ClassBuilder.generateAdditionalMethods(thisKind: PrimitiveType) { + generateCustomEquals(thisKind) + generateHashCode(thisKind) + if (thisKind in PrimitiveType.floatingPoint) { + generateBits(thisKind) } + } - val customEquals = MethodDescription( - doc = null, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - name = "equals", - arg = MethodParameter("other", thisKind.capitalized), + private fun ClassBuilder.generateHashCode(thisKind: PrimitiveType) { + method { + signature { + isOverride = true + methodName = "hashCode" + returnType = PrimitiveType.INT.capitalized + } + + when (thisKind) { + PrimitiveType.LONG -> "((this ushr 32) xor this).toInt()" + PrimitiveType.FLOAT -> "toBits()" + PrimitiveType.DOUBLE -> "toBits().hashCode()" + else -> "this${thisKind.castToIfNecessary(PrimitiveType.INT)}" + }.addAsSingleLineBody() + } + } + + private fun ClassBuilder.generateCustomEquals(thisKind: PrimitiveType) { + method { + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + methodName = "equals" + parameter { + name = "other" + type = thisKind.capitalized + } returnType = PrimitiveType.BOOLEAN.capitalized - ) - ).apply { + } + when (thisKind) { in PrimitiveType.floatingPoint -> "toBits() == other.toBits()".addAsSingleLineBody(bodyOnNewLine = false) else -> "kotlin.native.internal.areEqualByValue(this, other)".addAsSingleLineBody(bodyOnNewLine = false) } } + } - val bits = MethodDescription( - doc = null, - signature = MethodSignature( - isExternal = true, - visibility = MethodVisibility.INTERNAL, - name = "bits", - arg = null, + private fun ClassBuilder.generateBits(thisKind: PrimitiveType) { + method { + signature { + isExternal = true + visibility = MethodVisibility.INTERNAL + methodName = "bits" returnType = if (thisKind == PrimitiveType.FLOAT) PrimitiveType.INT.capitalized else PrimitiveType.LONG.capitalized - ) - ).apply { - this.addAnnotation("TypedIntrinsic(IntrinsicType.REINTERPRET)") - this.addAnnotation("PublishedApi") - } + } - return if (thisKind in PrimitiveType.floatingPoint) { - listOf(customEquals, hashCode, bits) - } else { - listOf(customEquals, hashCode) + annotations += "TypedIntrinsic(IntrinsicType.REINTERPRET)" + annotations += "PublishedApi" } } @@ -241,9 +251,9 @@ class NativePrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(w return this.uppercase(Locale.getDefault()) } - private fun MethodDescription.setAsExternal() { - addAnnotation("TypedIntrinsic(IntrinsicType.${this.signature.name.toNativeOperator()})") - this.signature.isExternal = true + private fun MethodBuilder.setAsExternal() { + annotations += "TypedIntrinsic(IntrinsicType.${methodName.toNativeOperator()})" + modifySignature { isExternal = true } } } } \ No newline at end of file diff --git a/generators/builtins/primitives/WasmPrimitivesGenerator.kt b/generators/builtins/primitives/WasmPrimitivesGenerator.kt index 56482d8ee61..ffa4e1ae7e5 100644 --- a/generators/builtins/primitives/WasmPrimitivesGenerator.kt +++ b/generators/builtins/primitives/WasmPrimitivesGenerator.kt @@ -10,21 +10,24 @@ import java.io.PrintWriter import java.util.* class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(writer) { - override fun FileDescription.modifyGeneratedFile() { - this.addSuppress("OVERRIDE_BY_INLINE") - this.addSuppress("NOTHING_TO_INLINE") - this.addSuppress("unused") - this.addSuppress("UNUSED_PARAMETER") - this.addImport("kotlin.wasm.internal.*") + override fun FileBuilder.modifyGeneratedFile() { + suppress("OVERRIDE_BY_INLINE") + suppress("NOTHING_TO_INLINE") + suppress("unused") + suppress("UNUSED_PARAMETER") + import("kotlin.wasm.internal.*") } - override fun ClassDescription.modifyGeneratedClass(thisKind: PrimitiveType) { - addAnnotation("WasmAutoboxed") + override fun ClassBuilder.modifyGeneratedClass(thisKind: PrimitiveType) { + annotations += "WasmAutoboxed" // used here little hack with name extension just to avoid creation of specialized "ConstructorParameterDescription" - constructorArg = MethodParameter("private val value", thisKind.capitalized) + constructorParam { + name = "private val value" + type = thisKind.capitalized + } } - override fun CompanionObjectDescription.modifyGeneratedCompanionObject(thisKind: PrimitiveType) { + override fun CompanionObjectBuilder.modifyGeneratedCompanionObject(thisKind: PrimitiveType) { isPublic = true } @@ -39,36 +42,35 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } } - override fun PropertyDescription.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) { + override fun PropertyBuilder.modifyGeneratedCompanionObjectProperty(thisKind: PrimitiveType) { if (this.name in setOf("POSITIVE_INFINITY", "NEGATIVE_INFINITY", "NaN")) { - this.addAnnotation("Suppress(\"DIVISION_BY_ZERO\")") + annotations += "Suppress(\"DIVISION_BY_ZERO\")" } } - override fun MethodDescription.modifyGeneratedCompareTo(thisKind: PrimitiveType, otherKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedCompareTo(thisKind: PrimitiveType, otherKind: PrimitiveType) { if (thisKind != otherKind || thisKind !in PrimitiveType.floatingPoint) { - this.signature.isInline = true + modifySignature { isInline = true } } - val argName = this.signature.arg!!.name if (otherKind == thisKind) { if (thisKind in PrimitiveType.floatingPoint) { """ // if any of values in NaN both comparisons return false - if (this > $argName) return 1 - if (this < $argName) return -1 + if (this > $parameterName) return 1 + if (this < $parameterName) return -1 val thisBits = this.toBits() - val otherBits = $argName.toBits() + val otherBits = $parameterName.toBits() - // Canonical NaN bits representation higher than any other bit represent value + // Canonical NaN bit representation is higher than any other value's bit representation return thisBits.compareTo(otherBits) """.trimIndent().addAsMultiLineBody() } else { val body = when (thisKind) { - PrimitiveType.BYTE -> "wasm_i32_compareTo(this.toInt(), $argName.toInt())" - PrimitiveType.SHORT -> "this.toInt().compareTo($argName.toInt())" - PrimitiveType.INT, PrimitiveType.LONG -> "wasm_${thisKind.prefixLowercase}_compareTo(this, $argName)" + PrimitiveType.BYTE -> "wasm_i32_compareTo(this.toInt(), $parameterName.toInt())" + PrimitiveType.SHORT -> "this.toInt().compareTo($parameterName.toInt())" + PrimitiveType.INT, PrimitiveType.LONG -> "wasm_${thisKind.prefixLowercase}_compareTo(this, $parameterName)" else -> throw IllegalArgumentException("Unsupported type $thisKind for generation `compareTo` method") } body.addAsSingleLineBody(bodyOnNewLine = true) @@ -77,29 +79,29 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } val thisCasted = "this" + thisKind.castToIfNecessary(otherKind) - val otherCasted = argName + otherKind.castToIfNecessary(thisKind) + val otherCasted = parameterName + otherKind.castToIfNecessary(thisKind) when { - thisKind == PrimitiveType.FLOAT && otherKind == PrimitiveType.DOUBLE -> "- ${otherCasted}.compareTo(this)" + thisKind == PrimitiveType.FLOAT && otherKind == PrimitiveType.DOUBLE -> "-${otherCasted}.compareTo(this)" else -> "$thisCasted.compareTo($otherCasted)" }.addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedBinaryOperation(thisKind: PrimitiveType, otherKind: PrimitiveType) { - val sign = this.signature.name.asSign() - val argName = this.signature.arg!!.name + override fun MethodBuilder.modifyGeneratedBinaryOperation(thisKind: PrimitiveType, otherKind: PrimitiveType) { + val sign = operatorSign(methodName) if (thisKind != PrimitiveType.BYTE && thisKind != PrimitiveType.SHORT && thisKind == otherKind) { val type = thisKind.capitalized - when (val methodName = this.signature.name) { + when (methodName) { "div" -> { val oneConst = if (thisKind == PrimitiveType.LONG) "-1L" else "-1" when (thisKind) { - PrimitiveType.INT, PrimitiveType.LONG -> "if (this == $type.MIN_VALUE && $argName == $oneConst) $type.MIN_VALUE else wasm_${thisKind.prefixLowercase}_div_s(this, $argName)" + PrimitiveType.INT, PrimitiveType.LONG -> "if (this == $type.MIN_VALUE && $parameterName == $oneConst) $type.MIN_VALUE " + + "else wasm_${thisKind.prefixLowercase}_div_s(this, $parameterName)" else -> return implementAsIntrinsic(thisKind, methodName) } } "rem" -> when (thisKind) { - in PrimitiveType.floatingPoint -> "this - (wasm_${thisKind.prefixLowercase}_nearest(this / $argName) * $argName)" + in PrimitiveType.floatingPoint -> "this - (wasm_${thisKind.prefixLowercase}_nearest(this / $parameterName) * $parameterName)" else -> return implementAsIntrinsic(thisKind, methodName) } else -> return implementAsIntrinsic(thisKind, methodName) @@ -107,19 +109,18 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri return } - this.signature.isInline = true - val returnTypeAsPrimitive = PrimitiveType.valueOf(this.signature.returnType.uppercase()) + modifySignature { isInline = true } + val returnTypeAsPrimitive = PrimitiveType.valueOf(returnType.uppercase()) val thisCasted = "this" + thisKind.castToIfNecessary(returnTypeAsPrimitive) - val otherCasted = argName + this.signature.arg.getTypeAsPrimitive().castToIfNecessary(returnTypeAsPrimitive) + val otherCasted = parameterName + parameterType.toPrimitiveType().castToIfNecessary(returnTypeAsPrimitive) "$thisCasted $sign $otherCasted".addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) { - val methodName = this.signature.name + override fun MethodBuilder.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) { if (thisKind == PrimitiveType.INT && methodName == "dec") { - setAdditionalDoc("TODO: Fix test compiler/testData/codegen/box/functions/invoke/invoke.kt with inline dec") + additionalDoc = "TODO: Fix test compiler/testData/codegen/box/functions/invoke/invoke.kt with inline dec" } else { - this.signature.isInline = true + modifySignature { isInline = true } } if (methodName in setOf("inc", "dec")) { @@ -139,7 +140,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri return implementAsIntrinsic(thisKind, methodName) } - val returnTypeAsPrimitive = PrimitiveType.valueOf(this.signature.returnType.uppercase()) + val returnTypeAsPrimitive = PrimitiveType.valueOf(returnType.uppercase()) val thisCasted = "this" + thisKind.castToIfNecessary(returnTypeAsPrimitive) val sign = if (methodName == "unaryMinus") { when (thisKind) { @@ -152,41 +153,41 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } } - override fun MethodDescription.modifyGeneratedRangeTo(thisKind: PrimitiveType) { - val rangeType = PrimitiveType.valueOf(this.signature.returnType.replace("Range", "").uppercase()) + override fun MethodBuilder.modifyGeneratedRangeTo(thisKind: PrimitiveType) { + val rangeType = PrimitiveType.valueOf(returnType.replace("Range", "").uppercase()) val thisCasted = "this" + thisKind.castToIfNecessary(rangeType) - val otherCasted = this.signature.arg!!.name + this.signature.arg.getTypeAsPrimitive().castToIfNecessary(rangeType) - "return ${this.signature.returnType}($thisCasted, $otherCasted)".addAsMultiLineBody() + val otherCasted = parameterName + parameterType.toPrimitiveType().castToIfNecessary(rangeType) + "return ${returnType}($thisCasted, $otherCasted)".addAsMultiLineBody() } - override fun MethodDescription.modifyGeneratedRangeUntil(thisKind: PrimitiveType) { - "this until ${this.signature.arg!!.name}".addAsSingleLineBody(bodyOnNewLine = false) + override fun MethodBuilder.modifyGeneratedRangeUntil(thisKind: PrimitiveType) { + "this until $parameterName".addAsSingleLineBody(bodyOnNewLine = false) } - override fun MethodDescription.modifyGeneratedBitShiftOperators(thisKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedBitShiftOperators(thisKind: PrimitiveType) { if (thisKind == PrimitiveType.INT) { - implementAsIntrinsic(thisKind, this.signature.name) + implementAsIntrinsic(thisKind, methodName) } else if (thisKind == PrimitiveType.LONG) { - this.signature.isInline = true - "wasm_i64_${this.signature.name.toWasmOperator().lowercase()}(this, ${signature.arg!!.name}.toLong())".addAsSingleLineBody(bodyOnNewLine = true) + modifySignature { isInline = true } + "wasm_i64_${methodName.toWasmOperator().lowercase()}(this, ${parameterName}.toLong())".addAsSingleLineBody(bodyOnNewLine = true) } } - override fun MethodDescription.modifyGeneratedBitwiseOperators(thisKind: PrimitiveType) { - if (this.signature.name == "inv") { - this.signature.isInline = true + override fun MethodBuilder.modifyGeneratedBitwiseOperators(thisKind: PrimitiveType) { + if (methodName == "inv") { + modifySignature { isInline = true } val oneConst = if (thisKind == PrimitiveType.LONG) "-1L" else "-1" "this.xor($oneConst)".addAsSingleLineBody(bodyOnNewLine = true) return } - implementAsIntrinsic(thisKind, this.signature.name) + implementAsIntrinsic(thisKind, methodName) } - override fun MethodDescription.modifyGeneratedConversions(thisKind: PrimitiveType) { - val returnTypeAsPrimitive = PrimitiveType.valueOf(this.signature.returnType.uppercase()) + override fun MethodBuilder.modifyGeneratedConversions(thisKind: PrimitiveType) { + val returnTypeAsPrimitive = PrimitiveType.valueOf(returnType.uppercase()) if (returnTypeAsPrimitive == thisKind) { - this.signature.isInline = true + modifySignature { isInline = true } "this".addAsSingleLineBody(bodyOnNewLine = true) return } @@ -194,7 +195,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri when (thisKind) { PrimitiveType.BYTE, PrimitiveType.SHORT -> when (returnTypeAsPrimitive) { // byte to byte conversion impossible here due to earlier check on type equality - PrimitiveType.BYTE -> "this.toInt().toByte()".also { this.signature.isInline = true } + PrimitiveType.BYTE -> "this.toInt().toByte()".also { modifySignature { isInline = true } } PrimitiveType.CHAR -> "reinterpretAsInt().reinterpretAsChar()" PrimitiveType.SHORT -> "reinterpretAsInt().reinterpretAsShort()" PrimitiveType.INT -> "reinterpretAsInt()" @@ -214,7 +215,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } PrimitiveType.LONG -> when (returnTypeAsPrimitive) { PrimitiveType.BYTE, PrimitiveType.CHAR, PrimitiveType.SHORT -> "this.toInt().to${returnTypeAsPrimitive.capitalized}()" - .also { this.signature.isInline = true } + .also { modifySignature { isInline = true } } PrimitiveType.INT -> "wasm_i32_wrap_i64(this)" PrimitiveType.FLOAT -> "wasm_f32_convert_i64_s(this)" PrimitiveType.DOUBLE -> "wasm_f64_convert_i64_s(this)" @@ -222,7 +223,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } in PrimitiveType.floatingPoint -> when (returnTypeAsPrimitive) { PrimitiveType.BYTE, PrimitiveType.CHAR, PrimitiveType.SHORT -> "this.toInt().to${returnTypeAsPrimitive.capitalized}()" - .also { this.signature.isInline = true } + .also { modifySignature { isInline = true } } PrimitiveType.INT -> "wasm_i32_trunc_sat_${thisKind.prefixLowercase}_s(this)" PrimitiveType.LONG -> "wasm_i64_trunc_sat_${thisKind.prefixLowercase}_s(this)" PrimitiveType.FLOAT -> "wasm_f32_demote_f64(this)" @@ -233,20 +234,19 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri }.addAsSingleLineBody(bodyOnNewLine = false) } - override fun MethodDescription.modifyGeneratedEquals(thisKind: PrimitiveType) { - val argName = this.signature.arg!!.name + override fun MethodBuilder.modifyGeneratedEquals(thisKind: PrimitiveType) { val additionalCheck = when (thisKind) { - PrimitiveType.LONG -> "wasm_i64_eq(this, $argName)" + PrimitiveType.LONG -> "wasm_i64_eq(this, $parameterName)" PrimitiveType.FLOAT -> "this.equals(other)" PrimitiveType.DOUBLE -> "this.toBits() == other.toBits()" else -> { - "wasm_i32_eq(this${thisKind.castToIfNecessary(PrimitiveType.INT)}, $argName${thisKind.castToIfNecessary(PrimitiveType.INT)})" + "wasm_i32_eq(this${thisKind.castToIfNecessary(PrimitiveType.INT)}, $parameterName${thisKind.castToIfNecessary(PrimitiveType.INT)})" } } - "\t$argName is ${thisKind.capitalized} && $additionalCheck".addAsSingleLineBody(bodyOnNewLine = true) + "$parameterName is ${thisKind.capitalized} && $additionalCheck".addAsSingleLineBody(bodyOnNewLine = true) } - override fun MethodDescription.modifyGeneratedToString(thisKind: PrimitiveType) { + override fun MethodBuilder.modifyGeneratedToString(thisKind: PrimitiveType) { when (thisKind) { in PrimitiveType.floatingPoint -> "dtoa(this${thisKind.castToIfNecessary(PrimitiveType.DOUBLE)})" PrimitiveType.INT, PrimitiveType.LONG -> "itoa${thisKind.bitSize}(this, 10)" @@ -254,62 +254,64 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri }.addAsSingleLineBody(bodyOnNewLine = true) } - override fun generateAdditionalMethods(thisKind: PrimitiveType): List { - val hashCode = MethodDescription( - doc = null, - signature = MethodSignature( - isOverride = true, - isInline = true, - name = "hashCode", - arg = null, - returnType = PrimitiveType.INT.capitalized - ) - ).apply { - when (thisKind) { - PrimitiveType.LONG -> "return ((this ushr 32) xor this).toInt()".addAsMultiLineBody() - PrimitiveType.FLOAT -> "toBits()".addAsSingleLineBody() - PrimitiveType.DOUBLE -> "toBits().hashCode()".addAsSingleLineBody() - else -> "return this${thisKind.castToIfNecessary(PrimitiveType.INT)}".addAsMultiLineBody() + override fun ClassBuilder.generateAdditionalMethods(thisKind: PrimitiveType) { + generateCustomEquals(thisKind) + generateHashCode(thisKind) + when { + thisKind == PrimitiveType.BYTE || thisKind == PrimitiveType.SHORT -> generateReinterpret(PrimitiveType.INT) + thisKind == PrimitiveType.INT -> { + setOf(PrimitiveType.BOOLEAN, PrimitiveType.BYTE, PrimitiveType.SHORT, PrimitiveType.CHAR) + .forEach { generateReinterpret(it) } } } + } - val customEquals = MethodDescription( - doc = null, - annotations = mutableListOf("kotlin.internal.IntrinsicConstEvaluation"), - signature = MethodSignature( - isInline = thisKind in PrimitiveType.floatingPoint, - name = "equals", - arg = MethodParameter("other", thisKind.capitalized), + private fun ClassBuilder.generateHashCode(thisKind: PrimitiveType) { + method { + signature { + isOverride = true + methodName = "hashCode" + returnType = PrimitiveType.INT.capitalized + } + + when (thisKind) { + PrimitiveType.LONG -> "((this ushr 32) xor this).toInt()" + PrimitiveType.FLOAT -> "toBits()" + PrimitiveType.DOUBLE -> "toBits().hashCode()" + else -> "this${thisKind.castToIfNecessary(PrimitiveType.INT)}" + }.addAsSingleLineBody() + } + } + + private fun ClassBuilder.generateCustomEquals(thisKind: PrimitiveType) { + method { + annotations += "kotlin.internal.IntrinsicConstEvaluation" + signature { + isInline = thisKind in PrimitiveType.floatingPoint + methodName = "equals" + parameter { + name = "other" + type = thisKind.capitalized + } returnType = PrimitiveType.BOOLEAN.capitalized - ) - ).apply { + } when (thisKind) { in PrimitiveType.floatingPoint -> "toBits() == other.toBits()".addAsSingleLineBody(bodyOnNewLine = false) - else -> implementAsIntrinsic(thisKind, this.signature.name) + else -> implementAsIntrinsic(thisKind, methodName) } } + } - val reinterprets = setOf(PrimitiveType.INT, PrimitiveType.BOOLEAN, PrimitiveType.BYTE, PrimitiveType.SHORT, PrimitiveType.CHAR) - .map { - MethodDescription( - doc = null, - annotations = mutableListOf("WasmNoOpCast", "PublishedApi"), - signature = MethodSignature( - visibility = MethodVisibility.INTERNAL, - name = "reinterpretAs${it.capitalized}", - arg = null, - returnType = it.capitalized - ) - ).apply { "implementedAsIntrinsic".addAsSingleLineBody(bodyOnNewLine = true) } + private fun ClassBuilder.generateReinterpret(otherKind: PrimitiveType) { + method { + annotations += "WasmNoOpCast" + annotations += "PublishedApi" + signature { + visibility = MethodVisibility.INTERNAL + methodName = "reinterpretAs${otherKind.capitalized}" + returnType = otherKind.capitalized } - - val reinterpretInt = reinterprets.first() - val otherReinterprets = reinterprets.drop(1).toTypedArray() - - return when (thisKind) { - PrimitiveType.BYTE, PrimitiveType.SHORT -> listOf(customEquals, hashCode, reinterpretInt) - PrimitiveType.INT -> listOf(customEquals, hashCode, *otherReinterprets) - else -> listOf(customEquals, hashCode) + "implementedAsIntrinsic".addAsSingleLineBody(bodyOnNewLine = true) } } @@ -328,9 +330,9 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri } } - private fun MethodDescription.implementAsIntrinsic(thisKind: PrimitiveType, methodName: String) { - this.signature.isInline = false - addAnnotation("WasmOp(WasmOp.${thisKind.prefixUppercase}_${methodName.toWasmOperator()})") + private fun MethodBuilder.implementAsIntrinsic(thisKind: PrimitiveType, methodName: String) { + modifySignature { isInline = false } + annotations += "WasmOp(WasmOp.${thisKind.prefixUppercase}_${methodName.toWasmOperator()})" "implementedAsIntrinsic".addAsSingleLineBody(bodyOnNewLine = true) } diff --git a/generators/builtins/primitives/builders.kt b/generators/builtins/primitives/builders.kt new file mode 100644 index 00000000000..313a10f3215 --- /dev/null +++ b/generators/builtins/primitives/builders.kt @@ -0,0 +1,301 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.generators.builtins.numbers.primitives + +import java.io.File + +private fun String.shift(): String { + return this.split(END_LINE).joinToString(separator = END_LINE) { if (it.isEmpty()) it else " $it" } +} + +internal fun file(init: FileBuilder.() -> Unit): FileBuilder { + val file = FileBuilder() + file.init() + return file +} + +internal interface PrimitiveBuilder { + fun build(): String + + fun throwIfAlreadyInitialized(arg: Any?, propertyName: String, className: String) { + if (arg != null) { + throw AssertionError("Property '$propertyName' for '$className' was already initialized") + } + } + + fun throwIfWasNotInitialized(arg: Any?, propertyName: String, className: String) { + if (arg == null) { + throw AssertionError("Property '$propertyName' for '$className' wasn't set to its value") + } + } + + fun throwNotInitialized(propertyName: String, className: String): Nothing { + throw AssertionError("Property '$propertyName' for '$className' wasn't initialized to access") + } +} + +internal abstract class AnnotatedAndDocumented { + private var doc: String? = null + val annotations: MutableList = mutableListOf() + var additionalDoc: String? = null + + fun appendDoc(doc: String) { + if (this.doc == null) { + this.doc = doc + } else { + this.doc += "$END_LINE$doc" + } + } + + protected fun StringBuilder.printDocumentationAndAnnotations(forceMultiLineDoc: Boolean = false) { + if (doc != null) { + appendLine(doc!!.printAsDoc(forceMultiLineDoc)) + } + + if (annotations.isNotEmpty()) { + appendLine(annotations.joinToString(separator = END_LINE) { "@$it" }) + } + + if (additionalDoc != null) { + appendLine("// $additionalDoc") + } + } + + private fun String.printAsDoc(forceMultiLine: Boolean = false): String { + if (this.contains(END_LINE) || forceMultiLine) { + return this.split(END_LINE).joinToString( + separator = END_LINE, prefix = "/**$END_LINE", postfix = "$END_LINE */" + ) { if (it.isEmpty()) " *" else " * $it" } + } + return "/** $this */" + } +} + +internal class FileBuilder : PrimitiveBuilder { + private val suppresses: MutableList = mutableListOf() + private val imports: MutableList = mutableListOf() + private val classes: MutableList = mutableListOf() + + fun suppress(suppress: String) { + suppresses += suppress + } + + fun import(newImport: String) { + imports += newImport + } + + fun klass(init: ClassBuilder.() -> Unit): ClassBuilder { + val classBuilder = ClassBuilder() + classes += classBuilder.apply(init) + return classBuilder + } + + override fun build(): String { + return buildString { + appendLine(File("license/COPYRIGHT_HEADER.txt").readText()) + appendLine() + appendLine("// Auto-generated file. DO NOT EDIT!") + appendLine() + + if (suppresses.isNotEmpty()) { + appendLine(suppresses.joinToString(separator = ", ", prefix = "@file:Suppress(", postfix = ")") { "\"$it\"" }) + appendLine() + } + + appendLine("package kotlin") + appendLine() + + if (imports.isNotEmpty()) { + appendLine(imports.joinToString(separator = END_LINE) { "import $it" }) + appendLine() + } + + append(classes.joinToString(separator = END_LINE) { it.build() }) + } + } +} + +internal class ClassBuilder : AnnotatedAndDocumented(), PrimitiveBuilder { + var isFinal: Boolean = false + var name: String = "" + private var constructorParam: MethodParameterBuilder? = null + private var companionObject: CompanionObjectBuilder? = null + private val methods: MutableList = mutableListOf() + + fun constructorParam(init: MethodParameterBuilder.() -> Unit) { + throwIfAlreadyInitialized(constructorParam, "constructorParam", "ClassBuilder") + constructorParam = MethodParameterBuilder().apply(init) + } + + fun companionObject(init: CompanionObjectBuilder.() -> Unit): CompanionObjectBuilder { + throwIfAlreadyInitialized(companionObject, "companionObject", "ClassBuilder") + val companionObjectBuilder = CompanionObjectBuilder() + companionObject = companionObjectBuilder.apply(init) + return companionObjectBuilder + } + + fun method(init: MethodBuilder.() -> Unit): MethodBuilder { + val methodBuilder = MethodBuilder() + methods += methodBuilder.apply(init) + return methodBuilder + } + + override fun build(): String { + return buildString { + this.printDocumentationAndAnnotations() + + append("public ") + if (isFinal) append("final ") + appendLine("class $name private constructor(${constructorParam?.build() ?: ""}) : Number(), Comparable<$name> {") + + companionObject?.let { appendLine(it.build().shift()) } + appendLine(methods.joinToString(separator = END_LINE + END_LINE) { it.build().shift() }) + appendLine("}") + } + } +} + +internal class CompanionObjectBuilder : AnnotatedAndDocumented(), PrimitiveBuilder { + var isPublic: Boolean = false + private val properties: MutableList = mutableListOf() + + fun property(init: PropertyBuilder.() -> Unit): PropertyBuilder { + val propertyBuilder = PropertyBuilder() + properties += propertyBuilder.apply(init) + return propertyBuilder + } + + override fun build(): String { + return buildString { + printDocumentationAndAnnotations() + if (isPublic) append("public ") + appendLine("companion object {") + appendLine(properties.joinToString(separator = END_LINE + END_LINE) { it.build().shift() }) + appendLine("}") + } + } +} + +internal class MethodSignatureBuilder : PrimitiveBuilder { + var isExternal: Boolean = false + var visibility: MethodVisibility = MethodVisibility.PUBLIC + var isOverride: Boolean = false + var isInline: Boolean = false + var isInfix: Boolean = false + var isOperator: Boolean = false + + var methodName: String? = null + private var parameter: MethodParameterBuilder? = null + var returnType: String? = null + + val parameterName: String + get() = parameter?.name ?: throwNotInitialized("name", "MethodParameterBuilder") + + val parameterType: String + get() = parameter?.type ?: throwNotInitialized("type", "MethodParameterBuilder") + + fun parameter(init: MethodParameterBuilder.() -> Unit): MethodParameterBuilder { + throwIfAlreadyInitialized(parameter, "parameter", "MethodSignatureBuilder") + val argBuilder = MethodParameterBuilder() + parameter = argBuilder.apply(init) + return argBuilder + } + + override fun build(): String { + throwIfWasNotInitialized(methodName, "methodName", "MethodSignatureBuilder") + throwIfWasNotInitialized(returnType, "returnType", "MethodSignatureBuilder") + + return buildString { + if (isExternal) append("external ") + append("${visibility.name.lowercase()} ") + if (isOverride) append("override ") + if (isInline) append("inline ") + if (isInfix) append("infix ") + if (isOperator) append("operator ") + append("fun $methodName(${parameter?.build() ?: ""}): $returnType") + } + } +} + +internal enum class MethodVisibility { + PUBLIC, INTERNAL, PRIVATE +} + +internal class MethodParameterBuilder : PrimitiveBuilder { + var name: String? = null + var type: String? = null + + override fun build(): String { + throwIfWasNotInitialized(name, "name", "MethodParameterBuilder") + throwIfWasNotInitialized(type, "type", "MethodParameterBuilder") + return "$name: $type" + } +} + +internal class MethodBuilder : AnnotatedAndDocumented(), PrimitiveBuilder { + private var signature: MethodSignatureBuilder? = null + private var body: String? = null + + val methodName: String + get() = signature?.methodName ?: throwNotInitialized("methodName", "MethodSignatureBuilder") + + val returnType: String + get() = signature?.returnType ?: throwNotInitialized("returnType", "MethodSignatureBuilder") + + val parameterName: String + get() = signature?.parameterName ?: throwNotInitialized("name", "MethodParameterBuilder") + + val parameterType: String + get() = signature?.parameterType ?: throwNotInitialized("type", "MethodParameterBuilder") + + fun signature(init: MethodSignatureBuilder.() -> Unit): MethodSignatureBuilder { + throwIfAlreadyInitialized(signature, "signature", "MethodBuilder") + val signatureBuilder = MethodSignatureBuilder() + signature = signatureBuilder.apply(init) + return signatureBuilder + } + + fun modifySignature(modify: MethodSignatureBuilder.() -> Unit) { + throwIfWasNotInitialized(signature, "signature", "MethodBuilder") + signature!!.apply(modify) + } + + override fun build(): String { + throwIfWasNotInitialized(signature, "signature", "MethodBuilder") + + return buildString { + printDocumentationAndAnnotations() + append(signature!!.build()) + append(body ?: "") + } + } + + fun String.addAsSingleLineBody(bodyOnNewLine: Boolean = false) { + val skip = if (bodyOnNewLine) "$END_LINE " else " " + body = " =$skip$this" + } + + fun String.addAsMultiLineBody() { + body = " {$END_LINE${this.shift()}$END_LINE}" + } +} + +internal class PropertyBuilder : AnnotatedAndDocumented(), PrimitiveBuilder { + var name: String? = null + var type: String? = null + var value: String? = null + + override fun build(): String { + throwIfWasNotInitialized(name, "name", "PropertyBuilder") + throwIfWasNotInitialized(type, "type", "PropertyBuilder") + throwIfWasNotInitialized(value, "value", "PropertyBuilder") + + return buildString { + printDocumentationAndAnnotations(forceMultiLineDoc = true) + append("public const val $name: $type = $value") + } + } +} diff --git a/generators/builtins/primitives/declarations.kt b/generators/builtins/primitives/declarations.kt deleted file mode 100644 index e5ce47331df..00000000000 --- a/generators/builtins/primitives/declarations.kt +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.generators.builtins.numbers.primitives - -import org.jetbrains.kotlin.generators.builtins.PrimitiveType -import java.io.File - -internal val END_LINE = "\n" - -private fun String.shift(): String { - return this.split(END_LINE).joinToString(separator = END_LINE) { if (it.isEmpty()) it else " $it" } -} - -internal abstract class AnnotatedAndDocumented { - protected abstract var doc: String? - protected abstract val annotations: MutableList - private var additionalDoc: String? = null - - fun addDoc(doc: String) { - if (this.doc == null) { - this.doc = doc - } else { - this.doc += "$END_LINE$doc" - } - } - - fun addAnnotation(annotation: String) { - annotations += annotation - } - - fun setAdditionalDoc(doc: String) { - additionalDoc = doc - } - - fun StringBuilder.printDocumentationAndAnnotations(forceMultiLineDoc: Boolean = false) { - if (doc != null) { - appendLine(doc!!.printAsDoc(forceMultiLineDoc)) - } - - if (annotations.isNotEmpty()) { - appendLine(annotations.joinToString(separator = END_LINE) { "@$it" }) - } - - if (additionalDoc != null) { - appendLine("// $additionalDoc") - } - } - - private fun String.printAsDoc(forceMultiLine: Boolean = false): String { - if (this.contains(END_LINE) || forceMultiLine) { - return this.split(END_LINE).joinToString( - separator = END_LINE, prefix = "/**$END_LINE", postfix = "$END_LINE */" - ) { if (it.isEmpty()) " *" else " * $it" } - } - return "/** $this */" - } -} - -internal data class FileDescription( - private val suppresses: MutableList = mutableListOf(), - private val imports: MutableList = mutableListOf(), - val classes: List -) { - fun addSuppress(suppress: String) { - suppresses += suppress - } - - fun addImport(newImport: String) { - imports += newImport - } - - override fun toString(): String { - return buildString { - appendLine(File("license/COPYRIGHT_HEADER.txt").readText()) - appendLine() - appendLine("// Auto-generated file. DO NOT EDIT!") - appendLine() - - if (suppresses.isNotEmpty()) { - appendLine(suppresses.joinToString(separator = ", ", prefix = "@file:Suppress(", postfix = ")") { "\"$it\"" }) - appendLine() - } - - appendLine("package kotlin") - appendLine() - - if (imports.isNotEmpty()) { - appendLine(imports.joinToString(separator = END_LINE) { "import $it" }) - appendLine() - } - - append(classes.joinToString(separator = END_LINE)) - } - } -} - -internal data class ClassDescription( - override var doc: String?, - override val annotations: MutableList, - var isFinal: Boolean = false, - val name: String, - var constructorArg: MethodParameter? = null, - val companionObject: CompanionObjectDescription, - val methods: List -) : AnnotatedAndDocumented() { - override fun toString(): String { - return buildString { - this.printDocumentationAndAnnotations() - - append("public ") - if (isFinal) append("final ") - appendLine("class $name private constructor(${constructorArg?.toString() ?: ""}) : Number(), Comparable<$name> {") - appendLine(companionObject.toString().shift()) - appendLine(methods.joinToString(separator = END_LINE + END_LINE) { it.toString().shift() }) - appendLine("}") - } - } -} - -internal data class CompanionObjectDescription( - override var doc: String? = null, - override val annotations: MutableList = mutableListOf(), - var isPublic: Boolean = false, - val properties: List -) : AnnotatedAndDocumented() { - override fun toString(): String { - return buildString { - printDocumentationAndAnnotations() - if (isPublic) append("public ") - appendLine("companion object {") - appendLine(properties.joinToString(separator = END_LINE + END_LINE) { it.toString().shift() }) - appendLine("}") - } - } -} - -internal data class MethodSignature( - var isExternal: Boolean = false, - val visibility: MethodVisibility = MethodVisibility.PUBLIC, - var isOverride: Boolean = false, - var isInline: Boolean = false, - var isInfix: Boolean = false, - var isOperator: Boolean = false, - val name: String, - val arg: MethodParameter?, - val returnType: String -) { - - override fun toString(): String { - return buildString { - if (isExternal) append("external ") - append("${visibility.name.lowercase()} ") - if (isOverride) append("override ") - if (isInline) append("inline ") - if (isInfix) append("infix ") - if (isOperator) append("operator ") - append("fun $name(${arg ?: ""}): $returnType") - } - } -} - -internal enum class MethodVisibility { - PUBLIC, INTERNAL, PRIVATE -} - -internal data class MethodParameter(val name: String, val type: String) { - fun getTypeAsPrimitive(): PrimitiveType = PrimitiveType.valueOf(type.uppercase()) - - override fun toString(): String { - return "$name: $type" - } -} - -internal data class MethodDescription( - override var doc: String?, - override val annotations: MutableList = mutableListOf(), - val signature: MethodSignature, - private var body: String? = null -) : AnnotatedAndDocumented() { - override fun toString(): String { - return buildString { - printDocumentationAndAnnotations() - append(signature) - append(body ?: "") - } - } - - fun String.addAsSingleLineBody(bodyOnNewLine: Boolean = false) { - val skip = if (bodyOnNewLine) "$END_LINE\t" else "" - body = " = $skip$this" - } - - fun String.addAsMultiLineBody() { - body = " {$END_LINE${this.shift()}$END_LINE}" - } -} - -internal data class PropertyDescription( - override var doc: String?, - override val annotations: MutableList = mutableListOf(), - val name: String, - val type: String, - val value: String -) : AnnotatedAndDocumented() { - override fun toString(): String { - return buildString { - printDocumentationAndAnnotations(forceMultiLineDoc = true) - append("public const val $name: $type = $value") - } - } -} diff --git a/generators/builtins/primitives/utils.kt b/generators/builtins/primitives/utils.kt index ac4c89cefdc..9278685954c 100644 --- a/generators/builtins/primitives/utils.kt +++ b/generators/builtins/primitives/utils.kt @@ -7,6 +7,8 @@ package org.jetbrains.kotlin.generators.builtins.numbers.primitives import org.jetbrains.kotlin.generators.builtins.PrimitiveType +internal const val END_LINE = "\n" + internal fun PrimitiveType.castToIfNecessary(otherType: PrimitiveType): String { if (this !in PrimitiveType.onlyNumeric || otherType !in PrimitiveType.onlyNumeric) { throw IllegalArgumentException("Cannot cast to non-numeric type") @@ -21,13 +23,17 @@ internal fun PrimitiveType.castToIfNecessary(otherType: PrimitiveType): String { return "" } -internal fun String.asSign(): String { - return when (this) { +internal fun operatorSign(methodName: String): String { + return when (methodName) { "plus" -> "+" "minus" -> "-" "times" -> "*" "div" -> "/" "rem" -> "%" - else -> throw IllegalArgumentException("Unsupported binary operation: ${this}") + else -> throw IllegalArgumentException("Unsupported binary operation: ${methodName}") } } + +internal fun String.toPrimitiveType(): PrimitiveType { + return PrimitiveType.valueOf(this.uppercase()) +} diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt index 1575efec9cb..c781745307f 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt @@ -54,7 +54,7 @@ public final class Byte private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.toShort().compareTo(other) + this.toShort().compareTo(other) /** * Compares this value with the specified value for order. @@ -63,7 +63,7 @@ public final class Byte private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.toInt().compareTo(other) + this.toInt().compareTo(other) /** * Compares this value with the specified value for order. @@ -72,7 +72,7 @@ public final class Byte private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.toLong().compareTo(other) + this.toLong().compareTo(other) /** * Compares this value with the specified value for order. @@ -81,7 +81,7 @@ public final class Byte private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -90,127 +90,127 @@ public final class Byte private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Int = - this.toInt() + other + this.toInt() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Long = - this.toLong() + other + this.toLong() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Int = - this.toInt() - other + this.toInt() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Long = - this.toLong() - other + this.toLong() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Int = - this.toInt() * other + this.toInt() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Long = - this.toLong() * other + this.toLong() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Int = - this.toInt() / other + this.toInt() / other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Long = - this.toLong() / other + this.toLong() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -220,7 +220,7 @@ public final class Byte private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -230,7 +230,7 @@ public final class Byte private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -240,7 +240,7 @@ public final class Byte private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Int = - this.toInt() % other + this.toInt() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -250,7 +250,7 @@ public final class Byte private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Long = - this.toLong() % other + this.toLong() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -260,7 +260,7 @@ public final class Byte private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -270,7 +270,7 @@ public final class Byte private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -291,12 +291,12 @@ public final class Byte private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Int = - this.toInt() + this.toInt() /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryMinus(): Int = - -this.toInt() + -this.toInt() /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): IntRange { @@ -357,7 +357,7 @@ public final class Byte private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toByte(): Byte = - this + this /** * Converts this [Byte] value to [Char]. @@ -427,20 +427,18 @@ public final class Byte private constructor() : Number(), Comparable { @TypedIntrinsic(IntrinsicType.SIGNED_TO_FLOAT) external public override fun toDouble(): Double - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Byte && kotlin.native.internal.areEqualByValue(this, other) - @kotlin.internal.IntrinsicConstEvaluation @GCUnsafeCall("Kotlin_Byte_toString") external public override fun toString(): String + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Byte && kotlin.native.internal.areEqualByValue(this, other) + @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Byte): Boolean = kotlin.native.internal.areEqualByValue(this, other) - public override fun hashCode(): Int { - return this.toInt() - } + public override fun hashCode(): Int = this.toInt() } /** Represents a 16-bit signed integer. */ @@ -477,7 +475,7 @@ public final class Short private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toShort()) + this.compareTo(other.toShort()) /** * Compares this value with the specified value for order. @@ -495,7 +493,7 @@ public final class Short private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.toInt().compareTo(other) + this.toInt().compareTo(other) /** * Compares this value with the specified value for order. @@ -504,7 +502,7 @@ public final class Short private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.toLong().compareTo(other) + this.toLong().compareTo(other) /** * Compares this value with the specified value for order. @@ -513,7 +511,7 @@ public final class Short private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -522,127 +520,127 @@ public final class Short private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Int = - this.toInt() + other + this.toInt() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Long = - this.toLong() + other + this.toLong() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Int = - this.toInt() - other + this.toInt() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Long = - this.toLong() - other + this.toLong() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Int = - this.toInt() * other + this.toInt() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Long = - this.toLong() * other + this.toLong() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Int = - this.toInt() / other + this.toInt() / other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Long = - this.toLong() / other + this.toLong() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -652,7 +650,7 @@ public final class Short private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -662,7 +660,7 @@ public final class Short private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -672,7 +670,7 @@ public final class Short private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Int = - this.toInt() % other + this.toInt() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -682,7 +680,7 @@ public final class Short private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Long = - this.toLong() % other + this.toLong() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -692,7 +690,7 @@ public final class Short private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -702,7 +700,7 @@ public final class Short private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -723,12 +721,12 @@ public final class Short private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Int = - this.toInt() + this.toInt() /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryMinus(): Int = - -this.toInt() + -this.toInt() /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): IntRange { @@ -813,7 +811,7 @@ public final class Short private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toShort(): Short = - this + this /** * Converts this [Short] value to [Int]. @@ -857,20 +855,18 @@ public final class Short private constructor() : Number(), Comparable { @TypedIntrinsic(IntrinsicType.SIGNED_TO_FLOAT) external public override fun toDouble(): Double - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Short && kotlin.native.internal.areEqualByValue(this, other) - @kotlin.internal.IntrinsicConstEvaluation @GCUnsafeCall("Kotlin_Short_toString") external public override fun toString(): String + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Short && kotlin.native.internal.areEqualByValue(this, other) + @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Short): Boolean = kotlin.native.internal.areEqualByValue(this, other) - public override fun hashCode(): Int { - return this.toInt() - } + public override fun hashCode(): Int = this.toInt() } /** Represents a 32-bit signed integer. */ @@ -907,7 +903,7 @@ public final class Int private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toInt()) + this.compareTo(other.toInt()) /** * Compares this value with the specified value for order. @@ -916,7 +912,7 @@ public final class Int private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.compareTo(other.toInt()) + this.compareTo(other.toInt()) /** * Compares this value with the specified value for order. @@ -934,7 +930,7 @@ public final class Int private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.toLong().compareTo(other) + this.toLong().compareTo(other) /** * Compares this value with the specified value for order. @@ -943,7 +939,7 @@ public final class Int private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -952,17 +948,17 @@ public final class Int private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Int = - this + other.toInt() + this + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Int = - this + other.toInt() + this + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -972,27 +968,27 @@ public final class Int private constructor() : Number(), Comparable { /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Long = - this.toLong() + other + this.toLong() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Int = - this - other.toInt() + this - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Int = - this - other.toInt() + this - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1002,27 +998,27 @@ public final class Int private constructor() : Number(), Comparable { /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Long = - this.toLong() - other + this.toLong() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Int = - this * other.toInt() + this * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Int = - this * other.toInt() + this * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1032,27 +1028,27 @@ public final class Int private constructor() : Number(), Comparable { /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Long = - this.toLong() * other + this.toLong() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Int = - this / other.toInt() + this / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Int = - this / other.toInt() + this / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1062,17 +1058,17 @@ public final class Int private constructor() : Number(), Comparable { /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Long = - this.toLong() / other + this.toLong() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1082,7 +1078,7 @@ public final class Int private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Int = - this % other.toInt() + this % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1092,7 +1088,7 @@ public final class Int private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Int = - this % other.toInt() + this % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1112,7 +1108,7 @@ public final class Int private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Long = - this.toLong() % other + this.toLong() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1122,7 +1118,7 @@ public final class Int private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1132,7 +1128,7 @@ public final class Int private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -1286,9 +1282,9 @@ public final class Int private constructor() : Number(), Comparable { * * The resulting `Char` code is represented by the least significant 16 bits of this `Int` value. */ + @Suppress("OVERRIDE_DEPRECATION") @kotlin.internal.IntrinsicConstEvaluation @TypedIntrinsic(IntrinsicType.INT_TRUNCATE) - @Suppress("OVERRIDE_DEPRECATION") external public override fun toChar(): Char /** @@ -1306,7 +1302,7 @@ public final class Int private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toInt(): Int = - this + this /** * Converts this [Int] value to [Long]. @@ -1340,20 +1336,18 @@ public final class Int private constructor() : Number(), Comparable { @TypedIntrinsic(IntrinsicType.SIGNED_TO_FLOAT) external public override fun toDouble(): Double - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Int && kotlin.native.internal.areEqualByValue(this, other) - @kotlin.internal.IntrinsicConstEvaluation @GCUnsafeCall("Kotlin_Int_toString") external public override fun toString(): String + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Int && kotlin.native.internal.areEqualByValue(this, other) + @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Int): Boolean = kotlin.native.internal.areEqualByValue(this, other) - public override fun hashCode(): Int { - return this - } + public override fun hashCode(): Int = this } /** Represents a 64-bit signed integer. */ @@ -1390,7 +1384,7 @@ public final class Long private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toLong()) + this.compareTo(other.toLong()) /** * Compares this value with the specified value for order. @@ -1399,7 +1393,7 @@ public final class Long private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.compareTo(other.toLong()) + this.compareTo(other.toLong()) /** * Compares this value with the specified value for order. @@ -1408,7 +1402,7 @@ public final class Long private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.compareTo(other.toLong()) + this.compareTo(other.toLong()) /** * Compares this value with the specified value for order. @@ -1426,7 +1420,7 @@ public final class Long private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -1435,22 +1429,22 @@ public final class Long private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Long = - this + other.toLong() + this + other.toLong() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Long = - this + other.toLong() + this + other.toLong() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Long = - this + other.toLong() + this + other.toLong() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1460,27 +1454,27 @@ public final class Long private constructor() : Number(), Comparable { /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Long = - this - other.toLong() + this - other.toLong() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Long = - this - other.toLong() + this - other.toLong() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Long = - this - other.toLong() + this - other.toLong() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1490,27 +1484,27 @@ public final class Long private constructor() : Number(), Comparable { /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Long = - this * other.toLong() + this * other.toLong() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Long = - this * other.toLong() + this * other.toLong() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Long = - this * other.toLong() + this * other.toLong() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1520,27 +1514,27 @@ public final class Long private constructor() : Number(), Comparable { /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Long = - this / other.toLong() + this / other.toLong() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Long = - this / other.toLong() + this / other.toLong() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Long = - this / other.toLong() + this / other.toLong() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1550,12 +1544,12 @@ public final class Long private constructor() : Number(), Comparable { /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1565,7 +1559,7 @@ public final class Long private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Long = - this % other.toLong() + this % other.toLong() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1575,7 +1569,7 @@ public final class Long private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Long = - this % other.toLong() + this % other.toLong() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1585,7 +1579,7 @@ public final class Long private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Long = - this % other.toLong() + this % other.toLong() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1605,7 +1599,7 @@ public final class Long private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1615,7 +1609,7 @@ public final class Long private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -1636,7 +1630,7 @@ public final class Long private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Long = - this + this /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1802,7 +1796,7 @@ public final class Long private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toLong(): Long = - this + this /** * Converts this [Long] value to [Float]. @@ -1826,20 +1820,18 @@ public final class Long private constructor() : Number(), Comparable { @TypedIntrinsic(IntrinsicType.SIGNED_TO_FLOAT) external public override fun toDouble(): Double - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Long && kotlin.native.internal.areEqualByValue(this, other) - @kotlin.internal.IntrinsicConstEvaluation @GCUnsafeCall("Kotlin_Long_toString") external public override fun toString(): String + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Long && kotlin.native.internal.areEqualByValue(this, other) + @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Long): Boolean = kotlin.native.internal.areEqualByValue(this, other) - public override fun hashCode(): Int { - return ((this ushr 32) xor this).toInt() - } + public override fun hashCode(): Int = ((this ushr 32) xor this).toInt() } /** Represents a single-precision 32-bit IEEE 754 floating point number. */ @@ -1893,7 +1885,7 @@ public final class Float private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Byte): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1902,7 +1894,7 @@ public final class Float private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Short): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1911,7 +1903,7 @@ public final class Float private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Int): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1920,7 +1912,7 @@ public final class Float private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Long): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1936,7 +1928,7 @@ public final class Float private constructor() : Number(), Comparable { val thisBits = this.toBits() val otherBits = other.toBits() - // Canonical NaN bits representation higher than any other bit represent value + // Canonical NaN bit representation is higher than any other value's bit representation return thisBits.compareTo(otherBits) } @@ -1947,27 +1939,27 @@ public final class Float private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Double): Int = - - other.compareTo(this) + -other.compareTo(this) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -1977,27 +1969,27 @@ public final class Float private constructor() : Number(), Comparable { /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2007,27 +1999,27 @@ public final class Float private constructor() : Number(), Comparable { /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2037,27 +2029,27 @@ public final class Float private constructor() : Number(), Comparable { /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2067,7 +2059,7 @@ public final class Float private constructor() : Number(), Comparable { /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2077,7 +2069,7 @@ public final class Float private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2087,7 +2079,7 @@ public final class Float private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2097,7 +2089,7 @@ public final class Float private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2107,7 +2099,7 @@ public final class Float private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2127,7 +2119,7 @@ public final class Float private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -2210,7 +2202,7 @@ public final class Float private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toFloat(): Float = - this + this /** * Converts this [Float] value to [Double]. @@ -2221,10 +2213,6 @@ public final class Float private constructor() : Number(), Comparable { @TypedIntrinsic(IntrinsicType.FLOAT_EXTEND) external public override fun toDouble(): Double - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Float && this.equals(other) - /** * Returns the string representation of this [Float] value. * @@ -2236,6 +2224,10 @@ public final class Float private constructor() : Number(), Comparable { @kotlin.internal.IntrinsicConstEvaluation public override fun toString(): String = NumberConverter.convert(this) + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Float && this.equals(other) + @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Float): Boolean = toBits() == other.toBits() @@ -2297,7 +2289,7 @@ public final class Double private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Byte): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2306,7 +2298,7 @@ public final class Double private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Short): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2315,7 +2307,7 @@ public final class Double private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Int): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2324,7 +2316,7 @@ public final class Double private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Long): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2333,7 +2325,7 @@ public final class Double private constructor() : Number(), Comparable { */ @kotlin.internal.IntrinsicConstEvaluation public operator fun compareTo(other: Float): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2349,34 +2341,34 @@ public final class Double private constructor() : Number(), Comparable { val thisBits = this.toBits() val otherBits = other.toBits() - // Canonical NaN bits representation higher than any other bit represent value + // Canonical NaN bit representation is higher than any other value's bit representation return thisBits.compareTo(otherBits) } /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2386,27 +2378,27 @@ public final class Double private constructor() : Number(), Comparable { /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2416,27 +2408,27 @@ public final class Double private constructor() : Number(), Comparable { /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2446,27 +2438,27 @@ public final class Double private constructor() : Number(), Comparable { /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -2481,7 +2473,7 @@ public final class Double private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2491,7 +2483,7 @@ public final class Double private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2501,7 +2493,7 @@ public final class Double private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2511,7 +2503,7 @@ public final class Double private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2521,7 +2513,7 @@ public final class Double private constructor() : Number(), Comparable { @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2625,11 +2617,7 @@ public final class Double private constructor() : Number(), Comparable { /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toDouble(): Double = - this - - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Double && this.equals(other) + this /** * Returns the string representation of this [Double] value. @@ -2642,6 +2630,10 @@ public final class Double private constructor() : Number(), Comparable { @kotlin.internal.IntrinsicConstEvaluation public override fun toString(): String = NumberConverter.convert(this) + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Double && this.equals(other) + @kotlin.internal.IntrinsicConstEvaluation public fun equals(other: Double): Boolean = toBits() == other.toBits() diff --git a/libraries/stdlib/js-ir/builtins/Primitives.kt b/libraries/stdlib/js-ir/builtins/Primitives.kt index e039c4b3485..f347fa198bc 100644 --- a/libraries/stdlib/js-ir/builtins/Primitives.kt +++ b/libraries/stdlib/js-ir/builtins/Primitives.kt @@ -274,7 +274,7 @@ public class Byte private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Byte): IntRange + public operator fun rangeUntil(other: Byte): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -283,7 +283,7 @@ public class Byte private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Short): IntRange + public operator fun rangeUntil(other: Short): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -292,7 +292,7 @@ public class Byte private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Int): IntRange + public operator fun rangeUntil(other: Int): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -301,7 +301,7 @@ public class Byte private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Long): LongRange + public operator fun rangeUntil(other: Long): LongRange = this until other /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation @@ -370,10 +370,10 @@ public class Byte private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean public override fun hashCode(): Int } @@ -643,7 +643,7 @@ public class Short private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Byte): IntRange + public operator fun rangeUntil(other: Byte): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -652,7 +652,7 @@ public class Short private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Short): IntRange + public operator fun rangeUntil(other: Short): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -661,7 +661,7 @@ public class Short private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Int): IntRange + public operator fun rangeUntil(other: Int): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -670,7 +670,7 @@ public class Short private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Long): LongRange + public operator fun rangeUntil(other: Long): LongRange = this until other /** * Converts this [Short] value to [Byte]. @@ -737,10 +737,10 @@ public class Short private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean public override fun hashCode(): Int } @@ -1010,7 +1010,7 @@ public class Int private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Byte): IntRange + public operator fun rangeUntil(other: Byte): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -1019,7 +1019,7 @@ public class Int private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Short): IntRange + public operator fun rangeUntil(other: Short): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -1028,7 +1028,7 @@ public class Int private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Int): IntRange + public operator fun rangeUntil(other: Int): IntRange = this until other /** * Creates a range from this value up to but excluding the specified [other] value. @@ -1037,7 +1037,7 @@ public class Int private constructor() : Number(), Comparable { */ @SinceKotlin("1.7") @ExperimentalStdlibApi - public operator fun rangeUntil(other: Long): LongRange + public operator fun rangeUntil(other: Long): LongRange = this until other /** * Shifts this value left by the [bitCount] number of bits. @@ -1150,10 +1150,10 @@ public class Int private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean public override fun hashCode(): Int } @@ -1485,10 +1485,10 @@ public class Float private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean public override fun hashCode(): Int } @@ -1822,10 +1822,10 @@ public class Double private constructor() : Number(), Comparable { public override fun toDouble(): Double @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean + public override fun toString(): String @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String + public override fun equals(other: Any?): Boolean public override fun hashCode(): Int } diff --git a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt index c294a9d31bb..574b55672a2 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt @@ -45,7 +45,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public override inline operator fun compareTo(other: Byte): Int = - wasm_i32_compareTo(this.toInt(), other.toInt()) + wasm_i32_compareTo(this.toInt(), other.toInt()) /** * Compares this value with the specified value for order. @@ -54,7 +54,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.toShort().compareTo(other) + this.toShort().compareTo(other) /** * Compares this value with the specified value for order. @@ -63,7 +63,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.toInt().compareTo(other) + this.toInt().compareTo(other) /** * Compares this value with the specified value for order. @@ -72,7 +72,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.toLong().compareTo(other) + this.toLong().compareTo(other) /** * Compares this value with the specified value for order. @@ -81,7 +81,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -90,127 +90,127 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Int = - this.toInt() + other + this.toInt() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Long = - this.toLong() + other + this.toLong() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Int = - this.toInt() - other + this.toInt() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Long = - this.toLong() - other + this.toLong() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Int = - this.toInt() * other + this.toInt() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Long = - this.toLong() * other + this.toLong() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Int = - this.toInt() / other + this.toInt() / other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Long = - this.toLong() / other + this.toLong() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -220,7 +220,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -230,7 +230,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -240,7 +240,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Int = - this.toInt() % other + this.toInt() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -250,7 +250,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Long = - this.toLong() % other + this.toLong() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -260,7 +260,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -270,7 +270,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -278,7 +278,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa * @sample samples.misc.Builtins.inc */ public inline operator fun inc(): Byte = - (this + 1).toByte() + (this + 1).toByte() /** * Returns this value decremented by one. @@ -286,17 +286,17 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa * @sample samples.misc.Builtins.dec */ public inline operator fun dec(): Byte = - (this - 1).toByte() + (this - 1).toByte() /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Int = - this.toInt() + this.toInt() /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryMinus(): Int = - -this.toInt() + -this.toInt() /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): IntRange { @@ -357,7 +357,7 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toByte(): Byte = - this + this /** * Converts this [Byte] value to [Char]. @@ -422,26 +422,24 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa public override fun toDouble(): Double = wasm_f64_convert_i32_s(this.toInt()) @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Byte && wasm_i32_eq(this.toInt(), other.toInt()) + public override fun toString(): String = + this.toInt().toString() @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String = - this.toInt().toString() + public override fun equals(other: Any?): Boolean = + other is Byte && wasm_i32_eq(this.toInt(), other.toInt()) @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_EQ) public fun equals(other: Byte): Boolean = - implementedAsIntrinsic + implementedAsIntrinsic - public override inline fun hashCode(): Int { - return this.toInt() - } + public override fun hashCode(): Int = this.toInt() @WasmNoOpCast @PublishedApi internal fun reinterpretAsInt(): Int = - implementedAsIntrinsic + implementedAsIntrinsic } /** Represents a 16-bit signed integer. */ @@ -478,7 +476,7 @@ public class Short private constructor(private val value: Short) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toShort()) + this.compareTo(other.toShort()) /** * Compares this value with the specified value for order. @@ -487,7 +485,7 @@ public class Short private constructor(private val value: Short) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public override inline operator fun compareTo(other: Short): Int = - this.toInt().compareTo(other.toInt()) + this.toInt().compareTo(other.toInt()) /** * Compares this value with the specified value for order. @@ -496,7 +494,7 @@ public class Short private constructor(private val value: Short) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.toInt().compareTo(other) + this.toInt().compareTo(other) /** * Compares this value with the specified value for order. @@ -505,7 +503,7 @@ public class Short private constructor(private val value: Short) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.toLong().compareTo(other) + this.toLong().compareTo(other) /** * Compares this value with the specified value for order. @@ -514,7 +512,7 @@ public class Short private constructor(private val value: Short) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -523,127 +521,127 @@ public class Short private constructor(private val value: Short) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Int = - this.toInt() + other.toInt() + this.toInt() + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Int = - this.toInt() + other + this.toInt() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Long = - this.toLong() + other + this.toLong() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Int = - this.toInt() - other.toInt() + this.toInt() - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Int = - this.toInt() - other + this.toInt() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Long = - this.toLong() - other + this.toLong() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Int = - this.toInt() * other.toInt() + this.toInt() * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Int = - this.toInt() * other + this.toInt() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Long = - this.toLong() * other + this.toLong() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Int = - this.toInt() / other.toInt() + this.toInt() / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Int = - this.toInt() / other + this.toInt() / other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Long = - this.toLong() / other + this.toLong() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -653,7 +651,7 @@ public class Short private constructor(private val value: Short) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -663,7 +661,7 @@ public class Short private constructor(private val value: Short) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Int = - this.toInt() % other.toInt() + this.toInt() % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -673,7 +671,7 @@ public class Short private constructor(private val value: Short) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Int = - this.toInt() % other + this.toInt() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -683,7 +681,7 @@ public class Short private constructor(private val value: Short) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Long = - this.toLong() % other + this.toLong() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -693,7 +691,7 @@ public class Short private constructor(private val value: Short) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -703,7 +701,7 @@ public class Short private constructor(private val value: Short) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -711,7 +709,7 @@ public class Short private constructor(private val value: Short) : Number(), Com * @sample samples.misc.Builtins.inc */ public inline operator fun inc(): Short = - (this + 1).toShort() + (this + 1).toShort() /** * Returns this value decremented by one. @@ -719,17 +717,17 @@ public class Short private constructor(private val value: Short) : Number(), Com * @sample samples.misc.Builtins.dec */ public inline operator fun dec(): Short = - (this - 1).toShort() + (this - 1).toShort() /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Int = - this.toInt() + this.toInt() /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryMinus(): Int = - -this.toInt() + -this.toInt() /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): IntRange { @@ -812,7 +810,7 @@ public class Short private constructor(private val value: Short) : Number(), Com /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toShort(): Short = - this + this /** * Converts this [Short] value to [Int]. @@ -853,26 +851,24 @@ public class Short private constructor(private val value: Short) : Number(), Com public override fun toDouble(): Double = wasm_f64_convert_i32_s(this.toInt()) @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Short && wasm_i32_eq(this.toInt(), other.toInt()) + public override fun toString(): String = + this.toInt().toString() @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String = - this.toInt().toString() + public override fun equals(other: Any?): Boolean = + other is Short && wasm_i32_eq(this.toInt(), other.toInt()) @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_EQ) public fun equals(other: Short): Boolean = - implementedAsIntrinsic + implementedAsIntrinsic - public override inline fun hashCode(): Int { - return this.toInt() - } + public override fun hashCode(): Int = this.toInt() @WasmNoOpCast @PublishedApi internal fun reinterpretAsInt(): Int = - implementedAsIntrinsic + implementedAsIntrinsic } /** Represents a 32-bit signed integer. */ @@ -909,7 +905,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toInt()) + this.compareTo(other.toInt()) /** * Compares this value with the specified value for order. @@ -918,7 +914,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.compareTo(other.toInt()) + this.compareTo(other.toInt()) /** * Compares this value with the specified value for order. @@ -927,7 +923,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @kotlin.internal.IntrinsicConstEvaluation public override inline operator fun compareTo(other: Int): Int = - wasm_i32_compareTo(this, other) + wasm_i32_compareTo(this, other) /** * Compares this value with the specified value for order. @@ -936,7 +932,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.toLong().compareTo(other) + this.toLong().compareTo(other) /** * Compares this value with the specified value for order. @@ -945,7 +941,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -954,130 +950,130 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Int = - this + other.toInt() + this + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Int = - this + other.toInt() + this + other.toInt() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_ADD) public operator fun plus(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Long = - this.toLong() + other + this.toLong() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Int = - this - other.toInt() + this - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Int = - this - other.toInt() + this - other.toInt() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_SUB) public operator fun minus(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Long = - this.toLong() - other + this.toLong() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Int = - this * other.toInt() + this * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Int = - this * other.toInt() + this * other.toInt() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_MUL) public operator fun times(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Long = - this.toLong() * other + this.toLong() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Int = - this / other.toInt() + this / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Int = - this / other.toInt() + this / other.toInt() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public operator fun div(other: Int): Int = - if (this == Int.MIN_VALUE && other == -1) Int.MIN_VALUE else wasm_i32_div_s(this, other) + if (this == Int.MIN_VALUE && other == -1) Int.MIN_VALUE else wasm_i32_div_s(this, other) /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Long = - this.toLong() / other + this.toLong() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1087,7 +1083,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Int = - this % other.toInt() + this % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1097,7 +1093,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Int = - this % other.toInt() + this % other.toInt() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1108,7 +1104,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_REM_S) public operator fun rem(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1118,7 +1114,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Long = - this.toLong() % other + this.toLong() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1128,7 +1124,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1138,7 +1134,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -1146,7 +1142,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara * @sample samples.misc.Builtins.inc */ public inline operator fun inc(): Int = - this + 1 + this + 1 /** * Returns this value decremented by one. @@ -1155,17 +1151,17 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ // TODO: Fix test compiler/testData/codegen/box/functions/invoke/invoke.kt with inline dec public operator fun dec(): Int = - this - 1 + this - 1 /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Int = - this + this /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryMinus(): Int = - 0 - this + 0 - this /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): IntRange { @@ -1232,7 +1228,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_SHL) public infix fun shl(bitCount: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** * Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with copies of the sign bit. @@ -1243,7 +1239,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_SHR_S) public infix fun shr(bitCount: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** * Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with zeros. @@ -1254,30 +1250,30 @@ public class Int private constructor(private val value: Int) : Number(), Compara @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_SHR_U) public infix fun ushr(bitCount: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Performs a bitwise AND operation between the two values. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_AND) public infix fun and(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Performs a bitwise OR operation between the two values. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_OR) public infix fun or(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Performs a bitwise XOR operation between the two values. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_XOR) public infix fun xor(other: Int): Int = - implementedAsIntrinsic + implementedAsIntrinsic /** Inverts the bits in this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline fun inv(): Int = - this.xor(-1) + this.xor(-1) /** * Converts this [Int] value to [Byte]. @@ -1300,8 +1296,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara */ @Suppress("OVERRIDE_DEPRECATION") @kotlin.internal.IntrinsicConstEvaluation - public override fun toChar(): Char = - (this and 0xFFFF).reinterpretAsChar() + public override fun toChar(): Char = (this and 0xFFFF).reinterpretAsChar() /** * Converts this [Int] value to [Short]. @@ -1317,7 +1312,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toInt(): Int = - this + this /** * Converts this [Int] value to [Long]. @@ -1349,41 +1344,39 @@ public class Int private constructor(private val value: Int) : Number(), Compara public override fun toDouble(): Double = wasm_f64_convert_i32_s(this) @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Int && wasm_i32_eq(this, other) + public override fun toString(): String = + itoa32(this, 10) @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String = - itoa32(this, 10) + public override fun equals(other: Any?): Boolean = + other is Int && wasm_i32_eq(this, other) @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I32_EQ) public fun equals(other: Int): Boolean = - implementedAsIntrinsic + implementedAsIntrinsic - public override inline fun hashCode(): Int { - return this - } + public override fun hashCode(): Int = this @WasmNoOpCast @PublishedApi internal fun reinterpretAsBoolean(): Boolean = - implementedAsIntrinsic + implementedAsIntrinsic @WasmNoOpCast @PublishedApi internal fun reinterpretAsByte(): Byte = - implementedAsIntrinsic + implementedAsIntrinsic @WasmNoOpCast @PublishedApi internal fun reinterpretAsShort(): Short = - implementedAsIntrinsic + implementedAsIntrinsic @WasmNoOpCast @PublishedApi internal fun reinterpretAsChar(): Char = - implementedAsIntrinsic + implementedAsIntrinsic } /** Represents a 64-bit signed integer. */ @@ -1420,7 +1413,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toLong()) + this.compareTo(other.toLong()) /** * Compares this value with the specified value for order. @@ -1429,7 +1422,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.compareTo(other.toLong()) + this.compareTo(other.toLong()) /** * Compares this value with the specified value for order. @@ -1438,7 +1431,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.compareTo(other.toLong()) + this.compareTo(other.toLong()) /** * Compares this value with the specified value for order. @@ -1447,7 +1440,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public override inline operator fun compareTo(other: Long): Int = - wasm_i64_compareTo(this, other) + wasm_i64_compareTo(this, other) /** * Compares this value with the specified value for order. @@ -1456,7 +1449,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.toFloat().compareTo(other) + this.toFloat().compareTo(other) /** * Compares this value with the specified value for order. @@ -1465,130 +1458,130 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - this.toDouble().compareTo(other) + this.toDouble().compareTo(other) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Long = - this + other.toLong() + this + other.toLong() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Long = - this + other.toLong() + this + other.toLong() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Long = - this + other.toLong() + this + other.toLong() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_ADD) public operator fun plus(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Float = - this.toFloat() + other + this.toFloat() + other /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Long = - this - other.toLong() + this - other.toLong() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Long = - this - other.toLong() + this - other.toLong() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Long = - this - other.toLong() + this - other.toLong() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_SUB) public operator fun minus(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Float = - this.toFloat() - other + this.toFloat() - other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Long = - this * other.toLong() + this * other.toLong() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Long = - this * other.toLong() + this * other.toLong() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Long = - this * other.toLong() + this * other.toLong() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_MUL) public operator fun times(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Float = - this.toFloat() * other + this.toFloat() * other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Long = - this / other.toLong() + this / other.toLong() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Long = - this / other.toLong() + this / other.toLong() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Long = - this / other.toLong() + this / other.toLong() /** Divides this value by the other value, truncating the result to an integer that is closer to zero. */ @kotlin.internal.IntrinsicConstEvaluation public operator fun div(other: Long): Long = - if (this == Long.MIN_VALUE && other == -1L) Long.MIN_VALUE else wasm_i64_div_s(this, other) + if (this == Long.MIN_VALUE && other == -1L) Long.MIN_VALUE else wasm_i64_div_s(this, other) /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Float = - this.toFloat() / other + this.toFloat() / other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1598,7 +1591,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Long = - this % other.toLong() + this % other.toLong() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1608,7 +1601,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Long = - this % other.toLong() + this % other.toLong() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1618,7 +1611,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Long = - this % other.toLong() + this % other.toLong() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1629,7 +1622,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_REM_S) public operator fun rem(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1639,7 +1632,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Float = - this.toFloat() % other + this.toFloat() % other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -1649,7 +1642,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -1657,7 +1650,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa * @sample samples.misc.Builtins.inc */ public inline operator fun inc(): Long = - this + 1L + this + 1L /** * Returns this value decremented by one. @@ -1665,17 +1658,17 @@ public class Long private constructor(private val value: Long) : Number(), Compa * @sample samples.misc.Builtins.dec */ public inline operator fun dec(): Long = - this - 1L + this - 1L /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Long = - this + this /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryMinus(): Long = - 0L - this + 0L - this /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Byte): LongRange { @@ -1741,7 +1734,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline infix fun shl(bitCount: Int): Long = - wasm_i64_shl(this, bitCount.toLong()) + wasm_i64_shl(this, bitCount.toLong()) /** * Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with copies of the sign bit. @@ -1751,7 +1744,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline infix fun shr(bitCount: Int): Long = - wasm_i64_shr_s(this, bitCount.toLong()) + wasm_i64_shr_s(this, bitCount.toLong()) /** * Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with zeros. @@ -1761,30 +1754,30 @@ public class Long private constructor(private val value: Long) : Number(), Compa */ @kotlin.internal.IntrinsicConstEvaluation public inline infix fun ushr(bitCount: Int): Long = - wasm_i64_shr_u(this, bitCount.toLong()) + wasm_i64_shr_u(this, bitCount.toLong()) /** Performs a bitwise AND operation between the two values. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_AND) public infix fun and(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** Performs a bitwise OR operation between the two values. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_OR) public infix fun or(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** Performs a bitwise XOR operation between the two values. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_XOR) public infix fun xor(other: Long): Long = - implementedAsIntrinsic + implementedAsIntrinsic /** Inverts the bits in this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline fun inv(): Long = - this.xor(-1L) + this.xor(-1L) /** * Converts this [Long] value to [Byte]. @@ -1808,8 +1801,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()")) @DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3") @kotlin.internal.IntrinsicConstEvaluation - public override inline fun toChar(): Char = - this.toInt().toChar() + public override inline fun toChar(): Char = this.toInt().toChar() /** * Converts this [Long] value to [Short]. @@ -1836,7 +1828,7 @@ public class Long private constructor(private val value: Long) : Number(), Compa /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toLong(): Long = - this + this /** * Converts this [Long] value to [Float]. @@ -1859,21 +1851,19 @@ public class Long private constructor(private val value: Long) : Number(), Compa public override fun toDouble(): Double = wasm_f64_convert_i64_s(this) @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Long && wasm_i64_eq(this, other) + public override fun toString(): String = + itoa64(this, 10) @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String = - itoa64(this, 10) + public override fun equals(other: Any?): Boolean = + other is Long && wasm_i64_eq(this, other) @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.I64_EQ) public fun equals(other: Long): Boolean = - implementedAsIntrinsic + implementedAsIntrinsic - public override inline fun hashCode(): Int { - return ((this ushr 32) xor this).toInt() - } + public override fun hashCode(): Int = ((this ushr 32) xor this).toInt() } /** Represents a single-precision 32-bit IEEE 754 floating point number. */ @@ -1928,7 +1918,7 @@ public class Float private constructor(private val value: Float) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1937,7 +1927,7 @@ public class Float private constructor(private val value: Float) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1946,7 +1936,7 @@ public class Float private constructor(private val value: Float) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1955,7 +1945,7 @@ public class Float private constructor(private val value: Float) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.compareTo(other.toFloat()) + this.compareTo(other.toFloat()) /** * Compares this value with the specified value for order. @@ -1971,7 +1961,7 @@ public class Float private constructor(private val value: Float) : Number(), Com val thisBits = this.toBits() val otherBits = other.toBits() - // Canonical NaN bits representation higher than any other bit represent value + // Canonical NaN bit representation is higher than any other value's bit representation return thisBits.compareTo(otherBits) } @@ -1982,131 +1972,131 @@ public class Float private constructor(private val value: Float) : Number(), Com */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Double): Int = - - other.compareTo(this) + -other.compareTo(this) /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Float = - this + other.toFloat() + this + other.toFloat() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F32_ADD) public operator fun plus(other: Float): Float = - implementedAsIntrinsic + implementedAsIntrinsic /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Double): Double = - this.toDouble() + other + this.toDouble() + other /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Float = - this - other.toFloat() + this - other.toFloat() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F32_SUB) public operator fun minus(other: Float): Float = - implementedAsIntrinsic + implementedAsIntrinsic /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Double): Double = - this.toDouble() - other + this.toDouble() - other /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Float = - this * other.toFloat() + this * other.toFloat() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F32_MUL) public operator fun times(other: Float): Float = - implementedAsIntrinsic + implementedAsIntrinsic /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Double): Double = - this.toDouble() * other + this.toDouble() * other /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Float = - this / other.toFloat() + this / other.toFloat() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F32_DIV) public operator fun div(other: Float): Float = - implementedAsIntrinsic + implementedAsIntrinsic /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Double): Double = - this.toDouble() / other + this.toDouble() / other /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2116,7 +2106,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2126,7 +2116,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2136,7 +2126,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2146,7 +2136,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Float = - this % other.toFloat() + this % other.toFloat() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2156,7 +2146,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public operator fun rem(other: Float): Float = - this - (wasm_f32_nearest(this / other) * other) + this - (wasm_f32_nearest(this / other) * other) /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2166,7 +2156,7 @@ public class Float private constructor(private val value: Float) : Number(), Com @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Double): Double = - this.toDouble() % other + this.toDouble() % other /** * Returns this value incremented by one. @@ -2174,7 +2164,7 @@ public class Float private constructor(private val value: Float) : Number(), Com * @sample samples.misc.Builtins.inc */ public inline operator fun inc(): Float = - this + 1.0f + this + 1.0f /** * Returns this value decremented by one. @@ -2182,18 +2172,18 @@ public class Float private constructor(private val value: Float) : Number(), Com * @sample samples.misc.Builtins.dec */ public inline operator fun dec(): Float = - this - 1.0f + this - 1.0f /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Float = - this + this /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F32_NEG) public operator fun unaryMinus(): Float = - implementedAsIntrinsic + implementedAsIntrinsic /** * Converts this [Float] value to [Byte]. @@ -2248,7 +2238,7 @@ public class Float private constructor(private val value: Float) : Number(), Com /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toFloat(): Float = - this + this /** * Converts this [Float] value to [Double]. @@ -2259,17 +2249,17 @@ public class Float private constructor(private val value: Float) : Number(), Com public override fun toDouble(): Double = wasm_f64_promote_f32(this) @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Float && this.equals(other) + public override fun toString(): String = + dtoa(this.toDouble()) @kotlin.internal.IntrinsicConstEvaluation - public override fun toString(): String = - dtoa(this.toDouble()) + public override fun equals(other: Any?): Boolean = + other is Float && this.equals(other) @kotlin.internal.IntrinsicConstEvaluation public inline fun equals(other: Float): Boolean = toBits() == other.toBits() - public override inline fun hashCode(): Int = toBits() + public override fun hashCode(): Int = toBits() } /** Represents a double-precision 64-bit IEEE 754 floating point number. */ @@ -2324,7 +2314,7 @@ public class Double private constructor(private val value: Double) : Number(), C */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Byte): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2333,7 +2323,7 @@ public class Double private constructor(private val value: Double) : Number(), C */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Short): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2342,7 +2332,7 @@ public class Double private constructor(private val value: Double) : Number(), C */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Int): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2351,7 +2341,7 @@ public class Double private constructor(private val value: Double) : Number(), C */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Long): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2360,7 +2350,7 @@ public class Double private constructor(private val value: Double) : Number(), C */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun compareTo(other: Float): Int = - this.compareTo(other.toDouble()) + this.compareTo(other.toDouble()) /** * Compares this value with the specified value for order. @@ -2376,133 +2366,133 @@ public class Double private constructor(private val value: Double) : Number(), C val thisBits = this.toBits() val otherBits = other.toBits() - // Canonical NaN bits representation higher than any other bit represent value + // Canonical NaN bit representation is higher than any other value's bit representation return thisBits.compareTo(otherBits) } /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Byte): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Short): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Int): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Long): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun plus(other: Float): Double = - this + other.toDouble() + this + other.toDouble() /** Adds the other value to this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F64_ADD) public operator fun plus(other: Double): Double = - implementedAsIntrinsic + implementedAsIntrinsic /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Byte): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Short): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Int): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Long): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun minus(other: Float): Double = - this - other.toDouble() + this - other.toDouble() /** Subtracts the other value from this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F64_SUB) public operator fun minus(other: Double): Double = - implementedAsIntrinsic + implementedAsIntrinsic /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Byte): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Short): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Int): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Long): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun times(other: Float): Double = - this * other.toDouble() + this * other.toDouble() /** Multiplies this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F64_MUL) public operator fun times(other: Double): Double = - implementedAsIntrinsic + implementedAsIntrinsic /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Byte): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Short): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Int): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Long): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun div(other: Float): Double = - this / other.toDouble() + this / other.toDouble() /** Divides this value by the other value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F64_DIV) public operator fun div(other: Double): Double = - implementedAsIntrinsic + implementedAsIntrinsic /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2512,7 +2502,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Byte): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2522,7 +2512,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Short): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2532,7 +2522,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Int): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2542,7 +2532,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Long): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2552,7 +2542,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public inline operator fun rem(other: Float): Double = - this % other.toDouble() + this % other.toDouble() /** * Calculates the remainder of truncating division of this value (dividend) by the other value (divisor). @@ -2562,7 +2552,7 @@ public class Double private constructor(private val value: Double) : Number(), C @SinceKotlin("1.1") @kotlin.internal.IntrinsicConstEvaluation public operator fun rem(other: Double): Double = - this - (wasm_f64_nearest(this / other) * other) + this - (wasm_f64_nearest(this / other) * other) /** * Returns this value incremented by one. @@ -2570,7 +2560,7 @@ public class Double private constructor(private val value: Double) : Number(), C * @sample samples.misc.Builtins.inc */ public inline operator fun inc(): Double = - this + 1.0 + this + 1.0 /** * Returns this value decremented by one. @@ -2578,18 +2568,18 @@ public class Double private constructor(private val value: Double) : Number(), C * @sample samples.misc.Builtins.dec */ public inline operator fun dec(): Double = - this - 1.0 + this - 1.0 /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public inline operator fun unaryPlus(): Double = - this + this /** Returns the negative of this value. */ @kotlin.internal.IntrinsicConstEvaluation @WasmOp(WasmOp.F64_NEG) public operator fun unaryMinus(): Double = - implementedAsIntrinsic + implementedAsIntrinsic /** * Converts this [Double] value to [Byte]. @@ -2654,18 +2644,18 @@ public class Double private constructor(private val value: Double) : Number(), C /** Returns this value. */ @kotlin.internal.IntrinsicConstEvaluation public override inline fun toDouble(): Double = - this - - @kotlin.internal.IntrinsicConstEvaluation - public override fun equals(other: Any?): Boolean = - other is Double && this.toBits() == other.toBits() + this @kotlin.internal.IntrinsicConstEvaluation public override fun toString(): String = - dtoa(this) + dtoa(this) + + @kotlin.internal.IntrinsicConstEvaluation + public override fun equals(other: Any?): Boolean = + other is Double && this.toBits() == other.toBits() @kotlin.internal.IntrinsicConstEvaluation public inline fun equals(other: Double): Boolean = toBits() == other.toBits() - public override inline fun hashCode(): Int = toBits().hashCode() + public override fun hashCode(): Int = toBits().hashCode() }