JS: minor refactoring
This commit is contained in:
@@ -139,7 +139,7 @@ class K2JSTranslator @JvmOverloads constructor(
|
||||
|
||||
// Global phases
|
||||
|
||||
val program = translationResult.buildProgram()
|
||||
val (program, importedModules) = translationResult.buildProgram()
|
||||
|
||||
program.resolveTemporaryNames()
|
||||
checkCanceled()
|
||||
@@ -152,7 +152,7 @@ class K2JSTranslator @JvmOverloads constructor(
|
||||
files,
|
||||
program,
|
||||
diagnostics,
|
||||
translationResult.importedModuleList.map { it.externalName },
|
||||
importedModules,
|
||||
moduleDescriptor,
|
||||
bindingTrace.bindingContext
|
||||
)
|
||||
|
||||
+4
-11
@@ -21,6 +21,7 @@ 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
|
||||
@@ -36,15 +37,7 @@ class AstGenerationResult(
|
||||
config: JsConfig
|
||||
) {
|
||||
|
||||
// TODO remove
|
||||
val newFragments = translatedSourceFiles.values.map { it.fragment }
|
||||
|
||||
// Only available after the merge
|
||||
val importedModuleList: List<JsImportedModule>
|
||||
get() = merger.importedModules
|
||||
|
||||
val innerModuleName: JsName
|
||||
get() = merger.internalModuleName
|
||||
val newFragments = translatedSourceFiles.values.map { it.fragment }.toSet()
|
||||
|
||||
private val cache = mutableMapOf<TranslationUnit.BinaryAst, DeserializedFileTranslationResult>()
|
||||
|
||||
@@ -68,10 +61,10 @@ class AstGenerationResult(
|
||||
}
|
||||
}
|
||||
|
||||
fun buildProgram(): JsProgram {
|
||||
fun buildProgram(): Pair<JsProgram, List<String>> {
|
||||
val fragments = units.map { translate(it).fragment }
|
||||
fragments.forEach { merger.addFragment(it) }
|
||||
return merger.buildProgram()
|
||||
return merger.buildProgram() to merger.importedModules.map { it.externalName }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.js.translate.context.Namer
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.*
|
||||
import java.util.*
|
||||
|
||||
fun expandIsCalls(fragments: List<JsProgramFragment>) {
|
||||
fun expandIsCalls(fragments: Iterable<JsProgramFragment>) {
|
||||
val visitor = TypeCheckRewritingVisitor()
|
||||
for (fragment in fragments) {
|
||||
visitor.accept(fragment.declarationBlock)
|
||||
|
||||
Reference in New Issue
Block a user