[JS IR] IR module to name
Merge-request: KT-MR-5672 Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com>
This commit is contained in:
@@ -410,6 +410,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
|||||||
ir.context,
|
ir.context,
|
||||||
mainCallArguments,
|
mainCallArguments,
|
||||||
relativeRequirePath = true,
|
relativeRequirePath = true,
|
||||||
|
moduleToName = ir.moduleFragmentToUniqueName
|
||||||
)
|
)
|
||||||
|
|
||||||
transformer.generateModule(ir.allModules, setOf(TranslationMode.fromFlags(arguments.irDce, arguments.irPerModule)))
|
transformer.generateModule(ir.allModules, setOf(TranslationMode.fromFlags(arguments.irDce, arguments.irPerModule)))
|
||||||
@@ -421,6 +422,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
|||||||
dceJs = arguments.irDce,
|
dceJs = arguments.irDce,
|
||||||
multiModule = arguments.irPerModule,
|
multiModule = arguments.irPerModule,
|
||||||
relativeRequirePath = true,
|
relativeRequirePath = true,
|
||||||
|
moduleToName = ir.moduleFragmentToUniqueName
|
||||||
)
|
)
|
||||||
|
|
||||||
transformer.generateModule(ir.allModules)
|
transformer.generateModule(ir.allModules)
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ class CompilationOutputs(
|
|||||||
class LoweredIr(
|
class LoweredIr(
|
||||||
val context: JsIrBackendContext,
|
val context: JsIrBackendContext,
|
||||||
val mainModule: IrModuleFragment,
|
val mainModule: IrModuleFragment,
|
||||||
val allModules: List<IrModuleFragment>
|
val allModules: List<IrModuleFragment>,
|
||||||
|
val moduleFragmentToUniqueName: Map<IrModuleFragment, String>,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun compile(
|
fun compile(
|
||||||
@@ -60,7 +61,7 @@ fun compile(
|
|||||||
icCompatibleIr2Js: Boolean = false,
|
icCompatibleIr2Js: Boolean = false,
|
||||||
): LoweredIr {
|
): LoweredIr {
|
||||||
|
|
||||||
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer, moduleToName) =
|
||||||
loadIr(depsDescriptors, irFactory, verifySignatures, filesToLower, loadFunctionInterfacesIntoStdlib = true)
|
loadIr(depsDescriptors, irFactory, verifySignatures, filesToLower, loadFunctionInterfacesIntoStdlib = true)
|
||||||
|
|
||||||
return compileIr(
|
return compileIr(
|
||||||
@@ -68,6 +69,7 @@ fun compile(
|
|||||||
depsDescriptors.mainModule,
|
depsDescriptors.mainModule,
|
||||||
depsDescriptors.compilerConfiguration,
|
depsDescriptors.compilerConfiguration,
|
||||||
dependencyModules,
|
dependencyModules,
|
||||||
|
moduleToName,
|
||||||
irBuiltIns,
|
irBuiltIns,
|
||||||
symbolTable,
|
symbolTable,
|
||||||
deserializer,
|
deserializer,
|
||||||
@@ -88,6 +90,7 @@ fun compileIr(
|
|||||||
mainModule: MainModule,
|
mainModule: MainModule,
|
||||||
configuration: CompilerConfiguration,
|
configuration: CompilerConfiguration,
|
||||||
dependencyModules: List<IrModuleFragment>,
|
dependencyModules: List<IrModuleFragment>,
|
||||||
|
moduleToName: Map<IrModuleFragment, String>,
|
||||||
irBuiltIns: IrBuiltIns,
|
irBuiltIns: IrBuiltIns,
|
||||||
symbolTable: SymbolTable,
|
symbolTable: SymbolTable,
|
||||||
deserializer: JsIrLinker,
|
deserializer: JsIrLinker,
|
||||||
@@ -147,7 +150,7 @@ fun compileIr(
|
|||||||
lowerPreservingTags(allModules, context, phaseConfig, it)
|
lowerPreservingTags(allModules, context, phaseConfig, it)
|
||||||
} ?: jsPhases.invokeToplevel(phaseConfig, context, allModules)
|
} ?: jsPhases.invokeToplevel(phaseConfig, context, allModules)
|
||||||
|
|
||||||
return LoweredIr(context, moduleFragment, allModules)
|
return LoweredIr(context, moduleFragment, allModules, moduleToName)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateJsCode(
|
fun generateJsCode(
|
||||||
|
|||||||
+1
-1
@@ -331,7 +331,7 @@ fun generateWrappedModuleBody(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val dependencies = others.map { module ->
|
val dependencies = others.map { module ->
|
||||||
val moduleName = module.moduleName
|
val moduleName = module.externalModuleName
|
||||||
|
|
||||||
moduleName to generateSingleWrappedModuleBody(
|
moduleName to generateSingleWrappedModuleBody(
|
||||||
moduleName,
|
moduleName,
|
||||||
|
|||||||
@@ -244,7 +244,8 @@ data class IrModuleInfo(
|
|||||||
val allDependencies: List<IrModuleFragment>,
|
val allDependencies: List<IrModuleFragment>,
|
||||||
val bultins: IrBuiltIns,
|
val bultins: IrBuiltIns,
|
||||||
val symbolTable: SymbolTable,
|
val symbolTable: SymbolTable,
|
||||||
val deserializer: JsIrLinker
|
val deserializer: JsIrLinker,
|
||||||
|
val moduleFragmentToUniqueName: Map<IrModuleFragment, String>,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun sortDependencies(mapping: Map<KotlinLibrary, ModuleDescriptor>): Collection<KotlinLibrary> {
|
fun sortDependencies(mapping: Map<KotlinLibrary, ModuleDescriptor>): Collection<KotlinLibrary> {
|
||||||
@@ -390,7 +391,14 @@ fun getIrModuleInfoForKlib(
|
|||||||
ExternalDependenciesGenerator(symbolTable, listOf(irLinker)).generateUnboundSymbolsAsDependencies()
|
ExternalDependenciesGenerator(symbolTable, listOf(irLinker)).generateUnboundSymbolsAsDependencies()
|
||||||
irLinker.postProcess()
|
irLinker.postProcess()
|
||||||
|
|
||||||
return IrModuleInfo(moduleFragment, deserializedModuleFragments, irBuiltIns, symbolTable, irLinker)
|
return IrModuleInfo(
|
||||||
|
moduleFragment,
|
||||||
|
deserializedModuleFragments,
|
||||||
|
irBuiltIns,
|
||||||
|
symbolTable,
|
||||||
|
irLinker,
|
||||||
|
deserializedModuleFragmentsToLib.getUniqueNameForEachFragment()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||||
@@ -457,7 +465,14 @@ fun getIrModuleInfoForSourceFiles(
|
|||||||
irBuiltIns.knownBuiltins.forEach { it.acceptVoid(mangleChecker) }
|
irBuiltIns.knownBuiltins.forEach { it.acceptVoid(mangleChecker) }
|
||||||
}
|
}
|
||||||
|
|
||||||
return IrModuleInfo(moduleFragment, deserializedModuleFragments, irBuiltIns, symbolTable, irLinker)
|
return IrModuleInfo(
|
||||||
|
moduleFragment,
|
||||||
|
deserializedModuleFragments,
|
||||||
|
irBuiltIns,
|
||||||
|
symbolTable,
|
||||||
|
irLinker,
|
||||||
|
deserializedModuleFragmentsToLib.getUniqueNameForEachFragment()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun prepareAnalyzedSourceModule(
|
fun prepareAnalyzedSourceModule(
|
||||||
@@ -830,3 +845,11 @@ private fun KlibMetadataIncrementalSerializer(configuration: CompilerConfigurati
|
|||||||
skipExpects = !configuration.expectActualLinker,
|
skipExpects = !configuration.expectActualLinker,
|
||||||
allowErrorTypes = allowErrors
|
allowErrorTypes = allowErrors
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun Map<IrModuleFragment, KotlinLibrary>.getUniqueNameForEachFragment(): Map<IrModuleFragment, String> {
|
||||||
|
return this.entries.mapNotNull { (moduleFragment, klib) ->
|
||||||
|
klib.manifestProperties.getProperty(KLIB_PROPERTY_JS_OUTPUT_NAME)?.let {
|
||||||
|
moduleFragment to it
|
||||||
|
}
|
||||||
|
}.toMap()
|
||||||
|
}
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ class JsIrBackendFacade(
|
|||||||
MainModule.Klib(inputArtifact.outputFile.absolutePath),
|
MainModule.Klib(inputArtifact.outputFile.absolutePath),
|
||||||
configuration,
|
configuration,
|
||||||
dependencyModules,
|
dependencyModules,
|
||||||
|
emptyMap(),
|
||||||
irModuleFragment.irBuiltins,
|
irModuleFragment.irBuiltins,
|
||||||
symbolTable,
|
symbolTable,
|
||||||
deserializer,
|
deserializer,
|
||||||
|
|||||||
Reference in New Issue
Block a user