[JS IR] Preparing for introducing sourcemap as another compilation output

* Rename `JsCode` to `CompilationOutputs`.
* Rename members of CompilerResult.

#KT-46551 In Progress
This commit is contained in:
Zalim Bashorov
2021-07-01 20:39:16 +03:00
committed by teamcityserver
parent d9b7230144
commit 64c6d852de
4 changed files with 19 additions and 19 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -284,8 +284,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
),
)
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
outputFile.writeText(jsCode.mainModule)
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.outputsAfterDce!! else compiledModule.outputs!!
outputFile.writeText(jsCode.jsCode)
jsCode.dependencies.forEach { (name, content) ->
outputFile.resolveSibling("$name.js").writeText(content)
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -27,12 +27,12 @@ import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
import org.jetbrains.kotlin.name.FqName
class CompilerResult(
val jsCode: JsCode?,
val dceJsCode: JsCode?,
val outputs: CompilationOutputs?,
val outputsAfterDce: CompilationOutputs?,
val tsDefinitions: String? = null
)
class JsCode(val mainModule: String, val dependencies: Iterable<Pair<String, String>> = emptyList())
class CompilationOutputs(val jsCode: String, val dependencies: Iterable<Pair<String, String>> = emptyList())
fun compile(
project: Project,
@@ -174,5 +174,5 @@ fun generateJsCode(
jsPhases.invokeToplevel(PhaseConfig(jsPhases), context, listOf(moduleFragment))
val transformer = IrModuleToJsTransformer(context, null, true, nameTables)
return transformer.generateModule(listOf(moduleFragment)).jsCode!!.mainModule
return transformer.generateModule(listOf(moduleFragment)).outputs!!.jsCode
}
@@ -1,12 +1,12 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.backend.js.transformers.irToJs
import org.jetbrains.kotlin.ir.backend.js.CompilerResult
import org.jetbrains.kotlin.ir.backend.js.JsCode
import org.jetbrains.kotlin.ir.backend.js.CompilationOutputs
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
import org.jetbrains.kotlin.ir.backend.js.eliminateDeadDeclarations
import org.jetbrains.kotlin.ir.backend.js.export.ExportModelGenerator
@@ -72,7 +72,7 @@ class IrModuleToJsTransformer(
return CompilerResult(jsCode, dceJsCode, dts)
}
private fun generateWrappedModuleBody(modules: Iterable<IrModuleFragment>, exportedModule: ExportedModule, namer: NameTables): JsCode {
private fun generateWrappedModuleBody(modules: Iterable<IrModuleFragment>, exportedModule: ExportedModule, namer: NameTables): CompilationOutputs {
if (multiModule) {
val refInfo = buildCrossModuleReferenceInfo(modules)
@@ -104,9 +104,9 @@ class IrModuleToJsTransformer(
)
}.reversed()
return JsCode(mainModule, dependencies)
return CompilationOutputs(mainModule, dependencies)
} else {
return JsCode(
return CompilationOutputs(
generateWrappedModuleBody2(
modules,
emptyList(),