|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.tree.Node
xtc.tree.GNode
public abstract class GNode
A generic node in an abstract syntax tree.
A note on memory conservation: Generic nodes created through thecreate(String) or create(String,int) methods
can have a variable number of children. While such nodes provide
considerable flexibility in creating and managing an abstract
syntax tree, their implementation also has a relatively high memory
and thus performance overhead. Consequently, this class provides
another set of create() methods, which directly take
the new node's children as arguments and return nodes specialized
for that number of children. After creation, the number of
children cannot be changed anymore. Code using generic nodes can
test whether a node supports a variable number of children through
Node.hasVariable() and convert fixed size nodes into variable
sized nodes through ensureVariable(GNode).
| Field Summary | |
|---|---|
static int |
MAX_FIXED
The maximum number of children for generic nodes that are optimized to hold a fixed number of children. |
| Method Summary | |
|---|---|
static GNode |
cast(Object o)
Cast the specified object to a generic node. |
static GNode |
create(GNode node)
Create a new generic node that is a (shallow) copy of the specified node. |
static GNode |
create(String name)
Create a new generic node with the specified name. |
static GNode |
create(String name,
boolean variable)
Create a new generic node with the specified name. |
static GNode |
create(String name,
int capacity)
Create a new generic node with the specified name. |
static GNode |
create(String name,
Object child)
Create a new generic node with the specified name and child. |
static GNode |
create(String name,
Object c1,
Object c2)
Create a new generic node with the specified name and children. |
static GNode |
create(String name,
Object c1,
Object c2,
Object c3)
Create a new generic node with the specified name and children. |
static GNode |
create(String name,
Object c1,
Object c2,
Object c3,
Object c4)
Create a new generic node with the specified name and children. |
static GNode |
create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5)
Create a new generic node with the specified name and children. |
static GNode |
create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5,
Object c6)
Create a new generic node with the specified name and children. |
static GNode |
create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5,
Object c6,
Object c7)
Create a new generic node with the specified name and children. |
static GNode |
create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5,
Object c6,
Object c7,
Object c8)
Create a new generic node with the specified name and children. |
static GNode |
createFromPair(String name,
Object base,
Pair rest)
Create a new generic node with the specified children. |
static GNode |
createFromPair(String name,
Pair p)
Create a new generic node with the list's nodes as its children. |
static GNode |
ensureVariable(GNode node)
Ensure that the specified node supports a variable number of children. |
boolean |
equals(Object o)
Determine whether this generic node equals the specified object. |
String |
getName()
Get the name of this node. |
int |
hashCode()
Get this generic node's hash code. |
boolean |
hasName(String name)
Determine whether this node's name is the same as the specified name. |
boolean |
hasTraversal()
Determine whether this node supports generic traversal of its children. |
boolean |
isGeneric()
Determine whether this node is generic. |
static boolean |
test(Object o)
Test whether the specified object is a generic node, possibly wrapped in annotations. |
| Methods inherited from class xtc.tree.Node |
|---|
add, add, addAll, addAll, addAll, addAll, addAllTo, addNode, contains, get, getBoolean, getBooleanProperty, getGeneric, getList, getLocation, getNode, getProperty, getString, getStringProperty, getTokenText, hasLocation, hasProperty, hasVariable, indexOf, isAnnotation, isEmpty, isList, isToken, iterator, lastIndexOf, properties, remove, removeProperty, set, setLocation, setLocation, setProperty, size, strip, toAnnotation, toList, toString, toToken, write |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_FIXED
| Method Detail |
|---|
public int hashCode()
hashCode in class Objectpublic boolean equals(Object o)
equals in class Objecto - The object to compare to.
true if this generic node equals the object.public final boolean isGeneric()
isGeneric in class Nodetrue.GNodepublic final boolean hasTraversal()
Nodefalse.
hasTraversal in class Nodetrue if this node supports generic traversal
of its children.public final String getName()
Node
getName in class Nodepublic final boolean hasName(String name)
Node
hasName in class Nodename - The name.
true if this node's name equals the
specified name.public static GNode create(String name)
name - The name.
public static GNode create(String name,
int capacity)
name - The name.capacity - The initial capacity.
IllegalArgumentException - Signals that the capacity is negative.
public static GNode create(String name,
boolean variable)
create(String). Invoking this method with a false variabel
flag results in a generic node with no children.
name - The name.variable - Flag for whether the new node supports a variable
number of children.
public static GNode create(String name,
Object child)
name - The name.child - The child.
public static GNode create(String name,
Object c1,
Object c2)
name - The name.c1 - The first child.c2 - The second child.
public static GNode create(String name,
Object c1,
Object c2,
Object c3)
name - The name.c1 - The first child.c2 - The second child.c3 - The third child.
public static GNode create(String name,
Object c1,
Object c2,
Object c3,
Object c4)
name - The name.c1 - The first child.c2 - The second child.c3 - The third child.c4 - The fourth child.
public static GNode create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5)
name - The name.c1 - The first child.c2 - The second child.c3 - The third child.c4 - The fourth child.c5 - The fifth child.
public static GNode create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5,
Object c6)
name - The name.c1 - The first child.c2 - The second child.c3 - The third child.c4 - The fourth child.c5 - The fifth child.c6 - The sixth child.
public static GNode create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5,
Object c6,
Object c7)
name - The name.c1 - The first child.c2 - The second child.c3 - The third child.c4 - The fourth child.c5 - The fifth child.c6 - The sixth child.c7 - The seventh child.
public static GNode create(String name,
Object c1,
Object c2,
Object c3,
Object c4,
Object c5,
Object c6,
Object c7,
Object c8)
name - The name.c1 - The first child.c2 - The second child.c3 - The third child.c4 - The fourth child.c5 - The fifth child.c6 - The sixth child.c7 - The seventh child.c8 - The eigth child.
public static GNode createFromPair(String name,
Pair p)
name - The name.p - The list of children.
public static GNode createFromPair(String name,
Object base,
Pair rest)
name - The name.base - The first child.rest - The rest of the children.
public static GNode create(GNode node)
node - The node to copy.
public static GNode ensureVariable(GNode node)
node - The generic node.
public static final boolean test(Object o)
o - The object.
true if the object is a possibly annotated
generic node.public static final GNode cast(Object o)
annotations, they are stripped before returning the object as a generic
node.
o - The object.
test(Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||