edu.cmu.cs.crystal.cfg.eclipse
Class EclipseCFGNode

java.lang.Object
  extended by edu.cmu.cs.crystal.cfg.eclipse.EclipseCFGNode
All Implemented Interfaces:
ICFGNode<ASTNode>

public class EclipseCFGNode
extends Object
implements ICFGNode<ASTNode>

This class has several purposes: 1) Wrap an ASTNode 2) Be a node in a CFG, with incoming and outgoing edges 3) Help us create a flat structure out of a heirarchical one. 1 and 2 are obvious, so we'll discuss 3. When we build a CFG, we are walking a hierarchical structure (the AST) and turning it into a flat structure (the CFG). When we get to a node, we must evaluate the children and then the node itself. However, we might later need to plug this subgraph into another part of the graph (like the else branch of an if). To do this, we need to know the starting point of the subgraph. Our node can tell what it's first child is, but what about it's child's child? To solve this, we have a 'startNode' which keeps track of the first node. Our startNode will be set to our first child's start node. This bottoms out in a case where the start node is oneself. We also need to know the ending node. In most cases, this is ourself. However, sometimes the node breaks control flow entirely, and it can not be hooked up to another node in the normal flow. To handle this, the endNode might be null.

Author:
ciera

Constructor Summary
EclipseCFGNode(ASTNode node)
           
 
Method Summary
 void addInputEdge(EclipseCFGEdge edge)
           
 void addOutputEdge(EclipseCFGEdge edge)
           
 att.grappa.Node addToGraph(att.grappa.Graph graph)
           
 ASTNode getASTNode()
           
 EclipseCFGNode getEnd()
           
 Set<EclipseCFGEdge> getInputEdges(ILabel label)
          Filters the output edges by the label we are looking for.
 Set<EclipseCFGEdge> getInputs()
           
 String getName()
           
 Set<EclipseCFGEdge> getOutputEdges(ILabel label)
          Filters the output edges by the label we are looking for.
 Set<EclipseCFGEdge> getOutputs()
           
 EclipseCFGNode getStart()
           
 void setASTNode(ASTNode node)
           
 void setEnd(EclipseCFGNode end)
           
 void setName(String name)
           
 void setStart(EclipseCFGNode start)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EclipseCFGNode

public EclipseCFGNode(ASTNode node)
Method Detail

getASTNode

public ASTNode getASTNode()
Specified by:
getASTNode in interface ICFGNode<ASTNode>
Returns:
The Node from which this CFGNode was created, may be null if this node is a dummy node. These nodes will still have input/output edges for control flow purposes.

setASTNode

public void setASTNode(ASTNode node)

getInputs

public Set<EclipseCFGEdge> getInputs()
Specified by:
getInputs in interface ICFGNode<ASTNode>

getOutputs

public Set<EclipseCFGEdge> getOutputs()
Specified by:
getOutputs in interface ICFGNode<ASTNode>

getEnd

public EclipseCFGNode getEnd()
Specified by:
getEnd in interface ICFGNode<ASTNode>

getStart

public EclipseCFGNode getStart()
Specified by:
getStart in interface ICFGNode<ASTNode>

getInputEdges

public Set<EclipseCFGEdge> getInputEdges(ILabel label)
Filters the output edges by the label we are looking for. If we find a combination of BooleanLabels with anything else, we will throw an exception. We're not yet sure what this means, and we'd like to investigate this case thoroughly.

Specified by:
getInputEdges in interface ICFGNode<ASTNode>
Parameters:
label - the label to search for, using .equals()
Returns:
The output edges that have the ILabel label, or the empty set if non exist

getOutputEdges

public Set<EclipseCFGEdge> getOutputEdges(ILabel label)
Filters the output edges by the label we are looking for.

Specified by:
getOutputEdges in interface ICFGNode<ASTNode>
Parameters:
label - the label to search for, using .equals()
Returns:
The output edges that have the ILabel label, or the empty set if non exist

setEnd

public void setEnd(EclipseCFGNode end)

setStart

public void setStart(EclipseCFGNode start)

addInputEdge

public void addInputEdge(EclipseCFGEdge edge)

addOutputEdge

public void addOutputEdge(EclipseCFGEdge edge)

addToGraph

public att.grappa.Node addToGraph(att.grappa.Graph graph)

setName

public void setName(String name)

toString

public String toString()
Overrides:
toString in class Object

getName

public String getName()