Package icyllis.arc3d.compiler.tree

# 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 Summary

  Constructors
  Constructor
  Description
  `TreeVisitor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `visitBinary(BinaryExpression expr)`
  `boolean`
  `visitBlock(BlockStatement stmt)`
  `boolean`
  `visitBreak(BreakStatement stmt)`
  `boolean`
  `visitConditional(ConditionalExpression expr)`
  `boolean`
  `visitConstructorCall(ConstructorCall expr)`
  `boolean`
  `visitContinue(ContinueStatement stmt)`
  `boolean`
  `visitDiscard(DiscardStatement stmt)`
  `boolean`
  `visitEmpty(EmptyStatement stmt)`
  `protected boolean`
  `visitExpression(Expression expr)`
  Fallback method for any expression kind that has not been overridden.
  `boolean`
  `visitExpression(ExpressionStatement stmt)`
  `boolean`
  `visitFieldAccess(FieldAccess expr)`
  `boolean`
  `visitForLoop(ForLoop stmt)`
  `boolean`
  `visitFunctionCall(FunctionCall expr)`
  `boolean`
  `visitFunctionDefinition(FunctionDefinition definition)`
  `boolean`
  `visitFunctionPrototype(FunctionPrototype prototype)`
  `boolean`
  `visitFunctionReference(FunctionReference expr)`
  `boolean`
  `visitGlobalVariableDecl(GlobalVariableDecl variableDecl)`
  `boolean`
  `visitIf(IfStatement stmt)`
  `boolean`
  `visitIndex(IndexExpression expr)`
  `boolean`
  `visitInterfaceBlock(InterfaceBlock interfaceBlock)`
  `boolean`
  `visitLiteral(Literal expr)`
  `boolean`
  `visitPostfix(PostfixExpression expr)`
  `boolean`
  `visitPrefix(PrefixExpression expr)`
  `boolean`
  `visitReturn(ReturnStatement stmt)`
  `protected boolean`
  `visitStatement(Statement stmt)`
  Fallback method for any statement kind that has not been overridden.
  `boolean`
  `visitStructDefinition(StructDefinition structDefinition)`
  `boolean`
  `visitSwitch(SwitchStatement stmt)`
  `boolean`
  `visitSwitchCase(SwitchCase stmt)`
  `boolean`
  `visitSwizzle(Swizzle expr)`
  `protected boolean`
  `visitTopLevelElement(TopLevelElement e)`
  Fallback method for any element kind that has not been overridden.
  `boolean`
  `visitTypeReference(TypeReference expr)`
  `boolean`
  `visitVariableDecl(VariableDecl variableDecl)`
  `boolean`
  `visitVariableReference(VariableReference expr)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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.