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

# 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.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.codehaus.groovy.classgen.asm.ClosureWriter

  `ClosureWriter.CorrectAccessedVariableVisitor, ClosureWriter.UseExistingReference`

- ## Field Summary

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

  `controller, GENERATED_CLOSURE_CLASS, OUTER_INSTANCE, PACKED_METHOD_PREFIX, THIS_OBJECT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StaticTypesClosureWriter(WriterController wc)`
  Creates a closure writer for statically compiled code generation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected ClassNode`
  `createClosureClass(ClosureExpression expression, int mods)`
  Creates a new inner class node representing the compiled form of a closure expression.
  `protected boolean`
  `isPackTriggered(ClosureExpression expression, boolean annotated)`
  Whether a packable, non-escaping closure literal should actually be packed.
  `protected void`
  `markHoistedBody(MethodNode hoisted)`
  Marks the hoisted body's compilation mode; the static writer overrides this to compile it statically.
  `protected boolean`
  `packedClosureUsesDelegateGuard()`
  Whether the packed adapter installs the runtime delegate guard.
  `protected ClassNode`
  `readOnlyCaptureType(String name, ClassNode declaredType, Variable variable)`
  The declared type of a read-only (by-value) capture parameter on the hoisted method.
  `protected String`
  `triggerDeclineReason(ClosureExpression expression)`
  A trigger-specific decline reason for `ClosureWriter.declineReason(org.codehaus.groovy.ast.expr.ClosureExpression)`, or `null` if the trigger did not decline this closure.

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

  `addConstructor, addFieldsForLocalVariables, addGeneratedClosureConstructorCall, addSerialVersionUIDField, createBlockStatementForConstructor, getClosureSharedVariables, getOrAddClosureClass, loadReference, loadThis, removeInitialValues, writeClosure, writePackedDispatcher`

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

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

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