|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.IR.Tree.Tree
public abstract class Tree
Tree
is the base class for the tree representation.
Nested Class Summary | |
---|---|
static interface |
Tree.CloneCallback
Callback interface to tree cloning code to allow you to update type and other annotations as the tree is cloned. |
Field Summary | |
---|---|
static ArrayFactory<Tree> |
arrayFactory
Array factory: returns Tree[] . |
protected Tree[] |
child
|
Constructor Summary | |
---|---|
protected |
Tree(TreeFactory tf,
HCodeElement source,
int arity)
|
Method Summary | |
---|---|
abstract void |
accept(TreeVisitor v)
Accept a visitor. |
Tree |
clone()
Clone a subtree. |
static Tree |
clone(TreeFactory ntf,
Tree root,
Tree.CloneCallback cb)
Returns a clone of root . |
protected Tree |
getChild(int which)
Fetch from the child array -- for subclass use only. |
TreeFactory |
getFactory()
Returns the TreeFactory that generated this
Tree . |
Tree |
getFirstChild()
Returns the leftmost child of this tree, or null if this node has no children. |
int |
getID()
Returns a unique numeric identifier for this Tree . |
int |
getLineNumber()
Returns the line in the original source file that this Tree is derived from. |
Tree |
getParent()
Returns the parent of this tree. |
Tree |
getSibling()
Returns the right sibling of this tree, null if there are no siblings to the right of this node. |
String |
getSourceFile()
Returns the original source file name that this Tree is
derived from. |
int |
hashCode()
|
ExpList |
kids()
Return a list of subexpressions of this Tree . |
abstract int |
kind()
Return an integer enumeration of the kind of this Tree . |
Tree |
rename(TempMap tm)
Rename while cloning a subtree. |
abstract Tree |
rename(TreeFactory tf,
TempMap tm,
Tree.CloneCallback cb)
Rename while cloning a subtree. |
void |
replace(Tree newTree)
Replace the tree rooted at this with a new tree. |
protected void |
setChild(int which,
Tree newChild)
Modify the child array -- for subclass use only. |
void |
unlink()
Make this a root-level tree, unlinking it from
its parent. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Tree[] child
public static final ArrayFactory<Tree> arrayFactory
Tree[]
.
Constructor Detail |
---|
protected Tree(TreeFactory tf, HCodeElement source, int arity)
Method Detail |
---|
public final int hashCode()
hashCode
in class Object
public final TreeFactory getFactory()
TreeFactory
that generated this
Tree
.
public final Tree getFirstChild()
public final Tree getSibling()
public final Tree getParent()
null
.
protected final Tree getChild(int which)
protected final void setChild(int which, Tree newChild)
public final void replace(Tree newTree)
this
with a new tree.
public final void unlink()
this
a root-level tree, unlinking it from
its parent.
public final String getSourceFile()
Tree
is
derived from.
getSourceFile
in interface HCodeElement
public final int getLineNumber()
Tree
is derived from.
getLineNumber
in interface HCodeElement
public final int getID()
Tree
.
getID
in interface HCodeElement
public abstract int kind()
Tree
. The enumerated values are defined in
TreeKind
.
public abstract void accept(TreeVisitor v)
public static Tree clone(TreeFactory ntf, Tree root, Tree.CloneCallback cb)
root
. The callback()
method of the supplied CloneCallback
will be invoked
with every cloned subtree, from the bottom up to the root. The
cloned subtree will be generated using the supplied
TreeFactory
, ntf
.
NOTE: tree objects may actually contain temps from two different
temp factories. The first temp factory with which a tree's
temps may be associated is the TempFactory
stored in their TreeFactory
. The second
is the TempFactory
used by the tree's
Frame
to generate registers. Since these
registers are assumed to be immutable, no temps from that
temp factory will be cloned by this method. All other temps
will be cloned using a new CloningTempMap
.
public final Tree clone()
this
.
clone
in class Object
public final Tree rename(TempMap tm)
TEMP
nodes
are renamed according to the supplied TempMap
.
Note that Temp
s not belonging to
this.getFactory().tempFactory()
are not affected.
public abstract Tree rename(TreeFactory tf, TempMap tm, Tree.CloneCallback cb)
TEMP
nodes
are renamed according to the supplied TempMap
.
Note that Temp
s not belonging to
this.getFactory().tempFactory()
are not affected.
The callback()
method of the supplied
CloneCallback
is invoked once on each subtree cloned,
starting from the leaves and working back to the root in a
post-order depth-first manner.
public ExpList kids()
Tree
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |