[JS IR] Fix compilation after rebase

This commit is contained in:
Ilya Goncharov
2021-02-18 10:31:06 +03:00
committed by TeamCityServer
parent 0182c09318
commit 0e00186ca1
5 changed files with 23 additions and 27 deletions
@@ -206,7 +206,8 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
irFactory = PersistentIrFactory(), // TODO IrFactoryImpl?
outputKlibPath = outputFile.path,
nopack = arguments.irProduceKlibDir,
jsOutputName = FileUtil.getNameWithoutExtension(outputFile),)
jsOutputName = FileUtil.getNameWithoutExtension(outputFile),
)
}
if (arguments.irProduceJs) {
@@ -56,7 +56,7 @@ fun compile(
irPerModulePrefix: String? = null,
): CompilerResult {
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer, moduleToName) =
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, irFactory)
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, irFactory, forceAllJs)
val moduleDescriptor = moduleFragment.descriptor
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrLoop
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.js.backend.ast.JsName
import org.jetbrains.kotlin.js.backend.ast.JsNameRef
class IrNamerImpl(
private val newNameTables: NameTables,
@@ -41,8 +42,6 @@ class IrNamerImpl(
}
}
override fun getNameForValueDeclaration(declaration: IrValueDeclaration): JsName =
getNameForStaticDeclaration(declaration)
override fun getNameForClass(klass: IrClass): JsName =
getNameForStaticDeclaration(klass)
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.js.backend.ast.JsGlobalBlock
class JsStaticContext(
val backendContext: JsIrBackendContext,
private val irNamer: IrNamer,
val globalNameScope: NameScope
val globalNameScope: NameScope,
) : IrNamer by irNamer {
val intrinsics = JsIntrinsicTransformers(backendContext)
val classModels = mutableMapOf<IrClassSymbol, JsIrClassModel>()
@@ -547,7 +547,8 @@ fun serializeModuleIntoKlib(
val serializedMetadata =
metadataSerializer.serializedMetadata(
compiledKotlinFiles.groupBy { it.irData.fqName }.map { (fqn, data) -> fqn to data.sortedBy { it.irData.path }.map { it.metadata } }.toMap(),
compiledKotlinFiles.groupBy { it.irData.fqName }
.map { (fqn, data) -> fqn to data.sortedBy { it.irData.path }.map { it.metadata } }.toMap(),
header
)
@@ -561,34 +562,29 @@ fun serializeModuleIntoKlib(
irVersion = KlibIrVersion.INSTANCE.toString()
)
val properties = if (containsErrorCode) {
Properties().also {
it.setProperty(KLIB_PROPERTY_CONTAINS_ERROR_CODE, "true")
}
} else null
val properties = Properties().also { p ->
if (jsOutputName != null) {
p.setProperty(KLIB_PROPERTY_JS_OUTPUT_NAME, jsOutputName)
}
if (containsErrorCode) {
p.setProperty(KLIB_PROPERTY_CONTAINS_ERROR_CODE, "true")
p.setProperty(KLIB_PROPERTY_CONTAINS_ERROR_CODE, "true")
}
}
buildKotlinLibrary(
linkDependencies = dependencies,
ir = fullSerializedIr,
metadata = serializedMetadata,
dataFlowGraph = null,
manifestProperties = properties,
moduleName = moduleName,
nopack = nopack,
perFile = perFile,
output = klibPath,
versions = versions,
builtInsPlatform = BuiltInsPlatform.JS
)
}
buildKotlinLibrary(
linkDependencies = dependencies,
ir = fullSerializedIr,
metadata = serializedMetadata,
dataFlowGraph = null,
manifestProperties = properties,
moduleName = moduleName,
nopack = nopack,
perFile = perFile,
output = klibPath,
versions = versions,
builtInsPlatform = BuiltInsPlatform.JS
)
}
const val KLIB_PROPERTY_JS_OUTPUT_NAME = "jsOutputName"