scale.backend
Class Node

java.lang.Object
  extended by scale.common.Root
      extended by scale.backend.Node
All Implemented Interfaces:
AnnotationInterface, DisplayNode
Direct Known Subclasses:
Hyperblock, PredicateBlock

public abstract class Node
extends Root
implements DisplayNode

This is an abstract class which represents a node in a graph.

$Id: Node.java,v 1.10 2007-10-31 16:39:16 bmaher Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.


Field Summary
protected  int color
           
protected  int label
           
protected  Vector<Node> predecessors
           
protected  Vector<Node> successors
           
protected  int tag
           
 
Constructor Summary
Node(int label)
          The default constructor.
 
Method Summary
 void addInEdge(Node in)
          Add an incoming edge.
 void addOutEdge(Node out)
          Add an out going edge.
 void deleteInEdge(Node in)
          Delete an incoming edge.
 void deleteOutEdge(Node out)
          Delete an outgoing edge.
 Node getInEdge(int i)
          Return the i-th predecessor node.
 Vector<Node> getInEdges()
          Return an array containing all predecessors.
 int getLabel()
          Return the unique identifier for this block.
 Node getOutEdge(int i)
          Return the i-th successor node.
 Vector<Node> getOutEdges()
          Return an array containing all successors.
 int getTag()
          Get the tag for the block.
 int indexOfInEdge(Node in)
          Return the index of the specified in-coming CFG edge.
 int indexOfOutEdge(Node out)
          Return the index of the specified out-going CFG edge.
protected abstract  void nextVisit()
          The next unique color for traversing the graph.
 int numInEdges()
          Return the number of in-coming edges.
 int numOutEdges()
          Return the number of out-going edges.
 void pushInEdges(Stack<Node> wl)
          Add the predecessors of this block to the stack if they haven't been visited before.
 void pushInEdges(Stack<Node> wl, HashSet<Node> visited)
          Add the predecessors of this block to the stack if they haven't been visited before.
 void pushOutEdges(Stack<Node> wl)
          Add the successors of this block to the stack if they haven't been visited before.
 void pushOutEdges(Stack<Node> wl, HashSet<java.lang.Object> visited)
          Add the successors of this block to the stack if they haven't been visited before.
 void replaceInEdge(Node oldEdge, Node newEdge)
          Replace the existing incoming edge with a new edge.
 void replaceOutEdge(Node oldEdge, Node newEdge)
          Replace the existing outgoing edge with a new edge.
 void setLabel(int label)
          Set the unique identifier for this block.
 void setTag(int tag)
          Set the tag for the block.
protected abstract  void setVisited()
          Mark that the block has been visited.
 void unlink()
          Remove this node from the graph.
abstract  boolean visited()
          Return true if the block has been visited.
 
Methods inherited from class scale.common.Root
addAnnotation, allAnnotations, allMatchingAnnotations, getAnnotation, getDisplayColorHint, getDisplayLabel, getDisplayName, getDisplayShapeHint, getDisplayString, getNodeCount, getNodeID, hasAnnotation, hasEqualAnnotation, hashCode, removeAnnotation, removeAnnotations, toString, toStringAnnotations, toStringClass, toStringSpecial, trace, trace, trace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface scale.common.DisplayNode
getDisplayColorHint, getDisplayLabel, getDisplayName, getDisplayShapeHint
 

Field Detail

successors

protected Vector<Node> successors

predecessors

protected Vector<Node> predecessors

color

protected int color

label

protected int label

tag

protected int tag
Constructor Detail

Node

public Node(int label)
The default constructor.

Method Detail

pushInEdges

public final void pushInEdges(Stack<Node> wl)
Add the predecessors of this block to the stack if they haven't been visited before.


pushInEdges

public final void pushInEdges(Stack<Node> wl,
                              HashSet<Node> visited)
Add the predecessors of this block to the stack if they haven't been visited before.

Parameters:
wl - the stack
visited - the set of visited nodes

pushOutEdges

public final void pushOutEdges(Stack<Node> wl)
Add the successors of this block to the stack if they haven't been visited before.


pushOutEdges

public final void pushOutEdges(Stack<Node> wl,
                               HashSet<java.lang.Object> visited)
Add the successors of this block to the stack if they haven't been visited before.

Parameters:
wl - the stack
visited - the set of visited nodes

numInEdges

public final int numInEdges()
Return the number of in-coming edges.


numOutEdges

public final int numOutEdges()
Return the number of out-going edges.


getInEdge

public final Node getInEdge(int i)
Return the i-th predecessor node. Caution must be used when using this method while adding or removing nodes from the PFG.


getOutEdge

public final Node getOutEdge(int i)
Return the i-th successor node. Caution must be used when using this method while adding or removing nodes from the PFG.


getInEdges

public final Vector<Node> getInEdges()
Return an array containing all predecessors.


getOutEdges

public final Vector<Node> getOutEdges()
Return an array containing all successors.


indexOfInEdge

public final int indexOfInEdge(Node in)
Return the index of the specified in-coming CFG edge. Return -1 if it's not an edge.


indexOfOutEdge

public final int indexOfOutEdge(Node out)
Return the index of the specified out-going CFG edge. Return -1 if it's not an edge.


replaceInEdge

public final void replaceInEdge(Node oldEdge,
                                Node newEdge)
Replace the existing incoming edge with a new edge.


replaceOutEdge

public final void replaceOutEdge(Node oldEdge,
                                 Node newEdge)
Replace the existing outgoing edge with a new edge.


addInEdge

public final void addInEdge(Node in)
Add an incoming edge.


addOutEdge

public final void addOutEdge(Node out)
Add an out going edge.


deleteOutEdge

public final void deleteOutEdge(Node out)
Delete an outgoing edge.


deleteInEdge

public final void deleteInEdge(Node in)
Delete an incoming edge.


unlink

public final void unlink()
Remove this node from the graph.


getLabel

public final int getLabel()
Return the unique identifier for this block.


setLabel

public final void setLabel(int label)
Set the unique identifier for this block.


setTag

public final void setTag(int tag)
Set the tag for the block.


getTag

public final int getTag()
Get the tag for the block.


setVisited

protected abstract void setVisited()
Mark that the block has been visited.


visited

public abstract boolean visited()
Return true if the block has been visited.


nextVisit

protected abstract void nextVisit()
The next unique color for traversing the graph.
This method is not static in order to support traversing graphs, where each node in the graph is itself a graph made up of nodes.