edu.cmu.cs.crystal.tac
Class TACFlowAnalysis<LE>

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

public class TACFlowAnalysis<LE>
extends MotherFlowAnalysis<LE>
implements ITACFlowAnalysis<LE>

This class implements flow analyses over 3-address code instructions (TACInstruction). To define a specific analysis, implement ITACTransferFunction for conventional or ITACBranchSensitiveTransferFunction for branch-sensitive flow analyses.

Since:
Crystal 3.3
Author:
Kevin Bierhoff

Field Summary
 
Fields inherited from class edu.cmu.cs.crystal.flow.MotherFlowAnalysis
log
 
Constructor Summary
TACFlowAnalysis(ITACBranchSensitiveTransferFunction<LE> transferFunction, CompilationUnitTACs eclipseTAC)
          Creates a branch sensitive flow analysis object.
TACFlowAnalysis(ITACBranchSensitiveTransferFunction<LE> transferFunction, IAnalysisInput analysisInput)
          Creates a branch sensitive flow analysis object.
TACFlowAnalysis(ITACTransferFunction<LE> transferFunction, CompilationUnitTACs eclipseTAC)
          Creates a branch insensitive flow analysis object.
TACFlowAnalysis(ITACTransferFunction<LE> transferFunction, IAnalysisInput analysisInput)
          Creates a branch insensitive flow analysis object
 
Method Summary
 ThisVariable getImplicitThisVariable(IBinding accessedElement)
          Returns the implicit this variable for accessing a given method or field after previously analyzing the method surrounding the access. It is the caller's responsibility to make sure to call this method only when analysis results for the method surrounding the access are available.
 IResult<LE> getLabeledResultsAfter(TACInstruction instr)
          Retrieves the analysis state that exists after analyzing the instruction.
 IResult<LE> getLabeledResultsBefore(TACInstruction instr)
          Retrieves the analysis state that exists before analyzing the instruction.
 ASTNode getNode(Variable x, TACInstruction instruction)
          Returns for error-reporting purposes a AST node that surrounds or is represented by a variable mentioned in a given instruction.
 LE getResultsAfter(TACInstruction instr)
          Retrieves the analysis state that exists after analyzing the instruction.
 LE getResultsBefore(TACInstruction instr)
          Retrieves the analysis state that exists before analyzing the instruction.
 SourceVariable getSourceVariable(IVariableBinding varBinding)
          Returns the variable for a given parameter or local after previously analyzing the method declaring the parameter or local. It is the caller's responsibility to make sure to call this method only when analysis results for the declaring method are available.
 ThisVariable getThisVariable(MethodDeclaration methodDecl)
          Returns the this variable for a given method after previously analyzing that method. It is the caller's responsibility to make sure to call this method only when analysis results for the given method are available.
 Variable getVariable(ASTNode node)
          Returns the TAC variable for a given ASTNode after previously analyzing the method surrounding the given node. It is the caller's responsibility to make sure to call this method only when analysis results for the surrounding method are available.
 
Methods inherited from class edu.cmu.cs.crystal.flow.MotherFlowAnalysis
getEndResults, getLabeledEndResult, getLabeledResultsAfter, getLabeledResultsBefore, getLabeledStartResult, getResultsAfter, getResultsAfterAST, getResultsAfterCFG, getResultsBefore, getResultsBeforeAST, getResultsBeforeCFG, getStartResults, setMonitor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.cmu.cs.crystal.flow.IFlowAnalysis
getEndResults, getLabeledEndResult, getLabeledResultsAfter, getLabeledResultsBefore, getLabeledStartResult, getResultsAfter, getResultsAfterAST, getResultsAfterCFG, getResultsBefore, getResultsBeforeAST, getResultsBeforeCFG, getStartResults
 

Constructor Detail

TACFlowAnalysis

public TACFlowAnalysis(ITACTransferFunction<LE> transferFunction,
                       IAnalysisInput analysisInput)
Creates a branch insensitive flow analysis object

Parameters:
transferFunction -
analysisInput -

TACFlowAnalysis

public TACFlowAnalysis(ITACTransferFunction<LE> transferFunction,
                       CompilationUnitTACs eclipseTAC)
Creates a branch insensitive flow analysis object.

Parameters:
transferFunction -
eclipseTAC -

TACFlowAnalysis

public TACFlowAnalysis(ITACBranchSensitiveTransferFunction<LE> transferFunction,
                       IAnalysisInput analysisInput)
Creates a branch sensitive flow analysis object.

Parameters:
transferFunction -
analysisInput -

TACFlowAnalysis

