private class RescopeGlobalSymbols.RewriteScopeCallback extends NodeTraversal.AbstractPostOrderCallback
var a = 1, b = 2, c = 3;becomes
var NS.a = 1, NS.b = 2, NS.c = 4(The var token is removed in a later traversal.)
a + bbecomes
NS.a + NS.b
a()becomes
(0,NS.a)()Notice the special syntax here to preserve the *this* semantics in the function call.
Modifier and Type | Class and Description |
---|---|
private class |
RescopeGlobalSymbols.RewriteScopeCallback.ModuleGlobal
Variable that doesn't cross module boundaries.
|
Modifier and Type | Field and Description |
---|---|
(package private) java.util.List<RescopeGlobalSymbols.RewriteScopeCallback.ModuleGlobal> |
preDeclarations |
Modifier | Constructor and Description |
---|---|
private |
RewriteScopeCallback() |
Modifier and Type | Method and Description |
---|---|
(package private) void |
declareModuleGlobals()
Adds back declarations for variables that do not cross module boundaries.
|
private void |
replaceSymbol(Node node,
java.lang.String name,
CompilerInput input) |
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
shouldTraverse
java.util.List<RescopeGlobalSymbols.RewriteScopeCallback.ModuleGlobal> preDeclarations
public void visit(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in postorder (after its children have been visited).
A node is visited only if all its parents should be traversed
(NodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node)
).
Implementations can have side effects (e.g. modifying the parse tree).
private void replaceSymbol(Node node, java.lang.String name, CompilerInput input)
void declareModuleGlobals()