[JS IR] Replace IrModuleToJsTransformer with IrModuleToJsTransformerTmp
This commit is contained in:
committed by
Space Team
parent
2ec07b861b
commit
d17794481d
@@ -82,15 +82,10 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
val mainCallArguments: List<String>?
|
||||
) {
|
||||
private fun lowerIr(): LoweredIr {
|
||||
val irFactory = when {
|
||||
arguments.irNewIr2Js -> IrFactoryImplForJsIC(WholeWorldStageController())
|
||||
else -> IrFactoryImpl
|
||||
}
|
||||
|
||||
return compile(
|
||||
module,
|
||||
phaseConfig,
|
||||
irFactory,
|
||||
IrFactoryImplForJsIC(WholeWorldStageController()),
|
||||
keep = arguments.irKeep?.split(",")
|
||||
?.filterNot { it.isEmpty() }
|
||||
?.toSet()
|
||||
@@ -106,7 +101,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
messageCollector
|
||||
),
|
||||
granularity = arguments.granularity,
|
||||
icCompatibleIr2Js = arguments.irNewIr2Js,
|
||||
icCompatibleIr2Js = true,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -123,22 +118,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
val out = generator.generateJsCode(relativeRequirePath = true, outJsProgram = false)
|
||||
return TransformResult(out, dts)
|
||||
}
|
||||
|
||||
fun compileAndTransformIrOld(): TransformResult {
|
||||
val ir = lowerIr()
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
ir.context,
|
||||
mainCallArguments,
|
||||
fullJs = !arguments.irDce,
|
||||
dceJs = arguments.irDce,
|
||||
multiModule = arguments.irPerModule,
|
||||
relativeRequirePath = true,
|
||||
moduleToName = ir.moduleFragmentToUniqueName
|
||||
)
|
||||
|
||||
val result = transformer.generateModule(ir.allModules)
|
||||
return TransformResult(result.outputs.values.single(), result.tsDefinitions ?: error("No ts definitions"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -427,12 +406,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
val start = System.currentTimeMillis()
|
||||
|
||||
try {
|
||||
|
||||
val (outputs, tsDefinitions) = if (arguments.irNewIr2Js) {
|
||||
Ir2JsTransformer(arguments, module, phaseConfig, messageCollector, mainCallArguments).compileAndTransformIrNew()
|
||||
} else {
|
||||
Ir2JsTransformer(arguments, module, phaseConfig, messageCollector, mainCallArguments).compileAndTransformIrOld()
|
||||
}
|
||||
val ir2JsTransformer = Ir2JsTransformer(arguments, module, phaseConfig, messageCollector, mainCallArguments)
|
||||
val (outputs, tsDefinitions) = ir2JsTransformer.compileAndTransformIrNew()
|
||||
|
||||
messageCollector.report(INFO, "Executable production duration: ${System.currentTimeMillis() - start}ms")
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.backend.js.lower.collectNativeImplementations
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.generateJsTests
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.moveBodilessDeclarationsToSeparatePlace
|
||||
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsIrLinker
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.TranslationMode
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.NameTables
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFactory
|
||||
@@ -160,21 +159,6 @@ fun compileIr(
|
||||
return LoweredIr(context, moduleFragment, allModules, moduleToName)
|
||||
}
|
||||
|
||||
fun generateJsCode(
|
||||
context: JsIrBackendContext,
|
||||
moduleFragment: IrModuleFragment,
|
||||
nameTables: NameTables
|
||||
): String {
|
||||
if (context.configuration.getBoolean(JSConfigurationKeys.GENERATE_POLYFILLS)) {
|
||||
collectNativeImplementations(context, moduleFragment)
|
||||
}
|
||||
moveBodilessDeclarationsToSeparatePlace(context, moduleFragment)
|
||||
jsPhases.invokeToplevel(PhaseConfig(jsPhases), context, listOf(moduleFragment))
|
||||
|
||||
val transformer = IrModuleToJsTransformer(context, null, true, nameTables)
|
||||
return transformer.generateModule(listOf(moduleFragment)).outputs[TranslationMode.FULL]!!.jsCode
|
||||
}
|
||||
|
||||
fun CompilationOutputs.writeSourceMapIfPresent(outputJsFile: File) {
|
||||
sourceMap?.let {
|
||||
val mapFile = outputJsFile.resolveSibling("${outputJsFile.name}.map")
|
||||
|
||||
-5
@@ -245,11 +245,6 @@ object JsEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
|
||||
applicability = DirectiveApplicability.Global
|
||||
)
|
||||
|
||||
val RUN_NEW_IR_2_JS by directive(
|
||||
description = "",
|
||||
applicability = DirectiveApplicability.Global
|
||||
)
|
||||
|
||||
val NO_COMMON_FILES by directive(
|
||||
"""
|
||||
Don't added helper files to prevent linking issues.
|
||||
|
||||
Reference in New Issue
Block a user