| java.lang.Object xtc.tree.Visitor
All known Subclasses: xtc.lang.jeannie.JeanniePrinter, xtc.parser.Annotator, xtc.lang.CAnalyzer, xtc.lang.JavaPrinter, xtc.parser.ReachabilityChecker, xtc.tree.Relocator, xtc.lang.p2.Printer, xtc.parser.DirectLeftRecurser, xtc.type.SourcePrinter, xtc.parser.Checker, xtc.lang.CPrinter, xtc.type.TypePrinter, xtc.lang.CCounter, xtc.lang.JavaAnalyzer, xtc.parser.CostEstimator, xtc.parser.MetaDataSetter, xtc.lang.JavaAstSimplifier, xtc.typical.FlagSetter, xtc.parser.ValueChecker, xtc.lang.jeannie.Analyzer, xtc.parser.LeftRecurser, xtc.parser.TextTester, xtc.typical.FreeVariableCollector, xtc.parser.Generifier, xtc.lang.jeannie.CodeGenerator, xtc.lang.jeannie.AstSimplifier, xtc.parser.GrammarVisitor, xtc.lang.p2.ConcurrencyAnalyzer, xtc.lang.jeannie.DebuggerInterpreter, xtc.parser.VariantSorter, xtc.parser.PrettyPrinter, xtc.parser.Transformer, xtc.parser.ListMaker, xtc.tree.Transducer, xtc.lang.jeannie.DebuggerAstAnalyzer, xtc.tree.ParseTreeStripper, xtc.lang.TypedLambdaPrinter, xtc.typical.TypeCollector, xtc.lang.p2.TypeAnalyzer, xtc.parser.CodeGenerator, xtc.parser.Resolver, xtc.typical.Transformer, xtc.parser.TreeExtractor, xtc.parser.TreeTyper, xtc.tree.ParseTreePrinter, xtc.lang.JavaExternalAnalyzer, xtc.parser.Copier, xtc.parser.EquivalenceTester, xtc.parser.ElementVoider, xtc.parser.MetaDataCreator,
Visitor | abstract public class Visitor (Code) | | A node visitor. In contrast to the basic visitor pattern (which
only works for a fixed set of object types), the node visitor is
extensible. As described in this
JavaWorld tip, the implementation relies on Java reflection to
dispatch to the appropriate visit() method. Note that
the node visitor does not recognize method names that append the
object type to the word "visit", rather it relies on the argument
type alone to identify the appropriate visit() method.
Note that to improve performance of dynamic dispatch, this class
uses a static method lookup cache. As a result, dispatch is not
thread-safe.
author: Robert Grimm version: $Revision: 1.1 $ |
Inner Class :static class CacheKey | |
Constructor Summary | |
public | Visitor() Create a new visitor. |
Method Summary | |
public Object | dispatch(Node node) Find the closest matching visit() method for the
specified node and invoke it. |
Visitor | public Visitor()(Code) | | Create a new visitor.
|
dispatch | public Object dispatch(Node node)(Code) | | Find the closest matching visit() method for the
specified node and invoke it. Optionally, a visit()
method may return a value, thus making it possible, for example,
to replace nodes or to construct entirely new trees. If the
visit() method does not return a value, this method
returns null .
Parameters: node - The node. The (optional) return value. throws: VisitorException - Signals that this visitor does not have a matching visit() method. throws: VisitingException - Signals an exceptional condition while visiting the specifiednode. |
|
|