final class MustBeReachingVariableDef extends DataFlowAnalysis<Node,MustBeReachingVariableDef.MustDef>
A
in A = foo()
is a reaching definition of
the use of A
in alert(A)
if all paths from entry node must
reaches that definition and it is the last definition before the use.Modifier and Type | Class and Description |
---|---|
(package private) static class |
MustBeReachingVariableDef.Definition
Abstraction of a local variable definition.
|
(package private) static class |
MustBeReachingVariableDef.MustDef
Must reaching definition lattice representation.
|
private static class |
MustBeReachingVariableDef.MustDefJoin |
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 AbstractCompiler |
compiler |
private java.util.Set<Var> |
escaped |
private Scope |
jsScope |
joinOp, MAX_STEPS, orderedWorkSet
Constructor and Description |
---|
MustBeReachingVariableDef(ControlFlowGraph<Node> cfg,
Scope jsScope,
AbstractCompiler compiler) |
Modifier and Type | Method and Description |
---|---|
private void |
addToDefIfLocal(java.lang.String name,
Node node,
Node rValue,
MustBeReachingVariableDef.MustDef def)
Set the variable lattice for the given name to the node value in the def
lattice.
|
private void |
computeDependence(MustBeReachingVariableDef.Definition def,
Node rValue)
Computes all the local variables that rValue reads from and store that
in the def's depends set.
|
private void |
computeMustDef(Node n,
Node cfgNode,
MustBeReachingVariableDef.MustDef output,
boolean conditional) |
(package private) MustBeReachingVariableDef.MustDef |
createEntryLattice()
Gets the incoming state of the entry node.
|
(package private) MustBeReachingVariableDef.MustDef |
createInitialEstimateLattice()
Gets the state of the initial estimation at each node.
|
(package private) boolean |
dependsOnOuterScopeVars(MustBeReachingVariableDef.Definition def) |
private void |
escapeParameters(MustBeReachingVariableDef.MustDef output) |
(package private) MustBeReachingVariableDef.MustDef |
flowThrough(Node n,
MustBeReachingVariableDef.MustDef input)
Computes the output state for a given node and input state.
|
(package private) MustBeReachingVariableDef.Definition |
getDef(java.lang.String name,
Node useNode)
Gets the must reaching definition of a given node.
|
(package private) Node |
getDefNode(java.lang.String name,
Node useNode) |
(package private) boolean |
isForward()
Checks whether the analysis is a forward flow analysis or backward flow
analysis.
|
private static boolean |
isParameter(Var v) |
analyze, analyze, computeEscaped, flow, getCfg, getExitLatticeElement, initialize, join, joinInputs
private final Scope jsScope
private final AbstractCompiler compiler
private final java.util.Set<Var> escaped
MustBeReachingVariableDef(ControlFlowGraph<Node> cfg, Scope jsScope, AbstractCompiler compiler)
boolean isForward()
DataFlowAnalysis
isForward
in class DataFlowAnalysis<Node,MustBeReachingVariableDef.MustDef>
true
if it is a forward analysis.MustBeReachingVariableDef.MustDef createEntryLattice()
DataFlowAnalysis
createEntryLattice
in class DataFlowAnalysis<Node,MustBeReachingVariableDef.MustDef>
MustBeReachingVariableDef.MustDef createInitialEstimateLattice()
DataFlowAnalysis
createInitialEstimateLattice
in class DataFlowAnalysis<Node,MustBeReachingVariableDef.MustDef>
MustBeReachingVariableDef.MustDef flowThrough(Node n, MustBeReachingVariableDef.MustDef input)
DataFlowAnalysis
flowThrough
in class DataFlowAnalysis<Node,MustBeReachingVariableDef.MustDef>
n
- The node.input
- Input lattice that should be read-only.private void computeMustDef(Node n, Node cfgNode, MustBeReachingVariableDef.MustDef output, boolean conditional)
n
- The node in question.cfgNode
- The node to addconditional
- true if the definition is not always executed.private void addToDefIfLocal(java.lang.String name, @Nullable Node node, @Nullable Node rValue, MustBeReachingVariableDef.MustDef def)
node
- The CFG node where the definition should be record to.
null
if this is a conditional define.private void escapeParameters(MustBeReachingVariableDef.MustDef output)
private static boolean isParameter(Var v)
private void computeDependence(MustBeReachingVariableDef.Definition def, Node rValue)
MustBeReachingVariableDef.Definition getDef(java.lang.String name, Node useNode)
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.useNode
- the location of the use where the definition reaches.boolean dependsOnOuterScopeVars(MustBeReachingVariableDef.Definition def)