Class StaticTypesClosureWriter

java.lang.Object
org.codehaus.groovy.classgen.asm.ClosureWriter
org.codehaus.groovy.classgen.asm.sc.StaticTypesClosureWriter

public class StaticTypesClosureWriter extends ClosureWriter
Writer responsible for generating closure classes in statically compiled mode.
  • Constructor Details

    • StaticTypesClosureWriter

      public StaticTypesClosureWriter(WriterController wc)
      Creates a closure writer for statically compiled code generation.
  • Method Details

    • isPackTriggered

      protected boolean isPackTriggered(ClosureExpression expression, boolean annotated)
      Description copied from class: ClosureWriter
      Whether a packable, non-escaping closure literal should actually be packed. Dynamic compilation has no proof of delegate-independence, so the only trigger is the @PackedClosures trust assertion; StaticTypesClosureWriter overrides this to add the groovy.target.closure.pack flag and the delegate-independence proof.
      Overrides:
      isPackTriggered in class ClosureWriter
      annotated - whether a non-DISABLED @PackedClosures is in scope
    • triggerDeclineReason

      protected String triggerDeclineReason(ClosureExpression expression)
      Description copied from class: ClosureWriter
      A trigger-specific decline reason for ClosureWriter.declineReason(org.codehaus.groovy.ast.expr.ClosureExpression), or null if the trigger did not decline this closure. Only the static writer has one (a delegate-resolved body); the dynamic path trusts the annotation and never declines on trigger grounds.
      Overrides:
      triggerDeclineReason in class ClosureWriter
    • readOnlyCaptureType

      protected ClassNode readOnlyCaptureType(String name, ClassNode declaredType, Variable variable)
      Description copied from class: ClosureWriter
      The declared type of a read-only (by-value) capture parameter on the hoisted method. The dynamic writer types it as Object; the static writer overrides this to the capture's declared/flow-inferred type so the body compiles with static dispatch. This is the seam that keeps @CompileStatic-specific typing out of the general (dynamic) emitter.
      Overrides:
      readOnlyCaptureType in class ClosureWriter
    • markHoistedBody

      protected void markHoistedBody(MethodNode hoisted)
      Description copied from class: ClosureWriter
      Marks the hoisted body's compilation mode; the static writer overrides this to compile it statically.
      Overrides:
      markHoistedBody in class ClosureWriter
    • packedClosureUsesDelegateGuard

      protected boolean packedClosureUsesDelegateGuard()
      Description copied from class: ClosureWriter
      Whether the packed adapter installs the runtime delegate guard. The dynamic trust path needs it (an unverifiable assertion must fail fast on misuse); the static writer proved independence, so it overrides this to false and a caller-set delegate is then stored and ignored.
      Overrides:
      packedClosureUsesDelegateGuard in class ClosureWriter
    • createClosureClass

      protected ClassNode createClosureClass(ClosureExpression expression, int mods)
      Creates a new inner class node representing the compiled form of a closure expression.
      Overrides:
      createClosureClass in class ClosureWriter
      Parameters:
      expression - the closure expression to compile
      mods - the access modifiers for the generated class
      Returns:
      the newly created closure class node