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 booleanhoistedBodyUsesReceiver(ClosureExpression expression) Whether the body, nested closures included, uses its this object:this, an instance field or property, an implicit-this call of an instance method, or the creation of an inner class instance, which passesthisas its enclosing instance (an instance of a static nested class takes none).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, markEscapingClosures, markEscapingClosures, 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. The dynamic path trusts the annotation except for a body that calls a method on a closure object; the static writer overrides this for a delegate-resolved body.- 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
-
hoistedBodyUsesReceiver
Whether the body, nested closures included, uses its this object:this, an instance field or property, an implicit-this call of an instance method, or the creation of an inner class instance, which passesthisas its enclosing instance (an instance of a static nested class takes none). A closure class castsgetThisObject()to the enclosing class for these, except for the methods ofObject, which it calls on the uncast this object; those count too, as the hoisted body can only call them on an instance of the enclosing class. Static members and extension methods (theprintlnfamily) do not count.- Overrides:
hoistedBodyUsesReceiverin 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
-