[Interop][Serialization] Skip files with C enums and structs
We don't need to serialize these files since stubs for enums and structs will be generated anew.
This commit is contained in:
committed by
Sergey Bogolepov
parent
e79b055c81
commit
ac5fd80cb4
+5
-1
@@ -116,9 +116,13 @@ internal class IrProviderForCEnumAndCStructStubs(
|
|||||||
private fun irParentFor(descriptor: ClassDescriptor): IrDeclarationContainer {
|
private fun irParentFor(descriptor: ClassDescriptor): IrDeclarationContainer {
|
||||||
val packageFragmentDescriptor = descriptor.findPackage()
|
val packageFragmentDescriptor = descriptor.findPackage()
|
||||||
return filesMap.getOrPut(packageFragmentDescriptor) {
|
return filesMap.getOrPut(packageFragmentDescriptor) {
|
||||||
IrFileImpl(NaiveSourceBasedFileEntryImpl("CTypeDefinitions"), packageFragmentDescriptor).also {
|
IrFileImpl(NaiveSourceBasedFileEntryImpl(cTypeDefinitionsFileName), packageFragmentDescriptor).also {
|
||||||
this@IrProviderForCEnumAndCStructStubs.module?.files?.add(it)
|
this@IrProviderForCEnumAndCStructStubs.module?.files?.add(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val cTypeDefinitionsFileName = "CTypeDefinitions"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+10
@@ -3,6 +3,7 @@ package org.jetbrains.kotlin.backend.konan.serialization
|
|||||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.*
|
import org.jetbrains.kotlin.backend.common.serialization.*
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||||
|
import org.jetbrains.kotlin.backend.konan.ir.interop.IrProviderForCEnumAndCStructStubs
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
@@ -18,6 +19,15 @@ class KonanIrModuleSerializer(
|
|||||||
private val signaturer = IdSignatureSerializer(KonanManglerIr)
|
private val signaturer = IdSignatureSerializer(KonanManglerIr)
|
||||||
private val globalDeclarationTable = KonanGlobalDeclarationTable(signaturer, irBuiltIns)
|
private val globalDeclarationTable = KonanGlobalDeclarationTable(signaturer, irBuiltIns)
|
||||||
|
|
||||||
|
// We skip files with IR for C structs and enums because they should be
|
||||||
|
// generated anew.
|
||||||
|
//
|
||||||
|
// See [IrProviderForCEnumAndCStructStubs.kt#L31] on why we generate IR.
|
||||||
|
// We may switch from IR generation to LazyIR later (at least for structs; enums are tricky)
|
||||||
|
// without changing kotlin libraries that depend on interop libraries.
|
||||||
|
override fun backendSpecificFileFilter(file: IrFile): Boolean =
|
||||||
|
file.fileEntry.name != IrProviderForCEnumAndCStructStubs.cTypeDefinitionsFileName
|
||||||
|
|
||||||
override fun createSerializerForFile(file: IrFile): KonanIrFileSerializer =
|
override fun createSerializerForFile(file: IrFile): KonanIrFileSerializer =
|
||||||
KonanIrFileSerializer(logger, DeclarationTable(globalDeclarationTable), expectDescriptorToSymbol, skipExpects = skipExpects)
|
KonanIrFileSerializer(logger, DeclarationTable(globalDeclarationTable), expectDescriptorToSymbol, skipExpects = skipExpects)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user