|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.dynamicjava.symbol.type.TreeWalker
public abstract class TreeWalker
A lightweight visitor for traversing (in depth-first order) arbitrary ASTGen-produced trees. Unlike the Visitor classes generated for a specific AST, implementations of TreeWalker are defined for all ASTs. They are more limited, having far fewer hooks available for manipulating the traversal process and handling different types of nodes. This minimal interface is enough, however, for simple visitors which aren't concerned with the semantic content of a tree and simply need to traverse its structure.
When passed to a node's walk() method, a TreeWalker can expect to receive
a specific sequence of method calls: visitNode(java.lang.Object, java.lang.String, int), then #visitField
and a recursive invocation for each of the node's fields. "Recursive invocations"
include additional visitNode() calls and invocations of the the other "visit"
methods for handling Strings, lists, primitives, and objects of unrecognized type.
(Note that the method to call is determined statically based on the field's declared
type, not at runtime.) Clients can prevent recursion into a non-atomic element's
children by returning false in the appropriate visit method.
| Constructor Summary | |
|---|---|
TreeWalker()
|
|
| Method Summary | |
|---|---|
void |
endIterated(java.lang.Object iterable,
int size)
Signal the end of a sequence of iterated elements. |
void |
endIteratedElement(int index,
java.lang.Object element)
Signal the end of recursion on an iterated element. |
void |
endNode(java.lang.Object node,
java.lang.String type,
int fields)
Signal the end of a sequence of node fields. |
void |
endNodeField(java.lang.String name,
java.lang.Object value)
Signal the end of recursion on an AST node's field. |
void |
endNonEmptyOption(java.lang.Object option)
Signal the end of recursion on a non-empty option. |
void |
endTuple(java.lang.Object tuple,
int arity)
Signal the end of a sequence of tuple elements. |
void |
endTupleElement(int index,
java.lang.Object element)
Signal the end of a tuple element. |
void |
visitBoolean(boolean b)
Visit a boolean primitive. |
void |
visitByte(byte b)
Visit a byte primitive. |
void |
visitChar(char c)
Visit a char primitive. |
void |
visitDouble(double d)
Visit a double primitive. |
void |
visitEmptyOption(java.lang.Object option)
Visit an empty option-typed value. |
void |
visitFloat(float f)
Visit a float primitive. |
void |
visitInt(int i)
Visit a int primitive. |
boolean |
visitIterated(java.lang.Object iterable)
Visit an Iterable or array. |
boolean |
visitIteratedElement(int index,
java.lang.Object element)
Visit an iterated element. |
void |
visitLong(long l)
Visit a long primitive. |
boolean |
visitNode(java.lang.Object node,
java.lang.String type,
int fields)
Visit an AST node. |
boolean |
visitNodeField(java.lang.String name,
java.lang.Object value)
Visit an AST node's field. |
boolean |
visitNonEmptyOption(java.lang.Object option)
Visit a non-empty option-typed value. |
void |
visitNull()
Visit a null reference. |
void |
visitShort(short s)
Visit a short primitive. |
void |
visitString(java.lang.String s)
Visit a string value. |
boolean |
visitTuple(java.lang.Object tuple,
int arity)
Visit a tuple-typed value. |
boolean |
visitTupleElement(int index,
java.lang.Object element)
Visit a tuple element. |
void |
visitUnknownObject(java.lang.Object o)
Visit an object that is not known statically to have an AST Node or other supported type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TreeWalker()
| Method Detail |
|---|
public boolean visitNode(java.lang.Object node,
java.lang.String type,
int fields)
true to recur on each of the node's fields.
public boolean visitNodeField(java.lang.String name,
java.lang.Object value)
true to recur on the field's value.
public void endNodeField(java.lang.String name,
java.lang.Object value)
public void endNode(java.lang.Object node,
java.lang.String type,
int fields)
public boolean visitIterated(java.lang.Object iterable)
true to recur on each element.
public boolean visitIteratedElement(int index,
java.lang.Object element)
true to recur on the element value.
public void endIteratedElement(int index,
java.lang.Object element)
public void endIterated(java.lang.Object iterable,
int size)
public boolean visitNonEmptyOption(java.lang.Object option)
true to recur on the nested value.
public void endNonEmptyOption(java.lang.Object option)
public void visitEmptyOption(java.lang.Object option)
public boolean visitTuple(java.lang.Object tuple,
int arity)
true to recur on the nested elements.
public boolean visitTupleElement(int index,
java.lang.Object element)
true to recur on the element value.
public void endTupleElement(int index,
java.lang.Object element)
public void endTuple(java.lang.Object tuple,
int arity)
public void visitString(java.lang.String s)
public void visitUnknownObject(java.lang.Object o)
public void visitNull()
visitNode, visitList,
visitUnknownObject, etc., where a field or element's value is null.
public void visitBoolean(boolean b)
public void visitChar(char c)
public void visitByte(byte b)
public void visitShort(short s)
public void visitInt(int i)
public void visitLong(long l)
public void visitFloat(float f)
public void visitDouble(double d)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||