[KLIB] Add a reliable mechanism to check if KLIB has IR inside

^KT-62341
This commit is contained in:
Dmitriy Dolovov
2023-10-05 12:21:51 +02:00
committed by Space Team
parent 4b2776e126
commit f276fe6506
3 changed files with 8 additions and 0 deletions
@@ -75,6 +75,7 @@ interface MetadataLibrary {
}
interface IrLibrary {
val hasIr: Boolean
val dataFlowGraph: ByteArray?
fun irDeclaration(index: Int, fileIndex: Int): ByteArray
fun type(index: Int, fileIndex: Int): ByteArray
@@ -89,6 +89,12 @@ class MetadataLibraryImpl(
abstract class IrLibraryImpl(
val access: IrLibraryAccess<IrKotlinLibraryLayout>
) : IrLibrary {
override val hasIr by lazy {
access.inPlace { it: IrKotlinLibraryLayout ->
it.irDir.exists
}
}
override val dataFlowGraph by lazy {
access.inPlace { it: IrKotlinLibraryLayout ->
it.dataFlowGraphFile.let { if (it.exists) it.readBytes() else null }