Package it.unive.lisa.analysis
Class AnalyzedCFG<A extends AbstractState<A>>
- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.code.CodeGraph<CFG,Statement,Edge>
-
- it.unive.lisa.program.cfg.CFG
-
- it.unive.lisa.analysis.AnalyzedCFG<A>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
- All Implemented Interfaces:
BaseLattice<AnalyzedCFG<A>>
,Lattice<AnalyzedCFG<A>>
,CodeMember
,Graph<CFG,Statement,Edge>
,StructuredObject
- Direct Known Subclasses:
OptimizedAnalyzedCFG
public class AnalyzedCFG<A extends AbstractState<A>> extends CFG implements BaseLattice<AnalyzedCFG<A>>
A control flow graph, that hasStatement
s as nodes andEdge
s as edges. It also maps each statement (and its inner expressions) to the result of a fixpoint computation, in the form of anAnalysisState
instance.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CANNOT_COMPARE_ERROR
Error message for the inability to compare two graphs.protected static java.lang.String
CANNOT_GLB_ERROR
Error message for the inability to glb two graphs.protected static java.lang.String
CANNOT_LUB_ERROR
Error message for the inability to lub two graphs.protected static java.lang.String
CANNOT_NARROW_ERROR
Error message for the inability to narrow two graphs.protected static java.lang.String
CANNOT_WIDEN_ERROR
Error message for the inability to widen two graphs.protected StatementStore<A>
entryStates
The map storing the entry state of each entry point.protected ScopeId
id
An id meant to identify this specific result, based on how it has been produced.protected StatementStore<A>
results
The map storing the analysis results.-
Fields inherited from class it.unive.lisa.util.datastructures.graph.code.CodeGraph
entrypoints, list
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description AnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.AnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, java.util.Map<Statement,AnalysisState<A>> entryStates, java.util.Map<Statement,AnalysisState<A>> results)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.AnalyzedCFG(CFG cfg, ScopeId id, StatementStore<A> entryStates, StatementStore<A> results)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnalyzedCFG<A>
bottom()
Yields the bottom element of this lattice.boolean
equals(java.lang.Object obj)
AnalysisState<A>
getAnalysisStateAfter(Statement st)
Yields the computed result at a given statement (exit state).AnalysisState<A>
getAnalysisStateBefore(Statement st)
Yields the computed result before a given statement (entry state).AnalysisState<A>
getEntryState()
Yields the entry state.AnalysisState<A>
getExitState()
Yields the exit state.ScopeId
getId()
Yields an id meant to identify this specific result, based on how it has been produced.AnalyzedCFG<A>
glbAux(AnalyzedCFG<A> other)
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled.int
hashCode()
boolean
isBottom()
Yieldstrue
if and only if this object represents the bottom of the lattice.boolean
isTop()
Yieldstrue
if and only if this object represents the top of the lattice.boolean
lessOrEqualAux(AnalyzedCFG<A> other)
Yieldstrue
if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.AnalyzedCFG<A>
lubAux(AnalyzedCFG<A> other)
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.AnalyzedCFG<A>
narrowingAux(AnalyzedCFG<A> other)
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled.StructuredRepresentation
representation()
Yields aStructuredRepresentation
of the information contained in this object's instance.protected boolean
sameIDs(AnalyzedCFG<A> other)
Yields whether or not theid
of this graph and the given one are the same.AnalyzedCFG<A>
top()
Yields the top element of this lattice.AnalyzedCFG<A>
wideningAux(AnalyzedCFG<A> other)
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.program.cfg.CFG
addControlFlowStructure, backwardFixpoint, backwardFixpoint, backwardFixpoint, computeBasicBlocks, extractControlFlowStructures, fixpoint, fixpoint, fixpoint, getAllExitpoints, getBasicBlocks, getControlFlowStructureOf, getControlFlowStructures, getCycleEntries, getDescriptor, getGenericProgramPoint, getGuards, getIfThenElseGuards, getLoopGuards, getMostRecentGuard, getMostRecentIfThenElseGuard, getMostRecentLoopGuard, getNormalExitpoints, isGuarded, isInsideIfThenElse, isInsideLoop, preSimplify, simplify, toSerializableGraph, toString, validate
-
Methods inherited from class it.unive.lisa.util.datastructures.graph.code.CodeGraph
addEdge, addNode, addNode, containsEdge, containsNode, followersOf, getEdgeConnecting, getEdges, getEdgesConnecting, getEdgesCount, getEntrypoints, getIngoingEdges, getNodeList, getNodes, getNodesCount, getOutgoingEdges, isEqualTo, predecessorsOf, simplify
-
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, toString, widening
-
Methods inherited from interface it.unive.lisa.util.datastructures.graph.Graph
accept, toSerializableGraph
-
-
-
-
Field Detail
-
CANNOT_LUB_ERROR
protected static final java.lang.String CANNOT_LUB_ERROR
Error message for the inability to lub two graphs.- See Also:
- Constant Field Values
-
CANNOT_GLB_ERROR
protected static final java.lang.String CANNOT_GLB_ERROR
Error message for the inability to glb two graphs.- See Also:
- Constant Field Values
-
CANNOT_WIDEN_ERROR
protected static final java.lang.String CANNOT_WIDEN_ERROR
Error message for the inability to widen two graphs.- See Also:
- Constant Field Values
-
CANNOT_NARROW_ERROR
protected static final java.lang.String CANNOT_NARROW_ERROR
Error message for the inability to narrow two graphs.- See Also:
- Constant Field Values
-
CANNOT_COMPARE_ERROR
protected static final java.lang.String CANNOT_COMPARE_ERROR
Error message for the inability to compare two graphs.- See Also:
- Constant Field Values
-
results
protected final StatementStore<A extends AbstractState<A>> results
The map storing the analysis results.
-
entryStates
protected final StatementStore<A extends AbstractState<A>> entryStates
The map storing the entry state of each entry point.
-
id
protected final ScopeId id
An id meant to identify this specific result, based on how it has been produced.
-
-
Constructor Detail
-
AnalyzedCFG
public AnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg
- the original control flow graphid
- aScopeId
meant to identify this specific result based on how it has been producedsingleton
- an instance of theAnalysisState
containing the abstract state of the analysis that was executed, used to retrieve top and bottom values
-
AnalyzedCFG
public AnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, java.util.Map<Statement,AnalysisState<A>> entryStates, java.util.Map<Statement,AnalysisState<A>> results)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg
- the original control flow graphid
- aScopeId
meant to identify this specific result based on how it has been producedsingleton
- an instance of theAnalysisState
containing the abstract state of the analysis that was executed, used to retrieve top and bottom valuesentryStates
- the entry state for each entry point of the cfgresults
- the results of the fixpoint computation
-
AnalyzedCFG
public AnalyzedCFG(CFG cfg, ScopeId id, StatementStore<A> entryStates, StatementStore<A> results)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg
- the original control flow graphid
- aScopeId
meant to identify this specific result based on how it has been producedentryStates
- the entry state for each entry point of the cfgresults
- the results of the fixpoint computation
-
-
Method Detail
-
getId
public ScopeId getId()
Yields an id meant to identify this specific result, based on how it has been produced. This method might returnnull
.- Returns:
- the identifier of this result
-
getAnalysisStateBefore
public AnalysisState<A> getAnalysisStateBefore(Statement st) throws SemanticException
Yields the computed result before a given statement (entry state).- Parameters:
st
- the statement- Returns:
- the result computed before the given statement
- Throws:
SemanticException
- if the lub operator fails
-
getAnalysisStateAfter
public AnalysisState<A> getAnalysisStateAfter(Statement st)
Yields the computed result at a given statement (exit state).- Parameters:
st
- the statement- Returns:
- the result computed at the given statement
-
getEntryState
public AnalysisState<A> getEntryState() throws SemanticException
Yields the entry state.- Returns:
- the entry state of the CFG
- Throws:
SemanticException
- if the lub operator fails
-
getExitState
public AnalysisState<A> getExitState() throws SemanticException
Yields the exit state.- Returns:
- the entry state of the CFG
- Throws:
SemanticException
- if the lub operator fails
-
lubAux
public AnalyzedCFG<A> lubAux(AnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lubAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
glbAux
public AnalyzedCFG<A> glbAux(AnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
glbAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the greatest lower bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
wideningAux
public AnalyzedCFG<A> wideningAux(AnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.lubAux(BaseLattice)
, and is thus safe for finite lattices and ACC ones.- Specified by:
wideningAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
narrowingAux
public AnalyzedCFG<A> narrowingAux(AnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.glbAux(BaseLattice)
, and is thus safe for finite lattices and DCC ones.- Specified by:
narrowingAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the narrowing between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
lessOrEqualAux
public boolean lessOrEqualAux(AnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Yieldstrue
if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lessOrEqualAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
true
if and only if that condition holds- Throws:
SemanticException
- if an error occurs during the computation
-
sameIDs
protected boolean sameIDs(AnalyzedCFG<A> other)
Yields whether or not theid
of this graph and the given one are the same.- Parameters:
other
- the other graph- Returns:
true
if that condition holds
-
top
public AnalyzedCFG<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.- Specified by:
top
in interfaceLattice<A extends AbstractState<A>>
- Returns:
- the top element
-
isTop
public boolean isTop()
Description copied from interface:Lattice
Yieldstrue
if and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthis
and the value returned byLattice.top()
, thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Specified by:
isTop
in interfaceLattice<A extends AbstractState<A>>
- Returns:
true
if this is the top of the lattice
-
bottom
public AnalyzedCFG<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.- Specified by:
bottom
in interfaceLattice<A extends AbstractState<A>>
- Returns:
- the bottom element
-
isBottom
public boolean isBottom()
Description copied from interface:Lattice
Yieldstrue
if and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthis
and the value returned byLattice.bottom()
, thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Specified by:
isBottom
in interfaceLattice<A extends AbstractState<A>>
- Returns:
true
if this is the bottom of the lattice
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceBaseLattice<A extends AbstractState<A>>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceBaseLattice<A extends AbstractState<A>>
- Overrides:
equals
in classjava.lang.Object
-
representation
public StructuredRepresentation representation()
Description copied from interface:StructuredObject
Yields aStructuredRepresentation
of the information contained in this object's instance.- Specified by:
representation
in interfaceStructuredObject
- Returns:
- the representation
-
-