Class 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 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