Package EDU.purdue.cs.bloat.tree
Class Node
- java.lang.Object
-
- EDU.purdue.cs.bloat.tree.Node
-
public abstract class Node extends java.lang.ObjectNode represents a node in an expression tree. Each Node has a value number and a key associated with it. The value number is used to eliminate statements and expressions that have the same value (PRE). Statements and expressions of the same value will be mapped to the same value number.
-
-
Constructor Summary
Constructors Constructor Description Node()Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Blockblock()Returns the basic block in which this Node resides.voidcleanup()Cleans up this node so that it is independent of the expression tree in which it resides.abstract voidcleanupOnly()Clean up this Node only.protected NodecopyInto(Node node)Copies the contents of one Node into another.booleanhasParent()intkey()A Node's key represents an integer value that can be used by an algorithm to mark this node.Nodeparent()voidreplaceWith(Node node)Replaces this node with another and perform cleanup.voidreplaceWith(Node node, boolean cleanup)Replaces this Node with node in its (this's) tree.voidsetKey(int key)voidsetParent(Node parent)Sets the parent Node of this Node.voidsetValueNumber(int valueNumber)Sets this Node's value number.java.lang.StringtoString()intvalueNumber()Returns this Node's value number.abstract voidvisit(TreeVisitor visitor)voidvisitChildren(TreeVisitor visitor)abstract voidvisitForceChildren(TreeVisitor visitor)Visit the children of this node.voidvisitOnly(TreeVisitor visitor)
-
-
-
Field Detail
-
parent
protected Node parent
-
-
Method Detail
-
valueNumber
public int valueNumber()
Returns this Node's value number.
-
setValueNumber
public void setValueNumber(int valueNumber)
Sets this Node's value number.
-
key
public int key()
A Node's key represents an integer value that can be used by an algorithm to mark this node. For instance, when dead code elimination is performed a Node is marked as DEAD or ALIVE.
-
setKey
public void setKey(int key)
-
visitForceChildren
public abstract void visitForceChildren(TreeVisitor visitor)
Visit the children of this node. Not all Nodes will have children to visit.
-
visit
public abstract void visit(TreeVisitor visitor)
-
visitChildren
public void visitChildren(TreeVisitor visitor)
-
visitOnly
public void visitOnly(TreeVisitor visitor)
-
block
public Block block()
Returns the basic block in which this Node resides.
-
setParent
public void setParent(Node parent)
Sets the parent Node of this Node.
-
hasParent
public boolean hasParent()
-
parent
public Node parent()
-
copyInto
protected Node copyInto(Node node)
Copies the contents of one Node into another.- Parameters:
node- A Node from which to copy.- Returns:
- node containing the contents of this Node.
-
cleanupOnly
public abstract void cleanupOnly()
Clean up this Node only. Does not effect its children nodes.
-
cleanup
public void cleanup()
Cleans up this node so that it is independent of the expression tree in which it resides. This is usually performed before a Node is moved from one part of an expression tree to another.Traverse the Tree starting at this Node. Remove the parent of each node and perform any Node-specific cleanup (see cleanupOnly). Sets various pointers to null so that they eventually may be garbage collected.
-
replaceWith
public void replaceWith(Node node)
Replaces this node with another and perform cleanup.
-
replaceWith
public void replaceWith(Node node, boolean cleanup)
Replaces this Node with node in its (this's) tree.- Parameters:
node- The Node with which to replace.cleanup- Do we perform cleanup on the tree?
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- Returns:
- A textual representation of this Node.
-
-