Class RecursionSolver<A extends it.unive.lisa.analysis.AbstractState<A>>
- java.lang.Object
-
- it.unive.lisa.interprocedural.CallGraphBasedAnalysis<A>
-
- it.unive.lisa.interprocedural.context.ContextBasedAnalysis<A>
-
- it.unive.lisa.interprocedural.context.recursion.RecursionSolver<A>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
- All Implemented Interfaces:
it.unive.lisa.interprocedural.InterproceduralAnalysis<A>
public class RecursionSolver<A extends it.unive.lisa.analysis.AbstractState<A>> extends ContextBasedAnalysis<A>
A recursion solver that applies the iterates of the recursion starting from bottom. This solver operates by restarting the recursion fromRecursion.getInvocation()
a number of times, until the results of all the members stabilize.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.interprocedural.context.ContextBasedAnalysis
conf, results, token
-
Fields inherited from class it.unive.lisa.interprocedural.CallGraphBasedAnalysis
app, callgraph, policy
-
-
Constructor Summary
Constructors Constructor Description RecursionSolver(ContextBasedAnalysis<A> backing, Recursion<A> recursion)
Builds the solver.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canShortcut(it.unive.lisa.program.cfg.CFG cfg)
Whether or not this analysis can avoid computing a fixpoint for the given cfg when it is invoked by a call, and shortcut to the result for the same token if it exists and if it was produced with a greater entry state.void
fixpoint(it.unive.lisa.analysis.AnalysisState<A> entryState, java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> fixpointWorkingSet, it.unive.lisa.conf.FixpointConfiguration conf)
it.unive.lisa.analysis.AnalysisState<A>
getAbstractResultOf(it.unive.lisa.program.cfg.statement.call.CFGCall call, it.unive.lisa.analysis.AnalysisState<A> entryState, it.unive.lisa.analysis.lattices.ExpressionSet[] parameters, it.unive.lisa.analysis.StatementStore<A> expressions)
void
init(it.unive.lisa.program.Application app, it.unive.lisa.interprocedural.callgraph.CallGraph callgraph, it.unive.lisa.interprocedural.OpenCallPolicy policy)
protected boolean
shouldCheckForRecursions()
Whether or not this analysis should look for recursions when evaluating calls, immediately returning bottom when one is found.void
solve()
Solves the recursion by applying its iterates starting from bottom.-
Methods inherited from class it.unive.lisa.interprocedural.context.ContextBasedAnalysis
getAnalysisResultsOf, getFixpointResults, shouldStoreFixpointResults
-
Methods inherited from class it.unive.lisa.interprocedural.CallGraphBasedAnalysis
getAbstractResultOf, needsCallGraph, prepareEntryStateOfEntryPoint, resolve
-
-
-
-
Constructor Detail
-
RecursionSolver
public RecursionSolver(ContextBasedAnalysis<A> backing, Recursion<A> recursion)
Builds the solver.- Parameters:
backing
- the analysis that backs this solver, and that can be used to query call resultsrecursion
- the recursion to solve
-
-
Method Detail
-
init
public void init(it.unive.lisa.program.Application app, it.unive.lisa.interprocedural.callgraph.CallGraph callgraph, it.unive.lisa.interprocedural.OpenCallPolicy policy) throws it.unive.lisa.interprocedural.InterproceduralAnalysisException
- Specified by:
init
in interfaceit.unive.lisa.interprocedural.InterproceduralAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Overrides:
init
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Throws:
it.unive.lisa.interprocedural.InterproceduralAnalysisException
-
fixpoint
public void fixpoint(it.unive.lisa.analysis.AnalysisState<A> entryState, java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> fixpointWorkingSet, it.unive.lisa.conf.FixpointConfiguration conf) throws it.unive.lisa.util.datastructures.graph.algorithms.FixpointException
- Specified by:
fixpoint
in interfaceit.unive.lisa.interprocedural.InterproceduralAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Overrides:
fixpoint
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Throws:
it.unive.lisa.util.datastructures.graph.algorithms.FixpointException
-
getAbstractResultOf
public it.unive.lisa.analysis.AnalysisState<A> getAbstractResultOf(it.unive.lisa.program.cfg.statement.call.CFGCall call, it.unive.lisa.analysis.AnalysisState<A> entryState, it.unive.lisa.analysis.lattices.ExpressionSet[] parameters, it.unive.lisa.analysis.StatementStore<A> expressions) throws it.unive.lisa.analysis.SemanticException
- Specified by:
getAbstractResultOf
in interfaceit.unive.lisa.interprocedural.InterproceduralAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Overrides:
getAbstractResultOf
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Throws:
it.unive.lisa.analysis.SemanticException
-
canShortcut
protected boolean canShortcut(it.unive.lisa.program.cfg.CFG cfg)
Description copied from class:ContextBasedAnalysis
Whether or not this analysis can avoid computing a fixpoint for the given cfg when it is invoked by a call, and shortcut to the result for the same token if it exists and if it was produced with a greater entry state.- Overrides:
canShortcut
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Parameters:
cfg
- the cfg under evaluation- Returns:
true
if that condition holds (defaults totrue
)
-
shouldCheckForRecursions
protected boolean shouldCheckForRecursions()
Description copied from class:ContextBasedAnalysis
Whether or not this analysis should look for recursions when evaluating calls, immediately returning bottom when one is found.- Overrides:
shouldCheckForRecursions
in classContextBasedAnalysis<A extends it.unive.lisa.analysis.AbstractState<A>>
- Returns:
true
if that condition holds (defaults totrue
)
-
solve
public void solve() throws it.unive.lisa.analysis.SemanticException
Solves the recursion by applying its iterates starting from bottom.- Throws:
it.unive.lisa.analysis.SemanticException
- if an exception happens during the computation
-
-