tip.cfg
Class CFGBuilder

java.lang.Object
  extended by tip.analysis.AnalysisAdapter
      extended by tip.analysis.DepthFirstAdapter
          extended by tip.cfg.CFGBuilder
All Implemented Interfaces:
Analysis

public class CFGBuilder
extends DepthFirstAdapter

CFGBuilder constructs control flow graphs for an AST based on the definitions in the SableCC grammar 'Control Flow Graph'-section.

Author:
Johnni Winther, jw@brics.dk

Method Summary
static ICFGCollection createCFGCollection(Node node)
          Creates a collection of control flow graphs based on a traversal starting in node.
static ICFGCollection createCFGCollection(Node node, NodeFilter filter)
          Creates a collection of control flow graphs based on a traversal starting in node using filter to decide which program point such appear in the resulting control flow graphs.
 void inABinopExp(ABinopExp node)
          Called by DepthFirstAdapter.caseABinopExp(ABinopExp) before traversing the children of ABinopExp.
 void inABlock(ABlock node)
          Called by DepthFirstAdapter.caseABlock(ABlock) before traversing the children of ABlock.
 void inABlockStm(ABlockStm node)
          Called by DepthFirstAdapter.caseABlockStm(ABlockStm) before traversing the children of ABlockStm.
 void inABody(ABody node)
          Called by DepthFirstAdapter.caseABody(ABody) before traversing the children of ABody.
 void inADeclStm(ADeclStm node)
          Called by DepthFirstAdapter.caseADeclStm(ADeclStm) before traversing the children of ADeclStm.
 void inADerefExp(ADerefExp node)
          Called by DepthFirstAdapter.caseADerefExp(ADerefExp) before traversing the children of ADerefExp.
 void inAFuncDecl(AFuncDecl node)
          Called by DepthFirstAdapter.caseAFuncDecl(AFuncDecl) before traversing the children of AFuncDecl.
 void inAFunctionCallExp(AFunctionCallExp node)
          Called by DepthFirstAdapter.caseAFunctionCallExp(AFunctionCallExp) before traversing the children of AFunctionCallExp.
 void inAFunctionPtrCallExp(AFunctionPtrCallExp node)
          Called by DepthFirstAdapter.caseAFunctionPtrCallExp(AFunctionPtrCallExp) before traversing the children of AFunctionPtrCallExp.
 void inAIfThenElseStm(AIfThenElseStm node)
          Called by DepthFirstAdapter.caseAIfThenElseStm(AIfThenElseStm) before traversing the children of AIfThenElseStm.
 void inAIfThenStm(AIfThenStm node)
          Called by DepthFirstAdapter.caseAIfThenStm(AIfThenStm) before traversing the children of AIfThenStm.
 void inAInputExp(AInputExp node)
          Called by DepthFirstAdapter.caseAInputExp(AInputExp) before traversing the children of AInputExp.
 void inAIntConstExp(AIntConstExp node)
          Called by DepthFirstAdapter.caseAIntConstExp(AIntConstExp) before traversing the children of AIntConstExp.
 void inAMallocExp(AMallocExp node)
          Called by DepthFirstAdapter.caseAMallocExp(AMallocExp) before traversing the children of AMallocExp.
 void inANullExp(ANullExp node)
          Called by DepthFirstAdapter.caseANullExp(ANullExp) before traversing the children of ANullExp.
 void inAOutputStm(AOutputStm node)
          Called by DepthFirstAdapter.caseAOutputStm(AOutputStm) before traversing the children of AOutputStm.
 void inAPointerExp(APointerExp node)
          Called by DepthFirstAdapter.caseAPointerExp(APointerExp) before traversing the children of APointerExp.
 void inAReturnStm(AReturnStm node)
          Called by DepthFirstAdapter.caseAReturnStm(AReturnStm) before traversing the children of AReturnStm.
 void inAVarExp(AVarExp node)
          Called by DepthFirstAdapter.caseAVarExp(AVarExp) before traversing the children of AVarExp.
 void inAWhileStm(AWhileStm node)
          Called by DepthFirstAdapter.caseAWhileStm(AWhileStm) before traversing the children of AWhileStm.
 void inAAssignPtrStm(AAssignPtrStm node)
          Called by DepthFirstAdapter.caseAAssignPtrStm(AAssignPtrStm) before traversing the children of AAssignPtrStm.
 void inAAssignVarStm(AAssignVarStm node)
          Called by DepthFirstAdapter.caseAAssignVarStm(AAssignVarStm) before traversing the children of AAssignVarStm.
 void outAFuncDecl(AFuncDecl node)
          Called by DepthFirstAdapter.caseAFuncDecl(AFuncDecl) after traversing the children of AFuncDecl.
 
