Groovy 2.2.1

org.codehaus.groovy.transform.sc
[Java] Class StaticCompilationVisitor

java.lang.Object
  org.codehaus.groovy.ast.CodeVisitorSupport
      org.codehaus.groovy.ast.ClassCodeVisitorSupport
          org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor
              org.codehaus.groovy.transform.sc.StaticCompilationVisitor

public class StaticCompilationVisitor
extends StaticTypeCheckingVisitor

This visitor is responsible for amending the AST with static compilation metadata or transform the AST so that a class or a method can be statically compiled. It may also throw errors specific to static compilation which are not considered as an error at the type check pass. For example, usage of spread operator is not allowed in statically compiled portions of code, while it may be statically checked. Static compilation relies on static type checking, which explains why this visitor extends the type checker visitor.

Authors:
Cedric Champeau


Field Summary
static MethodNode ARRAYLIST_ADD_METHOD

static ClassNode ARRAYLIST_CLASSNODE

static MethodNode ARRAYLIST_CONSTRUCTOR

 
Fields inherited from class StaticTypeCheckingVisitor
CLOSURE_CALL_NO_ARG, CLOSURE_CALL_ONE_ARG, CLOSURE_CALL_VARGS, CURRENT_SIGNATURE_PROTOCOL, CURRENT_SIGNATURE_PROTOCOL_VERSION, DELEGATES_TO, DELEGATES_TO_TARGET, DGM_CLASSNODE, EMPTY_METHODNODE_LIST, ERROR_COLLECTOR, GENERATED_EMPTY_STATEMENT, GET_DELEGATE, GET_OWNER, GET_THISOBJECT, ITERABLE_TYPE, LINKEDHASHMAP_CLASSNODE, TYPECHECKED_CLASSNODE, TYPECHECKING_ANNOTATIONS, TYPECHECKING_INFO_NODE, extension, returnAdder, returnListener, typeCheckingContext
 
Constructor Summary
StaticCompilationVisitor(SourceUnit unit, ClassNode node)

 
Method Summary
protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)

protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args)

protected ClassNode[] getTypeCheckingAnnotations()

static boolean isStaticallyCompiled(AnnotatedNode node)

void visitClass(ClassNode node)

void visitConstructorCallExpression(ConstructorCallExpression call)

void visitForLoop(ForStatement forLoop)

void visitMethod(MethodNode node)

void visitMethodCallExpression(MethodCallExpression call)

void visitSpreadExpression(SpreadExpression expression)

 
Methods inherited from class StaticTypeCheckingVisitor
addAmbiguousErrorMessage, addAssignmentError, addCategoryMethodCallError, addClosureReturnType, addError, addNoMatchingMethodError, addReceivers, addStaticTypeError, addTypeCheckingExtension, addTypeCheckingInfoAnnotation, addUnsupportedPreOrPostfixExpressionError, areCategoryMethodCalls, checkCast, checkClosureParameters, checkForbiddenSpreadArgument, checkGroovyConstructorMap, checkGroovyStyleConstructor, checkReturnType, collectAllInterfaceMethodsByName, existsProperty, existsProperty, extractPropertyNameFromMethodName, extractTemporaryTypeInfoKey, extractTypesFromParameters, findCurrentInstanceOfClass, findMethod, findMethodOrFail, findMethodsWithGenerated, formatArgumentList, fullyResolve, fullyResolveType, getArgumentTypes, getDelegationMetadata, getGroupOperationResultType, getInferredReturnType, getInferredReturnTypeFromWithClosureArgument, getOriginalDeclarationType, getResultType, getSourceUnit, getTemporaryTypesForExpression, getType, getTypeCheckingAnnotations, getTypeCheckingContext, hasRHSIncompleteGenericTypeInfo, hasSetter, inferComponentType, inferDiamondType, inferListExpressionType, inferLoopElementType, inferMapExpressionType, inferReturnTypeGenerics, initialize, isClassInnerClassOrEqualTo, isClosureCall, isNullConstant, isSecondPassNeededForControlStructure, isSkipMode, isSkippedInnerClass, makeOwnerList, performSecondPass, popAssignmentTracking, prettyPrintMethodList, pushAssignmentTracking, pushInstanceOfTypeInfo, restoreVariableExpressionMetadata, saveVariableExpressionMetadata, setMethodsToBeVisited, shouldSkipClassNode, shouldSkipMethodNode, silentlyVisitMethodNode, startMethodInference, storeInferredReturnType, storeInferredTypeForPropertyExpression, storeTargetMethod, storeType, typeCheckAssignment, typeCheckClosureCall, typeCheckMapConstructor, typeCheckMethodArgumentWithGenerics, typeCheckMethodsWithGenerics, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitCaseStatement, visitCastExpression, visitClass, visitClassExpression, visitClosureExpression, visitConstructorCallExpression, visitConstructorOrMethod, visitField, visitForLoop, visitIfElse, visitMethod, visitMethodCallArguments, visitMethodCallExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitReturnStatement, visitStaticMethodCallExpression, visitSwitch, visitTernaryExpression, visitTryCatchFinally, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression, visitWhileLoop, wrapTypeIfNecessary
 
