[JS IR] Use mappedNames in NameTable only for REPL

And throw exception for unsupported types in mapToKey
This commit is contained in:
Zalim Bashorov
2020-12-07 19:58:02 +03:00
parent faa24e3230
commit 7c5ea414b7
6 changed files with 29 additions and 24 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 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.
*/
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.scripting.repl.js.readLibrariesFromConfiguration
import kotlin.script.experimental.api.*
class JsScriptCompilerWithDependenciesProxy(private val environment: KotlinCoreEnvironment) : ScriptCompilerProxy {
private val nameTables = NameTables(emptyList())
private val nameTables = NameTables(emptyList(), mappedNames = mutableMapOf())
private val symbolTable = SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl)
private val dependencies: List<ModuleDescriptor> = readLibrariesFromConfiguration(environment.configuration)
private val compiler = JsCoreScriptingCompiler(environment, nameTables, symbolTable, dependencies)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 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.
*/
@@ -21,7 +21,7 @@ class JsReplCompiler(private val environment: KotlinCoreEnvironment) : ReplCompi
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> {
return JsReplCompilationState(
lock,
NameTables(emptyList()),
NameTables(emptyList(), mappedNames = mutableMapOf()),
readLibrariesFromConfiguration(environment.configuration),
ReplCodeAnalyzerBase.ResettableAnalyzerState(),
SymbolTable(IdSignatureDescriptor(JsManglerDesc), IrFactoryImpl)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 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.
*/
@@ -172,7 +172,7 @@ class DependencyLoader {
fun writeNames(nameTables: NameTables): ByteArray {
val result = StringBuilder()
for (entry in nameTables.mappedNames) {
for (entry in nameTables.mappedNames.orEmpty()) {
result.append("${entry.key} ${entry.value}" + System.lineSeparator())
}
return result.toString().toByteArray(Charset.defaultCharset())