Class AstHelper
java.lang.Object
org.codehaus.groovy.transform.tailrec.AstHelper
Helping to create a few standard AST constructs
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExpressionStatementcreateVariableAlias(String aliasName, ClassNode variableType, String variableName) Creates an alias variable that references another variable.static ExpressionStatementcreateVariableDefinition(String variableName, ClassNode variableType, Expression value) Creates a local variable declaration for the supplied value.static ExpressionStatementcreateVariableDefinition(String variableName, ClassNode variableType, Expression value, boolean variableShouldBeFinal) Creates a local variable declaration for the supplied value.static VariableExpressioncreateVariableReference(Map<String, ?> variableSpec) Creates a variable reference from a name/type specification map.static StatementThis statement will throw exception which will be caught and redirected to jump to surrounding while loop's start label Also works from within Closures but is a tiny bit slowerstatic StatementThis statement should make the code jump to surrounding while loop's start label Does not work from within Closures
-
Method Details
-
createVariableDefinition
public static ExpressionStatement createVariableDefinition(String variableName, ClassNode variableType, Expression value) Creates a local variable declaration for the supplied value.- Parameters:
variableName- the declared variable namevariableType- the declared variable typevalue- the initial value expression- Returns:
- a declaration statement for the new local variable
-
createVariableDefinition
public static ExpressionStatement createVariableDefinition(String variableName, ClassNode variableType, Expression value, boolean variableShouldBeFinal) Creates a local variable declaration for the supplied value.- Parameters:
variableName- the declared variable namevariableType- the declared variable typevalue- the initial value expressionvariableShouldBeFinal- whether the declared variable should befinal- Returns:
- a declaration statement for the new local variable
-
createVariableAlias
public static ExpressionStatement createVariableAlias(String aliasName, ClassNode variableType, String variableName) Creates an alias variable that references another variable.- Parameters:
aliasName- the alias variable namevariableType- the alias variable typevariableName- the referenced variable name- Returns:
- a declaration statement for the alias variable
-
createVariableReference
Creates a variable reference from a name/type specification map.- Parameters:
variableSpec- a map containingnameandtypeentries- Returns:
- a variable expression for the supplied specification
-
recurStatement
This statement should make the code jump to surrounding while loop's start label Does not work from within Closures -
recurByThrowStatement
This statement will throw exception which will be caught and redirected to jump to surrounding while loop's start label Also works from within Closures but is a tiny bit slower
-