Methods inherited from class ClassCodeVisitorSupport
visitMethod, visitField, visitReturnStatement, visitProperty, visitConstructor, visitClass, visitPackage, visitBlockStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitSwitch, visitWhileLoop, visitDeclarationExpression, visitImports, visitBreakStatement, visitContinueStatement, visitTryCatchFinally, visitAnnotations, visitCatchStatement, visitIfElse, visitAssertStatement, visitCaseStatement, visitSynchronizedStatement, visitThrowStatement, visitClassExpression, visitPropertyExpression, visitListExpression, visitConstantExpression, visitMethodCallExpression, visitStaticMethodCallExpression, visitConstructorCallExpression, visitBinaryExpression, visitTernaryExpression, visitShortTernaryExpression, visitPostfixExpression, visitPrefixExpression, visitBooleanExpression, visitNotExpression, visitClosureExpression, visitTupleExpression, visitArrayExpression, visitMapExpression, visitMapEntryExpression, visitRangeExpression, visitSpreadExpression, visitSpreadMapExpression, visitMethodPointerExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitBitwiseNegationExpression, visitCastExpression, visitVariableExpression, visitAttributeExpression, visitFieldExpression, visitGStringExpression, visitArgumentlistExpression, visitClosureListExpression, visitBytecodeExpression, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

ARRAYLIST_ADD_METHOD

public static final MethodNode ARRAYLIST_ADD_METHOD


ARRAYLIST_CLASSNODE

public static final ClassNode ARRAYLIST_CLASSNODE


ARRAYLIST_CONSTRUCTOR

public static final MethodNode ARRAYLIST_CONSTRUCTOR


 
Constructor Detail

StaticCompilationVisitor

public StaticCompilationVisitor(SourceUnit unit, ClassNode node)


 
Method Detail

existsProperty

@Overridefinal Reference rType = new Reference(objectExpressionType);
protected boolean existsProperty(PropertyExpression pexp, boolean checkForReadOnly, ClassCodeVisitorSupport visitor)


findMethodOrFail

@Overrideexpr.putNodeMetaData(BINARY_EXP_TARGET, new Object[] {methodNode, name});
protected MethodNode findMethodOrFail(Expression expr, ClassNode receiver, String name, ClassNode... args)


getTypeCheckingAnnotations

@Override
protected ClassNode[] getTypeCheckingAnnotations()


isStaticallyCompiled

public static boolean isStaticallyCompiled(AnnotatedNode node)


visitClass

@Override
public void visitClass(ClassNode node)


visitConstructorCallExpression

@Override
public void visitConstructorCallExpression(ConstructorCallExpression call)


visitForLoop

@Overrideif (!(collectionExpression instanceof ClosureListExpression)) {
public void visitForLoop(ForStatement forLoop)


visitMethod

@Override
public void visitMethod(MethodNode node)


visitMethodCallExpression

@Override
public void visitMethodCallExpression(MethodCallExpression call)


visitSpreadExpression

@Override
public void visitSpreadExpression(SpreadExpression expression)


 

Copyright © 2003-2013 The Codehaus. All rights reserved.