tip.cfg
Interface ICFG

All Known Implementing Classes:
CCFG

public interface ICFG

ICFG defines the interface for a control flow graph.

Author:
Johnni Winther, jw@brics.dk

Method Summary
 void add(IProgramPoint point)
          Adds the IProgramPoint point to the set of program points associated with this ICFG.
 void apply(Analysis analysis)
          Applies analysis to all nodes associated with program points in this control flow graph.
<Q> void
apply(Question<Q> caller, Q question)
          Applies the Question caller and question to all nodes associated with program points in this control flow graph.
 void clean()
          Cleans the control flow graph by removing all predecessors and successors of the program points in the program point set of this control flow graph which are not in the program point set of this control flow graph.
 ICFG clone()
          Returns a deep clone of the ICFG with respect to program points, i.e. program points are cloned but the associated AST nodes are not.
 boolean containsProgramPoint(IProgramPoint point)
          Returns true if this ICFG contains the IProgramPoint point.
 IProgramPoint getEntry()
          Returns the entry point of the control flow graph.
 IProgramPoint getExit()
          Returns the exit point of the control flow graph.
 String getName()
          Returns the name of the control flow graph
<T extends Node>
Collection<T>
getNodeDescendants(Class<T> classType)
          Returns a collection of descendants to the nodes associated to the program points in this control flow graph.
<T extends Node>
void
getNodeDescendants(Collection<T> collection, NodeFilter<T> filter)
          Adds children to the nodes associated to the program points in this control flow graph to collection.
<T extends Node>
Collection<T>
getNodeDescendants(NodeFilter<T> filter)
          Returns a collection of descendants to the nodes associated to the program points in this control flow graph.
 Collection<IProgramPoint> getProgramPoints()
          Returns the collection of program points in the control flow graph.
 void insertAfter(IProgramPoint point, IProgramPoint newPoint)
          Inserts newPoint in the control flow graph after point.
 void insertBefore(IProgramPoint point, IProgramPoint newPoint)
          Inserts newPoint in the control flow graph before point.
 void prefixCFG(ICFG cfg)
          Prefixes cfg in this control flow graph.
 void remove(IProgramPoint point)
          Removes the IProgramPoint point from the set of program points associated with this ICFG.
 void removePoint(IProgramPoint point)
          Removes point from this control flow graph, updating the predecessors and successors of point to point to eachother.
 void replaceByCFG(IProgramPoint point, ICFG cfg)
          Replaces point with cfg in this control flow graph.
 void replacePoint(IProgramPoint oldPoint, IProgramPoint newPoint)
          Replaces oldPoint with newPoint in this control flow graph.
 void suffixCFG(ICFG cfg)
          Suffixes cfg in this control flow graph.
 

Method Detail

getName

String getName()
Returns the name of the control flow graph

Returns:
the name of the control flow graph

add

void add(IProgramPoint point)
Adds the IProgramPoint point to the set of program points associated with this ICFG. Predecessors and successors are not updated.

Parameters:
point - the IProgramPoint to be added to this ICFG

remove

void remove(IProgramPoint point)
Removes the IProgramPoint point from the set of program points associated with this ICFG. Predecessors and successors are not updated.

Parameters:
point - the IProgramPoint to be removed from this ICFG

getProgramPoints

Collection<IProgramPoint> getProgramPoints()
Returns the collection of program points in the control flow graph. The program points in this control flow graph are those reachable from the entry node by the successor relation.

Returns:
the collection of program points in the control flow graph

containsProgramPoint

boolean containsProgramPoint(IProgramPoint point)
Returns true if this ICFG contains the IProgramPoint point.

Parameters:
point - the IProgramPoint in question
Returns:
true if this ICFG contains the IProgramPoint point

getEntry

IProgramPoint getEntry()
Returns the entry point of the control flow graph.

Returns:
the entry point of the control flow graph

getExit

IProgramPoint getExit()
Returns the exit point of the control flow graph.

Returns:
the exit point of the control flow graph

replaceByCFG

void replaceByCFG(IProgramPoint point,
                  ICFG cfg)
Replaces point with cfg in this control flow graph. That is, point is removed from this control flow graph, all predecessors of point are set to have all successors of the entry point in cfg as their successor instead of point and all successors of point are set to have all predecessors of the exit point in cfg as their predecessor instead of point. All program point in cfg, except the entry and exit points, are added to this control flow graph.

