Package org.codehaus.groovy.classgen.asm.sc

# Class StaticTypesWriterController

java.lang.Object
org.codehaus.groovy.classgen.asm.WriterController
org.codehaus.groovy.classgen.asm.DelegatingController
org.codehaus.groovy.classgen.asm.sc.StaticTypesWriterController

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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected boolean`
  `isInStaticallyCheckedMethod`

  ### Fields inherited from class org.codehaus.groovy.classgen.asm.WriterController

  `optimizeForInt`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StaticTypesWriterController(WriterController controller)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `BinaryExpressionHelper`
  `getBinaryExpressionHelper()`
  Returns the appropriate BinaryExpressionHelper for the current code path.
  `CallSiteWriter`
  `getCallSiteWriter()`
  Returns the CallSiteWriter responsible for generating dynamic call site infrastructure.
  `CallSiteWriter`
  `getCallSiteWriterFor(Expression expression)`
  Returns the CallSiteWriter for a specific expression.
  `ClosureWriter`
  `getClosureWriter()`
  Returns the ClosureWriter for compiling Groovy closure literals into inner classes implementing GroovyObject and supporting variable capture.
  `InvocationWriter`
  `getInvocationWriter()`
  Returns the InvocationWriter for compiling method calls and dynamic function invocations into appropriate bytecode patterns.
  `LambdaWriter`
  `getLambdaWriter()`
  Returns the LambdaWriter for compiling Java-style lambda expressions (using the `->` operator) into functional interfaces.
  `MethodReferenceExpressionWriter`
  `getMethodReferenceExpressionWriter()`
  Returns the MethodReferenceExpressionWriter for compiling method reference expressions compatible with Java functional interface targets.
  `CallSiteWriter`
  `getRegularCallSiteWriter()`
  `InvocationWriter`
  `getRegularInvocationWriter()`
  `StatementWriter`
  `getStatementWriter()`
  Returns the StatementWriter for compiling Groovy statements into bytecode.
  `TypeChooser`
  `getTypeChooser()`
  Returns the TypeChooser used to select appropriate type representations for expressions during compilation, supporting both dynamic and typed paths.
  `UnaryExpressionHelper`
  `getUnaryExpressionHelper()`
  Returns the appropriate UnaryExpressionHelper for the current code path.
  `void`
  `init(AsmClassGenerator asmClassGenerator, GeneratorContext gcon, org.objectweb.asm.ClassVisitor cv, ClassNode cn)`
  Initializes this controller with compilation context and ASM infrastructure.
  `boolean`
  `isFastPath()`
  Returns true if the compiler is currently in fast-path mode, emitting specialized bytecode for primitive type operations.
  `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(org.codehaus.groovy.ast.expr.Expression)`.
  `void`
  `setConstructorNode(ConstructorNode cn)`
  Sets the ConstructorNode for the constructor currently being compiled.
  `void`
  `setMethodNode(MethodNode mn)`
  Sets the MethodNode for the method currently being compiled.

  ### Methods inherited from class org.codehaus.groovy.classgen.asm.DelegatingController

  `getAcg, getAssertionWriter, getBytecodeVersion, getClassName, getClassNode, getClassVisitor, getCompileStack, getConstructorNode, getContext, getCv, getInterfaceClassLoadingClass, getInternalBaseClassName, getInternalClassName, getLineNumber, getMethodNode, getMethodPointerExpressionWriter, getMethodVisitor, getOperandStack, getOutermostClass, getReturnType, getSourceUnit, isConstructor, isInGeneratedFunction, isInGeneratedFunctionConstructor, isInScriptBody, isNotClinit, isStaticConstructor, isStaticContext, isStaticMethod, resetLineNumber, setInterfaceClassLoadingClass, setLineNumber, setMethodVisitor, shouldOptimizeForInt, switchToFastPath, switchToSlowPath`

  ### Methods inherited from class org.codehaus.groovy.classgen.asm.WriterController

  `getNextHelperMethodIndex, getSuperMethodNames, getThisType, visitLineNumber`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### isInStaticallyCheckedMethod

    protected boolean isInStaticallyCheckedMethod

- ## Constructor Details

  - ### StaticTypesWriterController

    public StaticTypesWriterController(WriterController controller)

- ## Method Details

  - ### init

    public void init(AsmClassGenerator asmClassGenerator, GeneratorContext gcon, org.objectweb.asm.ClassVisitor cv, ClassNode cn)
    Description copied from class: `WriterController`
    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.
    Overrides:
      `init` in class `DelegatingController`
    Parameters:
      `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

  - ### setMethodNode

    public void setMethodNode(MethodNode mn)
    Description copied from class: `WriterController`
    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.
    Overrides:
      `setMethodNode` in class `DelegatingController`
    Parameters:
      `mn` - the MethodNode to compile, or null to deactivate

  - ### setConstructorNode

    public void setConstructorNode(ConstructorNode cn)
    Description copied from class: `WriterController`
    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.
    Overrides:
      `setConstructorNode` in class `DelegatingController`
    Parameters:
      `cn` - the ConstructorNode to compile, or null to deactivate

  - ### methodHasDynamicResolution

    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(org.codehaus.groovy.ast.expr.Expression)`. The regular writer's per-method state must then be initialized at method entry.
    Since:
      6.0.0

  - ### isFastPath

    public boolean isFastPath()
    Description copied from class: `WriterController`
    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.
    Overrides:
      `isFastPath` in class `DelegatingController`
    Returns:
      true if fast-path compilation mode is active

  - ### getCallSiteWriter

    public CallSiteWriter getCallSiteWriter()
    Description copied from class: `WriterController`
    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.
    Overrides:
      `getCallSiteWriter` in class `DelegatingController`

  - ### getCallSiteWriterFor

    public CallSiteWriter getCallSiteWriterFor(Expression expression)
    Description copied from class: `WriterController`
    Returns the CallSiteWriter for a specific expression. Currently delegates to the default CallSiteWriter; reserved for future expression-specific optimization strategies.
    Overrides:
      `getCallSiteWriterFor` in class `DelegatingController`
    Parameters:
      `expression` - the expression being processed
    Returns:
      the appropriate call site writer for this expression

  - ### getRegularCallSiteWriter

    public CallSiteWriter getRegularCallSiteWriter()

  - ### getStatementWriter

    public StatementWriter getStatementWriter()
    Description copied from class: `WriterController`
    Returns the StatementWriter for compiling Groovy statements into bytecode. Selection depends on optimization mode: OptimizingStatementWriter for `WriterController.optimizeForInt`, otherwise generic StatementWriter.
    Overrides:
      `getStatementWriter` in class `DelegatingController`

  - ### getTypeChooser

    public TypeChooser getTypeChooser()
    Description copied from class: `WriterController`
    Returns the TypeChooser used to select appropriate type representations for expressions during compilation, supporting both dynamic and typed paths.
    Overrides:
      `getTypeChooser` in class `DelegatingController`

  - ### getInvocationWriter

    public InvocationWriter getInvocationWriter()
    Description copied from class: `WriterController`
    Returns the InvocationWriter for compiling method calls and dynamic function invocations into appropriate bytecode patterns.
    Overrides:
      `getInvocationWriter` in class `DelegatingController`

  - ### getRegularInvocationWriter

    public InvocationWriter getRegularInvocationWriter()

  - ### getBinaryExpressionHelper

    public BinaryExpressionHelper getBinaryExpressionHelper()
    Description copied from class: `WriterController`
    Returns the appropriate BinaryExpressionHelper for the current code path. Selects fast-path specialized handling when `WriterController.isFastPath()` is true, otherwise delegates to the general-purpose binary expression handler. Fast-path optimization is controlled by `WriterController.optimizeForInt`.
    Overrides:
      `getBinaryExpressionHelper` in class `DelegatingController`
    Returns:
      the binary expression writer for the active compilation mode

  - ### getMethodReferenceExpressionWriter

    public MethodReferenceExpressionWriter getMethodReferenceExpressionWriter()
    Description copied from class: `WriterController`
    Returns the MethodReferenceExpressionWriter for compiling method reference expressions compatible with Java functional interface targets.
    Overrides:
      `getMethodReferenceExpressionWriter` in class `DelegatingController`

  - ### getUnaryExpressionHelper

    public UnaryExpressionHelper getUnaryExpressionHelper()
    Description copied from class: `WriterController`
    Returns the appropriate UnaryExpressionHelper for the current code path. Selects fast-path specialized handling when `WriterController.isFastPath()` is true, otherwise delegates to the general-purpose unary expression handler. Fast-path optimization is controlled by `WriterController.optimizeForInt`.
    Overrides:
      `getUnaryExpressionHelper` in class `DelegatingController`
    Returns:
      the unary expression writer for the active compilation mode

  - ### getClosureWriter

    public ClosureWriter getClosureWriter()
    Description copied from class: `WriterController`
    Returns the ClosureWriter for compiling Groovy closure literals into inner classes implementing GroovyObject and supporting variable capture.
    Overrides:
      `getClosureWriter` in class `DelegatingController`

  - ### getLambdaWriter

    public LambdaWriter getLambdaWriter()
    Description copied from class: `WriterController`
    Returns the LambdaWriter for compiling Java-style lambda expressions (using the `->` operator) into functional interfaces.
    Overrides:
      `getLambdaWriter` in class `DelegatingController`