Class TreeVisitor

java.lang.Object
icyllis.arc3d.compiler.tree.TreeVisitor
Direct Known Subclasses:
SymbolUsage

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

    • visitFunctionPrototype

      public boolean visitFunctionPrototype(FunctionPrototype prototype)
    • visitFunctionDefinition

      public boolean visitFunctionDefinition(FunctionDefinition definition)
    • visitGlobalVariableDecl

      public boolean visitGlobalVariableDecl(GlobalVariableDecl variableDecl)
    • visitInterfaceBlock

      public boolean visitInterfaceBlock(InterfaceBlock interfaceBlock)
    • visitStructDefinition

      public boolean visitStructDefinition(StructDefinition structDefinition)
    • visitTopLevelElement

      @OverrideOnly protected boolean visitTopLevelElement(TopLevelElement e)
      Fallback method for any element kind that has not been overridden.
    • visitFunctionReference

      public boolean visitFunctionReference(FunctionReference expr)
    • visitVariableReference

      public boolean visitVariableReference(VariableReference expr)
    • visitTypeReference

      public boolean visitTypeReference(TypeReference expr)
    • visitLiteral

      public boolean visitLiteral(Literal expr)
    • visitFieldAccess

      public boolean visitFieldAccess(FieldAccess expr)
    • visitIndex

      public boolean visitIndex(IndexExpression expr)
    • visitPostfix

      public boolean visitPostfix(PostfixExpression expr)
    • visitPrefix

      public boolean visitPrefix(PrefixExpression expr)
    • visitBinary

      public boolean visitBinary(BinaryExpression expr)
    • visitConditional

      public boolean visitConditional(ConditionalExpression expr)
    • visitSwizzle

      public boolean visitSwizzle(Swizzle expr)
    • visitFunctionCall

      public boolean visitFunctionCall(FunctionCall expr)
    • visitConstructorCall

      public boolean visitConstructorCall(ConstructorCall expr)
    • visitExpression

      @OverrideOnly protected boolean visitExpression(Expression expr)
      Fallback method for any expression kind that has not been overridden.
    • visitBlock

      public boolean visitBlock(BlockStatement stmt)
    • visitBreak

      public boolean visitBreak(BreakStatement stmt)
    • visitContinue

      public boolean visitContinue(ContinueStatement stmt)
    • visitDiscard

      public boolean visitDiscard(DiscardStatement stmt)
    • visitEmpty

      public boolean visitEmpty(EmptyStatement stmt)
    • visitExpression

      public boolean visitExpression(ExpressionStatement stmt)
    • visitForLoop

      public boolean visitForLoop(ForLoop stmt)
    • visitIf

      public boolean visitIf(IfStatement stmt)
    • visitReturn

      public boolean visitReturn(ReturnStatement stmt)
    • visitSwitch

      public boolean visitSwitch(SwitchStatement stmt)
    • visitSwitchCase

      public boolean visitSwitchCase(SwitchCase stmt)
    • visitVariableDecl

      public boolean visitVariableDecl(VariableDecl variableDecl)
    • visitStatement

      @OverrideOnly protected boolean visitStatement(Statement stmt)
      Fallback method for any statement kind that has not been overridden.