Package it.unive.lisa.interprocedural
Class CFGResults<A extends AbstractState<A>>
- java.lang.Object
-
- it.unive.lisa.analysis.lattices.FunctionalLattice<CFGResults<A>,ScopeId,AnalyzedCFG<A>>
-
- it.unive.lisa.interprocedural.CFGResults<A>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
- All Implemented Interfaces:
BaseLattice<CFGResults<A>>
,Lattice<CFGResults<A>>
,StructuredObject
,java.lang.Iterable<java.util.Map.Entry<ScopeId,AnalyzedCFG<A>>>
public class CFGResults<A extends AbstractState<A>> extends FunctionalLattice<CFGResults<A>,ScopeId,AnalyzedCFG<A>>
AFunctionalLattice
fromScopeId
s toAnalyzedCFG
s. This class is meant to store fixpoint results on each token generated during the interprocedural analysis.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
FunctionalLattice.FunctionalLift<V extends Lattice<V>>, FunctionalLattice.KeyFunctionalLift<K>
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
function, lattice
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description CFGResults(AnalyzedCFG<A> lattice)
Builds a new result.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CFGResults<A>
bottom()
Yields the bottom element of this lattice.boolean
contains(ScopeId token)
Yieldstrue
if a result exists for the giventoken
.AnalyzedCFG<A>
get(ScopeId token)
Yields the recorded result for the giventoken
.java.util.Collection<AnalyzedCFG<A>>
getAll()
Yields all the results stored in this object, for any possibleScopeId
used.CFGResults<A>
mk(AnalyzedCFG<A> lattice, java.util.Map<ScopeId,AnalyzedCFG<A>> function)
Builds a instance of this class from the given lattice instance and the given mapping.org.apache.commons.lang3.tuple.Pair<java.lang.Boolean,AnalyzedCFG<A>>
putResult(ScopeId token, AnalyzedCFG<A> result)
Stores the result of a fixpoint computation on a cfg, if needed.AnalyzedCFG<A>
stateOfUnknown(ScopeId key)
Yields the value that should be returned byFunctionalLattice.getState(Object)
whenever the given key is not present in this map.CFGResults<A>
top()
Yields the top element of this lattice.-
Methods inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
equals, functionalLift, getKeys, getMap, getOtDefault, getState, getValues, glbAux, glbKeys, hashCode, isBottom, isTop, iterator, lessOrEqualAux, lubAux, lubKeys, mkNewFunction, narrowingAux, putState, representation, toString, wideningAux
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.BaseLattice
glb, lessOrEqual, lub, narrowing, widening
-
-
-
-
Constructor Detail
-
CFGResults
public CFGResults(AnalyzedCFG<A> lattice)
Builds a new result.- Parameters:
lattice
- a singleton instance used for retrieving top and bottom values
-
-
Method Detail
-
putResult
public org.apache.commons.lang3.tuple.Pair<java.lang.Boolean,AnalyzedCFG<A>> putResult(ScopeId token, AnalyzedCFG<A> result) throws SemanticException
Stores the result of a fixpoint computation on a cfg, if needed. This method returns a pair of a boolean and aAnalyzedCFG
, where (prev
is theAnalyzedCFG
already present for the giventoken
):- if no
prev
was stored fortoken
, than that token is mapped toresult
and this method returns<false, result>
- if
prev <= result
, thentoken
is mapped toresult
and this method returns<true, result>
- if
result <= prev
, then the mapping is left untouched and this method returns<false, prev>
- otherwise,
token
is mapped tolub = prev.lub(result)
and this method returns<true, lub>
- Parameters:
token
- theScopeId
that identifying the resultresult
- theAnalyzedCFG
to store- Returns:
true
if the previous result has been updated, if any- Throws:
SemanticException
- if something goes wrong during the update
- if no
-
contains
public boolean contains(ScopeId token)
Yieldstrue
if a result exists for the giventoken
.- Parameters:
token
- theScopeId
that identifying the result- Returns:
true
if that condition holds
-
get
public AnalyzedCFG<A> get(ScopeId token)
Yields the recorded result for the giventoken
. This differs fromFunctionalLattice.getState(Object)
as it returnsnull
instead ofLattice.bottom()
if there is no recorded result for the given token.- Parameters:
token
- theScopeId
that identifying the result- Returns:
- the result, or
null
-
getAll
public java.util.Collection<AnalyzedCFG<A>> getAll()
Yields all the results stored in this object, for any possibleScopeId
used.- Returns:
- the results
-
top
public CFGResults<A> top()
Description copied from interface:Lattice
Yields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()
accordingly to provide a coherent test.- Returns:
- the top element
-
bottom
public CFGResults<A> bottom()
Description copied from interface:Lattice
Yields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()
accordingly to provide a coherent test.- Returns:
- the bottom element
-
mk
public CFGResults<A> mk(AnalyzedCFG<A> lattice, java.util.Map<ScopeId,AnalyzedCFG<A>> function)
Description copied from class:FunctionalLattice
Builds a instance of this class from the given lattice instance and the given mapping.- Specified by:
mk
in classFunctionalLattice<CFGResults<A extends AbstractState<A>>,ScopeId,AnalyzedCFG<A extends AbstractState<A>>>
- Parameters:
lattice
- an instance of lattice to be used during semantic operations to retrieve top and bottom valuesfunction
- the function representing the mapping contained in the new environment; can benull
- Returns:
- a new instance of this class
-
stateOfUnknown
public AnalyzedCFG<A> stateOfUnknown(ScopeId key)
Description copied from class:FunctionalLattice
Yields the value that should be returned byFunctionalLattice.getState(Object)
whenever the given key is not present in this map.- Specified by:
stateOfUnknown
in classFunctionalLattice<CFGResults<A extends AbstractState<A>>,ScopeId,AnalyzedCFG<A extends AbstractState<A>>>
- Parameters:
key
- the key that is missing- Returns:
- the lattice element for keys not in the mapping
-
-