Class StaticTypesClosureWriter
java.lang.Object
org.codehaus.groovy.classgen.asm.ClosureWriter
org.codehaus.groovy.classgen.asm.sc.StaticTypesClosureWriter
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
ConstructorsConstructorDescriptionCreates a closure writer for statically compiled code generation. -
Method Summary
Modifier and TypeMethodDescriptionprotected ClassNodecreateClosureClass(ClosureExpression expression, int mods) Creates a new inner class node representing the compiled form of a closure expression.protected booleanisPackTriggered(ClosureExpression expression, boolean annotated) Whether a packable, non-escaping closure literal should actually be packed.protected voidmarkHoistedBody(MethodNode hoisted) Marks the hoisted body's compilation mode; the static writer overrides this to compile it statically.protected booleanWhether the packed adapter installs the runtime delegate guard.protected ClassNodereadOnlyCaptureType(String name, ClassNode declaredType, Variable variable) The declared type of a read-only (by-value) capture parameter on the hoisted method.protected StringtriggerDeclineReason(ClosureExpression expression) A trigger-specific decline reason forClosureWriter.declineReason(org.codehaus.groovy.ast.expr.ClosureExpression), ornullif 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
-
Constructor Details
-
StaticTypesClosureWriter
Creates a closure writer for statically compiled code generation.
-
-
Method Details
-
isPackTriggered
Description copied from class:ClosureWriterWhether a packable, non-escaping closure literal should actually be packed. Dynamic compilation has no proof of delegate-independence, so the only trigger is the@PackedClosurestrust assertion;StaticTypesClosureWriteroverrides this to add thegroovy.target.closure.packflag and the delegate-independence proof.- Overrides:
isPackTriggeredin classClosureWriterannotated- whether a non-DISABLED@PackedClosuresis in scope
-
triggerDeclineReason
Description copied from class:ClosureWriterA trigger-specific decline reason forClosureWriter.declineReason(org.codehaus.groovy.ast.expr.ClosureExpression), ornullif 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:
triggerDeclineReasonin classClosureWriter
-
readOnlyCaptureType
Description copied from class:ClosureWriterThe declared type of a read-only (by-value) capture parameter on the hoisted method. The dynamic writer types it asObject; 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:
readOnlyCaptureTypein classClosureWriter
-
markHoistedBody
Description copied from class:ClosureWriterMarks the hoisted body's compilation mode; the static writer overrides this to compile it statically.- Overrides:
markHoistedBodyin classClosureWriter
-
packedClosureUsesDelegateGuard
protected boolean packedClosureUsesDelegateGuard()Description copied from class:ClosureWriterWhether 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 tofalseand a caller-set delegate is then stored and ignored.- Overrides:
packedClosureUsesDelegateGuardin classClosureWriter
-
createClosureClass
Creates a new inner class node representing the compiled form of a closure expression.- Overrides:
createClosureClassin classClosureWriter- Parameters:
expression- the closure expression to compilemods- the access modifiers for the generated class- Returns:
- the newly created closure class node
-