IR: add IrClass.getInlineClassRepresentation, serialize/deserialize it
The change in FirDeclarationUtil is needed because in case of unsigned types loaded from the standard library, the primary constructor for some reason is not the first, but the second in the list of constructors.
This commit is contained in:
+9
-1
@@ -17,6 +17,11 @@ internal fun PersistentIrGenerator.generateClass() {
|
||||
)
|
||||
val superTypesField = Field("superTypes", +"List<" + import("IrType", "org.jetbrains.kotlin.ir.types") + ">", superTypeListProto)
|
||||
val modalityField = Field("modality", descriptorType("Modality"), modalityProto)
|
||||
val inlineClassRepresentationField = Field(
|
||||
"inlineClassRepresentation",
|
||||
descriptorType("InlineClassRepresentation") + "<" + import("IrSimpleType", "org.jetbrains.kotlin.ir.types") + ">?",
|
||||
inlineClassRepresentationProto
|
||||
)
|
||||
|
||||
writeFile("PersistentIrClass.kt", renderFile("org.jetbrains.kotlin.ir.declarations.persistent") {
|
||||
lines(
|
||||
@@ -72,6 +77,7 @@ internal fun PersistentIrGenerator.generateClass() {
|
||||
superTypesField.toPersistentField(+"emptyList()"),
|
||||
+"override var metadata: " + MetadataSource + "? = null",
|
||||
modalityField.toPersistentField(+"modality"),
|
||||
inlineClassRepresentationField.toPersistentField(+"null"),
|
||||
+"override var attributeOwnerId: " + IrAttributeContainer + " = this",
|
||||
),
|
||||
id,
|
||||
@@ -86,6 +92,7 @@ internal fun PersistentIrGenerator.generateClass() {
|
||||
modalityField,
|
||||
typeParametersField,
|
||||
superTypesField,
|
||||
inlineClassRepresentationField,
|
||||
)()
|
||||
})
|
||||
|
||||
@@ -96,5 +103,6 @@ internal fun PersistentIrGenerator.generateClass() {
|
||||
modalityField,
|
||||
typeParametersField,
|
||||
superTypesField,
|
||||
inlineClassRepresentationField,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-2
@@ -3,11 +3,11 @@
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||
|
||||
package org.jetbrains.kotlin.ir.persistentIrGenerator
|
||||
|
||||
import java.io.File
|
||||
import java.lang.IllegalStateException
|
||||
import java.lang.StringBuilder
|
||||
|
||||
internal interface R {
|
||||
fun text(t: String): R
|
||||
@@ -156,6 +156,11 @@ internal object PersistentIrGenerator {
|
||||
|
||||
val visibilityProto = Proto(null, "visibility", +"Long", DescriptorVisibility)
|
||||
val modalityProto = Proto(null, "modality", +"Long", descriptorType("Modality"))
|
||||
val inlineClassRepresentationProto = Proto(
|
||||
"IrInlineClassRepresentation", "inlineClassRepresentation",
|
||||
import("IrInlineClassRepresentation", protoPackage, "ProtoIrInlineClassRepresentation"),
|
||||
descriptorType("InlineClassRepresentation") + "<" + import("IrSimpleType", "org.jetbrains.kotlin.ir.types") + ">"
|
||||
)
|
||||
|
||||
val isExternalClassProto = Proto(null, "isExternalClass", +"Long", +"Boolean")
|
||||
val isExternalFieldProto = Proto(null, "isExternalField", +"Long", +"Boolean")
|
||||
@@ -180,6 +185,7 @@ internal object PersistentIrGenerator {
|
||||
variableProto,
|
||||
visibilityProto,
|
||||
modalityProto,
|
||||
inlineClassRepresentationProto,
|
||||
isExternalClassProto,
|
||||
isExternalFieldProto,
|
||||
isExternalFunctionProto,
|
||||
|
||||
Reference in New Issue
Block a user