Parameters:
point - the replaced point
cfg - the replacing control flow graph

prefixCFG

void prefixCFG(ICFG cfg)
Prefixes cfg in this control flow graph. That is, all successors of the entry point in cfg are set to be successors of the entry point in this control flow graph, and all successors of the entry point in this control flow graph are set as successors of the exit point in cfg. All program point in cfg, except the entry and exit points, are added to this control flow graph.

Parameters:
cfg - the prefixed cfg

suffixCFG

void suffixCFG(ICFG cfg)
Suffixes cfg in this control flow graph. That is, all predecessors of the exit point in cfg are set to be predecessors of the exit point in this control flow graph, and all predecessors of the exit point in this control flow graph are set as predecessors of the entry point in cfg. All program point in cfg, except the entry and exit points, are added to this control flow graph.

Parameters:
cfg - the suffixed cfg

replacePoint

void replacePoint(IProgramPoint oldPoint,
                  IProgramPoint newPoint)
Replaces oldPoint with newPoint in this control flow graph. Successors and predecessors are transferred from oldPoint to newPoint. oldPoint is removed from this control flow graph newPoint is added to this control flow graph.

Parameters:
oldPoint - the replaced point
newPoint - the replacing point

removePoint

void removePoint(IProgramPoint point)
Removes point from this control flow graph, updating the predecessors and successors of point to point to eachother.

Parameters:
point - the removed point

insertAfter

void insertAfter(IProgramPoint point,
                 IProgramPoint newPoint)
Inserts newPoint in the control flow graph after point. That is, all successors of point are set as successors of newPoint and newPoint is set as the sole successor of point

Parameters:
point - the point in this control flow graph after which newPoint is inserted
newPoint - the inserted point

insertBefore

void insertBefore(IProgramPoint point,
                  IProgramPoint newPoint)
Inserts newPoint in the control flow graph before point. That is, all predecessors of point are set as predecessors of newPoint and newPoint is set as the sole predecessor of point

Parameters:
point - the point in this control flow graph before which newPoint is inserted
newPoint - the inserted point

clean

void clean()
Cleans the control flow graph by removing all predecessors and successors of the program points in the program point set of this control flow graph which are not in the program point set of this control flow graph. This may be necessary for analyses to work correctly after having added points to the control flow graph from other control flow graphs, as after replaceByCFG(IProgramPoint,ICFG), prefixCFG(ICFG), suffixCFG(ICFG), replacePoint(IProgramPoint,IProgramPoint), insertAfter(IProgramPoint,IProgramPoint), and insertBefore(IProgramPoint,IProgramPoint).


getNodeDescendants

<T extends Node> Collection<T> getNodeDescendants(Class<T> classType)
Returns a collection of descendants to the nodes associated to the program points in this control flow graph. Only descendants that are subtypes of classType are returned.

Parameters:
classType - the supertype of returned descendants
Returns:
a collection of descendants to the associated nodes

getNodeDescendants

<T extends Node> Collection<T> getNodeDescendants(NodeFilter<T> filter)
Returns a collection of descendants to the nodes associated to the program points in this control flow graph. Only descendants that are accepted by the NodeFilter filter are returned.

Parameters:
filter - the NodeFilter used for filtering nodes
Returns:
a collection of descendants to the associated nodes

getNodeDescendants

<T extends Node> void getNodeDescendants(Collection<T> collection,
                                         NodeFilter<T> filter)
Adds children to the nodes associated to the program points in this control flow graph to collection. Only descendants that are accepted by the NodeFilter filter are returned.

Parameters:
collection - the collection to which the descendants are added
filter - the NodeFilter used for filtering nodes

apply

void apply(Analysis analysis)
Applies analysis to all nodes associated with program points in this control flow graph.

Parameters:
analysis - the Analysis applied to the associated nodes

apply

<Q> void apply(Question<Q> caller,
               Q question)
Applies the Question caller and question to all nodes associated with program points in this control flow graph.

Parameters:
caller - the Question applied to the associated nodes
question - the provided question

clone

ICFG clone()
Returns a deep clone of the ICFG with respect to program points, i.e. program points are cloned but the associated AST nodes are not.

Returns:
a deep clone of the ICFG