[Psi2Ir] Move to new linkage scheme based on IdSignature

Now SymbolTable operates with two types of symbols (public and private)
In case of Public symbol IdSignature is used as table key
Private one uses descriptor as the key in similar scheme as before
This commit is contained in:
Roman Artemev
2020-01-27 16:10:26 +03:00
committed by romanart
parent df7b7cf61a
commit 31d73c5d79
17 changed files with 433 additions and 206 deletions
@@ -200,7 +200,9 @@ fun loadIr(
}
is MainModule.Klib -> {
val moduleDescriptor = depsDescriptors.getModuleDescriptor(mainModule.lib)
val symbolTable = SymbolTable()
val mangler = JsManglerDesc
val signaturer = IdSignatureDescriptor(mangler)
val symbolTable = SymbolTable(signaturer)
val constantValueGenerator = ConstantValueGenerator(moduleDescriptor, symbolTable)
val typeTranslator = TypeTranslator(
symbolTable,
@@ -209,8 +211,8 @@ fun loadIr(
)
typeTranslator.constantValueGenerator = constantValueGenerator
constantValueGenerator.typeTranslator = typeTranslator
val irBuiltIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, symbolTable)
val deserializer = JsIrLinker(moduleDescriptor, JsMangler, emptyLoggingContext, irBuiltIns, symbolTable)
val irBuiltIns = IrBuiltIns(moduleDescriptor.builtIns, typeTranslator, signaturer, symbolTable)
val deserializer = JsIrLinker(emptyLoggingContext, irBuiltIns, symbolTable)
val deserializedModuleFragments = sortDependencies(allDependencies.getFullList(), depsDescriptors.descriptors).map {
val strategy =
@@ -234,14 +236,17 @@ fun loadIr(
private fun runAnalysisAndPreparePsi2Ir(depsDescriptors: ModulesStructure): GeneratorContext {
val analysisResult = depsDescriptors.runAnalysis()
val mangler = JsManglerDesc
val signaturer = IdSignatureDescriptor(mangler)
return GeneratorContext(
Psi2IrConfiguration(),
analysisResult.moduleDescriptor,
analysisResult.bindingContext,
depsDescriptors.compilerConfiguration.languageVersionSettings,
SymbolTable(),
JsGeneratorExtensions()
SymbolTable(signaturer),
GeneratorExtensions(),
signaturer
)
}
@@ -252,7 +257,8 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null
): IrModuleFragment {
val irProviders = generateTypicalIrProviderList(moduleDescriptor, irBuiltIns, symbolTable, deserializer)
val psi2Ir = Psi2IrTranslator(languageVersionSettings, configuration, mangler = JsMangler)
val signaturer = IdSignatureDescriptor(JsManglerDesc)
val psi2Ir = Psi2IrTranslator(languageVersionSettings, configuration, signaturer)
for (extension in IrGenerationExtension.getInstances(project)) {
psi2Ir.addPostprocessingStep { module ->
@@ -282,8 +288,10 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
fun GeneratorContext.generateModuleFragment(files: List<KtFile>, deserializer: IrDeserializer? = null, expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null): IrModuleFragment {
val irProviders = generateTypicalIrProviderList(moduleDescriptor, irBuiltIns, symbolTable, deserializer)
val mangler = JsManglerDesc
val signaturer = IdSignatureDescriptor(mangler)
return Psi2IrTranslator(
languageVersionSettings, configuration, mangler = JsMangler
languageVersionSettings, configuration, signaturer
).generateModuleFragment(this, files, irProviders, expectDescriptorToSymbol)
}