public class CallSiteWriter
extends Object
Bytecode writer for classic (non-invokedynamic) call sites.
Non-public API used by AsmClassGenerator. Do not use this class
in application code. Groovy 6 defaults to invokedynamic
(IndyCallSiteWriter);
this writer is selected only when indy is disabled. The generated
bytecode references org.codehaus.groovy.runtime.callsite.*, which
lives in the optional groovy-callsite module — that module must be
on the classpath both to emit and to execute such classes
(WriterController fails fast if it is missing when indy is off).
| Modifiers | Name | Description |
|---|---|---|
static String |
CONSTRUCTOR |
Sentinel name for constructor calls. |
| Constructor and description |
|---|
CallSiteWriter(WriterController wc)Creates a call site writer with the given controller. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
fallbackAttributeOrPropertySite(PropertyExpression expression, Expression objectExpression, String name, MethodCallerMultiAdapter adapter)Generates a fallback call for attribute or property access. |
|
public void |
generateCallSiteArray()Generates the call site array field and accessor methods. |
|
public List<String> |
getCallSites()Returns the list of call site names. |
|
public boolean |
hasCallSiteUse()Checks if any call sites have been used. |
|
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. |
|
public void |
makeCallSiteArrayInitializer()Generates bytecode to initialize the call site array field to null. |
|
public void |
makeGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis)Generates a general getProperty call. |
|
public void |
makeGroovyObjectGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis)Generates a GroovyObject getProperty call. |
|
public void |
makeSetPropertySite(PropertyExpression expression, Expression objectExpression, String name, MethodCallerMultiAdapter adapter, boolean groovyObject)Emits a property-write site (GROOVY-12138). |
|
public final void |
makeSingleArgumentCall(Expression receiver, String message, Expression arguments)Generates a single-argument method call. |
|
public void |
makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe)Generates a single-argument method call with optional safe navigation. |
|
public void |
makeSiteEntry()Generates bytecode to load the call site array into a local variable. |
|
public void |
prepareCallSite(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 for message. |
|
protected void |
prepareSiteAndReceiver(Expression receiver, String methodName, boolean implicitThis, boolean lhs)Generates bytecode to prepare the call site and receiver for a method call. |
|
protected void |
visitBoxedArgument(Expression exp)Visits an argument expression and ensures it is boxed. |
Sentinel name for constructor calls.
Creates a call site writer with the given controller.
wc - the writer controllerGenerates a fallback call for attribute or property access.
expression - the property expressionobjectExpression - the object expressionname - the property nameadapter - the method caller adapterGenerates the call site array field and accessor methods.
Checks if any call sites have been used.
Generates a general method call through the call site infrastructure.
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 callGenerates bytecode to initialize the call site array field to null.
Generates a general getProperty call.
receiver - the receiver expressionmethodName - the property namesafe - whether to use safe navigationimplicitThis - whether the receiver is implicit 'this'Generates a GroovyObject getProperty call.
receiver - the receiver expressionmethodName - the property namesafe - whether to use safe navigationimplicitThis - whether the receiver is implicit 'this' Emits a property-write site (GROOVY-12138). The assigned value is
already on the operand stack. The default implementation is the classic
ScriptBytecodeAdapter adapter call; the indy writer may override
this to emit an invokedynamic setProperty call site.
expression - the property expression being assignedobjectExpression - the receiver expressionname - the property nameadapter - the classic set adapter used for the default pathgroovyObject - whether the receiver is statically known to be a GroovyObjectGenerates a single-argument method call.
receiver - the receiver expressionmessage - the method namearguments - the argument expressionGenerates a single-argument method call with optional safe navigation.
receiver - the receiver expressionmessage - the method namearguments - the argument expressionsafe - whether to use safe navigationGenerates bytecode to load the call site array into a local variable.
Prepares a call-site entry for the named method on the bytecode operand stack,
loading the call-site array and selecting the slot for message.
message - the method name for which to prepare the call siteGenerates bytecode to prepare the call site and receiver for a method call.
receiver - the receiver expressionmethodName - the method nameimplicitThis - whether the receiver is implicit 'this'lhs - whether this is on the left-hand side of an assignmentVisits an argument expression and ensures it is boxed.
exp - the argument expressionCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.