public class InitializationStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>> extends CFAbstractStore<V,S>
CFAbstractStore
and additionally tracks which fields of the 'self'
reference have been initialized.InitializationTransfer
Store.FlowRule, Store.Kind
Modifier and Type | Field and Description |
---|---|
protected Set<VariableElement> |
initializedFields
The set of fields that are initialized.
|
protected Map<FlowExpressions.FieldAccess,V> |
invariantFields
The set of fields that have 'invariant' annotation.
|
analysis, arrayValues, classValues, fieldValues, localVariableValues, methodValues, sequentialSemantics, thisValue
Constructor and Description |
---|
InitializationStore(CFAbstractAnalysis<V,S,?> analysis,
boolean sequentialSemantics) |
InitializationStore(S other)
A copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addInitializedField(FlowExpressions.FieldAccess field)
Mark the field identified by the element
field as initialized (if it belongs to the
current class, or is static (in which case there is no aliasing issue and we can just add all
static fields). |
void |
addInitializedField(VariableElement f)
Mark the field identified by the element
f as initialized (the caller needs to ensure
that the field belongs to the current class, or is a static field). |
CFAbstractAnalysis<V,S,?> |
getAnalysis() |
Map<FlowExpressions.FieldAccess,V> |
getFieldValues() |
void |
insertValue(FlowExpressions.Receiver r,
V value)
Add the abstract value
value for the expression r (correctly deciding where
to store the information depending on the type of the expression r ). |
protected void |
internalVisualize(CFGVisualizer<V,S,?> viz)
Adds a representation of the internal information of this store to visualizer
viz . |
boolean |
isFieldInitialized(Element f)
Is the field identified by the element
f initialized? |
S |
leastUpperBound(S other)
Compute the least upper bound of two stores.
|
protected boolean |
supersetOf(CFAbstractStore<V,S> o)
Returns true iff this
CFAbstractStore contains a superset of the map entries of the
argument CFAbstractStore . |
void |
updateForMethodCall(MethodInvocationNode n,
AnnotatedTypeFactory atypeFactory,
V val)
Remove any information that might not be valid any more after a method call, and add
information guaranteed by the method.
|
canAlias, canInsertReceiver, clearValue, copy, equals, getValue, getValue, getValue, getValue, getValue, getValue, hashCode, initializeMethodParameter, initializeThisValue, insertThisValue, insertValue, isMonotonicUpdate, isSideEffectFree, removeConflicting, removeConflicting, removeConflicting, replaceValue, toString, updateForArrayAssignment, updateForAssignment, updateForFieldAccessAssignment, updateForLocalVariableAssignment, visualize, widenedUpperBound
protected final Set<VariableElement> initializedFields
protected final Map<FlowExpressions.FieldAccess,V extends CFAbstractValue<V>> invariantFields
public InitializationStore(CFAbstractAnalysis<V,S,?> analysis, boolean sequentialSemantics)
public InitializationStore(S other)
public void insertValue(FlowExpressions.Receiver r, V value)
value
for the expression r
(correctly deciding where
to store the information depending on the type of the expression r
).
This method does not take care of removing other information that might be influenced by changes to certain parts of the state.
If there is already a value v
present for r
, then the stronger of the new
and old value are taken (according to the lattice). Note that this happens per hierarchy, and
if the store already contains information about a hierarchy for which value
does not
contain information, then that information is preserved.
If the receiver is a field, and has an invariant annotation, then it can be considered initialized.
insertValue
in class CFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
public void updateForMethodCall(MethodInvocationNode n, AnnotatedTypeFactory atypeFactory, V val)
SideEffectFree
or Pure
), then no information needs to be removed.
a.f
needs to be removed, except
if the method n
cannot modify a.f
(e.g., if a
is a local
variable or this
, and f
is final).
val
in the store.
Additionally, the InitializationStore
keeps all field values for fields that have
the 'invariant' annotation.
updateForMethodCall
in class CFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
public void addInitializedField(FlowExpressions.FieldAccess field)
field
as initialized (if it belongs to the
current class, or is static (in which case there is no aliasing issue and we can just add all
static fields).public void addInitializedField(VariableElement f)
f
as initialized (the caller needs to ensure
that the field belongs to the current class, or is a static field).public boolean isFieldInitialized(Element f)
f
initialized?protected boolean supersetOf(CFAbstractStore<V,S> o)
CFAbstractStore
CFAbstractStore
contains a superset of the map entries of the
argument CFAbstractStore
. Note that we test the entry keys and values by Java
equality, not by any subtype relationship. This method is used primarily to simplify the
equals predicate.supersetOf
in class CFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
public S leastUpperBound(S other)
Store
Important: This method must fulfill the following contract:
this
.
other
.
this
, even if the signature is
more permissive.
leastUpperBound
in interface Store<S extends InitializationStore<V,S>>
leastUpperBound
in class CFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
protected void internalVisualize(CFGVisualizer<V,S,?> viz)
CFAbstractStore
viz
.internalVisualize
in class CFAbstractStore<V extends CFAbstractValue<V>,S extends InitializationStore<V,S>>
public Map<FlowExpressions.FieldAccess,V> getFieldValues()
public CFAbstractAnalysis<V,S,?> getAnalysis()