tip.cfg
Class FlowAnalysis<VariableType>

java.lang.Object
  extended by tip.cfg.CFGAnalysisAdapter
      extended by tip.cfg.FlowAnalysis<VariableType>
Type Parameters:
VariableType - the type of the variables associated with the program points
All Implemented Interfaces:
FixedPointAnalysis<VariableType>, ICFGAnalysis
Direct Known Subclasses:
AvailableExpressionsAnalysis, ConstantPropagationAnalysis, DivisionAnalysis, IntervalAnalysis, LivenessAnalysis, NullPointerAnalysis, ReachingDefinitionsAnalysis, ShapeAnalysis, SignAnalysis, VeryBusyExpressionsAnalysis

public abstract class FlowAnalysis<VariableType>
extends CFGAnalysisAdapter
implements FixedPointAnalysis<VariableType>

FlowAnalysis implements the basic structure for a flow analysis implementing the FixedPointAnalysis interface. To implement a flow analysis, the following must be provided:

Author:
Johnni Winther, jw@brics.dk

Method Summary
 boolean defaultNode(Node node, IProgramPoint point)
          Default implementation for program points: The variable for point is updated to be the join of the points in its dependency set.
 void end(ICFG cfg)
          end is called after the fixed point analysis of the control flow graph cfg has ended.
 Set<IProgramPoint> getDependencySet(IProgramPoint point)
          Returns the set of IProgramPoints that depend upon point.
 Lattice<VariableType> getLattice()
          Returns the Lattice used an analysis in progress.
 String getName()
          Returns the name of the analysis.
 VariableType getVariable(IProgramPoint point)
          Returns the (current) variable associated the point.
 String getVariableStringForPoint(IProgramPoint point)
          Returns a textual representation of the variable for point.
 String getVariableStringForPoint(IProgramPoint point, int distance)
          Returns a textual representation of the variable for point only included information relevant for points in the distance vicinity of point.
 boolean setVariable(IProgramPoint point, VariableType newVariable)
          Sets newVariable as the variable for point.
 void start(ICFG cfg)
          start is called before the fixed point analysis of the control flow graph cfg is started.
 
Methods inherited from class tip.cfg.CFGAnalysisAdapter
caseCAssignPtrStmPoint, caseCAssignVarStmPoint, caseCBinopExpPoint, caseCBlockPoint, caseCDeclStmPoint, caseCDerefExpPoint, caseCFunctionCallExpPoint, caseCFunctionPtrCallExpPoint, caseCIfThenElseStmPoint, caseCIfThenStmPoint, caseCInputExpPoint, caseCIntConstExpPoint, caseCMallocExpPoint, caseCNullExpPoint, caseCOutputStmPoint, caseCPointerExpPoint, caseCReturnStmPoint, caseCVarExpPoint, caseCWhileStmPoint, caseEntryPoint, caseExitPoint
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tip.cfg.FixedPointAnalysis
getVariableString
 
Methods inherited from interface tip.cfg.ICFGAnalysis
caseCAssignPtrStmPoint, caseCAssignVarStmPoint, caseCBinopExpPoint, caseCBlockPoint, caseCDeclStmPoint, caseCDerefExpPoint, caseCFunctionCallExpPoint, caseCFunctionPtrCallExpPoint, caseCIfThenElseStmPoint, caseCIfThenStmPoint, caseCInputExpPoint, caseCIntConstExpPoint, caseCMallocExpPoint, caseCNullExpPoint, caseCOutputStmPoint, caseCPointerExpPoint, caseCReturnStmPoint, caseCVarExpPoint, caseCWhileStmPoint, caseEntryPoint, caseExitPoint
 

Method Detail

getName

public String getName()
Returns the name of the analysis.

Specified by:
getName in interface FixedPointAnalysis<VariableType>
Returns:
the name of the analysis

getLattice

public Lattice<VariableType> getLattice()
Returns the Lattice used an analysis in progress. If no analysis is in progress null is returned.

Returns:
the Lattice used an analysis in progress

start

public void start(ICFG cfg)
start is called before the fixed point analysis of the control flow graph cfg is started. createLattice(ICFG) is called to initial the lattice for the control flow graph cfg.

Specified by:
start in interface FixedPointAnalysis<VariableType>
Parameters:
cfg - the control flow graph on which the analysis is made

end

public void end(ICFG cfg)
end is called after the fixed point analysis of the control flow graph cfg has ended. This resets the lattice information.

Specified by:
end in interface FixedPointAnalysis<VariableType>
Parameters:
cfg - the control flow graph on which the analysis has been made

getVariable

public VariableType getVariable(IProgramPoint point)
Returns the (current) variable associated the point.

Specified by:
getVariable in interface FixedPointAnalysis<VariableType>
Parameters:
point - the IProgramPoint for which the variable is returned
Returns:
the (current) variable associated the point

setVariable

public boolean setVariable(IProgramPoint point,
                           VariableType newVariable)
Sets newVariable as the variable for point. The method returns true if the new variable was not equal to the existing variable, thus the analysis has not reached a fixedpoint.

Parameters:
point - the program point to which the variable is associated
newVariable - the new variable for the program point
Returns:
true if the variable of the program point was changed

getDependencySet

public Set<IProgramPoint> getDependencySet(IProgramPoint point)
Returns the set of IProgramPoints that depend upon point.

Specified by:
getDependencySet in interface FixedPointAnalysis<VariableType>
Parameters:
point - the IProgramPoint for which the dependency set is returned
Returns:
the set of IProgramPoints that depend upon point

defaultNode

public boolean defaultNode(Node node,
                           IProgramPoint point)
Default implementation for program points: The variable for point is updated to be the join of the points in its dependency set.

Overrides:
defaultNode in class CFGAnalysisAdapter
Parameters:
node - the node associated with point
point - the handled point
Returns:
true is the variable chaned
See Also:
join(IProgramPoint)

getVariableStringForPoint

public String getVariableStringForPoint(IProgramPoint point)
Returns a textual representation of the variable for point.

Specified by:
getVariableStringForPoint in interface FixedPointAnalysis<VariableType>
Parameters:
point - the point for which the variable string is returned
Returns:
a textual representation of the variable for point

getVariableStringForPoint

public String getVariableStringForPoint(IProgramPoint point,
                                        int distance)
Returns a textual representation of the variable for point only included information relevant for points in the distance vicinity of point.

Specified by:
getVariableStringForPoint in interface FixedPointAnalysis<VariableType>
Parameters:
point - the point for which the variable string is returned
distance - the vicinity distance taken into account
Returns:
a textual representation of the varaible for point
See Also:
IProgramPoint.getVicinity(int)