|
5 | 5 |
|
6 | 6 | package org.jetbrains.kotlin.generators.builtins.unsigned
|
7 | 7 |
|
8 |
| - |
9 |
| -import org.jetbrains.kotlin.generators.builtins.* |
| 8 | +import org.jetbrains.kotlin.generators.builtins.PrimitiveType |
| 9 | +import org.jetbrains.kotlin.generators.builtins.UnsignedType |
| 10 | +import org.jetbrains.kotlin.generators.builtins.convert |
10 | 11 | import org.jetbrains.kotlin.generators.builtins.generateBuiltIns.BuiltInsSourceGenerator
|
11 | 12 | import org.jetbrains.kotlin.generators.builtins.numbers.GeneratePrimitives
|
| 13 | +import org.jetbrains.kotlin.generators.builtins.printDoc |
12 | 14 | import java.io.File
|
13 | 15 | import java.io.PrintWriter
|
14 | 16 |
|
15 |
| - |
16 | 17 | fun generateUnsignedTypes(
|
17 | 18 | targetDir: File,
|
18 | 19 | generate: (File, (PrintWriter) -> BuiltInsSourceGenerator) -> Unit
|
@@ -134,7 +135,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
134 | 135 | if (otherType == type) out.print("override ")
|
135 | 136 | out.print("inline operator fun compareTo(other: ${otherType.capitalized}): Int = ")
|
136 | 137 | if (otherType == type && maxByDomainCapacity(type, UnsignedType.UINT) == type) {
|
137 |
| - out.println("${className.toLowerCase()}Compare(this.data, other.data)") |
| 138 | + out.println("${className.lowercase()}Compare(this.data, other.data)") |
138 | 139 | } else {
|
139 | 140 | if (maxOf(type, otherType) < UnsignedType.UINT) {
|
140 | 141 | out.println("this.toInt().compareTo(other.toInt())")
|
@@ -165,8 +166,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
165 | 166 | if (type == otherType && type == returnType) {
|
166 | 167 | when (name) {
|
167 | 168 | "plus", "minus", "times" -> out.println("$className(this.data.$name(other.data))")
|
168 |
| - "div" -> out.println("${type.capitalized.toLowerCase()}Divide(this, other)") |
169 |
| - "rem" -> out.println("${type.capitalized.toLowerCase()}Remainder(this, other)") |
| 169 | + "div" -> out.println("${type.capitalized.lowercase()}Divide(this, other)") |
| 170 | + "rem" -> out.println("${type.capitalized.lowercase()}Remainder(this, other)") |
170 | 171 | else -> error(name)
|
171 | 172 | }
|
172 | 173 | } else {
|
@@ -348,7 +349,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
348 | 349 | out.print(" public inline fun to$otherName(): $otherName = ")
|
349 | 350 | when (type) {
|
350 | 351 | UnsignedType.UINT, UnsignedType.ULONG ->
|
351 |
| - out.println(if (otherType == PrimitiveType.FLOAT) "this.toDouble().toFloat()" else className.toLowerCase() + "ToDouble(data)") |
| 352 | + out.println(if (otherType == PrimitiveType.FLOAT) "this.toDouble().toFloat()" else className.lowercase() + "ToDouble(data)") |
352 | 353 | else ->
|
353 | 354 | out.println("this.toInt().to$otherName()")
|
354 | 355 | }
|
@@ -466,7 +467,7 @@ class UnsignedIteratorsGenerator(out: PrintWriter) : BuiltInsSourceGenerator(out
|
466 | 467 | class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
467 | 468 | val elementType = type.capitalized
|
468 | 469 | val arrayType = elementType + "Array"
|
469 |
| - val arrayTypeOf = elementType.toLowerCase() + "ArrayOf" |
| 470 | + val arrayTypeOf = elementType.lowercase() + "ArrayOf" |
470 | 471 | val storageElementType = type.asSigned.capitalized
|
471 | 472 | val storageArrayType = storageElementType + "Array"
|
472 | 473 | override fun generateBody() {
|
|
0 commit comments