class GatherSideEffectSubexpressionsCallback extends java.lang.Object implements NodeTraversal.Callback
Modifier and Type | Class and Description |
---|---|
(package private) static class |
GatherSideEffectSubexpressionsCallback.GetReplacementSideEffectSubexpressions
Populates the provided replacement list by appending copies of
subtrees that have side effects.
|
(package private) static interface |
GatherSideEffectSubexpressionsCallback.SideEffectAccumulator
Used by GatherSideEffectSubexpressionsCallback to notify client
code about side effect expressions that should be kept.
|
Modifier and Type | Field and Description |
---|---|
private GatherSideEffectSubexpressionsCallback.SideEffectAccumulator |
accumulator |
private AbstractCompiler |
compiler |
private static java.util.Set<java.lang.Integer> |
FORBIDDEN_TYPES |
Constructor and Description |
---|
GatherSideEffectSubexpressionsCallback(AbstractCompiler compiler,
GatherSideEffectSubexpressionsCallback.SideEffectAccumulator accumulator) |
Modifier and Type | Method and Description |
---|---|
private boolean |
isClassDefiningCall(Node callNode)
Determines if a call defines a class inheritance or mixing
relation, according to the current coding convention.
|
(package private) boolean |
processConstructorCall(Node node)
Processes a NEW expression.
|
(package private) boolean |
processFunctionCall(Node node)
Processes a CALL expression.
|
(package private) boolean |
processHook(Node node)
Processes a HOOK expression.
|
(package private) boolean |
processShortCircuitExpression(Node node)
Processes an AND or OR expression.
|
boolean |
shouldTraverse(NodeTraversal traversal,
Node node,
Node parent)
Computes the list of subtrees whose root nodes have side effects.
|
void |
visit(NodeTraversal traversal,
Node node,
Node parent)
Visits a node in postorder (after its children have been visited).
|
private static final java.util.Set<java.lang.Integer> FORBIDDEN_TYPES
private final AbstractCompiler compiler
private final GatherSideEffectSubexpressionsCallback.SideEffectAccumulator accumulator
GatherSideEffectSubexpressionsCallback(AbstractCompiler compiler, GatherSideEffectSubexpressionsCallback.SideEffectAccumulator accumulator)
compiler
- - AbstractCompiler objectaccumulator
- - object that will accumulate roots of
subtrees that have side effects.private boolean isClassDefiningCall(Node callNode)
public boolean shouldTraverse(NodeTraversal traversal, Node node, Node parent)
If the current subtree's root has side effects this method should call accumulator.keepSubTree and return 'false' to add the subtree to the result list and avoid avoid traversing the nodes children.
Branching nodes whose then or else branch contain side effects must be simplified by doing a recursive traversal; this method should call the appropriate accumulator 'keepSimplified' method and return 'false' to stop the regular traversal.
shouldTraverse
in interface NodeTraversal.Callback
boolean processShortCircuitExpression(Node node)
boolean processHook(Node node)
boolean processFunctionCall(Node node)
boolean processConstructorCall(Node node)
public void visit(NodeTraversal traversal, Node node, 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).
visit
in interface NodeTraversal.Callback