[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:
Sergey Bogolepov
2019-10-29 11:56:07 +07:00
parent 5629627cca
commit 608885d118
8 changed files with 41 additions and 6 deletions
@@ -49,7 +49,7 @@ class DeclarationStubGenerator(
}
private val typeTranslator = TypeTranslator(lazyTable, languageVersionSettings, moduleDescriptor.builtIns, LazyScopedTypeParametersResolver(lazyTable), true)
val typeTranslator = TypeTranslator(lazyTable, languageVersionSettings, moduleDescriptor.builtIns, LazyScopedTypeParametersResolver(lazyTable), true)
private val constantValueGenerator = ConstantValueGenerator(moduleDescriptor, lazyTable)
private val facadeClassMap = mutableMapOf<DeserializedContainerSource, IrClass?>()
@@ -57,6 +57,7 @@ class DeclarationStubGenerator(
init {
typeTranslator.constantValueGenerator = constantValueGenerator
constantValueGenerator.typeTranslator = typeTranslator
irProviders.filterIsInstance<LazyIrProvider>().forEach { it.declarationStubGenerator = this }
}
private fun getDeclaration(symbol: IrSymbol): IrDeclaration? {
@@ -21,6 +21,7 @@ package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.*
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyDeclarationBase
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazySymbolTable
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
@@ -33,6 +34,16 @@ interface IrProvider {
fun getDeclaration(symbol: IrSymbol): IrDeclaration?
}
/**
* Extension of [IrProvider] which always produces inheritors of [IrLazyDeclarationBase].
* Thus, it needs [declarationStubGenerator] to be able to produce IR declarations.
*/
interface LazyIrProvider: IrProvider {
var declarationStubGenerator: DeclarationStubGenerator
override fun getDeclaration(symbol: IrSymbol): IrLazyDeclarationBase?
}
interface IrDeserializer : IrProvider {
fun declareForwardDeclarations()
}