[Generator] Rename additionalDoc, put its content before annotations

This commit is contained in:
Ilya Gorbunov
2023-08-28 21:20:38 +02:00
committed by Space Team
parent cd392ebe69
commit 60bbd08569
6 changed files with 12 additions and 12 deletions
@@ -419,7 +419,7 @@ class JsCharGenerator(writer: PrintWriter) : CharGenerator(writer) {
} }
override fun MethodBuilder.modifyGeneratedToString() { override fun MethodBuilder.modifyGeneratedToString() {
additionalDoc = "TODO implicit usages of toString and valueOf must be covered in DCE" additionalComments = "TODO implicit usages of toString and valueOf must be covered in DCE"
annotations += "Suppress(\"JS_NAME_PROHIBITED_FOR_OVERRIDE\")" annotations += "Suppress(\"JS_NAME_PROHIBITED_FOR_OVERRIDE\")"
annotations += "JsName(\"toString\")" annotations += "JsName(\"toString\")"
"return js(\"String\").fromCharCode(value).unsafeCast<String>()".addAsMultiLineBody() "return js(\"String\").fromCharCode(value).unsafeCast<String>()".addAsMultiLineBody()
@@ -146,7 +146,7 @@ class JsPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(write
if (thisKind == PrimitiveType.LONG) { if (thisKind == PrimitiveType.LONG) {
method { method {
additionalDoc = """ additionalComments = """
This method is used by JavaScript to convert objects of type Long to primitives. This method is used by JavaScript to convert objects of type Long to primitives.
This is essential for the JavaScript interop. This is essential for the JavaScript interop.
JavaScript functions that expect `number` are imported in Kotlin as expecting `kotlin.Number` JavaScript functions that expect `number` are imported in Kotlin as expecting `kotlin.Number`
@@ -120,7 +120,7 @@ class WasmPrimitivesGenerator(writer: PrintWriter) : BasePrimitivesGenerator(wri
override fun MethodBuilder.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) { override fun MethodBuilder.modifyGeneratedUnaryOperation(thisKind: PrimitiveType) {
if (thisKind == PrimitiveType.INT && methodName == "dec") { if (thisKind == PrimitiveType.INT && methodName == "dec") {
additionalDoc = "TODO: Fix test compiler/testData/codegen/box/functions/invoke/invoke.kt with inline dec" additionalComments = "TODO: Fix test compiler/testData/codegen/box/functions/invoke/invoke.kt with inline dec"
} else { } else {
modifySignature { isInline = true } modifySignature { isInline = true }
} }
+7 -7
View File
@@ -40,7 +40,7 @@ internal interface PrimitiveBuilder {
internal abstract class AnnotatedAndDocumented { internal abstract class AnnotatedAndDocumented {
private var doc: String? = null private var doc: String? = null
val annotations: MutableList<String> = mutableListOf() val annotations: MutableList<String> = mutableListOf()
var additionalDoc: String? = null var additionalComments: String? = null
fun appendDoc(doc: String) { fun appendDoc(doc: String) {
if (this.doc == null) { if (this.doc == null) {
@@ -55,15 +55,15 @@ internal abstract class AnnotatedAndDocumented {
appendLine(doc!!.printAsDoc(forceMultiLineDoc)) appendLine(doc!!.printAsDoc(forceMultiLineDoc))
} }
if (annotations.isNotEmpty()) { if (additionalComments != null) {
appendLine(annotations.joinToString(separator = END_LINE) { "@$it" }) additionalComments!!.lines().forEach { line ->
}
if (additionalDoc != null) {
additionalDoc!!.lines().forEach { line ->
appendLine("// $line") appendLine("// $line")
} }
} }
if (annotations.isNotEmpty()) {
appendLine(annotations.joinToString(separator = END_LINE) { "@$it" })
}
} }
private fun String.printAsDoc(forceMultiLine: Boolean = false): String { private fun String.printAsDoc(forceMultiLine: Boolean = false): String {
+1 -1
View File
@@ -106,10 +106,10 @@ internal constructor(private val value: Int) : Comparable<Char> {
@kotlin.internal.IntrinsicConstEvaluation @kotlin.internal.IntrinsicConstEvaluation
public fun toDouble(): Double = value.toDouble() public fun toDouble(): Double = value.toDouble()
// TODO implicit usages of toString and valueOf must be covered in DCE
@kotlin.internal.IntrinsicConstEvaluation @kotlin.internal.IntrinsicConstEvaluation
@Suppress("JS_NAME_PROHIBITED_FOR_OVERRIDE") @Suppress("JS_NAME_PROHIBITED_FOR_OVERRIDE")
@JsName("toString") @JsName("toString")
// TODO implicit usages of toString and valueOf must be covered in DCE
public override fun toString(): String { public override fun toString(): String {
return js("String").fromCharCode(value).unsafeCast<String>() return js("String").fromCharCode(value).unsafeCast<String>()
} }
@@ -1578,13 +1578,13 @@ public class Long internal constructor(internal val low: Int, internal val high:
public override fun hashCode(): Int = hashCode(this) public override fun hashCode(): Int = hashCode(this)
@JsName("valueOf")
// This method is used by JavaScript to convert objects of type Long to primitives. // This method is used by JavaScript to convert objects of type Long to primitives.
// This is essential for the JavaScript interop. // This is essential for the JavaScript interop.
// JavaScript functions that expect `number` are imported in Kotlin as expecting `kotlin.Number` // JavaScript functions that expect `number` are imported in Kotlin as expecting `kotlin.Number`
// (in our standard library, and also in user projects if they use Dukat for generating external declarations). // (in our standard library, and also in user projects if they use Dukat for generating external declarations).
// Because `kotlin.Number` is a supertype of `Long` too, there has to be a way for JS to know how to handle Longs. // Because `kotlin.Number` is a supertype of `Long` too, there has to be a way for JS to know how to handle Longs.
// See KT-50202 // See KT-50202
@JsName("valueOf")
internal fun valueOf(): Double = toDouble() internal fun valueOf(): Double = toDouble()
} }