Class TreeVisitor

java.lang.Object
icyllis.arc3d.compiler.analysis.TreeVisitor

public abstract class TreeVisitor extends Object
Utility class to visit every element, statement, and expression in a program IR. This is intended for simple analysis and accumulation, where custom visitation behavior is only needed for a limited set of expression kinds.

Subclasses should override visitExpression/visitStatement/visitElement as needed and intercept elements of interest. They can then invoke the base class's function to visit all sub expressions. They can also choose not to call the base function to arrest recursion, or implement custom recursion.

The visit functions return a bool that determines how the default implementation recursions. Once any visit call returns true, the default behavior stops recursion and propagates true up the stack.

  • Constructor Details

    • TreeVisitor

      public TreeVisitor()
  • Method Details

    • visitTopLevelElement

      public boolean visitTopLevelElement(@NonNull TopLevelElement e)
    • visitExpression

      public boolean visitExpression(@NonNull Expression expr)
    • visitStatement

      public boolean visitStatement(@NonNull Statement stmt)