class LinkedFlowScope extends java.lang.Object implements FlowScope
Modifier and Type | Class and Description |
---|---|
private static class |
LinkedFlowScope.FlatFlowScopeCache
A map that tries to cache as much symbol table information
as possible in a map.
|
(package private) static class |
LinkedFlowScope.FlowScopeJoinOp
Join the two FlowScopes.
|
private static class |
LinkedFlowScope.LinkedFlowSlot
A static slot that can be used in a linked list.
|
Modifier and Type | Field and Description |
---|---|
private LinkedFlowScope.FlatFlowScopeCache |
cache |
private int |
depth |
private LinkedFlowScope.FlatFlowScopeCache |
flattened |
private boolean |
frozen |
private LinkedFlowScope.LinkedFlowSlot |
lastSlot |
(package private) static int |
MAX_DEPTH |
private LinkedFlowScope |
parent |
Modifier | Constructor and Description |
---|---|
(package private) |
LinkedFlowScope(LinkedFlowScope.FlatFlowScopeCache cache) |
private |
LinkedFlowScope(LinkedFlowScope.FlatFlowScopeCache cache,
LinkedFlowScope directParent) |
(package private) |
LinkedFlowScope(LinkedFlowScope directParent) |
Modifier and Type | Method and Description |
---|---|
private java.util.Map<java.lang.String,StaticTypedSlot<JSType>> |
allFlowSlots()
Gets all the symbols that have been defined before this point
in the current flow.
|
void |
completeScope(StaticTypedScope<JSType> staticScope)
Look through the given scope, and try to find slots where it doesn't
have enough type information.
|
FlowScope |
createChildFlowScope()
Creates a child of this flow scope, to represent an instruction
directly following this one.
|
static LinkedFlowScope |
createEntryLattice(TypedScope scope)
Creates an entry lattice for the flow.
|
private static boolean |
diffSlots(StaticTypedSlot<JSType> slotA,
StaticTypedSlot<JSType> slotB)
Determines whether two slots are meaningfully different for the
purposes of data flow analysis.
|
boolean |
equals(java.lang.Object other) |
StaticTypedSlot<JSType> |
findUniqueRefinedSlot(FlowScope blindScope)
Iterate through all the linked flow scopes before this one.
|
private boolean |
flowsFromBottom()
Whether this flows from a bottom scope.
|
private TypedScope |
getFunctionScope()
Gets the function scope for this flow scope.
|
StaticTypedSlot<JSType> |
getOwnSlot(java.lang.String name)
Like
getSlot but does not recurse into parent scopes. |
StaticTypedScope<JSType> |
getParentScope()
Returns the scope enclosing this one or null if none.
|
Node |
getRootNode()
Returns the root node associated with this scope.
|
StaticTypedSlot<JSType> |
getSlot(java.lang.String name)
Get the slot for the given symbol.
|
JSType |
getTypeOfThis()
Returns the expected type of
this in the current scope. |
int |
hashCode() |
void |
inferQualifiedSlot(Node node,
java.lang.String symbol,
JSType bottomType,
JSType inferredType,
boolean declared)
Infer the type of a qualified name.
|
void |
inferSlotType(java.lang.String symbol,
JSType type)
Defines the type of a symbol at this point in the flow.
|
LinkedFlowScope |
optimize()
Remove flow scopes that add nothing to the flow.
|
private final LinkedFlowScope.FlatFlowScopeCache cache
private final LinkedFlowScope parent
private int depth
static final int MAX_DEPTH
private LinkedFlowScope.FlatFlowScopeCache flattened
private boolean frozen
private LinkedFlowScope.LinkedFlowSlot lastSlot
private LinkedFlowScope(LinkedFlowScope.FlatFlowScopeCache cache, LinkedFlowScope directParent)
LinkedFlowScope(LinkedFlowScope.FlatFlowScopeCache cache)
LinkedFlowScope(LinkedFlowScope directParent)
private TypedScope getFunctionScope()
private boolean flowsFromBottom()
public static LinkedFlowScope createEntryLattice(TypedScope scope)
public void inferSlotType(java.lang.String symbol, JSType type)
FlowScope
inferSlotType
in interface FlowScope
public void inferQualifiedSlot(Node node, java.lang.String symbol, JSType bottomType, JSType inferredType, boolean declared)
FlowScope
inferQualifiedSlot
in interface FlowScope
public JSType getTypeOfThis()
StaticTypedScope
this
in the current scope.getTypeOfThis
in interface StaticTypedScope<JSType>
public Node getRootNode()
StaticScope
getRootNode
in interface StaticScope
public StaticTypedScope<JSType> getParentScope()
StaticTypedScope
getParentScope
in interface StaticTypedScope<JSType>
getParentScope
in interface StaticScope
public StaticTypedSlot<JSType> getSlot(java.lang.String name)
getSlot
in interface StaticTypedScope<JSType>
getSlot
in interface StaticScope
name
- The name of the variable slot to look up.null
if no
definition exists.public StaticTypedSlot<JSType> getOwnSlot(java.lang.String name)
StaticTypedScope
getSlot
but does not recurse into parent scopes.getOwnSlot
in interface StaticTypedScope<JSType>
getOwnSlot
in interface StaticScope
public FlowScope createChildFlowScope()
FlowScope
createChildFlowScope
in interface FlowScope
public StaticTypedSlot<JSType> findUniqueRefinedSlot(FlowScope blindScope)
findUniqueRefinedSlot
in interface FlowScope
blindScope
- The scope before the refinement, i.e. some parent of the
this scope or itself.public void completeScope(StaticTypedScope<JSType> staticScope)
completeScope
in interface FlowScope
public LinkedFlowScope optimize()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
private static boolean diffSlots(StaticTypedSlot<JSType> slotA, StaticTypedSlot<JSType> slotB)
private java.util.Map<java.lang.String,StaticTypedSlot<JSType>> allFlowSlots()
var x = 3;
function f() {
var y = 5;
y = 6; // FLOW POINT
var z = y;
return z;
}
A FlowScope at FLOW POINT will return a slot for y, but not
a slot for x or z.public int hashCode()
hashCode
in class java.lang.Object