Class StaticInvocationWriter
java.lang.Object
org.codehaus.groovy.classgen.asm.InvocationWriter
org.codehaus.groovy.classgen.asm.sc.StaticInvocationWriter
Invocation writer for statically compiled code paths.
-
Field Summary
Fields inherited from class org.codehaus.groovy.classgen.asm.InvocationWriter
castToVargsArray, controller, currentCall, invokeClosureMethod, invokeMethod, invokeMethodOnCurrent, invokeMethodOnSuper, invokeStaticMethod -
Constructor Summary
ConstructorsConstructorDescriptionCreates an invocation writer that favors direct bytecode calls over dynamic dispatch. -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleanisPrivateBridgeMethodsCallAllowed(ClassNode receiver, ClassNode caller) Deprecated.Use bridge metadata on the declaring class instead of probing outer-class nesting manually.protected voidloadArguments(List<Expression> argumentList, Parameter[] parameters) Evaluates and loads each argument expression, handling varargs packing.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).voidmakeCall(Expression origin, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis) Generates bytecode for a method call.protected booleantryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args) Deprecated.protected booleantryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args, ClassNode thisClass) Attempts to make a direct method call on a bridge method, if it exists.protected booleanwriteDirectMethodCall(MethodNode target, boolean implicitThis, Expression receiver, TupleExpression args) Emits a direct (INVOKE*) bytecode call totargetwhen static type information is available.voidGenerates bytecode for a constructor call expression, choosing the appropriate strategy (direct, AIC, or normal call-site).voidGenerates bytecode for athis()orsuper()constructor call at the start of a constructor body.Methods inherited from class org.codehaus.groovy.classgen.asm.InvocationWriter
castNonPrimitiveToBool, castToNonPrimitiveIfNecessary, coerce, finnishConstructorCall, getMethodName, makeArgumentList, makeCall, makeClassForNameCall, makeDirectCall, makeSingleArgumentCall, makeSingleArgumentCall, makeUncachedCall, prepareConstructorCall, writeAICCall, writeInvokeMethod, writeInvokeStaticMethod, writeNormalConstructorCall
-
Constructor Details
-
StaticInvocationWriter
Creates an invocation writer that favors direct bytecode calls over dynamic dispatch.
-
-
Method Details
-
writeInvokeConstructor
Generates bytecode for a constructor call expression, choosing the appropriate strategy (direct, AIC, or normal call-site).- Overrides:
writeInvokeConstructorin classInvocationWriter- Parameters:
call- the constructor call expression to compile
-
writeSpecialConstructorCall
Generates bytecode for athis()orsuper()constructor call at the start of a constructor body.- Overrides:
writeSpecialConstructorCallin classInvocationWriter- Parameters:
call- the constructor call expression representingthis()orsuper()
-
tryBridgeMethod
@Deprecated protected boolean tryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args) Deprecated.Attempts to make a direct method call on a bridge method, if it exists. -
tryBridgeMethod
protected boolean tryBridgeMethod(MethodNode target, Expression receiver, boolean implicitThis, TupleExpression args, ClassNode thisClass) Attempts to make a direct method call on a bridge method, if it exists. -
writeDirectMethodCall
protected boolean writeDirectMethodCall(MethodNode target, boolean implicitThis, Expression receiver, TupleExpression args) Emits a direct (INVOKE*) bytecode call totargetwhen static type information is available. Returnsfalseif a direct call cannot be made.- Overrides:
writeDirectMethodCallin classInvocationWriter- Parameters:
target- the resolved method node to call directlyimplicitThis- whether the receiver is implicitthisreceiver- the receiver expression (may benull)args- the argument tuple- Returns:
trueif the call was emitted,falseotherwise
-
isPrivateBridgeMethodsCallAllowed
@Deprecated(since="6.0.0") protected static boolean isPrivateBridgeMethodsCallAllowed(ClassNode receiver, ClassNode caller) Deprecated.Use bridge metadata on the declaring class instead of probing outer-class nesting manually. -
loadArguments
Evaluates and loads each argument expression, handling varargs packing.- Overrides:
loadArgumentsin classInvocationWriter- Parameters:
argumentList- the argument expressions to evaluateparameters- the declared parameters of the target method
-
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
-
makeCall
public void makeCall(Expression origin, Expression receiver, Expression message, Expression arguments, MethodCallerMultiAdapter adapter, boolean safe, boolean spreadSafe, boolean implicitThis) Generates bytecode for a method call.- Overrides:
makeCallin classInvocationWriter- Parameters:
origin- the original expressionreceiver- 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 implicit 'this'
-