Make most of unsigned operations inline only

This commit is contained in:
Ilya Gorbunov
2018-09-17 20:24:30 +03:00
parent d793221a7b
commit 9e0708e85a
7 changed files with 387 additions and 373 deletions
+23 -12
View File
@@ -44,7 +44,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
out.println("@Suppress(\"NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS\")")
out.println("@SinceKotlin(\"1.3\")")
out.println("@ExperimentalUnsignedTypes")
out.println("public inline class $className internal constructor(private val data: $storageType) : Comparable<$className> {")
out.println("public inline class $className @PublishedApi internal constructor(@PublishedApi internal val data: $storageType) : Comparable<$className> {")
out.println()
out.println(""" companion object {
/**
@@ -100,8 +100,10 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
* 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.
*/""")
if (otherType != type)
out.println(" @kotlin.internal.InlineOnly")
out.print(" public ")
if (otherType == type) out.print("override ")
if (otherType == type) out.print("override ") else out.print("inline ")
out.print("operator fun compareTo(other: ${otherType.capitalized}): Int = ")
if (otherType == type && maxByDomainCapacity(type, UnsignedType.UINT) == type) {
out.println("${className.toLowerCase()}Compare(this.data, other.data)")
@@ -126,7 +128,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
val returnType = getOperatorReturnType(type, otherType)
out.println(" /** $doc */")
out.print(" public operator fun $name(other: ${otherType.capitalized}): ${returnType.capitalized} = ")
out.println(" @kotlin.internal.InlineOnly")
out.print(" public inline operator fun $name(other: ${otherType.capitalized}): ${returnType.capitalized} = ")
if (type == otherType && type == returnType) {
when (name) {
"plus", "minus", "times" -> out.println("$className(this.data.$name(other.data))")
@@ -146,7 +149,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
for ((name, doc) in GeneratePrimitives.unaryOperators) {
if (name in listOf("unaryPlus", "unaryMinus")) continue
out.println(" /** $doc */")
out.println(" public operator fun $name(): $className = $className(data.$name())")
out.println(" @kotlin.internal.InlineOnly")
out.println(" public inline operator fun $name(): $className = $className(data.$name())")
}
out.println()
@@ -157,7 +161,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
val rangeType = rangeElementType.capitalized + "Range"
fun convert(name: String) = if (rangeElementType == type) name else "$name.to${rangeElementType.capitalized}()"
out.println(" /** Creates a range from this value to the specified [other] value. */")
out.println(" public operator fun rangeTo(other: $className): $rangeType = $rangeType(${convert("this")}, ${convert("other")})")
out.println(" @kotlin.internal.InlineOnly")
out.println(" public inline operator fun rangeTo(other: $className): $rangeType = $rangeType(${convert("this")}, ${convert("other")})")
out.println()
}
@@ -167,7 +172,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
fun generateShiftOperator(name: String, implementation: String = name) {
val doc = GeneratePrimitives.shiftOperators[implementation]!!
out.println(" /** $doc */")
out.println(" public infix fun $name(bitCount: Int): $className = $className(data $implementation bitCount)")
out.println(" @kotlin.internal.InlineOnly")
out.println(" public inline infix fun $name(bitCount: Int): $className = $className(data $implementation bitCount)")
}
generateShiftOperator("shl")
@@ -177,17 +183,20 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
private fun generateBitwiseOperators() {
for ((name, doc) in GeneratePrimitives.bitwiseOperators) {
out.println(" /** $doc */")
out.println(" public infix fun $name(other: $className): $className = $className(this.data $name other.data)")
out.println(" @kotlin.internal.InlineOnly")
out.println(" public inline infix fun $name(other: $className): $className = $className(this.data $name other.data)")
}
out.println(" /** Inverts the bits in this value. */")
out.println(" public fun inv(): $className = $className(data.inv())")
out.println(" @kotlin.internal.InlineOnly")
out.println(" public inline fun inv(): $className = $className(data.inv())")
out.println()
}
private fun generateMemberConversions() {
for (otherType in UnsignedType.values()) {
val signed = otherType.asSigned.capitalized
out.print(" public fun to$signed(): $signed = ")
out.println(" @kotlin.internal.InlineOnly")
out.print(" public inline fun to$signed(): $signed = ")
out.println(when {
otherType < type -> "data.to$signed()"
otherType == type -> "data"
@@ -198,9 +207,10 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
for (otherType in UnsignedType.values()) {
val name = otherType.capitalized
out.print(" public fun to$name(): $name = ")
out.println(" @kotlin.internal.InlineOnly")
out.print(" public inline fun to$name(): $name = ")
out.println(when {
otherType > type -> "data.to${otherType.capitalized}() and ${type.mask}u"
otherType > type -> "${otherType.capitalized}(data.to${otherType.asSigned.capitalized}() and ${type.mask})"
otherType == type -> "this"
else -> "data.to${otherType.capitalized}()"
})
@@ -214,7 +224,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
val thisSigned = type.asSigned.capitalized
out.println("@SinceKotlin(\"1.3\")")
out.println("@ExperimentalUnsignedTypes")
out.print("public fun $otherSigned.to$className(): $className = ")
out.println("@kotlin.internal.InlineOnly")
out.print("public inline fun $otherSigned.to$className(): $className = ")
out.println(when {
otherType == type -> "$className(this)"
else -> "$className(this.to$thisSigned())"
+85 -43
View File
@@ -12,7 +12,7 @@ import kotlin.experimental.*
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline class UByte internal constructor(private val data: Byte) : Comparable<UByte> {
public inline class UByte @PublishedApi internal constructor(@PublishedApi internal val data: Byte) : Comparable<UByte> {
companion object {
/**
@@ -48,93 +48,131 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
* 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.
*/
public operator fun compareTo(other: UShort): Int = this.toUInt().compareTo(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UShort): Int = this.toUInt().compareTo(other.toUInt())
/**
* 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.
*/
public operator fun compareTo(other: UInt): Int = this.toUInt().compareTo(other)
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UInt): Int = this.toUInt().compareTo(other)
/**
* 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.
*/
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
/** Adds the other value to this value. */
public operator fun plus(other: UByte): UInt = this.toUInt().plus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UByte): UInt = this.toUInt().plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UShort): UInt = this.toUInt().plus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UShort): UInt = this.toUInt().plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UInt): UInt = this.toUInt().plus(other)
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UInt): UInt = this.toUInt().plus(other)
/** Adds the other value to this value. */
public operator fun plus(other: ULong): ULong = this.toULong().plus(other)
@kotlin.internal.InlineOnly
public inline operator fun plus(other: ULong): ULong = this.toULong().plus(other)
/** Subtracts the other value from this value. */
public operator fun minus(other: UByte): UInt = this.toUInt().minus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UByte): UInt = this.toUInt().minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UShort): UInt = this.toUInt().minus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UShort): UInt = this.toUInt().minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UInt): UInt = this.toUInt().minus(other)
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UInt): UInt = this.toUInt().minus(other)
/** Subtracts the other value from this value. */
public operator fun minus(other: ULong): ULong = this.toULong().minus(other)
@kotlin.internal.InlineOnly
public inline operator fun minus(other: ULong): ULong = this.toULong().minus(other)
/** Multiplies this value by the other value. */
public operator fun times(other: UByte): UInt = this.toUInt().times(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UByte): UInt = this.toUInt().times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UShort): UInt = this.toUInt().times(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UShort): UInt = this.toUInt().times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UInt): UInt = this.toUInt().times(other)
@kotlin.internal.InlineOnly
public inline operator fun times(other: UInt): UInt = this.toUInt().times(other)
/** Multiplies this value by the other value. */
public operator fun times(other: ULong): ULong = this.toULong().times(other)
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = this.toULong().times(other)
/** Divides this value by the other value. */
public operator fun div(other: UByte): UInt = this.toUInt().div(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): UInt = this.toUInt().div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UShort): UInt = this.toUInt().div(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): UInt = this.toUInt().div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UInt): UInt = this.toUInt().div(other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): UInt = this.toUInt().div(other)
/** Divides this value by the other value. */
public operator fun div(other: ULong): ULong = this.toULong().div(other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = this.toULong().div(other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UByte): UInt = this.toUInt().rem(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): UInt = this.toUInt().rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UShort): UInt = this.toUInt().rem(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): UInt = this.toUInt().rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UInt): UInt = this.toUInt().rem(other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): UInt = this.toUInt().rem(other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: ULong): ULong = this.toULong().rem(other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** Increments this value. */
public operator fun inc(): UByte = UByte(data.inc())
@kotlin.internal.InlineOnly
public inline operator fun inc(): UByte = UByte(data.inc())
/** Decrements this value. */
public operator fun dec(): UByte = UByte(data.dec())
@kotlin.internal.InlineOnly
public inline operator fun dec(): UByte = UByte(data.dec())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: UByte): UIntRange = UIntRange(this.toUInt(), other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: UByte): UIntRange = UIntRange(this.toUInt(), other.toUInt())
/** Performs a bitwise AND operation between the two values. */
public infix fun and(other: UByte): UByte = UByte(this.data and other.data)
@kotlin.internal.InlineOnly
public inline infix fun and(other: UByte): UByte = UByte(this.data and other.data)
/** Performs a bitwise OR operation between the two values. */
public infix fun or(other: UByte): UByte = UByte(this.data or other.data)
@kotlin.internal.InlineOnly
public inline infix fun or(other: UByte): UByte = UByte(this.data or other.data)
/** Performs a bitwise XOR operation between the two values. */
public infix fun xor(other: UByte): UByte = UByte(this.data xor other.data)
@kotlin.internal.InlineOnly
public inline infix fun xor(other: UByte): UByte = UByte(this.data xor other.data)
/** Inverts the bits in this value. */
public fun inv(): UByte = UByte(data.inv())
@kotlin.internal.InlineOnly
public inline fun inv(): UByte = UByte(data.inv())
public fun toByte(): Byte = data
public fun toShort(): Short = data.toShort() and 0xFF
public fun toInt(): Int = data.toInt() and 0xFF
public fun toLong(): Long = data.toLong() and 0xFF
@kotlin.internal.InlineOnly
public inline fun toByte(): Byte = data
@kotlin.internal.InlineOnly
public inline fun toShort(): Short = data.toShort() and 0xFF
@kotlin.internal.InlineOnly
public inline fun toInt(): Int = data.toInt() and 0xFF
@kotlin.internal.InlineOnly
public inline fun toLong(): Long = data.toLong() and 0xFF
public fun toUByte(): UByte = this
public fun toUShort(): UShort = data.toUShort() and 0xFFu
public fun toUInt(): UInt = data.toUInt() and 0xFFu
public fun toULong(): ULong = data.toULong() and 0xFFu
@kotlin.internal.InlineOnly
public inline fun toUByte(): UByte = this
@kotlin.internal.InlineOnly
public inline fun toUShort(): UShort = UShort(data.toShort() and 0xFF)
@kotlin.internal.InlineOnly
public inline fun toUInt(): UInt = UInt(data.toInt() and 0xFF)
@kotlin.internal.InlineOnly
public inline fun toULong(): ULong = ULong(data.toLong() and 0xFF)
public override fun toString(): String = toInt().toString()
@@ -142,13 +180,17 @@ public inline class UByte internal constructor(private val data: Byte) : Compara
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Byte.toUByte(): UByte = UByte(this)
@kotlin.internal.InlineOnly
public inline fun Byte.toUByte(): UByte = UByte(this)
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Short.toUByte(): UByte = UByte(this.toByte())
@kotlin.internal.InlineOnly
public inline fun Short.toUByte(): UByte = UByte(this.toByte())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Int.toUByte(): UByte = UByte(this.toByte())
@kotlin.internal.InlineOnly
public inline fun Int.toUByte(): UByte = UByte(this.toByte())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Long.toUByte(): UByte = UByte(this.toByte())
@kotlin.internal.InlineOnly
public inline fun Long.toUByte(): UByte = UByte(this.toByte())
+89 -45
View File
@@ -12,7 +12,7 @@ import kotlin.experimental.*
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline class UInt internal constructor(private val data: Int) : Comparable<UInt> {
public inline class UInt @PublishedApi internal constructor(@PublishedApi internal val data: Int) : Comparable<UInt> {
companion object {
/**
@@ -41,14 +41,16 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
* 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.
*/
public operator fun compareTo(other: UByte): Int = this.compareTo(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UByte): Int = this.compareTo(other.toUInt())
/**
* 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.
*/
public operator fun compareTo(other: UShort): Int = this.compareTo(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UShort): Int = this.compareTo(other.toUInt())
/**
* Compares this value with the specified value for order.
@@ -62,83 +64,121 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
* 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.
*/
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
/** Adds the other value to this value. */
public operator fun plus(other: UByte): UInt = this.plus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UByte): UInt = this.plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UShort): UInt = this.plus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UShort): UInt = this.plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UInt): UInt = UInt(this.data.plus(other.data))
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UInt): UInt = UInt(this.data.plus(other.data))
/** Adds the other value to this value. */
public operator fun plus(other: ULong): ULong = this.toULong().plus(other)
@kotlin.internal.InlineOnly
public inline operator fun plus(other: ULong): ULong = this.toULong().plus(other)
/** Subtracts the other value from this value. */
public operator fun minus(other: UByte): UInt = this.minus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UByte): UInt = this.minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UShort): UInt = this.minus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UShort): UInt = this.minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UInt): UInt = UInt(this.data.minus(other.data))
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UInt): UInt = UInt(this.data.minus(other.data))
/** Subtracts the other value from this value. */
public operator fun minus(other: ULong): ULong = this.toULong().minus(other)
@kotlin.internal.InlineOnly
public inline operator fun minus(other: ULong): ULong = this.toULong().minus(other)
/** Multiplies this value by the other value. */
public operator fun times(other: UByte): UInt = this.times(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UByte): UInt = this.times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UShort): UInt = this.times(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UShort): UInt = this.times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UInt): UInt = UInt(this.data.times(other.data))
@kotlin.internal.InlineOnly
public inline operator fun times(other: UInt): UInt = UInt(this.data.times(other.data))
/** Multiplies this value by the other value. */
public operator fun times(other: ULong): ULong = this.toULong().times(other)
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = this.toULong().times(other)
/** Divides this value by the other value. */
public operator fun div(other: UByte): UInt = this.div(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): UInt = this.div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UShort): UInt = this.div(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): UInt = this.div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UInt): UInt = uintDivide(this, other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): UInt = uintDivide(this, other)
/** Divides this value by the other value. */
public operator fun div(other: ULong): ULong = this.toULong().div(other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = this.toULong().div(other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UByte): UInt = this.rem(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): UInt = this.rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UShort): UInt = this.rem(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): UInt = this.rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UInt): UInt = uintRemainder(this, other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): UInt = uintRemainder(this, other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: ULong): ULong = this.toULong().rem(other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** Increments this value. */
public operator fun inc(): UInt = UInt(data.inc())
@kotlin.internal.InlineOnly
public inline operator fun inc(): UInt = UInt(data.inc())
/** Decrements this value. */
public operator fun dec(): UInt = UInt(data.dec())
@kotlin.internal.InlineOnly
public inline operator fun dec(): UInt = UInt(data.dec())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: UInt): UIntRange = UIntRange(this, other)
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: UInt): UIntRange = UIntRange(this, other)
/** Shifts this value left by the [bitCount] number of bits. */
public infix fun shl(bitCount: Int): UInt = UInt(data shl bitCount)
@kotlin.internal.InlineOnly
public inline infix fun shl(bitCount: Int): UInt = UInt(data shl bitCount)
/** Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with zeros. */
public infix fun shr(bitCount: Int): UInt = UInt(data ushr bitCount)
@kotlin.internal.InlineOnly
public inline infix fun shr(bitCount: Int): UInt = UInt(data ushr bitCount)
/** Performs a bitwise AND operation between the two values. */
public infix fun and(other: UInt): UInt = UInt(this.data and other.data)
@kotlin.internal.InlineOnly
public inline infix fun and(other: UInt): UInt = UInt(this.data and other.data)
/** Performs a bitwise OR operation between the two values. */
public infix fun or(other: UInt): UInt = UInt(this.data or other.data)
@kotlin.internal.InlineOnly
public inline infix fun or(other: UInt): UInt = UInt(this.data or other.data)
/** Performs a bitwise XOR operation between the two values. */
public infix fun xor(other: UInt): UInt = UInt(this.data xor other.data)
@kotlin.internal.InlineOnly
public inline infix fun xor(other: UInt): UInt = UInt(this.data xor other.data)
/** Inverts the bits in this value. */
public fun inv(): UInt = UInt(data.inv())
@kotlin.internal.InlineOnly
public inline fun inv(): UInt = UInt(data.inv())
public fun toByte(): Byte = data.toByte()
public fun toShort(): Short = data.toShort()
public fun toInt(): Int = data
public fun toLong(): Long = data.toLong() and 0xFFFF_FFFF
@kotlin.internal.InlineOnly
public inline fun toByte(): Byte = data.toByte()
@kotlin.internal.InlineOnly
public inline fun toShort(): Short = data.toShort()
@kotlin.internal.InlineOnly
public inline fun toInt(): Int = data
@kotlin.internal.InlineOnly
public inline fun toLong(): Long = data.toLong() and 0xFFFF_FFFF
public fun toUByte(): UByte = data.toUByte()
public fun toUShort(): UShort = data.toUShort()
public fun toUInt(): UInt = this
public fun toULong(): ULong = data.toULong() and 0xFFFF_FFFFu
@kotlin.internal.InlineOnly
public inline fun toUByte(): UByte = data.toUByte()
@kotlin.internal.InlineOnly
public inline fun toUShort(): UShort = data.toUShort()
@kotlin.internal.InlineOnly
public inline fun toUInt(): UInt = this
@kotlin.internal.InlineOnly
public inline fun toULong(): ULong = ULong(data.toLong() and 0xFFFF_FFFF)
public override fun toString(): String = toLong().toString()
@@ -146,13 +186,17 @@ public inline class UInt internal constructor(private val data: Int) : Comparabl
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Byte.toUInt(): UInt = UInt(this.toInt())
@kotlin.internal.InlineOnly
public inline fun Byte.toUInt(): UInt = UInt(this.toInt())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Short.toUInt(): UInt = UInt(this.toInt())
@kotlin.internal.InlineOnly
public inline fun Short.toUInt(): UInt = UInt(this.toInt())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Int.toUInt(): UInt = UInt(this)
@kotlin.internal.InlineOnly
public inline fun Int.toUInt(): UInt = UInt(this)
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Long.toUInt(): UInt = UInt(this.toInt())
@kotlin.internal.InlineOnly
public inline fun Long.toUInt(): UInt = UInt(this.toInt())
+89 -45
View File
@@ -12,7 +12,7 @@ import kotlin.experimental.*
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline class ULong internal constructor(private val data: Long) : Comparable<ULong> {
public inline class ULong @PublishedApi internal constructor(@PublishedApi internal val data: Long) : Comparable<ULong> {
companion object {
/**
@@ -41,21 +41,24 @@ public inline class ULong internal constructor(private val data: Long) : Compara
* 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.
*/
public operator fun compareTo(other: UByte): Int = this.compareTo(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UByte): Int = this.compareTo(other.toULong())
/**
* 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.
*/
public operator fun compareTo(other: UShort): Int = this.compareTo(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UShort): Int = this.compareTo(other.toULong())
/**
* 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.
*/
public operator fun compareTo(other: UInt): Int = this.compareTo(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UInt): Int = this.compareTo(other.toULong())
/**
* Compares this value with the specified value for order.
@@ -65,80 +68,117 @@ public inline class ULong internal constructor(private val data: Long) : Compara
public override operator fun compareTo(other: ULong): Int = ulongCompare(this.data, other.data)
/** Adds the other value to this value. */
public operator fun plus(other: UByte): ULong = this.plus(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UByte): ULong = this.plus(other.toULong())
/** Adds the other value to this value. */
public operator fun plus(other: UShort): ULong = this.plus(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UShort): ULong = this.plus(other.toULong())
/** Adds the other value to this value. */
public operator fun plus(other: UInt): ULong = this.plus(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UInt): ULong = this.plus(other.toULong())
/** Adds the other value to this value. */
public operator fun plus(other: ULong): ULong = ULong(this.data.plus(other.data))
@kotlin.internal.InlineOnly
public inline operator fun plus(other: ULong): ULong = ULong(this.data.plus(other.data))
/** Subtracts the other value from this value. */
public operator fun minus(other: UByte): ULong = this.minus(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UByte): ULong = this.minus(other.toULong())
/** Subtracts the other value from this value. */
public operator fun minus(other: UShort): ULong = this.minus(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UShort): ULong = this.minus(other.toULong())
/** Subtracts the other value from this value. */
public operator fun minus(other: UInt): ULong = this.minus(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UInt): ULong = this.minus(other.toULong())
/** Subtracts the other value from this value. */
public operator fun minus(other: ULong): ULong = ULong(this.data.minus(other.data))
@kotlin.internal.InlineOnly
public inline operator fun minus(other: ULong): ULong = ULong(this.data.minus(other.data))
/** Multiplies this value by the other value. */
public operator fun times(other: UByte): ULong = this.times(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UByte): ULong = this.times(other.toULong())
/** Multiplies this value by the other value. */
public operator fun times(other: UShort): ULong = this.times(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UShort): ULong = this.times(other.toULong())
/** Multiplies this value by the other value. */
public operator fun times(other: UInt): ULong = this.times(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UInt): ULong = this.times(other.toULong())
/** Multiplies this value by the other value. */
public operator fun times(other: ULong): ULong = ULong(this.data.times(other.data))
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = ULong(this.data.times(other.data))
/** Divides this value by the other value. */
public operator fun div(other: UByte): ULong = this.div(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): ULong = this.div(other.toULong())
/** Divides this value by the other value. */
public operator fun div(other: UShort): ULong = this.div(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): ULong = this.div(other.toULong())
/** Divides this value by the other value. */
public operator fun div(other: UInt): ULong = this.div(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): ULong = this.div(other.toULong())
/** Divides this value by the other value. */
public operator fun div(other: ULong): ULong = ulongDivide(this, other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = ulongDivide(this, other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UByte): ULong = this.rem(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): ULong = this.rem(other.toULong())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UShort): ULong = this.rem(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): ULong = this.rem(other.toULong())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UInt): ULong = this.rem(other.toULong())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): ULong = this.rem(other.toULong())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: ULong): ULong = ulongRemainder(this, other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = ulongRemainder(this, other)
/** Increments this value. */
public operator fun inc(): ULong = ULong(data.inc())
@kotlin.internal.InlineOnly
public inline operator fun inc(): ULong = ULong(data.inc())
/** Decrements this value. */
public operator fun dec(): ULong = ULong(data.dec())
@kotlin.internal.InlineOnly
public inline operator fun dec(): ULong = ULong(data.dec())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: ULong): ULongRange = ULongRange(this, other)
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: ULong): ULongRange = ULongRange(this, other)
/** Shifts this value left by the [bitCount] number of bits. */
public infix fun shl(bitCount: Int): ULong = ULong(data shl bitCount)
@kotlin.internal.InlineOnly
public inline infix fun shl(bitCount: Int): ULong = ULong(data shl bitCount)
/** Shifts this value right by the [bitCount] number of bits, filling the leftmost bits with zeros. */
public infix fun shr(bitCount: Int): ULong = ULong(data ushr bitCount)
@kotlin.internal.InlineOnly
public inline infix fun shr(bitCount: Int): ULong = ULong(data ushr bitCount)
/** Performs a bitwise AND operation between the two values. */
public infix fun and(other: ULong): ULong = ULong(this.data and other.data)
@kotlin.internal.InlineOnly
public inline infix fun and(other: ULong): ULong = ULong(this.data and other.data)
/** Performs a bitwise OR operation between the two values. */
public infix fun or(other: ULong): ULong = ULong(this.data or other.data)
@kotlin.internal.InlineOnly
public inline infix fun or(other: ULong): ULong = ULong(this.data or other.data)
/** Performs a bitwise XOR operation between the two values. */
public infix fun xor(other: ULong): ULong = ULong(this.data xor other.data)
@kotlin.internal.InlineOnly
public inline infix fun xor(other: ULong): ULong = ULong(this.data xor other.data)
/** Inverts the bits in this value. */
public fun inv(): ULong = ULong(data.inv())
@kotlin.internal.InlineOnly
public inline fun inv(): ULong = ULong(data.inv())
public fun toByte(): Byte = data.toByte()
public fun toShort(): Short = data.toShort()
public fun toInt(): Int = data.toInt()
public fun toLong(): Long = data
@kotlin.internal.InlineOnly
public inline fun toByte(): Byte = data.toByte()
@kotlin.internal.InlineOnly
public inline fun toShort(): Short = data.toShort()
@kotlin.internal.InlineOnly
public inline fun toInt(): Int = data.toInt()
@kotlin.internal.InlineOnly
public inline fun toLong(): Long = data
public fun toUByte(): UByte = data.toUByte()
public fun toUShort(): UShort = data.toUShort()
public fun toUInt(): UInt = data.toUInt()
public fun toULong(): ULong = this
@kotlin.internal.InlineOnly
public inline fun toUByte(): UByte = data.toUByte()
@kotlin.internal.InlineOnly
public inline fun toUShort(): UShort = data.toUShort()
@kotlin.internal.InlineOnly
public inline fun toUInt(): UInt = data.toUInt()
@kotlin.internal.InlineOnly
public inline fun toULong(): ULong = this
public override fun toString(): String = ulongToString(data)
@@ -146,13 +186,17 @@ public inline class ULong internal constructor(private val data: Long) : Compara
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Byte.toULong(): ULong = ULong(this.toLong())
@kotlin.internal.InlineOnly
public inline fun Byte.toULong(): ULong = ULong(this.toLong())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Short.toULong(): ULong = ULong(this.toLong())
@kotlin.internal.InlineOnly
public inline fun Short.toULong(): ULong = ULong(this.toLong())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Int.toULong(): ULong = ULong(this.toLong())
@kotlin.internal.InlineOnly
public inline fun Int.toULong(): ULong = ULong(this.toLong())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Long.toULong(): ULong = ULong(this)
@kotlin.internal.InlineOnly
public inline fun Long.toULong(): ULong = ULong(this)
+85 -43
View File
@@ -12,7 +12,7 @@ import kotlin.experimental.*
@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS")
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public inline class UShort internal constructor(private val data: Short) : Comparable<UShort> {
public inline class UShort @PublishedApi internal constructor(@PublishedApi internal val data: Short) : Comparable<UShort> {
companion object {
/**
@@ -41,7 +41,8 @@ public inline class UShort internal constructor(private val data: Short) : Compa
* 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.
*/
public operator fun compareTo(other: UByte): Int = this.toUInt().compareTo(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UByte): Int = this.toUInt().compareTo(other.toUInt())
/**
* Compares this value with the specified value for order.
@@ -55,86 +56,123 @@ public inline class UShort internal constructor(private val data: Short) : Compa
* 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.
*/
public operator fun compareTo(other: UInt): Int = this.toUInt().compareTo(other)
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: UInt): Int = this.toUInt().compareTo(other)
/**
* 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.
*/
public operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
@kotlin.internal.InlineOnly
public inline operator fun compareTo(other: ULong): Int = this.toULong().compareTo(other)
/** Adds the other value to this value. */
public operator fun plus(other: UByte): UInt = this.toUInt().plus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UByte): UInt = this.toUInt().plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UShort): UInt = this.toUInt().plus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UShort): UInt = this.toUInt().plus(other.toUInt())
/** Adds the other value to this value. */
public operator fun plus(other: UInt): UInt = this.toUInt().plus(other)
@kotlin.internal.InlineOnly
public inline operator fun plus(other: UInt): UInt = this.toUInt().plus(other)
/** Adds the other value to this value. */
public operator fun plus(other: ULong): ULong = this.toULong().plus(other)
@kotlin.internal.InlineOnly
public inline operator fun plus(other: ULong): ULong = this.toULong().plus(other)
/** Subtracts the other value from this value. */
public operator fun minus(other: UByte): UInt = this.toUInt().minus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UByte): UInt = this.toUInt().minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UShort): UInt = this.toUInt().minus(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UShort): UInt = this.toUInt().minus(other.toUInt())
/** Subtracts the other value from this value. */
public operator fun minus(other: UInt): UInt = this.toUInt().minus(other)
@kotlin.internal.InlineOnly
public inline operator fun minus(other: UInt): UInt = this.toUInt().minus(other)
/** Subtracts the other value from this value. */
public operator fun minus(other: ULong): ULong = this.toULong().minus(other)
@kotlin.internal.InlineOnly
public inline operator fun minus(other: ULong): ULong = this.toULong().minus(other)
/** Multiplies this value by the other value. */
public operator fun times(other: UByte): UInt = this.toUInt().times(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UByte): UInt = this.toUInt().times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UShort): UInt = this.toUInt().times(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun times(other: UShort): UInt = this.toUInt().times(other.toUInt())
/** Multiplies this value by the other value. */
public operator fun times(other: UInt): UInt = this.toUInt().times(other)
@kotlin.internal.InlineOnly
public inline operator fun times(other: UInt): UInt = this.toUInt().times(other)
/** Multiplies this value by the other value. */
public operator fun times(other: ULong): ULong = this.toULong().times(other)
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = this.toULong().times(other)
/** Divides this value by the other value. */
public operator fun div(other: UByte): UInt = this.toUInt().div(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): UInt = this.toUInt().div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UShort): UInt = this.toUInt().div(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): UInt = this.toUInt().div(other.toUInt())
/** Divides this value by the other value. */
public operator fun div(other: UInt): UInt = this.toUInt().div(other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): UInt = this.toUInt().div(other)
/** Divides this value by the other value. */
public operator fun div(other: ULong): ULong = this.toULong().div(other)
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = this.toULong().div(other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UByte): UInt = this.toUInt().rem(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): UInt = this.toUInt().rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UShort): UInt = this.toUInt().rem(other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): UInt = this.toUInt().rem(other.toUInt())
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: UInt): UInt = this.toUInt().rem(other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): UInt = this.toUInt().rem(other)
/** Calculates the remainder of dividing this value by the other value. */
public operator fun rem(other: ULong): ULong = this.toULong().rem(other)
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** Increments this value. */
public operator fun inc(): UShort = UShort(data.inc())
@kotlin.internal.InlineOnly
public inline operator fun inc(): UShort = UShort(data.inc())
/** Decrements this value. */
public operator fun dec(): UShort = UShort(data.dec())
@kotlin.internal.InlineOnly
public inline operator fun dec(): UShort = UShort(data.dec())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: UShort): UIntRange = UIntRange(this.toUInt(), other.toUInt())
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: UShort): UIntRange = UIntRange(this.toUInt(), other.toUInt())
/** Performs a bitwise AND operation between the two values. */
public infix fun and(other: UShort): UShort = UShort(this.data and other.data)
@kotlin.internal.InlineOnly
public inline infix fun and(other: UShort): UShort = UShort(this.data and other.data)
/** Performs a bitwise OR operation between the two values. */
public infix fun or(other: UShort): UShort = UShort(this.data or other.data)
@kotlin.internal.InlineOnly
public inline infix fun or(other: UShort): UShort = UShort(this.data or other.data)
/** Performs a bitwise XOR operation between the two values. */
public infix fun xor(other: UShort): UShort = UShort(this.data xor other.data)
@kotlin.internal.InlineOnly
public inline infix fun xor(other: UShort): UShort = UShort(this.data xor other.data)
/** Inverts the bits in this value. */
public fun inv(): UShort = UShort(data.inv())
@kotlin.internal.InlineOnly
public inline fun inv(): UShort = UShort(data.inv())
public fun toByte(): Byte = data.toByte()
public fun toShort(): Short = data
public fun toInt(): Int = data.toInt() and 0xFFFF
public fun toLong(): Long = data.toLong() and 0xFFFF
@kotlin.internal.InlineOnly
public inline fun toByte(): Byte = data.toByte()
@kotlin.internal.InlineOnly
public inline fun toShort(): Short = data
@kotlin.internal.InlineOnly
public inline fun toInt(): Int = data.toInt() and 0xFFFF
@kotlin.internal.InlineOnly
public inline fun toLong(): Long = data.toLong() and 0xFFFF
public fun toUByte(): UByte = data.toUByte()
public fun toUShort(): UShort = this
public fun toUInt(): UInt = data.toUInt() and 0xFFFFu
public fun toULong(): ULong = data.toULong() and 0xFFFFu
@kotlin.internal.InlineOnly
public inline fun toUByte(): UByte = data.toUByte()
@kotlin.internal.InlineOnly
public inline fun toUShort(): UShort = this
@kotlin.internal.InlineOnly
public inline fun toUInt(): UInt = UInt(data.toInt() and 0xFFFF)
@kotlin.internal.InlineOnly
public inline fun toULong(): ULong = ULong(data.toLong() and 0xFFFF)
public override fun toString(): String = toInt().toString()
@@ -142,13 +180,17 @@ public inline class UShort internal constructor(private val data: Short) : Compa
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Byte.toUShort(): UShort = UShort(this.toShort())
@kotlin.internal.InlineOnly
public inline fun Byte.toUShort(): UShort = UShort(this.toShort())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Short.toUShort(): UShort = UShort(this)
@kotlin.internal.InlineOnly
public inline fun Short.toUShort(): UShort = UShort(this)
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Int.toUShort(): UShort = UShort(this.toShort())
@kotlin.internal.InlineOnly
public inline fun Int.toUShort(): UShort = UShort(this.toShort())
@SinceKotlin("1.3")
@ExperimentalUnsignedTypes
public fun Long.toUShort(): UShort = UShort(this.toShort())
@kotlin.internal.InlineOnly
public inline fun Long.toUShort(): UShort = UShort(this.toShort())
@@ -2,19 +2,22 @@
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.jvm.JvmName("UnsignedKt")
@file:UseExperimental(ExperimentalUnsignedTypes::class)
package kotlin
internal fun uintCompare(v1: Int, v2: Int): Int = (v1 xor Int.MIN_VALUE).compareTo(v2 xor Int.MIN_VALUE)
internal fun ulongCompare(v1: Long, v2: Long): Int = (v1 xor Long.MIN_VALUE).compareTo(v2 xor Long.MIN_VALUE)
@PublishedApi
internal fun uintDivide(v1: UInt, v2: UInt): UInt = (v1.toLong() / v2.toLong()).toUInt()
@PublishedApi
internal fun uintRemainder(v1: UInt, v2: UInt): UInt = (v1.toLong() % v2.toLong()).toUInt()
// Division and remainder are based on Guava's UnsignedLongs implementation
// Copyright 2011 The Guava Authors
@PublishedApi
internal fun ulongDivide(v1: ULong, v2: ULong): ULong {
val dividend = v1.toLong()
val divisor = v2.toLong()
@@ -34,6 +37,7 @@ internal fun ulongDivide(v1: ULong, v2: ULong): ULong {
}
@PublishedApi
internal fun ulongRemainder(v1: ULong, v2: ULong): ULong {
val dividend = v1.toLong()
val divisor = v2.toLong()
@@ -206,56 +206,19 @@ public final class kotlin/UByte : java/lang/Comparable {
public static final field MIN_VALUE B
public static final field SIZE_BITS I
public static final field SIZE_BYTES I
public static final fun and-7apg3OU (BB)B
public static final synthetic fun box-impl (B)Lkotlin/UByte;
public synthetic fun compareTo (Ljava/lang/Object;)I
public fun compareTo-7apg3OU (B)I
public static fun compareTo-7apg3OU (BB)I
public static final fun compareTo-VKZWuLQ (BJ)I
public static final fun compareTo-WZ4Q5Ns (BI)I
public static final fun compareTo-xj2QHRw (BS)I
public static final fun dec-impl (B)B
public static final fun div-7apg3OU (BB)I
public static final fun div-VKZWuLQ (BJ)J
public static final fun div-WZ4Q5Ns (BI)I
public static final fun div-xj2QHRw (BS)I
public static fun constructor-impl (B)B
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (BLjava/lang/Object;)Z
public static final fun equals-impl0 (BB)Z
public fun hashCode ()I
public static fun hashCode-impl (B)I
public static final fun inc-impl (B)B
public static final fun inv-impl (B)B
public static final fun minus-7apg3OU (BB)I
public static final fun minus-VKZWuLQ (BJ)J
public static final fun minus-WZ4Q5Ns (BI)I
public static final fun minus-xj2QHRw (BS)I
public static final fun or-7apg3OU (BB)B
public static final fun plus-7apg3OU (BB)I
public static final fun plus-VKZWuLQ (BJ)J
public static final fun plus-WZ4Q5Ns (BI)I
public static final fun plus-xj2QHRw (BS)I
public static final fun rangeTo-7apg3OU (BB)Lkotlin/ranges/UIntRange;
public static final fun rem-7apg3OU (BB)I
public static final fun rem-VKZWuLQ (BJ)J
public static final fun rem-WZ4Q5Ns (BI)I
public static final fun rem-xj2QHRw (BS)I
public static final fun times-7apg3OU (BB)I
public static final fun times-VKZWuLQ (BJ)J
public static final fun times-WZ4Q5Ns (BI)I
public static final fun times-xj2QHRw (BS)I
public static final fun toByte-impl (B)B
public static final fun toInt-impl (B)I
public static final fun toLong-impl (B)J
public static final fun toShort-impl (B)S
public fun toString ()Ljava/lang/String;
public static fun toString-impl (B)Ljava/lang/String;
public static final fun toUByte-impl (B)B
public static final fun toUInt-impl (B)I
public static final fun toULong-impl (B)J
public static final fun toUShort-impl (B)S
public final synthetic fun unbox-impl ()B
public static final fun xor-7apg3OU (BB)B
}
public final class kotlin/UByte$Companion {
@@ -299,71 +262,25 @@ public final class kotlin/UByteArray : java/util/Collection, kotlin/jvm/internal
public final synthetic fun unbox-impl ()[B
}
public final class kotlin/UByteKt {
public static final fun toUByte (B)B
public static final fun toUByte (I)B
public static final fun toUByte (J)B
public static final fun toUByte (S)B
}
public final class kotlin/UInt : java/lang/Comparable {
public static final field Companion Lkotlin/UInt$Companion;
public static final field MAX_VALUE I
public static final field MIN_VALUE I
public static final field SIZE_BITS I
public static final field SIZE_BYTES I
public static final fun and-WZ4Q5Ns (II)I
public static final synthetic fun box-impl (I)Lkotlin/UInt;
public synthetic fun compareTo (Ljava/lang/Object;)I
public static final fun compareTo-7apg3OU (IB)I
public static final fun compareTo-VKZWuLQ (IJ)I
public fun compareTo-WZ4Q5Ns (I)I
public static fun compareTo-WZ4Q5Ns (II)I
public static final fun compareTo-xj2QHRw (IS)I
public static final fun dec-impl (I)I
public static final fun div-7apg3OU (IB)I
public static final fun div-VKZWuLQ (IJ)J
public static final fun div-WZ4Q5Ns (II)I
public static final fun div-xj2QHRw (IS)I
public static fun constructor-impl (I)I
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (ILjava/lang/Object;)Z
public static final fun equals-impl0 (II)Z
public fun hashCode ()I
public static fun hashCode-impl (I)I
public static final fun inc-impl (I)I
public static final fun inv-impl (I)I
public static final fun minus-7apg3OU (IB)I
public static final fun minus-VKZWuLQ (IJ)J
public static final fun minus-WZ4Q5Ns (II)I
public static final fun minus-xj2QHRw (IS)I
public static final fun or-WZ4Q5Ns (II)I
public static final fun plus-7apg3OU (IB)I
public static final fun plus-VKZWuLQ (IJ)J
public static final fun plus-WZ4Q5Ns (II)I
public static final fun plus-xj2QHRw (IS)I
public static final fun rangeTo-WZ4Q5Ns (II)Lkotlin/ranges/UIntRange;
public static final fun rem-7apg3OU (IB)I
public static final fun rem-VKZWuLQ (IJ)J
public static final fun rem-WZ4Q5Ns (II)I
public static final fun rem-xj2QHRw (IS)I
public static final fun shl-impl (II)I
public static final fun shr-impl (II)I
public static final fun times-7apg3OU (IB)I
public static final fun times-VKZWuLQ (IJ)J
public static final fun times-WZ4Q5Ns (II)I
public static final fun times-xj2QHRw (IS)I
public static final fun toByte-impl (I)B
public static final fun toInt-impl (I)I
public static final fun toLong-impl (I)J
public static final fun toShort-impl (I)S
public fun toString ()Ljava/lang/String;
public static fun toString-impl (I)Ljava/lang/String;
public static final fun toUByte-impl (I)B
public static final fun toUInt-impl (I)I
public static final fun toULong-impl (I)J
public static final fun toUShort-impl (I)S
public final synthetic fun unbox-impl ()I
public static final fun xor-WZ4Q5Ns (II)I
}
public final class kotlin/UInt$Companion {
@@ -407,71 +324,25 @@ public final class kotlin/UIntArray : java/util/Collection, kotlin/jvm/internal/
public final synthetic fun unbox-impl ()[I
}
public final class kotlin/UIntKt {
public static final fun toUInt (B)I
public static final fun toUInt (I)I
public static final fun toUInt (J)I
public static final fun toUInt (S)I
}
public final class kotlin/ULong : java/lang/Comparable {
public static final field Companion Lkotlin/ULong$Companion;
public static final field MAX_VALUE J
public static final field MIN_VALUE J
public static final field SIZE_BITS I
public static final field SIZE_BYTES I
public static final fun and-VKZWuLQ (JJ)J
public static final synthetic fun box-impl (J)Lkotlin/ULong;
public synthetic fun compareTo (Ljava/lang/Object;)I
public static final fun compareTo-7apg3OU (JB)I
public fun compareTo-VKZWuLQ (J)I
public static fun compareTo-VKZWuLQ (JJ)I
public static final fun compareTo-WZ4Q5Ns (JI)I
public static final fun compareTo-xj2QHRw (JS)I
public static final fun dec-impl (J)J
public static final fun div-7apg3OU (JB)J
public static final fun div-VKZWuLQ (JJ)J
public static final fun div-WZ4Q5Ns (JI)J
public static final fun div-xj2QHRw (JS)J
public static fun constructor-impl (J)J
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (JLjava/lang/Object;)Z
public static final fun equals-impl0 (JJ)Z
public fun hashCode ()I
public static fun hashCode-impl (J)I
public static final fun inc-impl (J)J
public static final fun inv-impl (J)J
public static final fun minus-7apg3OU (JB)J
public static final fun minus-VKZWuLQ (JJ)J
public static final fun minus-WZ4Q5Ns (JI)J
public static final fun minus-xj2QHRw (JS)J
public static final fun or-VKZWuLQ (JJ)J
public static final fun plus-7apg3OU (JB)J
public static final fun plus-VKZWuLQ (JJ)J
public static final fun plus-WZ4Q5Ns (JI)J
public static final fun plus-xj2QHRw (JS)J
public static final fun rangeTo-VKZWuLQ (JJ)Lkotlin/ranges/ULongRange;
public static final fun rem-7apg3OU (JB)J
public static final fun rem-VKZWuLQ (JJ)J
public static final fun rem-WZ4Q5Ns (JI)J
public static final fun rem-xj2QHRw (JS)J
public static final fun shl-impl (JI)J
public static final fun shr-impl (JI)J
public static final fun times-7apg3OU (JB)J
public static final fun times-VKZWuLQ (JJ)J
public static final fun times-WZ4Q5Ns (JI)J
public static final fun times-xj2QHRw (JS)J
public static final fun toByte-impl (J)B
public static final fun toInt-impl (J)I
public static final fun toLong-impl (J)J
public static final fun toShort-impl (J)S
public fun toString ()Ljava/lang/String;
public static fun toString-impl (J)Ljava/lang/String;
public static final fun toUByte-impl (J)B
public static final fun toUInt-impl (J)I
public static final fun toULong-impl (J)J
public static final fun toUShort-impl (J)S
public final synthetic fun unbox-impl ()J
public static final fun xor-VKZWuLQ (JJ)J
}
public final class kotlin/ULong$Companion {
@@ -515,69 +386,25 @@ public final class kotlin/ULongArray : java/util/Collection, kotlin/jvm/internal
public final synthetic fun unbox-impl ()[J
}
public final class kotlin/ULongKt {
public static final fun toULong (B)J
public static final fun toULong (I)J
public static final fun toULong (J)J
public static final fun toULong (S)J
}
public final class kotlin/UShort : java/lang/Comparable {
public static final field Companion Lkotlin/UShort$Companion;
public static final field MAX_VALUE S
public static final field MIN_VALUE S
public static final field SIZE_BITS I
public static final field SIZE_BYTES I
public static final fun and-xj2QHRw (SS)S
public static final synthetic fun box-impl (S)Lkotlin/UShort;
public synthetic fun compareTo (Ljava/lang/Object;)I
public static final fun compareTo-7apg3OU (SB)I
public static final fun compareTo-VKZWuLQ (SJ)I
public static final fun compareTo-WZ4Q5Ns (SI)I
public fun compareTo-xj2QHRw (S)I
public static fun compareTo-xj2QHRw (SS)I
public static final fun dec-impl (S)S
public static final fun div-7apg3OU (SB)I
public static final fun div-VKZWuLQ (SJ)J
public static final fun div-WZ4Q5Ns (SI)I
public static final fun div-xj2QHRw (SS)I
public static fun constructor-impl (S)S
public fun equals (Ljava/lang/Object;)Z
public static fun equals-impl (SLjava/lang/Object;)Z
public static final fun equals-impl0 (SS)Z
public fun hashCode ()I
public static fun hashCode-impl (S)I
public static final fun inc-impl (S)S
public static final fun inv-impl (S)S
public static final fun minus-7apg3OU (SB)I
public static final fun minus-VKZWuLQ (SJ)J
public static final fun minus-WZ4Q5Ns (SI)I
public static final fun minus-xj2QHRw (SS)I
public static final fun or-xj2QHRw (SS)S
public static final fun plus-7apg3OU (SB)I
public static final fun plus-VKZWuLQ (SJ)J
public static final fun plus-WZ4Q5Ns (SI)I
public static final fun plus-xj2QHRw (SS)I
public static final fun rangeTo-xj2QHRw (SS)Lkotlin/ranges/UIntRange;
public static final fun rem-7apg3OU (SB)I
public static final fun rem-VKZWuLQ (SJ)J
public static final fun rem-WZ4Q5Ns (SI)I
public static final fun rem-xj2QHRw (SS)I
public static final fun times-7apg3OU (SB)I
public static final fun times-VKZWuLQ (SJ)J
public static final fun times-WZ4Q5Ns (SI)I
public static final fun times-xj2QHRw (SS)I
public static final fun toByte-impl (S)B
public static final fun toInt-impl (S)I
public static final fun toLong-impl (S)J
public static final fun toShort-impl (S)S
public fun toString ()Ljava/lang/String;
public static fun toString-impl (S)Ljava/lang/String;
public static final fun toUByte-impl (S)B
public static final fun toUInt-impl (S)I
public static final fun toULong-impl (S)J
public static final fun toUShort-impl (S)S
public final synthetic fun unbox-impl ()S
public static final fun xor-xj2QHRw (SS)S
}
public final class kotlin/UShort$Companion {
@@ -621,13 +448,6 @@ public final class kotlin/UShortArray : java/util/Collection, kotlin/jvm/interna
public final synthetic fun unbox-impl ()[S
}
public final class kotlin/UShortKt {
public static final fun toUShort (B)S
public static final fun toUShort (I)S
public static final fun toUShort (J)S
public static final fun toUShort (S)S
}
public final class kotlin/UninitializedPropertyAccessException : java/lang/RuntimeException {
public fun <init> ()V
public fun <init> (Ljava/lang/String;)V
@@ -643,6 +463,13 @@ public final class kotlin/Unit {
public abstract interface annotation class kotlin/UnsafeVariance : java/lang/annotation/Annotation {
}
public final class kotlin/UnsignedKt {
public static final fun uintDivide-J1ME1BU (II)I
public static final fun uintRemainder-J1ME1BU (II)I
public static final fun ulongDivide-eb3DHEI (JJ)J
public static final fun ulongRemainder-eb3DHEI (JJ)J
}
public abstract interface annotation class kotlin/UseExperimental : java/lang/annotation/Annotation {
public abstract fun markerClass ()[Ljava/lang/Class;
}