JS: review fixes
This commit is contained in:
@@ -224,7 +224,7 @@ class K2JSTranslator @JvmOverloads constructor(
|
||||
add(fragment.initializerBlock)
|
||||
fragment.tests?.let { add(it) }
|
||||
fragment.mainFunction?.let { add(it) }
|
||||
addAll(fragment.inlinedFunctionWrappers.values)
|
||||
addAll(fragment.inlinedLocalDeclarations.values)
|
||||
})
|
||||
|
||||
val definedNames = collectDefinedNamesInAllScopes(allCode)
|
||||
|
||||
@@ -701,12 +701,12 @@ public final class StaticContext {
|
||||
|
||||
@Nullable
|
||||
private JsName getModuleInnerName(@NotNull DeclarationDescriptor descriptor) {
|
||||
JsImportedModule module = getJsImportedModuleModule(descriptor);
|
||||
JsImportedModule module = getJsImportedModule(descriptor);
|
||||
return module == null ? null : module.getInternalName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public JsImportedModule getJsImportedModuleModule(@NotNull DeclarationDescriptor descriptor) {
|
||||
private JsImportedModule getJsImportedModule(@NotNull DeclarationDescriptor descriptor) {
|
||||
ModuleDescriptor module = DescriptorUtils.getContainingModule(descriptor);
|
||||
if (currentModule == module) {
|
||||
return currentModuleAsImported;
|
||||
@@ -840,7 +840,7 @@ public final class StaticContext {
|
||||
String moduleName = suggestModuleName(declaration);
|
||||
if (moduleName.equals(Namer.KOTLIN_LOWER_NAME)) return null;
|
||||
|
||||
JsImportedModule importedModule = getJsImportedModuleModule(declaration);
|
||||
JsImportedModule importedModule = getJsImportedModule(declaration);
|
||||
if (importedModule == null) return null;
|
||||
|
||||
return exportModuleForInline(moduleName, importedModule);
|
||||
|
||||
+2
-3
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.facade.TranslationUnit
|
||||
import org.jetbrains.kotlin.js.inline.util.toIdentitySet
|
||||
import org.jetbrains.kotlin.protobuf.CodedInputStream
|
||||
import org.jetbrains.kotlin.serialization.js.ast.JsAstDeserializer
|
||||
import org.jetbrains.kotlin.serialization.js.ast.JsAstProtoBuf
|
||||
@@ -46,7 +45,7 @@ class AstGenerationResult(
|
||||
private val sourceRoots = config.sourceMapRoots.map { File(it) }
|
||||
private val deserializer = JsAstDeserializer(merger.program, sourceRoots)
|
||||
|
||||
fun translate(unit: TranslationUnit): FileTranslationResult =
|
||||
fun getTranslationResult(unit: TranslationUnit): FileTranslationResult =
|
||||
when (unit) {
|
||||
is TranslationUnit.SourceFile -> translatedSourceFiles[unit]!!
|
||||
is TranslationUnit.BinaryAst -> cache.getOrPut(unit) {
|
||||
@@ -62,7 +61,7 @@ class AstGenerationResult(
|
||||
}
|
||||
|
||||
fun buildProgram(): Pair<JsProgram, List<String>> {
|
||||
val fragments = units.map { translate(it).fragment }
|
||||
val fragments = units.map { getTranslationResult(it).fragment }
|
||||
fragments.forEach { merger.addFragment(it) }
|
||||
return merger.buildProgram() to merger.importedModules.map { it.externalName }
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class Merger(
|
||||
|
||||
fragment.tests?.let { rename(it) }
|
||||
fragment.mainFunction?.let { rename(it) }
|
||||
fragment.inlinedFunctionWrappers.values.forEach { rename(it) }
|
||||
fragment.inlinedLocalDeclarations.values.forEach { rename(it) }
|
||||
}
|
||||
|
||||
private fun <T : JsNode> Map<JsName, JsName>.rename(rootNode: T): T {
|
||||
@@ -210,7 +210,7 @@ class Merger(
|
||||
fragment.tryUpdateMain()
|
||||
addExportStatements(fragment)
|
||||
|
||||
fragment.inlinedFunctionWrappers.forEach { (tag, imports) ->
|
||||
fragment.inlinedLocalDeclarations.forEach { (tag, imports) ->
|
||||
importedFunctionWrappers.putIfAbsent(tag, imports)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1276
|
||||
// FILE: lib.kt
|
||||
|
||||
// Force contructor renaming
|
||||
// Force constructor renaming
|
||||
val dummy = run {
|
||||
if (false) {
|
||||
js("A")
|
||||
@@ -19,7 +19,7 @@ inline fun ok() = A("O").s + A('K').s
|
||||
// FILE: main.kt
|
||||
|
||||
|
||||
// TODO add directives for primary contructor invocations
|
||||
// TODO add directives for primary constructor invocations
|
||||
// CHECK_CALLED_IN_SCOPE: function=A_init_0 scope=box
|
||||
// CHECK_NOT_CALLED_IN_SCOPE: function=A_init scope=box
|
||||
fun box(): String {
|
||||
|
||||
Reference in New Issue
Block a user