edu.cmu.cs.crystal.flow
Class MotherFlowAnalysis<LE>

java.lang.Object
  extended by edu.cmu.cs.crystal.flow.MotherFlowAnalysis<LE>
Type Parameters:
LE - the type that represents the analysis knowledge
All Implemented Interfaces:
IFlowAnalysis<LE>
Direct Known Subclasses:
FlowAnalysis, TACFlowAnalysis

public abstract class MotherFlowAnalysis<LE>
extends Object
implements IFlowAnalysis<LE>

Abstract base class for flow analyses that implements a worklist algorithm and provides various methods to access analysis results. Methods are analyzed lazily when results for AST nodes inside a method are requested.

Author:
David Dickey, Jonathan Aldrich, Kevin Bierhoff, Ciera Jaspan

Field Summary
static Logger log
           
 
Constructor Summary
MotherFlowAnalysis()
          Initializes a fresh flow analysis object.
 
Method Summary
 LE getEndResults(MethodDeclaration decl)
          Gets the lattice results at the end of a method.
 IResult<LE> getLabeledEndResult(MethodDeclaration d)
          Gets the lattice results at the end of a method.
 IResult<LE> getLabeledResultsAfter(ASTNode node)
          Retrieves the analysis state that exists after analyzing the node in the control flow graph.
 IResult<LE> getLabeledResultsBefore(ASTNode node)
          Retrieves the analysis state that exists before analyzing the node in the control flow graph.
 IResult<LE> getLabeledStartResult(MethodDeclaration d)
          Gets the lattice results at the start of a method.
 LE getResultsAfter(ASTNode node)
          Deprecated. 
 LE getResultsAfterAST(ASTNode node)
          Retrieves the analysis state that exists after analyzing the node in the abstract syntax tree.
 LE getResultsAfterCFG(ASTNode node)
          Retrieves the analysis state that exists after analyzing the node in the control flow graph.
 LE getResultsBefore(ASTNode node)
          Deprecated. 
 LE getResultsBeforeAST(ASTNode node)
          Retrieves the analysis state that exists before analyzing the node in the abstract syntax tree.
 LE getResultsBeforeCFG(ASTNode node)
          Retrieves the analysis state that exists before analyzing the node in the control flow graph.
 LE getStartResults(MethodDeclaration decl)
          Gets the lattice results at the start of a method.
 void setMonitor(Option<org.eclipse.core.runtime.IProgressMonitor> monitor)
          Use the given progress monitor to cancel subsequent flow analysis runs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final Logger log
Constructor Detail

MotherFlowAnalysis

public MotherFlowAnalysis()
Initializes a fresh flow analysis object.

Method Detail

setMonitor

public void setMonitor(Option<org.eclipse.core.runtime.IProgressMonitor> monitor)
Use the given progress monitor to cancel subsequent flow analysis runs. Previously computed results may still be available. If a monitor is set then subsequent accesses to analysis results may through a CancellationException which, if not caught, will abort the current overall Crystal analysis job.

Parameters:
monitor - Monitor to listen for cancellation or Option.none() if worklist runs should not be canceled.

getResultsBefore

@Deprecated
public LE getResultsBefore(ASTNode node)
Deprecated. 

Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists before analyzing the node, including bottom. Before is respective to normal program flow and not the direction of the analysis.

Specified by:
getResultsBefore in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the lattice that represents the analysis state before analyzing the node. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsBeforeCFG(ASTNode)

getResultsBeforeCFG

public LE getResultsBeforeCFG(ASTNode node)
Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists before analyzing the node in the control flow graph. Before is respective to normal program flow and not the direction of the analysis. When called on an expression, this returns the lattice that occurs before this expression is evaluated, but after all sub-expressions are evaluated. For example, when called on an assignment, it returns the lattice after the left and right sub-expressions are evaluated, but before the assignment itself takes place. If there are multiple before lattices for this node, they are joined and returned.

Specified by:
getResultsBeforeCFG in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the lattice that represents the analysis state before analyzing the corresponding node in the control flow graph. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsBeforeAST(ASTNode), IFlowAnalysis.getLabeledResultsBefore(ASTNode)

getResultsBeforeAST

public LE getResultsBeforeAST(ASTNode node)
Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists before analyzing the node in the abstract syntax tree. Before is respective to normal program flow and not the direction of the analysis. When called on an expression, this returns the lattice that occurs before all sub-expressions are evaluated. For example, when called on an assignment, it returns the lattice before either the left or right sub-expressions are evaluated. If there are multiple before lattices for this node, they are joined and returned.

Specified by:
getResultsBeforeAST in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the lattice that represents the analysis state before analyzing any node contained by the given node in the abstract syntax tree. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsBeforeCFG(ASTNode)

getResultsAfter

@Deprecated
public LE getResultsAfter(ASTNode node)
Deprecated. 

Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists after analyzing the node, including bottom. After is respective to normal program flow and not the direction of the analysis.

