class MaybeReachingVariableUse extends DataFlowAnalysis<Node,MaybeReachingVariableUse.ReachingUses>
A
in alert(A)
is a "may be" reaching use of
the definition of A
at A = foo()
if at least one path from
the use node reaches that definition and it is the last definition before
the use on that path.Modifier and Type | Class and Description |
---|---|
(package private) static class |
MaybeReachingVariableUse.ReachingUses
May use definition lattice representation.
|
private static class |
MaybeReachingVariableUse.ReachingUsesJoinOp
The join is a simple union because of the "may be" nature of the analysis.
|
DataFlowAnalysis.BranchedFlowState<L extends LatticeElement>, DataFlowAnalysis.BranchedForwardDataFlowAnalysis<N,L extends LatticeElement>, DataFlowAnalysis.FlowState<L extends LatticeElement>, DataFlowAnalysis.MaxIterationsExceededException
Modifier and Type | Field and Description |
---|---|
private java.util.Set<Var> |
escaped |
private Scope |
jsScope |
joinOp, MAX_STEPS, orderedWorkSet
Constructor and Description |
---|
MaybeReachingVariableUse(ControlFlowGraph<Node> cfg,
Scope jsScope,
AbstractCompiler compiler) |
Modifier and Type | Method and Description |
---|---|
private void |
addToUseIfLocal(java.lang.String name,
Node node,
MaybeReachingVariableUse.ReachingUses use)
Sets the variable for the given name to the node value in the upward
exposed lattice.
|
private void |
computeMayUse(Node n,
Node cfgNode,
MaybeReachingVariableUse.ReachingUses output,
boolean conditional) |
(package private) MaybeReachingVariableUse.ReachingUses |
createEntryLattice()
Gets the incoming state of the entry node.
|
(package private) MaybeReachingVariableUse.ReachingUses |
createInitialEstimateLattice()
Gets the state of the initial estimation at each node.
|
(package private) MaybeReachingVariableUse.ReachingUses |
flowThrough(Node n,
MaybeReachingVariableUse.ReachingUses input)
Computes the output state for a given node and input state.
|
(package private) java.util.Collection<Node> |
getUses(java.lang.String name,
Node defNode)
Gets a list of nodes that may be using the value assigned to
name
in defNode . |
private boolean |
hasExceptionHandler(Node cfgNode) |
(package private) boolean |
isForward()
Checks whether the analysis is a forward flow analysis or backward flow
analysis.
|
private void |
removeFromUseIfLocal(java.lang.String name,
MaybeReachingVariableUse.ReachingUses use)
Removes the variable for the given name from the node value in the upward
exposed lattice.
|
analyze, analyze, computeEscaped, flow, getCfg, getExitLatticeElement, initialize, join, joinInputs
MaybeReachingVariableUse(ControlFlowGraph<Node> cfg, Scope jsScope, AbstractCompiler compiler)
boolean isForward()
DataFlowAnalysis
isForward
in class DataFlowAnalysis<Node,MaybeReachingVariableUse.ReachingUses>
true
if it is a forward analysis.MaybeReachingVariableUse.ReachingUses createEntryLattice()
DataFlowAnalysis
createEntryLattice
in class DataFlowAnalysis<Node,MaybeReachingVariableUse.ReachingUses>
MaybeReachingVariableUse.ReachingUses createInitialEstimateLattice()
DataFlowAnalysis
createInitialEstimateLattice
in class DataFlowAnalysis<Node,MaybeReachingVariableUse.ReachingUses>
MaybeReachingVariableUse.ReachingUses flowThrough(Node n, MaybeReachingVariableUse.ReachingUses input)
DataFlowAnalysis
flowThrough
in class DataFlowAnalysis<Node,MaybeReachingVariableUse.ReachingUses>
n
- The node.input
- Input lattice that should be read-only.private boolean hasExceptionHandler(Node cfgNode)
private void computeMayUse(Node n, Node cfgNode, MaybeReachingVariableUse.ReachingUses output, boolean conditional)
private void addToUseIfLocal(java.lang.String name, Node node, MaybeReachingVariableUse.ReachingUses use)
private void removeFromUseIfLocal(java.lang.String name, MaybeReachingVariableUse.ReachingUses use)
java.util.Collection<Node> getUses(java.lang.String name, Node defNode)
name
in defNode
. defNode
must be one of the control flow graph
nodes.name
- name of the variable. It can only be names of local variable
that are not function parameters, escaped variables or variables
declared in catch.defNode
- The list of upward exposed use for the variable.