public TACFlowAnalysis(ITACBranchSensitiveTransferFunction<LE> transferFunction,
                       CompilationUnitTACs eclipseTAC)
Creates a branch sensitive flow analysis object.

Parameters:
transferFunction -
eclipseTAC -
Method Detail

getResultsAfter

public LE getResultsAfter(TACInstruction instr)
Description copied from interface: ITACFlowAnalysis
Retrieves the analysis state that exists after analyzing the instruction. After is respective to normal program flow and not the direction of the analysis.

Specified by:
getResultsAfter in interface ITACFlowAnalysis<LE>
Parameters:
instr - the TACInstruction of interest
Returns:
the lattice that represents the analysis state before analyzing the instruction. Or null if the node doesn't have a corresponding control flow node.

getResultsBefore

public LE getResultsBefore(TACInstruction instr)
Description copied from interface: ITACFlowAnalysis
Retrieves the analysis state that exists before analyzing the instruction. Before is respective to normal program flow and not the direction of the analysis.

Specified by:
getResultsBefore in interface ITACFlowAnalysis<LE>
Parameters:
instr - the TACInstruction of interest
Returns:
the lattice that represents the analysis state before analyzing the instruction. Or null if the node doesn't have a corresponding control flow node.

getLabeledResultsAfter

public IResult<LE> getLabeledResultsAfter(TACInstruction instr)
Description copied from interface: ITACFlowAnalysis
Retrieves the analysis state that exists after analyzing the instruction. After is respective to normal program flow and not the direction of the analysis.

Specified by:
getLabeledResultsAfter in interface ITACFlowAnalysis<LE>
Parameters:
instr - the TACInstruction of interest
Returns:
the lattice that represents the analysis state after analyzing the instruction. Or null if the node doesn't have a corresponding control flow node.

getLabeledResultsBefore

public IResult<LE> getLabeledResultsBefore(TACInstruction instr)
Description copied from interface: ITACFlowAnalysis
Retrieves the analysis state that exists before analyzing the instruction. Before is respective to normal program flow and not the direction of the analysis.

Specified by:
getLabeledResultsBefore in interface ITACFlowAnalysis<LE>
Parameters:
instr - the TACInstruction of interest
Returns:
the lattice that represents the analysis state after analyzing the instruction. Or null if the node doesn't have a corresponding control flow node.

getNode

public ASTNode getNode(Variable x,
                       TACInstruction instruction)
Description copied from interface: ITACFlowAnalysis
Returns for error-reporting purposes a AST node that surrounds or is represented by a variable mentioned in a given instruction.

Specified by:
getNode in interface ITACFlowAnalysis<LE>
Parameters:
x - A variable.
instruction - Instruction that mentions x
Returns:
A AST node that surrounds or is represented by a variable mentioned in a given instruction.

getVariable

public Variable getVariable(ASTNode node)
Description copied from interface: ITACFlowAnalysis
Returns the TAC variable for a given ASTNode after previously analyzing the method surrounding the given node. It is the caller's responsibility to make sure to call this method only when analysis results for the surrounding method are available.

Specified by:
getVariable in interface ITACFlowAnalysis<LE>
Parameters:
node - AST node in the previously analyzed method.
Returns:
The TAC variable for a given ASTNode.

getThisVariable

public ThisVariable getThisVariable(MethodDeclaration methodDecl)
Description copied from interface: ITACFlowAnalysis
Returns the this variable for a given method after previously analyzing that method. It is the caller's responsibility to make sure to call this method only when analysis results for the given method are available.

Specified by:
getThisVariable in interface ITACFlowAnalysis<LE>
Parameters:
methodDecl - The method for which this is requested.
Returns:
The this variable for the given method.

getSourceVariable

public SourceVariable getSourceVariable(IVariableBinding varBinding)
Description copied from interface: ITACFlowAnalysis
Returns the variable for a given parameter or local after previously analyzing the method declaring the parameter or local. It is the caller's responsibility to make sure to call this method only when analysis results for the declaring method are available.

Specified by:
getSourceVariable in interface ITACFlowAnalysis<LE>
Parameters:
varBinding - Binding of a local or parameter.
Returns:
the variable for the given parameter or local.

getImplicitThisVariable

public ThisVariable getImplicitThisVariable(IBinding accessedElement)
Description copied from interface: ITACFlowAnalysis
Returns the implicit this variable for accessing a given method or field after previously analyzing the method surrounding the access. It is the caller's responsibility to make sure to call this method only when analysis results for the method surrounding the access are available.

Specified by:
getImplicitThisVariable in interface ITACFlowAnalysis<LE>
Returns:
the implicit this for the accessed element