Refactor JS translator to generate code for new inliner

This commit is contained in:
Alexey Andreev
2017-06-27 18:55:34 +03:00
parent 29857e48c8
commit 7c421b0b83
37 changed files with 771 additions and 211 deletions
@@ -33,7 +33,7 @@ import java.util.*;
*/
public class JsVisitorWithContextImpl extends JsVisitorWithContext {
private final Stack<JsContext<JsStatement>> statementContexts = new Stack<JsContext<JsStatement>>();
protected final Stack<JsContext<JsStatement>> statementContexts = new Stack<JsContext<JsStatement>>();
public class ListContext<T extends JsNode> extends JsContext<T> {
private List<T> nodes;
@@ -76,7 +76,7 @@ public class JsVisitorWithContextImpl extends JsVisitorWithContext {
return null;
}
protected void traverse(List<T> nodes) {
public void traverse(List<T> nodes) {
assert previous.isEmpty(): "addPrevious() was called before traverse()";
assert next.isEmpty(): "addNext() was called before traverse()";
this.nodes = nodes;
@@ -102,6 +102,9 @@ public class JsVisitorWithContextImpl extends JsVisitorWithContext {
index += next.size();
}
}
previous.clear();
next.clear();
}
}
@@ -29,6 +29,8 @@ var JsName.staticRef: JsNode? by MetadataProperty(default = null)
var JsName.descriptor: DeclarationDescriptor? by MetadataProperty(default = null)
var JsName.localAlias: JsName? by MetadataProperty(default = null)
// TODO: move this to module 'js.inliner' and change dependency on 'frontend' to dependency on 'descriptors'
var JsInvocation.inlineStrategy: InlineStrategy? by MetadataProperty(default = null)