final class ClosureCodeRemoval extends java.lang.Object implements CompilerPass
Compiler pass that removes Closure-specific code patterns.
Currently does the following:
Modifier and Type | Class and Description |
---|---|
private class |
ClosureCodeRemoval.FindAbstractMethods
Identifies all assignments of the abstract method to a variable.
|
private class |
ClosureCodeRemoval.FindAssertionCalls
Identifies all assertion calls.
|
private class |
ClosureCodeRemoval.RemovableAssignment
Utility class to track a node and its parent.
|
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
ABSTRACT_METHOD_NAME
Name used to denote an abstract function
|
private java.util.List<ClosureCodeRemoval.RemovableAssignment> |
abstractMethodAssignmentNodes
List of names referenced in successive generations of finding referenced
nodes.
|
private java.util.List<Node> |
assertionCalls
List of assertion functions.
|
private AbstractCompiler |
compiler
Reference to the JS compiler
|
private boolean |
removeAbstractMethods |
private boolean |
removeAssertionCalls |
Constructor and Description |
---|
ClosureCodeRemoval(AbstractCompiler compiler,
boolean removeAbstractMethods,
boolean removeAssertionCalls)
Creates a Closure code remover.
|
Modifier and Type | Method and Description |
---|---|
void |
process(Node externs,
Node root)
Process the JS with root node root.
|
private final AbstractCompiler compiler
static final java.lang.String ABSTRACT_METHOD_NAME
private final boolean removeAbstractMethods
private final boolean removeAssertionCalls
private final java.util.List<ClosureCodeRemoval.RemovableAssignment> abstractMethodAssignmentNodes
private final java.util.List<Node> assertionCalls
ClosureCodeRemoval(AbstractCompiler compiler, boolean removeAbstractMethods, boolean removeAssertionCalls)
compiler
- The AbstractCompilerremoveAbstractMethods
- Remove declarations of abstract methods.removeAssertionCalls
- Remove calls to goog.assert functions.public void process(Node externs, Node root)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS tree