Methods inherited from class tip.analysis.DepthFirstAdapter
caseABinopExp, caseABlock, caseABlockStm, caseABody, caseADeclStm, caseADerefExp, caseADivideBinop, caseAEqBinop, caseAFuncDecl, caseAFunctionCallExp, caseAFunctionPtrCallExp, caseAGtBinop, caseAIfThenElseStm, caseAIfThenStm, caseAInputExp, caseAIntConstExp, caseALocalDecl, caseAMallocExp, caseAMinusBinop, caseANullExp, caseAOutputStm, caseAPlusBinop, caseAPointerExp, caseAProgram, caseAReturnStm, caseATimesBinop, caseAVarExp, caseAWhileStm, caseStart, caseAAssignPtrStm, caseAAssignVarStm, defaultIn, defaultInPBinop, defaultInPBlock, defaultInPBody, defaultInPDecl, defaultInPExp, defaultInPProgram, defaultInPStm, defaultOut, defaultOutPBinop, defaultOutPBlock, defaultOutPBody, defaultOutPDecl, defaultOutPExp, defaultOutPProgram, defaultOutPStm, defaultPBinop, defaultPBlock, defaultPBody, defaultPDecl, defaultPExp, defaultPProgram, defaultPStm, inADivideBinop, inAEqBinop, inAGtBinop, inALocalDecl, inAMinusBinop, inAPlusBinop, inAProgram, inATimesBinop, inStart, outABinopExp, outABlock, outABlockStm, outABody, outADeclStm, outADerefExp, outADivideBinop, outAEqBinop, outAFunctionCallExp, outAFunctionPtrCallExp, outAGtBinop, outAIfThenElseStm, outAIfThenStm, outAInputExp, outAIntConstExp, outALocalDecl, outAMallocExp, outAMinusBinop, outANullExp, outAOutputStm, outAPlusBinop, outAPointerExp, outAProgram, outAReturnStm, outATimesBinop, outAVarExp, outAWhileStm, outStart, outAAssignPtrStm, outAAssignVarStm
 
Methods inherited from class tip.analysis.AnalysisAdapter
caseEOF, caseTAnd, caseTAssign, caseTComma, caseTCommentBlock, caseTCommentSingle, caseTDiv, caseTElse, caseTEq, caseTGt, caseTIdentifier, caseTIf, caseTInput, caseTIntegerConst, caseTLBrace, caseTLPar, caseTMalloc, caseTMinus, caseTNull, caseTOutput, caseTPlus, caseTRBrace, caseTReturn, caseTRPar, caseTSemicolon, caseTStar, caseTVar, caseTWhile, caseTWhiteSpace, defaultNode, defaultToken, getIn, getOut, setIn, setOut
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

inABlockStm

