[Groovy] Class VariableExpressionReplacer
- org.codehaus.groovy.transform.tailrec.VariableExpressionReplacer
@CompileStatic class VariableExpressionReplacer extends CodeVisitorSupport
Tool for replacing VariableExpression instances in an AST by other VariableExpression instances. Regardless of a real change taking place in nested expressions, all considered expression (trees) will be replaced. This could be optimized to accelerate compilation. Within
- TailRecursive:
- it is used - to swap the access of method args with the access to iteration variables - to swap the access of iteration variables with the access of temp vars
Properties Summary
Type | Name and description |
---|---|
Closure<VariableExpression> |
replaceWith |
Closure<Boolean> |
when |
Constructor Summary
Constructor and description |
---|
VariableExpressionReplacer
() |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
void |
replaceIn(ASTNode root) | |
void |
visitAssertStatement(AssertStatement statement) | |
void |
visitBinaryExpression(BinaryExpression expression) It's the only Expression type in which replacing is considered. | |
void |
visitCaseStatement(CaseStatement statement) | |
void |
visitDoWhileLoop(DoWhileStatement loop) | |
void |
visitExpressionStatement(ExpressionStatement statement) | |
void |
visitForLoop(ForStatement forLoop) | |
void |
visitIfElse(IfStatement ifElse) | |
void |
visitReturnStatement(ReturnStatement statement) | |
void |
visitSwitch(SwitchStatement statement) | |
void |
visitSynchronizedStatement(SynchronizedStatement statement) | |
void |
visitThrowStatement(ThrowStatement statement) | |
void |
visitWhileLoop(WhileStatement loop) |
Inherited Methods Summary
Property Detail
Closure<VariableExpression> replaceWith
Closure<Boolean> when
Constructor Detail
VariableExpressionReplacer()
Method Detail
void replaceIn(ASTNode root)
void visitAssertStatement(AssertStatement statement)
void visitBinaryExpression(BinaryExpression expression)
It's the only Expression type in which replacing is considered. That's an abuse of the class, but I couldn't think of a better way.
void visitCaseStatement(CaseStatement statement)
void visitDoWhileLoop(DoWhileStatement loop)
void visitExpressionStatement(ExpressionStatement statement)
void visitForLoop(ForStatement forLoop)
void visitIfElse(IfStatement ifElse)
void visitReturnStatement(ReturnStatement statement)
void visitSwitch(SwitchStatement statement)
void visitSynchronizedStatement(SynchronizedStatement statement)
void visitThrowStatement(ThrowStatement statement)
void visitWhileLoop(WhileStatement loop)
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/transform/tailrec/VariableExpressionReplacer.html