Minor cleanup in JS backend
This commit is contained in:
@@ -13,14 +13,10 @@ import java.util.List;
|
||||
* Represents a JavaScript block in the global scope.
|
||||
*/
|
||||
public class JsGlobalBlock extends JsBlock {
|
||||
|
||||
public JsGlobalBlock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlobalBlock() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isGlobalBlock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.js.backend.ast;
|
||||
|
||||
/**
|
||||
/*
|
||||
* Taken from GWT project with modifications.
|
||||
* Original:
|
||||
* repository: https://gwt.googlesource.com/gwt
|
||||
@@ -33,15 +33,15 @@ import java.util.*;
|
||||
*/
|
||||
public class JsVisitorWithContextImpl extends JsVisitorWithContext {
|
||||
|
||||
protected final Stack<JsContext<JsStatement>> statementContexts = new Stack<JsContext<JsStatement>>();
|
||||
protected final Stack<JsContext<JsStatement>> statementContexts = new Stack<>();
|
||||
|
||||
public class ListContext<T extends JsNode> extends JsContext<T> {
|
||||
private List<T> nodes;
|
||||
private int index;
|
||||
|
||||
// Those are reset in every iteration of traverse()
|
||||
private final List<T> previous = new SmartList<T>();
|
||||
private final List<T> next = new SmartList<T>();
|
||||
private final List<T> previous = new SmartList<>();
|
||||
private final List<T> next = new SmartList<>();
|
||||
private boolean removed = false;
|
||||
|
||||
@Override
|
||||
@@ -138,7 +138,7 @@ public class JsVisitorWithContextImpl extends JsVisitorWithContext {
|
||||
}
|
||||
}
|
||||
|
||||
protected static void checkReplacement(@SuppressWarnings("UnusedParameters") JsNode origNode, JsNode newNode) {
|
||||
private static void checkReplacement(@SuppressWarnings("UnusedParameters") JsNode origNode, JsNode newNode) {
|
||||
if (newNode == null) throw new RuntimeException("Cannot replace with null");
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class JsVisitorWithContextImpl extends JsVisitorWithContext {
|
||||
|
||||
@Override
|
||||
protected <T extends JsStatement> JsStatement doAcceptStatement(T statement) {
|
||||
List<JsStatement> statements = new SmartList<JsStatement>(statement);
|
||||
List<JsStatement> statements = new SmartList<>(statement);
|
||||
doAcceptStatementList(statements);
|
||||
|
||||
if (statements.size() == 1) {
|
||||
@@ -166,7 +166,7 @@ public class JsVisitorWithContextImpl extends JsVisitorWithContext {
|
||||
|
||||
@Override
|
||||
protected void doAcceptStatementList(List<JsStatement> statements) {
|
||||
ListContext<JsStatement> context = new ListContext<JsStatement>();
|
||||
ListContext<JsStatement> context = new ListContext<>();
|
||||
statementContexts.push(context);
|
||||
context.traverse(statements);
|
||||
statementContexts.pop();
|
||||
|
||||
@@ -18,16 +18,12 @@ package org.jetbrains.kotlin.js.inline.context
|
||||
|
||||
import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.synthetic
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.IdentityHashMap
|
||||
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||
import org.jetbrains.kotlin.js.inline.util.replaceNames
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||
|
||||
class NamingContext(private val statementContext: JsContext<JsStatement>) {
|
||||
private val renamings = IdentityHashMap<JsName, JsExpression>()
|
||||
private val declarations = ArrayList<JsVars>()
|
||||
private val renamings = mutableMapOf<JsName, JsExpression>()
|
||||
private val declarations = mutableListOf<JsVars>()
|
||||
private var addedDeclarations = false
|
||||
|
||||
fun applyRenameTo(target: JsNode): JsNode {
|
||||
|
||||
Reference in New Issue
Block a user