public abstract class InnerClassVisitorHelper
extends ClassCodeVisitorSupport
Abstract base class providing helper methods for inner class visitors. This class contains utility methods for generating dispatcher code that allows inner classes to access members of their enclosing classes.
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected static void |
addFieldInit(Parameter p, FieldNode fn, BlockStatement block)Adds a statement to initialize a field from a constructor parameter. |
|
protected static ClassNode |
getClassNode(ClassNode cn, boolean isStatic)Returns the class node to expose when wiring dispatch methods for an inner class. |
|
protected static int |
getObjectDistance(ClassNode cn)Calculates the inheritance distance from the supplied type to Object. |
|
protected static boolean |
isStatic(InnerClassNode cn)Determines whether the supplied inner class behaves as a static nested class. |
|
protected static void |
setMethodDispatcherCode(BlockStatement block, Expression target, Parameter[] parameters)Generates method dispatcher code for dynamic method invocation. |
|
protected static void |
setPropertyGetterDispatcher(BlockStatement block, Expression target, Parameter[] parameters)Generates property getter dispatcher code for dynamic property access. |
|
protected static void |
setPropertySetterDispatcher(BlockStatement block, Expression target, Parameter[] parameters)Generates property setter dispatcher code for dynamic property access. |
|
protected static boolean |
shouldHandleImplicitThisForInnerClass(ClassNode cn)Determines whether synthetic outer-instance handling should be applied to the inner class. |
Adds a statement to initialize a field from a constructor parameter.
p - the parameter to read fromfn - the field to initializeblock - the block statement to add the initialization toReturns the class node to expose when wiring dispatch methods for an inner class.
cn - the enclosing class nodeisStatic - whether the generated access is static Calculates the inheritance distance from the supplied type to Object.
cn - the class node to measureObjectDetermines whether the supplied inner class behaves as a static nested class.
cn - the inner class node to testtrue if no outer-instance field is requiredGenerates method dispatcher code for dynamic method invocation. Handles both single arguments and spread arguments.
block - the block to add the dispatcher code totarget - the target object to invoke methods onparameters - the dispatcher method parameters (method name, arguments)Generates property getter dispatcher code for dynamic property access.
block - the block to add the dispatcher code totarget - the target object to get the property fromparameters - the dispatcher method parameters (property name)Generates property setter dispatcher code for dynamic property access.
block - the block to add the dispatcher code totarget - the target object to set the property onparameters - the dispatcher method parameters (property name, value)Determines whether synthetic outer-instance handling should be applied to the inner class.
cn - the class node to testtrue if implicit this$0 handling is required