Package org.codehaus.groovy.classgen.asm
Class CallSiteWriter
java.lang.Object
org.codehaus.groovy.classgen.asm.CallSiteWriter
- Direct Known Subclasses:
IndyCallSiteWriter,StaticTypesCallSiteWriter
This class represents non-public API used by AsmClassGenerator. Don't
use this class in your code
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a call site writer with the given controller. -
Method Summary
Modifier and TypeMethodDescriptionvoidfallbackAttributeOrPropertySite(PropertyExpression expression, Expression objectExpression, String name, MethodCallerMultiAdapter adapter) Generates a fallback call for attribute or property access.voidGenerates the call site array field and accessor methods.Returns the list of call site names.booleanChecks if any call sites have been used.voidmakeCallSite(Expression receiver, String message, Expression arguments, boolean safe, boolean implicitThis, boolean callCurrent, boolean callStatic) Generates a general method call through the call site infrastructure.voidGenerates bytecode to initialize the call site array field to null.voidmakeGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis) Generates a general getProperty call.voidmakeGroovyObjectGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis) Generates a GroovyObject getProperty call.final voidmakeSingleArgumentCall(Expression receiver, String message, Expression arguments) Generates a single-argument method call.voidmakeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe) Generates a single-argument method call with optional safe navigation.voidGenerates bytecode to load the call site array into a local variable.voidprepareCallSite(String message) Prepares a call-site entry for the named method on the bytecode operand stack, loading the call-site array and selecting the slot formessage.protected voidprepareSiteAndReceiver(Expression receiver, String methodName, boolean implicitThis, boolean lhs) Generates bytecode to prepare the call site and receiver for a method call.protected voidVisits an argument expression and ensures it is boxed.
-
Field Details
-
CONSTRUCTOR
Sentinel name for constructor calls.- See Also:
-
-
Constructor Details
-
CallSiteWriter
Creates a call site writer with the given controller.- Parameters:
wc- the writer controller
-
-
Method Details
-
makeSiteEntry
public void makeSiteEntry()Generates bytecode to load the call site array into a local variable. -
generateCallSiteArray
public void generateCallSiteArray()Generates the call site array field and accessor methods. -
prepareCallSite
Prepares a call-site entry for the named method on the bytecode operand stack, loading the call-site array and selecting the slot formessage.- Parameters:
message- the method name for which to prepare the call site
-
prepareSiteAndReceiver
protected void prepareSiteAndReceiver(Expression receiver, String methodName, boolean implicitThis, boolean lhs) Generates bytecode to prepare the call site and receiver for a method call.- Parameters:
receiver- the receiver expressionmethodName- the method nameimplicitThis- whether the receiver is implicit 'this'lhs- whether this is on the left-hand side of an assignment
-
visitBoxedArgument
Visits an argument expression and ensures it is boxed.- Parameters:
exp- the argument expression
-
makeSingleArgumentCall
Generates a single-argument method call.- Parameters:
receiver- the receiver expressionmessage- the method namearguments- the argument expression
-
makeSingleArgumentCall
public void makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe) Generates a single-argument method call with optional safe navigation.- Parameters:
receiver- the receiver expressionmessage- the method namearguments- the argument expressionsafe- whether to use safe navigation
-
makeGroovyObjectGetPropertySite
public void makeGroovyObjectGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis) Generates a GroovyObject getProperty call.- Parameters:
receiver- the receiver expressionmethodName- the property namesafe- whether to use safe navigationimplicitThis- whether the receiver is implicit 'this'
-
makeGetPropertySite
public void makeGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis) Generates a general getProperty call.- Parameters:
receiver- the receiver expressionmethodName- the property namesafe- whether to use safe navigationimplicitThis- whether the receiver is implicit 'this'
-
makeCallSite
public void makeCallSite(Expression receiver, String message, Expression arguments, boolean safe, boolean implicitThis, boolean callCurrent, boolean callStatic) Generates a general method call through the call site infrastructure.- Parameters:
receiver- the receiver expressionmessage- the method namearguments- the arguments expressionsafe- whether to use safe navigationimplicitThis- whether the receiver is implicit 'this'callCurrent- whether to call on the current objectcallStatic- whether this is a static method call
-
getCallSites
Returns the list of call site names.- Returns:
- the call site names
-
makeCallSiteArrayInitializer
public void makeCallSiteArrayInitializer()Generates bytecode to initialize the call site array field to null. -
hasCallSiteUse
public boolean hasCallSiteUse()Checks if any call sites have been used.- Returns:
- true if call sites have been used
-
fallbackAttributeOrPropertySite
public void fallbackAttributeOrPropertySite(PropertyExpression expression, Expression objectExpression, String name, MethodCallerMultiAdapter adapter) Generates a fallback call for attribute or property access.- Parameters:
expression- the property expressionobjectExpression- the object expressionname- the property nameadapter- the method caller adapter
-