[Interop][Linker] Simplify IrProviderForCEnumAndCStructStubs
This commit is contained in:
committed by
Sergey Bogolepov
parent
6c24e9091d
commit
0e9dbf3939
+2
-6
@@ -245,12 +245,10 @@ internal val psiToIrPhase = konanUnitPhase(
|
||||
if (this.stdlibModule in modulesWithoutDCE) {
|
||||
functionIrClassFactory.buildAllClasses()
|
||||
}
|
||||
modulesWithoutDCE
|
||||
.filter(ModuleDescriptor::isFromInteropLibrary)
|
||||
.forEach(irProviderForCEnumsAndCStructs::buildAllEnumsAndStructsFrom)
|
||||
|
||||
module.acceptVoid(ManglerChecker(KonanManglerIr, Ir2DescriptorManglerAdapter(KonanManglerDesc)))
|
||||
|
||||
module.files += irProviderForCEnumsAndCStructs.outputFiles
|
||||
|
||||
irModule = module
|
||||
irModules = deserializer.modules.filterValues { llvmModuleSpecification.containsModule(it) }
|
||||
ir.symbols = symbols
|
||||
@@ -258,8 +256,6 @@ internal val psiToIrPhase = konanUnitPhase(
|
||||
functionIrClassFactory.module =
|
||||
(listOf(irModule!!) + deserializer.modules.values)
|
||||
.single { it.descriptor.isKonanStdlib() }
|
||||
|
||||
irProviderForCEnumsAndCStructs.module = module
|
||||
},
|
||||
name = "Psi2Ir",
|
||||
description = "Psi to IR conversion",
|
||||
|
||||
+7
-12
@@ -60,15 +60,12 @@ internal class IrProviderForCEnumAndCStructStubs(
|
||||
private val cStructClassGenerator =
|
||||
CStructVarClassGenerator(context, interopBuiltIns)
|
||||
|
||||
var module: IrModuleFragment? = null
|
||||
set(value) {
|
||||
if (value == null)
|
||||
error("Provide a valid non-null module")
|
||||
if (field != null)
|
||||
error("Module has already been set")
|
||||
field = value
|
||||
value.files += filesMap.values
|
||||
}
|
||||
/**
|
||||
* The final output of this provider is a list of files which contain IR declarations
|
||||
* of enums and structs that should be generated.
|
||||
*/
|
||||
val outputFiles: List<IrFile>
|
||||
get() = filesMap.values.toList()
|
||||
|
||||
fun canHandleSymbol(symbol: IrSymbol): Boolean {
|
||||
if (!symbol.isPublicApi) return false
|
||||
@@ -116,9 +113,7 @@ internal class IrProviderForCEnumAndCStructStubs(
|
||||
private fun irParentFor(descriptor: ClassDescriptor): IrDeclarationContainer {
|
||||
val packageFragmentDescriptor = descriptor.findPackage()
|
||||
return filesMap.getOrPut(packageFragmentDescriptor) {
|
||||
IrFileImpl(NaiveSourceBasedFileEntryImpl(cTypeDefinitionsFileName), packageFragmentDescriptor).also {
|
||||
this@IrProviderForCEnumAndCStructStubs.module?.files?.add(it)
|
||||
}
|
||||
IrFileImpl(NaiveSourceBasedFileEntryImpl(cTypeDefinitionsFileName), packageFragmentDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user