Class StaticCompilationTransformer
java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeExpressionTransformer
org.codehaus.groovy.transform.sc.transformers.StaticCompilationTransformer
- All Implemented Interfaces:
ExpressionTransformer,GroovyClassVisitor,GroovyCodeVisitor,ErrorCollecting
Some expressions use symbols as aliases to method calls (<<, +=, ...). In static compilation,
if such a method call is found, we transform the original binary expression into a method
call expression so that the call gets statically compiled.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ClassNodeClass node forScriptBytecodeAdapter.protected static final Map<Integer,MethodNode> Comparison helpers onScriptBytecodeAdapterkeyed by Groovy token type. -
Constructor Summary
ConstructorsConstructorDescriptionStaticCompilationTransformer(SourceUnit unit, StaticTypeCheckingVisitor visitor) Creates a static compilation transformer for the supplied source unit and visitor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the class currently enclosing the transformation context.protected SourceUnitReturns the source unit currently being transformed.Returns the type chooser used by this transformer.transform(Expression expr) Dispatches expression transformation to the specialized helper for the expression type.voidvisitClass(ClassNode node) Visits a class and then recursively visits its inner classes.voidVisits a statement container within the current class or method.protected voidvisitConstructorOrMethod(MethodNode node, boolean isConstructor) Visits a constructor or method unless it is explicitly marked to skip static compilation.voidvisitField(FieldNode node) Preserves constant field initializers that must remain inline for later compilation phases.Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
setSourcePosition, visitAnnotation, visitAssertStatement, visitCaseStatement, visitClosureExpression, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoopMethods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotations, visitAnnotations, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitStatementAnnotations, visitTryCatchFinallyMethods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpressionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor
visit, visit, visitEmptyExpression, visitListOfExpressions
-
Field Details
-
BYTECODE_ADAPTER_CLASS
Class node forScriptBytecodeAdapter. -
BYTECODE_BINARY_ADAPTERS
Comparison helpers onScriptBytecodeAdapterkeyed by Groovy token type.
-
-
Constructor Details
-
StaticCompilationTransformer
Creates a static compilation transformer for the supplied source unit and visitor.- Parameters:
unit- the source unit being transformedvisitor- the visitor providing type-checking metadata
-
-
Method Details
-
getSourceUnit
Returns the source unit currently being transformed.- Specified by:
getSourceUnitin classClassCodeVisitorSupport- Returns:
- the active source unit
-
getTypeChooser
Returns the type chooser used by this transformer.- Returns:
- the static types type chooser
-
getClassNode
Returns the class currently enclosing the transformation context.- Returns:
- the current enclosing class node
-
visitClassCodeContainer
Visits a statement container within the current class or method.- Overrides:
visitClassCodeContainerin classClassCodeVisitorSupport- Parameters:
code- the code container to visit
-
transform
Dispatches expression transformation to the specialized helper for the expression type.- Specified by:
transformin interfaceExpressionTransformer- Overrides:
transformin classClassCodeExpressionTransformer- Parameters:
expr- the expression to transform- Returns:
- the transformed expression
-
visitClass
Visits a class and then recursively visits its inner classes.- Specified by:
visitClassin interfaceGroovyClassVisitor- Overrides:
visitClassin classClassCodeVisitorSupport- Parameters:
node- the class node to process
-
visitField
Preserves constant field initializers that must remain inline for later compilation phases.- Specified by:
visitFieldin interfaceGroovyClassVisitor- Overrides:
visitFieldin classClassCodeExpressionTransformer- Parameters:
node- the field to process
-
visitConstructorOrMethod
Visits a constructor or method unless it is explicitly marked to skip static compilation.- Overrides:
visitConstructorOrMethodin classClassCodeExpressionTransformer- Parameters:
node- the method or constructor to processisConstructor- whethernodeis a constructor
-