[IR] Don't produce gaps for skipped IR declarations during serialization
This commit is contained in:
committed by
Space Team
parent
a4c9a4f150
commit
161fe1d2ca
+3
-4
@@ -21,8 +21,6 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
|||||||
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
import org.jetbrains.kotlin.ir.visitors.acceptVoid
|
||||||
import org.jetbrains.kotlin.library.SerializedDeclaration
|
import org.jetbrains.kotlin.library.SerializedDeclaration
|
||||||
import org.jetbrains.kotlin.library.SerializedIrFile
|
import org.jetbrains.kotlin.library.SerializedIrFile
|
||||||
import org.jetbrains.kotlin.library.SkippedDeclaration
|
|
||||||
import org.jetbrains.kotlin.library.TopLevelDeclaration
|
|
||||||
import org.jetbrains.kotlin.library.impl.IrMemoryArrayWriter
|
import org.jetbrains.kotlin.library.impl.IrMemoryArrayWriter
|
||||||
import org.jetbrains.kotlin.library.impl.IrMemoryDeclarationWriter
|
import org.jetbrains.kotlin.library.impl.IrMemoryDeclarationWriter
|
||||||
import org.jetbrains.kotlin.library.impl.IrMemoryStringWriter
|
import org.jetbrains.kotlin.library.impl.IrMemoryStringWriter
|
||||||
@@ -1425,7 +1423,8 @@ open class IrFileSerializer(
|
|||||||
|
|
||||||
file.declarations.forEach {
|
file.declarations.forEach {
|
||||||
if (skipExpects && it.descriptor.isExpectMember && !it.descriptor.isSerializableExpectClass) {
|
if (skipExpects && it.descriptor.isExpectMember && !it.descriptor.isSerializableExpectClass) {
|
||||||
topLevelDeclarations.add(SkippedDeclaration)
|
// Skip the declaration unless it is `expect annotation class` marked with `OptionalExpectation`
|
||||||
|
// without the corresponding `actual` counterpart for the current leaf target.
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1437,7 +1436,7 @@ open class IrFileSerializer(
|
|||||||
// TODO: keep order similar
|
// TODO: keep order similar
|
||||||
val sigIndex = protoIdSignatureMap[idSig]
|
val sigIndex = protoIdSignatureMap[idSig]
|
||||||
?: if (it is IrErrorDeclaration) protoIdSignature(idSig) else error("Not found ID for $idSig (${it.render()})")
|
?: if (it is IrErrorDeclaration) protoIdSignature(idSig) else error("Not found ID for $idSig (${it.render()})")
|
||||||
topLevelDeclarations.add(TopLevelDeclaration(sigIndex, idSig.toString(), byteArray))
|
topLevelDeclarations.add(SerializedDeclaration(sigIndex, idSig.toString(), byteArray))
|
||||||
proto.addDeclarationId(sigIndex)
|
proto.addDeclarationId(sigIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,24 +32,8 @@ class SerializedMetadata(
|
|||||||
val fragmentNames: List<String>
|
val fragmentNames: List<String>
|
||||||
)
|
)
|
||||||
|
|
||||||
sealed class SerializedDeclaration {
|
class SerializedDeclaration(val id: Int, val declarationName: String, val bytes: ByteArray) {
|
||||||
abstract val id: Int
|
val size = bytes.size
|
||||||
abstract val size: Int
|
|
||||||
abstract val bytes: ByteArray
|
|
||||||
|
|
||||||
abstract val declarationName: String
|
|
||||||
}
|
|
||||||
|
|
||||||
class TopLevelDeclaration(override val id: Int, override val declarationName: String, override val bytes: ByteArray) :
|
|
||||||
SerializedDeclaration() {
|
|
||||||
override val size = bytes.size
|
|
||||||
}
|
|
||||||
|
|
||||||
object SkippedDeclaration : SerializedDeclaration() {
|
|
||||||
override val id = -1
|
|
||||||
override val size = 0
|
|
||||||
override val bytes = ByteArray(0)
|
|
||||||
override val declarationName: String = "<SKIPPED>"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SerializedIrFile(
|
class SerializedIrFile(
|
||||||
|
|||||||
Reference in New Issue
Block a user