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
public class StaticCompilationTransformer extends ClassCodeExpressionTransformer
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
Fields Modifier and Type Field Description protected static ClassNode
BYTECODE_ADAPTER_CLASS
protected static Map<Integer,MethodNode>
BYTECODE_BINARY_ADAPTERS
-
Constructor Summary
Constructors Constructor Description StaticCompilationTransformer(SourceUnit unit, StaticTypeCheckingVisitor visitor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassNode
getClassNode()
protected SourceUnit
getSourceUnit()
StaticTypesTypeChooser
getTypeChooser()
Expression
transform(Expression expr)
Transforms the given expression into another expressionvoid
visitClass(ClassNode node)
Visit a ClassNode.void
visitClassCodeContainer(Statement code)
protected void
visitConstructorOrMethod(MethodNode node, boolean isConstructor)
-
Methods inherited from class org.codehaus.groovy.ast.ClassCodeExpressionTransformer
setSourcePosition, visitAnnotation, visitAssertStatement, visitCaseStatement, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitProperty, visitReturnStatement, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitWhileLoop
-
Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport
addError, visitAnnotations, visitBlockStatement, visitBreakStatement, visitCatchStatement, visitConstructor, visitContinueStatement, visitDeclarationExpression, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitStatement, visitTryCatchFinally
-
Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport
afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureExpression, 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, visitVariableExpression
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor
visitEmptyExpression, visitListOfExpressions
-
-
-
-
Field Detail
-
BYTECODE_ADAPTER_CLASS
protected static final ClassNode BYTECODE_ADAPTER_CLASS
-
BYTECODE_BINARY_ADAPTERS
protected static final Map<Integer,MethodNode> BYTECODE_BINARY_ADAPTERS
-
-
Constructor Detail
-
StaticCompilationTransformer
public StaticCompilationTransformer(SourceUnit unit, StaticTypeCheckingVisitor visitor)
-
-
Method Detail
-
getSourceUnit
protected SourceUnit getSourceUnit()
- Specified by:
getSourceUnit
in classClassCodeVisitorSupport
-
getTypeChooser
public StaticTypesTypeChooser getTypeChooser()
-
getClassNode
public ClassNode getClassNode()
-
visitClassCodeContainer
public void visitClassCodeContainer(Statement code)
- Overrides:
visitClassCodeContainer
in classClassCodeVisitorSupport
-
transform
public Expression transform(Expression expr)
Description copied from interface:ExpressionTransformer
Transforms the given expression into another expression- Specified by:
transform
in interfaceExpressionTransformer
- Overrides:
transform
in classClassCodeExpressionTransformer
-
visitClass
public void visitClass(ClassNode node)
Description copied from interface:GroovyClassVisitor
Visit a ClassNode.- Specified by:
visitClass
in interfaceGroovyClassVisitor
- Overrides:
visitClass
in classClassCodeVisitorSupport
-
visitConstructorOrMethod
protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
- Overrides:
visitConstructorOrMethod
in classClassCodeExpressionTransformer
-
-