[IR] Partial linkage: Enable it by just passing a boolean flag to IR linker constructor
This commit is contained in:
committed by
Space Team
parent
a0fdf08b56
commit
15635482aa
+1
-1
@@ -49,7 +49,7 @@ internal class JsIrLinkerLoader(
|
||||
val moduleDescriptor = loadedModules.keys.last()
|
||||
val typeTranslator = TypeTranslatorImpl(symbolTable, compilerConfiguration.languageVersionSettings, moduleDescriptor)
|
||||
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
return JsIrLinker(null, compilerConfiguration.irMessageLogger, irBuiltIns, symbolTable, null)
|
||||
return JsIrLinker(null, compilerConfiguration.irMessageLogger, irBuiltIns, symbolTable, partialLinkageEnabled = false, null)
|
||||
}
|
||||
|
||||
private fun loadModules(): Map<ModuleDescriptor, KotlinLibrary> {
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ open class JvmIrCodegenFactory(
|
||||
input.languageVersionSettings,
|
||||
Psi2IrConfiguration(
|
||||
input.ignoreErrors,
|
||||
allowUnboundSymbols = false,
|
||||
partialLinkageEnabled = false,
|
||||
input.skipBodies
|
||||
),
|
||||
messageLogger::checkNoUnboundSymbols
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.psi2ir
|
||||
|
||||
class Psi2IrConfiguration(
|
||||
val ignoreErrors: Boolean = false,
|
||||
val allowUnboundSymbols: Boolean = false,
|
||||
val partialLinkageEnabled: Boolean = false,
|
||||
val skipBodies: Boolean = false,
|
||||
) {
|
||||
val generateBodies: Boolean
|
||||
|
||||
@@ -113,7 +113,7 @@ class Psi2IrTranslator(
|
||||
}
|
||||
|
||||
private fun GeneratorContext.checkNoUnboundSymbols(whenDetected: () -> String) {
|
||||
if (!configuration.allowUnboundSymbols)
|
||||
if (!configuration.partialLinkageEnabled)
|
||||
checkNoUnboundSymbols(symbolTable, whenDetected())
|
||||
}
|
||||
}
|
||||
|
||||
+9
-3
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.backend.common.overrides.FileLocalAwareLinker
|
||||
import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData
|
||||
import org.jetbrains.kotlin.backend.common.serialization.linkerissues.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupport
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupportImpl
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
@@ -30,6 +31,7 @@ abstract class KotlinIrLinker(
|
||||
val builtIns: IrBuiltIns,
|
||||
val symbolTable: SymbolTable,
|
||||
private val exportedDependencies: List<ModuleDescriptor>,
|
||||
partialLinkageEnabled: Boolean,
|
||||
val symbolProcessor: IrSymbolDeserializer.(IrSymbol, IdSignature) -> IrSymbol = { s, _ -> s },
|
||||
) : IrDeserializer, FileLocalAwareLinker {
|
||||
|
||||
@@ -51,7 +53,11 @@ abstract class KotlinIrLinker(
|
||||
|
||||
private lateinit var linkerExtensions: Collection<IrDeserializer.IrLinkerExtension>
|
||||
|
||||
open val unlinkedDeclarationsSupport: UnlinkedDeclarationsSupport get() = UnlinkedDeclarationsSupport.DISABLED
|
||||
val unlinkedDeclarationsSupport: UnlinkedDeclarationsSupport = if (partialLinkageEnabled)
|
||||
UnlinkedDeclarationsSupportImpl(builtIns)
|
||||
else
|
||||
UnlinkedDeclarationsSupport.DISABLED
|
||||
|
||||
protected open val userVisibleIrModulesSupport: UserVisibleIrModulesSupport get() = UserVisibleIrModulesSupport.DEFAULT
|
||||
|
||||
fun deserializeOrReturnUnboundIrSymbolIfPartialLinkageEnabled(
|
||||
@@ -72,7 +78,7 @@ abstract class KotlinIrLinker(
|
||||
val symbol: IrSymbol? = actualModuleDeserializer?.tryDeserializeIrSymbol(idSignature, symbolKind)
|
||||
|
||||
return symbol ?: run {
|
||||
if (unlinkedDeclarationsSupport.allowUnboundSymbols)
|
||||
if (unlinkedDeclarationsSupport.partialLinkageEnabled)
|
||||
referenceDeserializedSymbol(symbolTable, null, symbolKind, idSignature)
|
||||
else
|
||||
SignatureIdNotFoundInModuleWithDependencies(
|
||||
@@ -164,7 +170,7 @@ abstract class KotlinIrLinker(
|
||||
?: tryResolveCustomDeclaration(symbol)
|
||||
?: return null
|
||||
} catch (e: IrSymbolTypeMismatchException) {
|
||||
if (!unlinkedDeclarationsSupport.allowUnboundSymbols) {
|
||||
if (!unlinkedDeclarationsSupport.partialLinkageEnabled) {
|
||||
SymbolTypeMismatch(e, deserializersForModules.values, userVisibleIrModulesSupport).raiseIssue(messageLogger)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ internal inline fun <reified T : IrAnnotationContainer> checkErrorNodesAllowed(e
|
||||
|
||||
// N.B. Checks for absence of unbound symbols only when unbound symbols are not allowed.
|
||||
fun KotlinIrLinker.checkNoUnboundSymbols(symbolTable: SymbolTable, whenDetected: String) {
|
||||
if (!unlinkedDeclarationsSupport.allowUnboundSymbols)
|
||||
if (!unlinkedDeclarationsSupport.partialLinkageEnabled)
|
||||
messageLogger.checkNoUnboundSymbols(symbolTable, whenDetected)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
|
||||
interface UnlinkedDeclarationsSupport {
|
||||
val allowUnboundSymbols: Boolean
|
||||
val partialLinkageEnabled: Boolean
|
||||
|
||||
/** For general use in IR linker. */
|
||||
fun markUsedClassifiersExcludingUnlinkedFromFakeOverrideBuilding(fakeOverrideBuilder: FakeOverrideBuilder)
|
||||
@@ -29,7 +29,7 @@ interface UnlinkedDeclarationsSupport {
|
||||
|
||||
companion object {
|
||||
val DISABLED = object : UnlinkedDeclarationsSupport {
|
||||
override val allowUnboundSymbols get() = false
|
||||
override val partialLinkageEnabled get() = false
|
||||
override fun markUsedClassifiersExcludingUnlinkedFromFakeOverrideBuilding(fakeOverrideBuilder: FakeOverrideBuilder) = Unit
|
||||
override fun markUsedClassifiersInInlineLazyIrFunction(function: IrFunction) = Unit
|
||||
override fun processUnlinkedDeclarations(messageLogger: IrMessageLogger, lazyRoots: () -> List<IrElement>) = Unit
|
||||
|
||||
+3
-10
@@ -28,10 +28,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||
|
||||
class UnlinkedDeclarationsSupportImpl(
|
||||
private val builtIns: IrBuiltIns,
|
||||
override val allowUnboundSymbols: Boolean
|
||||
) : UnlinkedDeclarationsSupport {
|
||||
class UnlinkedDeclarationsSupportImpl(private val builtIns: IrBuiltIns) : UnlinkedDeclarationsSupport {
|
||||
private val handler = object : UnlinkedMarkerTypeHandler {
|
||||
override val unlinkedMarkerType = IrSimpleTypeImpl(
|
||||
classifier = builtIns.anyClass,
|
||||
@@ -45,9 +42,9 @@ class UnlinkedDeclarationsSupportImpl(
|
||||
|
||||
private val usedClassifierSymbols = UsedClassifierSymbols()
|
||||
|
||||
override fun markUsedClassifiersExcludingUnlinkedFromFakeOverrideBuilding(fakeOverrideBuilder: FakeOverrideBuilder) {
|
||||
if (!allowUnboundSymbols) return
|
||||
override val partialLinkageEnabled get() = true
|
||||
|
||||
override fun markUsedClassifiersExcludingUnlinkedFromFakeOverrideBuilding(fakeOverrideBuilder: FakeOverrideBuilder) {
|
||||
val entries = fakeOverrideBuilder.fakeOverrideCandidates
|
||||
if (entries.isEmpty()) return
|
||||
|
||||
@@ -114,8 +111,6 @@ class UnlinkedDeclarationsSupportImpl(
|
||||
}
|
||||
|
||||
override fun markUsedClassifiersInInlineLazyIrFunction(function: IrFunction) {
|
||||
if (!allowUnboundSymbols) return
|
||||
|
||||
function.acceptChildrenVoid(object : IrElementVisitorVoid {
|
||||
override fun visitElement(element: IrElement) {
|
||||
element.acceptChildrenVoid(this)
|
||||
@@ -173,8 +168,6 @@ class UnlinkedDeclarationsSupportImpl(
|
||||
}
|
||||
|
||||
override fun processUnlinkedDeclarations(messageLogger: IrMessageLogger, lazyRoots: () -> List<IrElement>) {
|
||||
if (!allowUnboundSymbols) return
|
||||
|
||||
val processor = UnlinkedDeclarationsProcessor(builtIns, usedClassifierSymbols, handler, messageLogger)
|
||||
processor.addLinkageErrorIntoUnlinkedClasses()
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDes
|
||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataIncrementalSerializer
|
||||
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataVersion
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupportImpl
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
@@ -121,7 +120,7 @@ fun generateIrForKlibSerialization(
|
||||
val incrementalDataProvider = configuration.get(JSConfigurationKeys.INCREMENTAL_DATA_PROVIDER)
|
||||
val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
|
||||
val messageLogger = configuration.irMessageLogger
|
||||
val allowUnboundSymbols = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
val partialLinkageEnabled = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
|
||||
val serializedIrFiles = mutableListOf<SerializedIrFile>()
|
||||
|
||||
@@ -152,7 +151,7 @@ fun generateIrForKlibSerialization(
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), irFactory)
|
||||
val psi2Ir = Psi2IrTranslator(
|
||||
configuration.languageVersionSettings,
|
||||
Psi2IrConfiguration(errorPolicy.allowErrors, allowUnboundSymbols),
|
||||
Psi2IrConfiguration(errorPolicy.allowErrors, partialLinkageEnabled),
|
||||
messageLogger::checkNoUnboundSymbols
|
||||
)
|
||||
val psi2IrContext = psi2Ir.createGeneratorContext(analysisResult.moduleDescriptor, analysisResult.bindingContext, symbolTable)
|
||||
@@ -172,6 +171,7 @@ fun generateIrForKlibSerialization(
|
||||
messageLogger,
|
||||
psi2IrContext.irBuiltIns,
|
||||
psi2IrContext.symbolTable,
|
||||
partialLinkageEnabled = false,
|
||||
feContext,
|
||||
ICData(serializedIrFiles, errorPolicy.allowErrors),
|
||||
stubGenerator = stubGenerator
|
||||
@@ -313,7 +313,7 @@ fun loadIr(
|
||||
val allDependencies = depsDescriptors.allDependencies.map { it.library }
|
||||
val errorPolicy = configuration.get(JSConfigurationKeys.ERROR_TOLERANCE_POLICY) ?: ErrorTolerancePolicy.DEFAULT
|
||||
val messageLogger = configuration.irMessageLogger
|
||||
val allowUnboundSymbol = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
val partialLinkageEnabled = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
|
||||
val signaturer = IdSignatureDescriptor(JsManglerDesc)
|
||||
val symbolTable = SymbolTable(signaturer, irFactory)
|
||||
@@ -321,7 +321,7 @@ fun loadIr(
|
||||
when (mainModule) {
|
||||
is MainModule.SourceFiles -> {
|
||||
assert(filesToLoad == null)
|
||||
val psi2IrContext = preparePsi2Ir(depsDescriptors, errorPolicy, symbolTable, allowUnboundSymbol)
|
||||
val psi2IrContext = preparePsi2Ir(depsDescriptors, errorPolicy, symbolTable, partialLinkageEnabled)
|
||||
val friendModules =
|
||||
mapOf(psi2IrContext.moduleDescriptor.name.asString() to depsDescriptors.friendDependencies.map { it.library.uniqueName })
|
||||
|
||||
@@ -376,18 +376,17 @@ fun getIrModuleInfoForKlib(
|
||||
val typeTranslator = TypeTranslatorImpl(symbolTable, configuration.languageVersionSettings, moduleDescriptor)
|
||||
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
|
||||
val allowUnboundSymbols = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
val unlinkedDeclarationsSupport = UnlinkedDeclarationsSupportImpl(irBuiltIns, allowUnboundSymbols)
|
||||
val partialLinkageEnabled = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
|
||||
val irLinker = JsIrLinker(
|
||||
currentModule = null,
|
||||
messageLogger = messageLogger,
|
||||
builtIns = irBuiltIns,
|
||||
symbolTable = symbolTable,
|
||||
partialLinkageEnabled = partialLinkageEnabled,
|
||||
translationPluginContext = null,
|
||||
icData = null,
|
||||
friendModules = friendModules,
|
||||
unlinkedDeclarationsSupport = unlinkedDeclarationsSupport
|
||||
friendModules = friendModules
|
||||
)
|
||||
|
||||
val deserializedModuleFragmentsToLib = deserializeDependencies(sortedDependencies, irLinker, mainModuleLib, filesToLoad, mapping)
|
||||
@@ -435,18 +434,17 @@ fun getIrModuleInfoForSourceFiles(
|
||||
JsIrLinker.JsFePluginContext(moduleDescriptor, symbolTable, typeTranslator, irBuiltIns)
|
||||
}
|
||||
|
||||
val allowUnboundSymbols = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
val unlinkedDeclarationsSupport = UnlinkedDeclarationsSupportImpl(irBuiltIns, allowUnboundSymbols)
|
||||
val partialLinkageEnabled = configuration[JSConfigurationKeys.PARTIAL_LINKAGE] ?: false
|
||||
|
||||
val irLinker = JsIrLinker(
|
||||
currentModule = psi2IrContext.moduleDescriptor,
|
||||
messageLogger = messageLogger,
|
||||
builtIns = irBuiltIns,
|
||||
symbolTable = symbolTable,
|
||||
partialLinkageEnabled = partialLinkageEnabled,
|
||||
translationPluginContext = feContext,
|
||||
icData = null,
|
||||
friendModules = friendModules,
|
||||
unlinkedDeclarationsSupport = unlinkedDeclarationsSupport
|
||||
)
|
||||
val deserializedModuleFragmentsToLib = deserializeDependencies(allSortedDependencies, irLinker, null,null, mapping)
|
||||
val deserializedModuleFragments = deserializedModuleFragmentsToLib.keys.toList()
|
||||
@@ -506,12 +504,12 @@ private fun preparePsi2Ir(
|
||||
depsDescriptors: ModulesStructure,
|
||||
errorIgnorancePolicy: ErrorTolerancePolicy,
|
||||
symbolTable: SymbolTable,
|
||||
allowUnboundSymbols: Boolean
|
||||
partialLinkageEnabled: Boolean
|
||||
): GeneratorContext {
|
||||
val analysisResult = depsDescriptors.jsFrontEndResult
|
||||
val psi2Ir = Psi2IrTranslator(
|
||||
depsDescriptors.compilerConfiguration.languageVersionSettings,
|
||||
Psi2IrConfiguration(errorIgnorancePolicy.allowErrors, allowUnboundSymbols),
|
||||
Psi2IrConfiguration(errorIgnorancePolicy.allowErrors, partialLinkageEnabled),
|
||||
depsDescriptors.compilerConfiguration::checkNoUnboundSymbols
|
||||
)
|
||||
return psi2Ir.createGeneratorContext(
|
||||
|
||||
+2
-6
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder
|
||||
import org.jetbrains.kotlin.backend.common.serialization.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupport
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupportImpl
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.builders.TranslationPluginContext
|
||||
@@ -22,13 +20,10 @@ import org.jetbrains.kotlin.library.containsErrorCode
|
||||
|
||||
class JsIrLinker(
|
||||
private val currentModule: ModuleDescriptor?, messageLogger: IrMessageLogger, builtIns: IrBuiltIns, symbolTable: SymbolTable,
|
||||
partialLinkageEnabled: Boolean,
|
||||
override val translationPluginContext: TranslationPluginContext?,
|
||||
private val icData: ICData? = null,
|
||||
friendModules: Map<String, Collection<String>> = emptyMap(),
|
||||
override val unlinkedDeclarationsSupport: UnlinkedDeclarationsSupport = UnlinkedDeclarationsSupportImpl(
|
||||
builtIns,
|
||||
allowUnboundSymbols = false
|
||||
),
|
||||
private val stubGenerator: DeclarationStubGenerator? = null
|
||||
) : KotlinIrLinker(
|
||||
currentModule = currentModule,
|
||||
@@ -36,6 +31,7 @@ class JsIrLinker(
|
||||
builtIns = builtIns,
|
||||
symbolTable = symbolTable,
|
||||
exportedDependencies = emptyList(),
|
||||
partialLinkageEnabled = partialLinkageEnabled,
|
||||
symbolProcessor = { symbol, idSig ->
|
||||
if (idSig.isLocal) {
|
||||
symbol.privateSignature = IdSignature.CompositeSignature(IdSignature.FileSignature(fileSymbol), idSig)
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ class JvmIrLinker(
|
||||
private val stubGenerator: DeclarationStubGenerator,
|
||||
private val manglerDesc: JvmDescriptorMangler,
|
||||
private val enableIdSignatures: Boolean,
|
||||
) : KotlinIrLinker(currentModule, messageLogger, typeSystem.irBuiltIns, symbolTable, emptyList()) {
|
||||
) : KotlinIrLinker(currentModule, messageLogger, typeSystem.irBuiltIns, symbolTable, emptyList(), partialLinkageEnabled = false) {
|
||||
|
||||
// TODO: provide friend modules
|
||||
override val fakeOverrideBuilder = FakeOverrideBuilder(this, symbolTable, JvmIrMangler, typeSystem, emptyMap())
|
||||
|
||||
@@ -224,7 +224,7 @@ abstract class AbstractKlibTextTestCase : CodegenTestCase() {
|
||||
val typeTranslator =
|
||||
TypeTranslatorImpl(symbolTable, myEnvironment.configuration.languageVersionSettings, testDescriptor)
|
||||
val irBuiltIns = IrBuiltInsOverDescriptors(testDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
val irLinker = JsIrLinker(null, IrMessageLogger.None, irBuiltIns, symbolTable, null)
|
||||
val irLinker = JsIrLinker(null, IrMessageLogger.None, irBuiltIns, symbolTable, partialLinkageEnabled = false, null)
|
||||
irLinker.deserializeIrModuleHeader(stdlibDescriptor, stdlib)
|
||||
val testModule = irLinker.deserializeIrModuleHeader(testDescriptor, klib, { DeserializationStrategy.ALL })
|
||||
irLinker.init(null, emptyList())
|
||||
@@ -290,7 +290,7 @@ abstract class AbstractKlibTextTestCase : CodegenTestCase() {
|
||||
val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl, NameProvider.DEFAULT)
|
||||
val context = psi2Ir.createGeneratorContext(moduleDescriptor, bindingContext, symbolTable)
|
||||
val irBuiltIns = context.irBuiltIns
|
||||
val irLinker = JsIrLinker(moduleDescriptor, messageLogger, irBuiltIns, symbolTable, null)
|
||||
val irLinker = JsIrLinker(moduleDescriptor, messageLogger, irBuiltIns, symbolTable, partialLinkageEnabled = false, null)
|
||||
irLinker.deserializeIrModuleHeader(stdlibDescriptor, stdlib)
|
||||
|
||||
return psi2Ir.generateModuleFragment(context, ktFiles, listOf(irLinker), emptyList(), expectActualSymbols) to bindingContext
|
||||
|
||||
@@ -473,6 +473,7 @@ class GenerateIrRuntime {
|
||||
messageLogger,
|
||||
psi2IrContext.irBuiltIns,
|
||||
psi2IrContext.symbolTable,
|
||||
partialLinkageEnabled = false,
|
||||
null
|
||||
)
|
||||
|
||||
@@ -548,7 +549,7 @@ class GenerateIrRuntime {
|
||||
val typeTranslator = TypeTranslatorImpl(symbolTable, languageVersionSettings, moduleDescriptor)
|
||||
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
|
||||
val jsLinker = JsIrLinker(moduleDescriptor, IrMessageLogger.None, irBuiltIns, symbolTable, null)
|
||||
val jsLinker = JsIrLinker(moduleDescriptor, IrMessageLogger.None, irBuiltIns, symbolTable, partialLinkageEnabled = false, null)
|
||||
|
||||
val moduleFragment = jsLinker.deserializeFullModule(moduleDescriptor, moduleDescriptor.kotlinLibrary)
|
||||
jsLinker.init(null, emptyList())
|
||||
@@ -573,7 +574,7 @@ class GenerateIrRuntime {
|
||||
val typeTranslator = TypeTranslatorImpl(symbolTable, languageVersionSettings, moduleDescriptor)
|
||||
val irBuiltIns = IrBuiltInsOverDescriptors(moduleDescriptor.builtIns, typeTranslator, symbolTable)
|
||||
|
||||
val jsLinker = JsIrLinker(moduleDescriptor, IrMessageLogger.None, irBuiltIns, symbolTable, null)
|
||||
val jsLinker = JsIrLinker(moduleDescriptor, IrMessageLogger.None, irBuiltIns, symbolTable, partialLinkageEnabled = false, null)
|
||||
|
||||
val moduleFragment = jsLinker.deserializeFullModule(moduleDescriptor, moduleDescriptor.kotlinLibrary)
|
||||
// Create stubs
|
||||
|
||||
+3
-6
@@ -7,7 +7,6 @@ import org.jetbrains.kotlin.backend.common.serialization.DescriptorByIdSignature
|
||||
import org.jetbrains.kotlin.backend.common.serialization.linkerissues.checkNoUnboundSymbols
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.ManglerChecker
|
||||
import org.jetbrains.kotlin.backend.common.serialization.mangle.descriptor.Ir2DescriptorManglerAdapter
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupportImpl
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isForwardDeclarationModule
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.isFromInteropLibrary
|
||||
import org.jetbrains.kotlin.backend.konan.ir.KonanSymbols
|
||||
@@ -52,11 +51,11 @@ internal fun Context.psiToIr(
|
||||
val expectActualLinker = config.configuration[CommonConfigurationKeys.EXPECT_ACTUAL_LINKER] ?: false
|
||||
val messageLogger = config.configuration[IrMessageLogger.IR_MESSAGE_LOGGER] ?: IrMessageLogger.None
|
||||
|
||||
val allowUnboundSymbols = config.configuration[KonanConfigKeys.PARTIAL_LINKAGE] ?: false
|
||||
val partialLinkageEnabled = config.configuration[KonanConfigKeys.PARTIAL_LINKAGE] ?: false
|
||||
|
||||
val translator = Psi2IrTranslator(
|
||||
config.configuration.languageVersionSettings,
|
||||
Psi2IrConfiguration(ignoreErrors = false, allowUnboundSymbols = allowUnboundSymbols),
|
||||
Psi2IrConfiguration(ignoreErrors = false, partialLinkageEnabled),
|
||||
messageLogger::checkNoUnboundSymbols
|
||||
)
|
||||
val generatorContext = translator.createGeneratorContext(moduleDescriptor, bindingContext, symbolTable)
|
||||
@@ -123,8 +122,6 @@ internal fun Context.psiToIr(
|
||||
config.resolve.includedLibraries.map { it.uniqueName }
|
||||
).associateWith { friendModules }
|
||||
|
||||
val unlinkedDeclarationsSupport = UnlinkedDeclarationsSupportImpl(generatorContext.irBuiltIns, allowUnboundSymbols)
|
||||
|
||||
KonanIrLinker(
|
||||
currentModule = moduleDescriptor,
|
||||
translationPluginContext = translationContext,
|
||||
@@ -136,10 +133,10 @@ internal fun Context.psiToIr(
|
||||
stubGenerator = stubGenerator,
|
||||
cenumsProvider = irProviderForCEnumsAndCStructs,
|
||||
exportedDependencies = exportedDependencies,
|
||||
partialLinkageEnabled = partialLinkageEnabled,
|
||||
cachedLibraries = config.cachedLibraries,
|
||||
lazyIrForCaches = config.lazyIrForCaches,
|
||||
libraryBeingCached = config.libraryToCache,
|
||||
unlinkedDeclarationsSupport = unlinkedDeclarationsSupport,
|
||||
userVisibleIrModulesSupport = config.userVisibleIrModulesSupport
|
||||
).also { linker ->
|
||||
|
||||
|
||||
+2
-5
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.backend.common.serialization.encodings.BinaryNameAnd
|
||||
import org.jetbrains.kotlin.backend.common.serialization.encodings.BinarySymbolData
|
||||
import org.jetbrains.kotlin.backend.common.serialization.encodings.FunctionFlags
|
||||
import org.jetbrains.kotlin.backend.common.serialization.linkerissues.UserVisibleIrModulesSupport
|
||||
import org.jetbrains.kotlin.backend.common.serialization.unlinked.UnlinkedDeclarationsSupport
|
||||
import org.jetbrains.kotlin.backend.konan.*
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.ClassLayoutBuilder
|
||||
import org.jetbrains.kotlin.backend.konan.descriptors.findPackage
|
||||
@@ -42,8 +41,6 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.lazy.IrLazyClass
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
@@ -320,12 +317,12 @@ internal class KonanIrLinker(
|
||||
private val stubGenerator: DeclarationStubGenerator,
|
||||
private val cenumsProvider: IrProviderForCEnumAndCStructStubs,
|
||||
exportedDependencies: List<ModuleDescriptor>,
|
||||
partialLinkageEnabled: Boolean,
|
||||
private val cachedLibraries: CachedLibraries,
|
||||
private val lazyIrForCaches: Boolean,
|
||||
private val libraryBeingCached: PartialCacheInfo?,
|
||||
override val unlinkedDeclarationsSupport: UnlinkedDeclarationsSupport,
|
||||
override val userVisibleIrModulesSupport: UserVisibleIrModulesSupport
|
||||
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, exportedDependencies) {
|
||||
) : KotlinIrLinker(currentModule, messageLogger, builtIns, symbolTable, exportedDependencies, partialLinkageEnabled) {
|
||||
|
||||
companion object {
|
||||
private val C_NAMES_NAME = Name.identifier("cnames")
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class JsScriptDependencyCompiler(
|
||||
|
||||
val typeTranslator = TypeTranslatorImpl(symbolTable, languageVersionSettings, moduleDescriptor)
|
||||
val irBuiltIns = IrBuiltInsOverDescriptors(builtIns, typeTranslator, symbolTable)
|
||||
val jsLinker = JsIrLinker(null, messageLogger, irBuiltIns, symbolTable, null)
|
||||
val jsLinker = JsIrLinker(null, messageLogger, irBuiltIns, symbolTable, partialLinkageEnabled = false, null)
|
||||
|
||||
val irDependencies = dependencies.map { jsLinker.deserializeFullModule(it, it.kotlinLibrary) }
|
||||
val moduleFragment = irDependencies.last()
|
||||
|
||||
Reference in New Issue
Block a user