public class StaticTypesWriterController
extends DelegatingController
An alternative WriterController which handles static types and method dispatch. In case of a "mixed mode" where only some methods are annotated with TypeChecked then this writer will delegate to the classic writer controller.
| Modifiers | Name | Description |
|---|---|---|
protected boolean |
isInStaticallyCheckedMethod |
Tracks whether the current member is being emitted through the static-compilation fast path. |
| Fields inherited from class | Fields |
|---|---|
class WriterController |
optimizeForInt |
| Constructor and description |
|---|
StaticTypesWriterController(WriterController controller)Creates a delegating writer controller that switches between dynamic and static code-generation strategies. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public BinaryExpressionHelper |
getBinaryExpressionHelper()* * Returns the appropriate BinaryExpressionHelper for the current code path. * Selects fast-path specialized handling when isFastPath() is true, * otherwise delegates to the general-purpose binary expression handler. * Fast-path optimization is controlled by optimizeForInt. * *
|
|
public CallSiteWriter |
getCallSiteWriter()* * Returns the CallSiteWriter responsible for generating dynamic call site * infrastructure. Behavior depends on bytecode strategy: either invokedynamic * for modern JVMs or traditional call-site caching for broader compatibility. |
|
public CallSiteWriter |
getCallSiteWriterFor(Expression expression)* * Returns the CallSiteWriter for a specific expression. * Currently delegates to the default CallSiteWriter; reserved for * future expression-specific optimization strategies. * *
|
|
public ClosureWriter |
getClosureWriter()* * Returns the ClosureWriter for compiling Groovy closure literals into * inner classes implementing GroovyObject and supporting variable capture. |
|
public InvocationWriter |
getInvocationWriter()* * Returns the InvocationWriter for compiling method calls and dynamic * function invocations into appropriate bytecode patterns. |
|
public LambdaWriter |
getLambdaWriter()* * Returns the LambdaWriter for compiling Java-style lambda expressions * (using the -> operator) into functional interfaces.
|
|
public MethodReferenceExpressionWriter |
getMethodReferenceExpressionWriter()* * Returns the MethodReferenceExpressionWriter for compiling method reference * expressions compatible with Java functional interface targets. |
|
public CallSiteWriter |
getRegularCallSiteWriter()Returns the regular dynamic call-site writer used for fallback expressions. |
|
public InvocationWriter |
getRegularInvocationWriter()Returns the regular dynamic invocation writer used for fallback expressions. |
|
public StatementWriter |
getStatementWriter()* * Returns the StatementWriter for compiling Groovy statements into bytecode. * Selection depends on optimization mode: OptimizingStatementWriter for * optimizeForInt, otherwise generic StatementWriter. |
|
public TypeChooser |
getTypeChooser()* * Returns the TypeChooser used to select appropriate type representations * for expressions during compilation, supporting both dynamic and typed paths. |
|
public UnaryExpressionHelper |
getUnaryExpressionHelper()* * Returns the appropriate UnaryExpressionHelper for the current code path. * Selects fast-path specialized handling when isFastPath() is true, * otherwise delegates to the general-purpose unary expression handler. * Fast-path optimization is controlled by optimizeForInt. * *
|
|
public void |
init(AsmClassGenerator asmClassGenerator, GeneratorContext gcon, org.objectweb.asm.ClassVisitor cv, ClassNode cn)* * Initializes this controller with compilation context and ASM infrastructure. * Must be called exactly once before any bytecode generation operations. * Sets up all supporting writers (call site, closure, lambda, etc.) and * configures optimization strategies based on compiler configuration. * *
|
|
public boolean |
isFastPath()* * Returns true if the compiler is currently in fast-path mode, * emitting specialized bytecode for primitive type operations. * Use this to determine whether expression helpers should apply optimizations. * *
|
|
public boolean |
methodHasDynamicResolution()GROOVY-11968: returns true when the current statically compiled method
contains one or more sub-expressions that will be routed through the regular
(non-static) call site writer via getCallSiteWriterFor. |
|
public void |
setConstructorNode(ConstructorNode cn)* * Sets the ConstructorNode for the constructor currently being compiled. * Automatically clears any active method node, since only one can be active. * Used during compilation to track which constructor's bytecode is being generated. * *
|
|
public void |
setMethodNode(MethodNode mn)* * Sets the MethodNode for the method currently being compiled. * Automatically clears any active constructor node, since only one can be active. * Used during compilation to track which method's bytecode is being generated. * *
|
Tracks whether the current member is being emitted through the static-compilation fast path.
Creates a delegating writer controller that switches between dynamic and static code-generation strategies.
* * Returns the appropriate BinaryExpressionHelper for the current code path. * Selects fast-path specialized handling when isFastPath() is true, * otherwise delegates to the general-purpose binary expression handler. * Fast-path optimization is controlled by optimizeForInt. * *
* * Returns the CallSiteWriter responsible for generating dynamic call site * infrastructure. Behavior depends on bytecode strategy: either invokedynamic * for modern JVMs or traditional call-site caching for broader compatibility.
* * Returns the CallSiteWriter for a specific expression. * Currently delegates to the default CallSiteWriter; reserved for * future expression-specific optimization strategies. * *
expression - the expression being processed
** * Returns the ClosureWriter for compiling Groovy closure literals into * inner classes implementing GroovyObject and supporting variable capture.
* * Returns the InvocationWriter for compiling method calls and dynamic * function invocations into appropriate bytecode patterns.
*
* Returns the LambdaWriter for compiling Java-style lambda expressions
* (using the -> operator) into functional interfaces.
* * Returns the MethodReferenceExpressionWriter for compiling method reference * expressions compatible with Java functional interface targets.
Returns the regular dynamic call-site writer used for fallback expressions.
Returns the regular dynamic invocation writer used for fallback expressions.
* * Returns the StatementWriter for compiling Groovy statements into bytecode. * Selection depends on optimization mode: OptimizingStatementWriter for * optimizeForInt, otherwise generic StatementWriter.
* * Returns the TypeChooser used to select appropriate type representations * for expressions during compilation, supporting both dynamic and typed paths.
* * Returns the appropriate UnaryExpressionHelper for the current code path. * Selects fast-path specialized handling when isFastPath() is true, * otherwise delegates to the general-purpose unary expression handler. * Fast-path optimization is controlled by optimizeForInt. * *
* * Initializes this controller with compilation context and ASM infrastructure. * Must be called exactly once before any bytecode generation operations. * Sets up all supporting writers (call site, closure, lambda, etc.) and * configures optimization strategies based on compiler configuration. * *
asmClassGenerator - the class generator managing the overall compilation
*gcon - the compilation context tracking state across the compilation unit
*cv - the ASM ClassVisitor for emitting bytecode directives
*cn - the ClassNode being compiled* * Returns true if the compiler is currently in fast-path mode, * emitting specialized bytecode for primitive type operations. * Use this to determine whether expression helpers should apply optimizations. * *
GROOVY-11968: returns true when the current statically compiled method
contains one or more sub-expressions that will be routed through the regular
(non-static) call site writer via getCallSiteWriterFor. The regular
writer's per-method state must then be initialized at method entry.
* * Sets the ConstructorNode for the constructor currently being compiled. * Automatically clears any active method node, since only one can be active. * Used during compilation to track which constructor's bytecode is being generated. * *
constructorNode - the ConstructorNode to compile, or null to deactivate* * Sets the MethodNode for the method currently being compiled. * Automatically clears any active constructor node, since only one can be active. * Used during compilation to track which method's bytecode is being generated. * *
methodNode - the MethodNode to compile, or null to deactivateCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.