public void inABlockStm(ABlockStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseABlockStm(ABlockStm) before traversing the children of ABlockStm.

Overrides:
inABlockStm in class DepthFirstAdapter
Parameters:
node - the visited ABlockStm node

inAIfThenStm

public void inAIfThenStm(AIfThenStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAIfThenStm(AIfThenStm) before traversing the children of AIfThenStm.

Overrides:
inAIfThenStm in class DepthFirstAdapter
Parameters:
node - the visited AIfThenStm node

inAWhileStm

public void inAWhileStm(AWhileStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAWhileStm(AWhileStm) before traversing the children of AWhileStm.

Overrides:
inAWhileStm in class DepthFirstAdapter
Parameters:
node - the visited AWhileStm node

inAPointerExp

public void inAPointerExp(APointerExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAPointerExp(APointerExp) before traversing the children of APointerExp.

Overrides:
inAPointerExp in class DepthFirstAdapter
Parameters:
node - the visited APointerExp node

inAMallocExp

public void inAMallocExp(AMallocExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAMallocExp(AMallocExp) before traversing the children of AMallocExp.

Overrides:
inAMallocExp in class DepthFirstAdapter
Parameters:
node - the visited AMallocExp node

inAFuncDecl

public void inAFuncDecl(AFuncDecl node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAFuncDecl(AFuncDecl) before traversing the children of AFuncDecl.

Overrides:
inAFuncDecl in class DepthFirstAdapter
Parameters:
node - the visited AFuncDecl node

outAFuncDecl

public void outAFuncDecl(AFuncDecl node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAFuncDecl(AFuncDecl) after traversing the children of AFuncDecl.

Overrides:
outAFuncDecl in class DepthFirstAdapter
Parameters:
node - the visited AFuncDecl node

inABlock

public void inABlock(ABlock node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseABlock(ABlock) before traversing the children of ABlock.

Overrides:
inABlock in class DepthFirstAdapter
Parameters:
node - the visited ABlock node

inADerefExp

public void inADerefExp(ADerefExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseADerefExp(ADerefExp) before traversing the children of ADerefExp.

Overrides:
inADerefExp in class DepthFirstAdapter
Parameters:
node - the visited ADerefExp node

inANullExp

public void inANullExp(ANullExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseANullExp(ANullExp) before traversing the children of ANullExp.

Overrides:
inANullExp in class DepthFirstAdapter
Parameters:
node - the visited ANullExp node

inAIntConstExp

public void inAIntConstExp(AIntConstExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAIntConstExp(AIntConstExp) before traversing the children of AIntConstExp.

Overrides:
inAIntConstExp in class DepthFirstAdapter
Parameters:
node - the visited AIntConstExp node

inABinopExp

public void inABinopExp(ABinopExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseABinopExp(ABinopExp) before traversing the children of ABinopExp.

Overrides:
inABinopExp in class DepthFirstAdapter
Parameters:
node - the visited ABinopExp node

inAFunctionPtrCallExp

public void inAFunctionPtrCallExp(AFunctionPtrCallExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAFunctionPtrCallExp(AFunctionPtrCallExp) before traversing the children of AFunctionPtrCallExp.

Overrides:
inAFunctionPtrCallExp in class DepthFirstAdapter
Parameters:
node - the visited AFunctionPtrCallExp node

inAAssignVarStm

public void inAAssignVarStm(AAssignVarStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAAssignVarStm(AAssignVarStm) before traversing the children of AAssignVarStm.

Overrides:
inAAssignVarStm in class DepthFirstAdapter
Parameters:
node - the visited AAssignVarStm node

inAOutputStm

public void inAOutputStm(AOutputStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAOutputStm(AOutputStm) before traversing the children of AOutputStm.

Overrides:
inAOutputStm in class DepthFirstAdapter
Parameters:
node - the visited AOutputStm node

inAReturnStm

public void inAReturnStm(AReturnStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAReturnStm(AReturnStm) before traversing the children of AReturnStm.

Overrides:
inAReturnStm in class DepthFirstAdapter
Parameters:
node - the visited AReturnStm node

inAFunctionCallExp

public void inAFunctionCallExp(AFunctionCallExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAFunctionCallExp(AFunctionCallExp) before traversing the children of AFunctionCallExp.

Overrides:
inAFunctionCallExp in class DepthFirstAdapter
Parameters:
node - the visited AFunctionCallExp node

inADeclStm

public void inADeclStm(ADeclStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseADeclStm(ADeclStm) before traversing the children of ADeclStm.

Overrides:
inADeclStm in class DepthFirstAdapter
Parameters:
node - the visited ADeclStm node

inAInputExp

public void inAInputExp(AInputExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAInputExp(AInputExp) before traversing the children of AInputExp.

Overrides:
inAInputExp in class DepthFirstAdapter
Parameters:
node - the visited AInputExp node

inABody

public void inABody(ABody node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseABody(ABody) before traversing the children of ABody.

Overrides:
inABody in class DepthFirstAdapter
Parameters:
node - the visited ABody node

inAIfThenElseStm

public void inAIfThenElseStm(AIfThenElseStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAIfThenElseStm(AIfThenElseStm) before traversing the children of AIfThenElseStm.

Overrides:
inAIfThenElseStm in class DepthFirstAdapter
Parameters:
node - the visited AIfThenElseStm node

inAVarExp

public void inAVarExp(AVarExp node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAVarExp(AVarExp) before traversing the children of AVarExp.

Overrides:
inAVarExp in class DepthFirstAdapter
Parameters:
node - the visited AVarExp node

inAAssignPtrStm

public void inAAssignPtrStm(AAssignPtrStm node)
Description copied from class: DepthFirstAdapter
Called by DepthFirstAdapter.caseAAssignPtrStm(AAssignPtrStm) before traversing the children of AAssignPtrStm.

Overrides:
inAAssignPtrStm in class DepthFirstAdapter
Parameters:
node - the visited AAssignPtrStm node

createCFGCollection

public static ICFGCollection createCFGCollection(Node node)
Creates a collection of control flow graphs based on a traversal starting in node.

Parameters:
node - the node in which the traversal starts
Returns:
a collection of control flow graphs based on node

createCFGCollection

public static ICFGCollection createCFGCollection(Node node,
                                                 NodeFilter filter)
Creates a collection of control flow graphs based on a traversal starting in node using filter to decide which program point such appear in the resulting control flow graphs.

Parameters:
node - the node in which the traversal starts
filter - the NodeFilter used in the construction
Returns:
a collection of control flow graphs based on node