[JS IR BE] Codegen class model refactorings

Reduce JsScope usage
This commit is contained in:
Svyatoslav Kuzmich
2019-06-24 15:07:59 +03:00
parent e7a5e5b4a0
commit 685597d20a
9 changed files with 43 additions and 48 deletions
@@ -18,6 +18,5 @@ package org.jetbrains.kotlin.js.backend.ast
class JsClassModel(val name: JsName, val superName: JsName?) {
val interfaces: MutableSet<JsName> = mutableSetOf()
val preDeclarationBlock = JsGlobalBlock() // TODO only used in IR backend => hide from current backend
val postDeclarationBlock = JsGlobalBlock()
}
@@ -20,11 +20,15 @@ public class JsName extends HasMetadata implements Symbol {
/**
* @param ident the unmangled ident to use for this name
*/
JsName(@NotNull String ident, boolean temporary) {
public JsName(@NotNull String ident, boolean temporary) {
this.ident = ident;
this.temporary = temporary;
}
public JsName(@NotNull String ident) {
this(ident, false);
}
public boolean isTemporary() {
return temporary;
}
@@ -137,9 +137,7 @@ class ImportIntoFragmentInliningScope private constructor(
get() = JsBlock(
JsBlock(fragment.inlinedLocalDeclarations.values.toList()),
fragment.declarationBlock,
JsBlock(fragment.classes.values.flatMap {
listOf(it.preDeclarationBlock, it.postDeclarationBlock)
}),
JsBlock(fragment.classes.values.map { it.postDeclarationBlock }),
fragment.exportBlock,
JsExpressionStatement(JsFunction(JsDynamicScope, fragment.initializerBlock, ""))
).also { block ->