[KLIB] Use IrMessageLogger in klib linker to report errors
This commit is contained in:
@@ -82,12 +82,6 @@ val KotlinLibrary.isBuiltIns: Boolean
|
||||
fun loadKlib(klibPath: String) =
|
||||
resolveSingleFileKlib(KFile(KFile(klibPath).absolutePath))
|
||||
|
||||
val emptyLoggingContext = object : LoggingContext {
|
||||
override var inVerbosePhase = false
|
||||
|
||||
override fun log(message: () -> String) {}
|
||||
}
|
||||
|
||||
private val CompilerConfiguration.metadataVersion
|
||||
get() = get(CommonConfigurationKeys.METADATA_VERSION) as? KlibMetadataVersion ?: KlibMetadataVersion.INSTANCE
|
||||
|
||||
@@ -109,6 +103,7 @@ fun generateKLib(
|
||||
) {
|
||||
val incrementalDataProvider = configuration.get(JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER)
|
||||
val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
|
||||
val messageLogger = configuration.get(IrMessageLogger.IR_MESSAGE_LOGGER) ?: IrMessageLogger.None
|
||||
|
||||
val icData: List<KotlinFileSerializedData>
|
||||
val serializedIrFiles: List<SerializedIrFile>?
|
||||
@@ -154,7 +149,7 @@ fun generateKLib(
|
||||
}
|
||||
val irLinker = JsIrLinker(
|
||||
psi2IrContext.moduleDescriptor,
|
||||
emptyLoggingContext,
|
||||
messageLogger,
|
||||
psi2IrContext.irBuiltIns,
|
||||
psi2IrContext.symbolTable,
|
||||
functionFactory,
|
||||
@@ -166,7 +161,7 @@ fun generateKLib(
|
||||
irLinker.deserializeOnlyHeaderModule(depsDescriptors.getModuleDescriptor(it), it)
|
||||
}
|
||||
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, files, irLinker, expectDescriptorToSymbol)
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, files, irLinker, messageLogger, expectDescriptorToSymbol)
|
||||
|
||||
moduleFragment.acceptVoid(ManglerChecker(JsManglerIr, Ir2DescriptorManglerAdapter(JsManglerDesc)))
|
||||
if (configuration.getBoolean(JSConfigurationKeys.FAKE_OVERRIDE_VALIDATOR)) {
|
||||
@@ -184,6 +179,7 @@ fun generateKLib(
|
||||
moduleName,
|
||||
project,
|
||||
configuration,
|
||||
messageLogger,
|
||||
psi2IrContext.bindingContext,
|
||||
files,
|
||||
outputKlibPath,
|
||||
@@ -225,6 +221,7 @@ fun loadIr(
|
||||
): IrModuleInfo {
|
||||
val depsDescriptors = ModulesStructure(project, mainModule, analyzer, configuration, allDependencies, friendDependencies)
|
||||
val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
|
||||
val messageLogger = configuration.get(IrMessageLogger.IR_MESSAGE_LOGGER) ?: IrMessageLogger.None
|
||||
|
||||
when (mainModule) {
|
||||
is MainModule.SourceFiles -> {
|
||||
@@ -236,12 +233,12 @@ fun loadIr(
|
||||
val feContext = psi2IrContext.run {
|
||||
JsIrLinker.JsFePluginContext(moduleDescriptor, bindingContext, symbolTable, typeTranslator, irBuiltIns)
|
||||
}
|
||||
val irLinker = JsIrLinker(psi2IrContext.moduleDescriptor, emptyLoggingContext, irBuiltIns, symbolTable, functionFactory, feContext, null)
|
||||
val irLinker = JsIrLinker(psi2IrContext.moduleDescriptor, messageLogger, irBuiltIns, symbolTable, functionFactory, feContext, null)
|
||||
val deserializedModuleFragments = sortDependencies(allDependencies.getFullList(), depsDescriptors.descriptors).map {
|
||||
irLinker.deserializeIrModuleHeader(depsDescriptors.getModuleDescriptor(it), it)
|
||||
}
|
||||
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, mainModule.files, irLinker)
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, mainModule.files, irLinker, messageLogger)
|
||||
symbolTable.noUnboundLeft("Unbound symbols left after linker")
|
||||
|
||||
// TODO: not sure whether this check should be enabled by default. Add configuration key for it.
|
||||
@@ -273,7 +270,7 @@ fun loadIr(
|
||||
val irBuiltIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
val functionFactory = IrFunctionFactory(irBuiltIns, symbolTable)
|
||||
val irLinker =
|
||||
JsIrLinker(null, emptyLoggingContext, irBuiltIns, symbolTable, functionFactory, null, null)
|
||||
JsIrLinker(null, messageLogger, irBuiltIns, symbolTable, functionFactory, null, null)
|
||||
|
||||
val deserializedModuleFragments = sortDependencies(allDependencies.getFullList(), depsDescriptors.descriptors).map {
|
||||
val strategy =
|
||||
@@ -315,6 +312,7 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
|
||||
project: Project,
|
||||
files: List<KtFile>,
|
||||
irLinker: IrDeserializer,
|
||||
messageLogger: IrMessageLogger,
|
||||
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null
|
||||
): IrModuleFragment {
|
||||
val psi2Ir = Psi2IrTranslator(languageVersionSettings, configuration)
|
||||
@@ -466,6 +464,7 @@ fun serializeModuleIntoKlib(
|
||||
moduleName: String,
|
||||
project: Project,
|
||||
configuration: CompilerConfiguration,
|
||||
messageLogger: IrMessageLogger,
|
||||
bindingContext: BindingContext,
|
||||
files: List<KtFile>,
|
||||
klibPath: String,
|
||||
@@ -481,7 +480,7 @@ fun serializeModuleIntoKlib(
|
||||
|
||||
val serializedIr =
|
||||
JsIrModuleSerializer(
|
||||
emptyLoggingContext,
|
||||
messageLogger,
|
||||
moduleFragment.irBuiltins,
|
||||
expectDescriptorToSymbol = expectDescriptorToSymbol,
|
||||
skipExpects = !configuration.expectActualLinker
|
||||
|
||||
+5
-5
@@ -5,23 +5,23 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrAnnotationContainer
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class JsIrFileSerializer(
|
||||
logger: LoggingContext,
|
||||
messageLogger: IrMessageLogger,
|
||||
declarationTable: DeclarationTable,
|
||||
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>,
|
||||
skipExpects: Boolean,
|
||||
bodiesOnlyForInlines: Boolean = false
|
||||
) : IrFileSerializer(
|
||||
logger,
|
||||
messageLogger,
|
||||
declarationTable,
|
||||
expectDescriptorToSymbol,
|
||||
bodiesOnlyForInlines = bodiesOnlyForInlines,
|
||||
|
||||
+3
-3
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder
|
||||
import org.jetbrains.kotlin.backend.common.serialization.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
@@ -14,6 +13,7 @@ import org.jetbrains.kotlin.ir.builders.TranslationPluginContext
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrAbstractFunctionFactory
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
import org.jetbrains.kotlin.ir.util.ReferenceSymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
@@ -23,11 +23,11 @@ import org.jetbrains.kotlin.library.containsErrorCode
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
|
||||
class JsIrLinker(
|
||||
private val currentModule: ModuleDescriptor?, logger: LoggingContext, builtIns: IrBuiltIns, symbolTable: SymbolTable,
|
||||
private val currentModule: ModuleDescriptor?, messageLogger: IrMessageLogger, builtIns: IrBuiltIns, symbolTable: SymbolTable,
|
||||
override val functionalInterfaceFactory: IrAbstractFunctionFactory,
|
||||
override val translationPluginContext: TranslationPluginContext?,
|
||||
private val icData: ICData? = null
|
||||
) : KotlinIrLinker(currentModule, logger, builtIns, symbolTable, emptyList()) {
|
||||
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, emptyList()) {
|
||||
|
||||
override val fakeOverrideBuilder = FakeOverrideBuilder(this, symbolTable, IdSignatureSerializer(JsManglerIr), builtIns)
|
||||
|
||||
|
||||
+4
-4
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.LoggingContext
|
||||
import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable
|
||||
import org.jetbrains.kotlin.backend.common.serialization.IrModuleSerializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureSerializer
|
||||
@@ -13,17 +12,18 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
|
||||
class JsIrModuleSerializer(
|
||||
logger: LoggingContext,
|
||||
messageLogger: IrMessageLogger,
|
||||
irBuiltIns: IrBuiltIns,
|
||||
private val expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>,
|
||||
val skipExpects: Boolean
|
||||
) : IrModuleSerializer<JsIrFileSerializer>(logger) {
|
||||
) : IrModuleSerializer<JsIrFileSerializer>(messageLogger) {
|
||||
|
||||
private val signaturer = IdSignatureSerializer(JsManglerIr)
|
||||
private val globalDeclarationTable = JsGlobalDeclarationTable(signaturer, irBuiltIns)
|
||||
|
||||
override fun createSerializerForFile(file: IrFile): JsIrFileSerializer =
|
||||
JsIrFileSerializer(logger, DeclarationTable(globalDeclarationTable), expectDescriptorToSymbol, skipExpects = skipExpects)
|
||||
JsIrFileSerializer(messageLogger, DeclarationTable(globalDeclarationTable), expectDescriptorToSymbol, skipExpects = skipExpects)
|
||||
}
|
||||
Reference in New Issue
Block a user