Package icyllis.arc3d.compiler.tree
Class TreeVisitor
java.lang.Object
icyllis.arc3d.compiler.tree.TreeVisitor
- Direct Known Subclasses:
SymbolUsage
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
visitBinary
(BinaryExpression expr) boolean
visitBlock
(BlockStatement stmt) boolean
visitBreak
(BreakStatement stmt) boolean
boolean
boolean
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
boolean
visitFieldAccess
(FieldAccess expr) boolean
visitForLoop
(ForLoop stmt) boolean
boolean
visitFunctionDefinition
(FunctionDefinition definition) boolean
visitFunctionPrototype
(FunctionPrototype prototype) boolean
boolean
visitGlobalVariableDecl
(GlobalVariableDecl variableDecl) boolean
visitIf
(IfStatement stmt) boolean
visitIndex
(IndexExpression expr) boolean
visitInterfaceBlock
(InterfaceBlock interfaceBlock) boolean
visitLiteral
(Literal expr) boolean
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
Fallback method for any element kind that has not been overridden.boolean
boolean
visitVariableDecl
(VariableDecl variableDecl) boolean
-
Constructor Details
-
TreeVisitor
public TreeVisitor()
-
-
Method Details
-
visitFunctionPrototype
-
visitFunctionDefinition
-
visitGlobalVariableDecl
-
visitInterfaceBlock
-
visitStructDefinition
-
visitTopLevelElement
Fallback method for any element kind that has not been overridden. -
visitFunctionReference
-
visitVariableReference
-
visitTypeReference
-
visitLiteral
-
visitFieldAccess
-
visitIndex
-
visitPostfix
-
visitPrefix
-
visitBinary
-
visitConditional
-
visitSwizzle
-
visitFunctionCall
-
visitConstructorCall
-
visitExpression
Fallback method for any expression kind that has not been overridden. -
visitBlock
-
visitBreak
-
visitContinue
-
visitDiscard
-
visitEmpty
-
visitExpression
-
visitForLoop
-
visitIf
-
visitReturn
-
visitSwitch
-
visitSwitchCase
-
visitVariableDecl
-
visitStatement
Fallback method for any statement kind that has not been overridden.
-