Class InvokeDynamicWriter
java.lang.Object
org.codehaus.groovy.classgen.asm.InvocationWriter
org.codehaus.groovy.classgen.asm.indy.InvokeDynamicWriter
This Writer is used to generate the call invocation byte codes
for usage by invokedynamic.
-
Field Summary
Fields inherited from class org.codehaus.groovy.classgen.asm.InvocationWriter
castToVargsArray, controller, currentCall, invokeClosureMethod, invokeMethod, invokeMethodOnCurrent, invokeMethodOnSuper, invokeStaticMethod -
Constructor Summary
ConstructorsConstructorDescriptionInvokeDynamicWriter(WriterController controller) Creates an invocation writer that emitsinvokedynamiccall sites. -
Method Summary
Modifier and TypeMethodDescriptionvoidcastNonPrimitiveToBool(ClassNode sourceType) Unboxes a non-primitive value on the operand stack to a primitiveboolean.voidcastToNonPrimitiveIfNecessary(ClassNode sourceType, ClassNode targetType) Converts sourceType to a non-primitive by using Groovy casting.voidEmits a Groovyascoercion fromfromtotarget.protected booleanmakeCachedCall(Expression origin, ClassExpression sender, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis, boolean containsSpreadExpression) Attempts to emit a call-site-cached invocation (or invokedynamic).voidmakeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe) Generates a single-argument method call via the call-site writer.protected voidwriteGetProperty(Expression receiver, String propertyName, boolean safe, boolean implicitThis, boolean groovyObject) Emits aninvokedynamicproperty-get call site with the given flags.protected voidEmits a normal (non-direct, non-AIC) constructor call via the call-site writer.protected voidwriteSetProperty(Expression receiver, String propertyName, boolean implicitThis, boolean groovyObject) Emits aninvokedynamicproperty-write call site (GROOVY-12138).Methods inherited from class org.codehaus.groovy.classgen.asm.InvocationWriter
finnishConstructorCall, getMethodName, loadArguments, makeArgumentList, makeCall, makeCall, makeClassForNameCall, makeDirectCall, makeSingleArgumentCall, makeUncachedCall, prepareConstructorCall, writeAICCall, writeDirectMethodCall, writeInvokeConstructor, writeInvokeMethod, writeInvokeStaticMethod, writeSpecialConstructorCall
-
Constructor Details
-
InvokeDynamicWriter
Creates an invocation writer that emitsinvokedynamiccall sites.
-
-
Method Details
-
makeCachedCall
protected boolean makeCachedCall(Expression origin, ClassExpression sender, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis, boolean containsSpreadExpression) Attempts to emit a call-site-cached invocation (or invokedynamic). Returnsfalseif the call cannot be cached, causing the caller to fall through to the uncached path.- Overrides:
makeCachedCallin classInvocationWriter- Parameters:
origin- the original call expressionsender- the class from which the call is dispatchedreceiver- the receiver expressionmessage- the method name expressionarguments- the arguments expressionadapter- the method caller adaptersafe- whether to use safe navigationspreadSafe- whether to use spread-safe navigationimplicitThis- whether the receiver is implicitthiscontainsSpreadExpression- whether any argument uses spread- Returns:
trueif a cached call was emitted
-
makeSingleArgumentCall
public void makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe) Generates a single-argument method call via the call-site writer.- Overrides:
makeSingleArgumentCallin classInvocationWriter- Parameters:
receiver- the receiver expressionmessage- the method namearguments- the single argument expressionsafe- whether to use safe navigation (?.)
-
writeGetProperty
protected void writeGetProperty(Expression receiver, String propertyName, boolean safe, boolean implicitThis, boolean groovyObject) Emits aninvokedynamicproperty-get call site with the given flags. -
writeSetProperty
protected void writeSetProperty(Expression receiver, String propertyName, boolean implicitThis, boolean groovyObject) Emits aninvokedynamicproperty-write call site (GROOVY-12138). On entry, the assigned value sits on the operand stack (the assignment machinery evaluates the RHS before visiting the LHS). The value is boxed, the receiver pushed, and the two swapped so the call-site shape is receiver-first —(ReceiverType, ValueType)void— preserving the runtime invariant thatarguments[0]is the receiver. The void return means no operand-stack result to clean up, matching the classic adapter path's accounting. -
writeNormalConstructorCall
Emits a normal (non-direct, non-AIC) constructor call via the call-site writer.- Overrides:
writeNormalConstructorCallin classInvocationWriter- Parameters:
call- the constructor call expression to compile
-
coerce
Emits a Groovyascoercion fromfromtotarget.- Overrides:
coercein classInvocationWriter- Parameters:
from- the source type currently on the operand stacktarget- the target type to coerce to
-
castToNonPrimitiveIfNecessary
Converts sourceType to a non-primitive by using Groovy casting. sourceType might be a primitive This might be done using SBA#castToType- Overrides:
castToNonPrimitiveIfNecessaryin classInvocationWriter
-
castNonPrimitiveToBool
Unboxes a non-primitive value on the operand stack to a primitiveboolean.- Overrides:
castNonPrimitiveToBoolin classInvocationWriter- Parameters:
sourceType- the type currently on top of the operand stack
-