[Linker] Extend KotlinIrLinker infrastructure to support libraries that
doesn't contain IR. Also bump ABI version because of addition of `ir_provider` property
This commit is contained in:
+5
-1
@@ -56,7 +56,7 @@ abstract class GlobalDeclarationTable(private val mangler: KotlinMangler, privat
|
||||
fun isExportedDeclaration(declaration: IrDeclaration): Boolean = with(mangler) { declaration.isExported() }
|
||||
}
|
||||
|
||||
class DeclarationTable(
|
||||
open class DeclarationTable(
|
||||
private val descriptorTable: DescriptorTable,
|
||||
private val globalDeclarationTable: GlobalDeclarationTable,
|
||||
startIndex: Long
|
||||
@@ -71,7 +71,11 @@ class DeclarationTable(
|
||||
|
||||
fun isExportedDeclaration(declaration: IrDeclaration) = globalDeclarationTable.isExportedDeclaration(declaration)
|
||||
|
||||
protected open fun tryComputeBackendSpecificUniqId(declaration: IrDeclaration): UniqId? =
|
||||
null
|
||||
|
||||
private fun computeUniqIdByDeclaration(declaration: IrDeclaration): UniqId {
|
||||
tryComputeBackendSpecificUniqId(declaration)?.let { return it }
|
||||
return if (declaration.isLocalDeclaration()) {
|
||||
table.getOrPut(declaration) { UniqId(localIndex++) }
|
||||
} else globalDeclarationTable.computeUniqIdByDeclaration(declaration)
|
||||
|
||||
+9
@@ -506,6 +506,12 @@ abstract class KotlinIrLinker(
|
||||
error("Deserializer for declaration $key is not found")
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that descriptor shouldn't be processed by some backend-specific logic.
|
||||
* For example, it is the case for Native interop libraries where there is no IR in libraries.
|
||||
*/
|
||||
protected open fun DeclarationDescriptor.shouldBeDeserialized(): Boolean = true
|
||||
|
||||
private fun deserializeAllReachableTopLevels() {
|
||||
do {
|
||||
val moduleDeserializer = modulesWithReachableTopLevels.first()
|
||||
@@ -521,6 +527,9 @@ abstract class KotlinIrLinker(
|
||||
// This is Native specific. Try to eliminate.
|
||||
if (topLevelDescriptor.module.isForwardDeclarationModule) return null
|
||||
|
||||
//
|
||||
if (!topLevelDescriptor.shouldBeDeserialized()) return null
|
||||
|
||||
require(checkAccessibility(topLevelDescriptor)) {
|
||||
"Locally accessible declarations should not be accessed here $topLevelDescriptor"
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ internal val DeclarationDescriptor.isExpectMember: Boolean
|
||||
internal val DeclarationDescriptor.isSerializableExpectClass: Boolean
|
||||
get() = this is ClassDescriptor && ExpectedActualDeclarationChecker.shouldGenerateExpectClass(this)
|
||||
|
||||
internal tailrec fun DeclarationDescriptor.findPackage(): PackageFragmentDescriptor {
|
||||
tailrec fun DeclarationDescriptor.findPackage(): PackageFragmentDescriptor {
|
||||
return if (this is PackageFragmentDescriptor) this
|
||||
else this.containingDeclaration!!.findPackage()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user