Specified by:
getResultsAfter in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the lattice that represents the analysis state before analyzing the node. Will be bottom if the node doesn't have a corresponding control flow node.

getResultsAfterCFG

public LE getResultsAfterCFG(ASTNode node)
Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists after analyzing the node in the control flow graph. After is respective to normal program flow and not the direction of the analysis. When called on an node, this returns the lattice that occurs after this node is evaluated, but after all sub-node are evaluated. In particular, calling this on a while node will return results after the while node is evaluated, but not after the entire statement in the AST For most expressions, this returns the same result as IFlowAnalysis.getResultsAfterAST(ASTNode) If there are multiple before lattices for this node, they are joined and returned.

Specified by:
getResultsAfterCFG in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the lattice that represents the analysis state before analyzing the corresponding node in the control flow graph. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsAfterAST(ASTNode), IFlowAnalysis.getLabeledResultsAfter(ASTNode)

getResultsAfterAST

public LE getResultsAfterAST(ASTNode node)
Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists after analyzing the node in the abstract syntax tree. After is respective to normal program flow and not the direction of the analysis. When called on an node, this returns the lattice that occurs after this node and all sub-nodes are evaluated. In particular, calling this on a while node will return results after the entire while statement (including all sub-expressions) is evaluated. For most expressions, this returns the same result as IFlowAnalysis.getResultsAfterCFG(ASTNode) If there are multiple before lattices for this node, they are joined and returned.

Specified by:
getResultsAfterAST in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the lattice that represents the analysis state after analyzing any node contained by the given node in the abstract syntax tree. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsAfterCFG(ASTNode)

getEndResults

public LE getEndResults(MethodDeclaration decl)
Description copied from interface: IFlowAnalysis
Gets the lattice results at the end of a method. This will join all possible exits from a method, including explicit returns, the default return, and exceptional exits.

Specified by:
getEndResults in interface IFlowAnalysis<LE>
Parameters:
decl - The method declaration to get results for
Returns:
The lattice results at the end of the method.

getStartResults

public LE getStartResults(MethodDeclaration decl)
Description copied from interface: IFlowAnalysis
Gets the lattice results at the start of a method. This will probably be the same as the results from calling IFlowAnalysisDefinition.createEntryValue(MethodDeclaration)

Specified by:
getStartResults in interface IFlowAnalysis<LE>
Parameters:
decl - The method declaration to get results for
Returns:
The lattice results at the beginning of the method.
See Also:
IFlowAnalysisDefinition.createEntryValue(MethodDeclaration)

getLabeledResultsBefore

public IResult<LE> getLabeledResultsBefore(ASTNode node)
Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists before analyzing the node in the control flow graph. Works like IFlowAnalysis.getResultsBeforeCFG(ASTNode), except it keeps all the labels separated in an IResult.

Specified by:
getLabeledResultsBefore in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the IResult that represents the analysis state before analyzing the corresponding node in the control flow graph, separated for each incoming edge. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsBeforeCFG(ASTNode)

getLabeledResultsAfter

public IResult<LE> getLabeledResultsAfter(ASTNode node)
Description copied from interface: IFlowAnalysis
Retrieves the analysis state that exists after analyzing the node in the control flow graph. Works like IFlowAnalysis.getResultsAfterCFG(ASTNode), except it keeps all the labels separated in an IResult.

Specified by:
getLabeledResultsAfter in interface IFlowAnalysis<LE>
Parameters:
node - the ASTNode of interest
Returns:
the IResult that represents the analysis state after analyzing the corresponding node in the control flow graph, separated for each incoming edge. Will be bottom if the node doesn't have a corresponding control flow node.
See Also:
IFlowAnalysis.getResultsAfterCFG(ASTNode)

getLabeledEndResult

public IResult<LE> getLabeledEndResult(MethodDeclaration d)
Description copied from interface: IFlowAnalysis
Gets the lattice results at the end of a method. This method should be used when the caller wants to access different possible ending results, such as exceptional exits v. normal returns.

Specified by:
getLabeledEndResult in interface IFlowAnalysis<LE>
Returns:
The analysis results at the end of the method.
See Also:
IFlowAnalysis.getEndResults(MethodDeclaration)

getLabeledStartResult

public IResult<LE> getLabeledStartResult(MethodDeclaration d)
Description copied from interface: IFlowAnalysis
Gets the lattice results at the start of a method. Theoretically, this will be the same as IFlowAnalysis.getStartResults(MethodDeclaration) and IFlowAnalysisDefinition.createEntryValue(MethodDeclaration). However, it might be different for a system which keeps multiple possible contexts in which the method could be called from based on some specifications.

Specified by:
getLabeledStartResult in interface IFlowAnalysis<LE>
Returns:
The analysis results at the beginning of the method, separated by incoming edge.
See Also:
IFlowAnalysisDefinition.createEntryValue(MethodDeclaration), IFlowAnalysis.getStartResults(MethodDeclaration)