Package org.codehaus.groovy.classgen.asm

# Class CallSiteWriter

java.lang.Object
org.codehaus.groovy.classgen.asm.CallSiteWriter

Direct Known Subclasses:
  `IndyCallSiteWriter`, `StaticTypesCallSiteWriter`

public class CallSiteWriter extends Object
This class represents non-public API used by AsmClassGenerator. Don't use this class in your code

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CONSTRUCTOR`
  Sentinel name for constructor calls.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CallSiteWriter(WriterController wc)`
  Creates a call site writer with the given controller.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `fallbackAttributeOrPropertySite(PropertyExpression expression, Expression objectExpression, String name, MethodCallerMultiAdapter adapter)`
  Generates a fallback call for attribute or property access.
  `void`
  `generateCallSiteArray()`
  Generates the call site array field and accessor methods.
  `List<String>`
  `getCallSites()`
  Returns the list of call site names.
  `boolean`
  `hasCallSiteUse()`
  Checks if any call sites have been used.
  `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.
  `void`
  `makeCallSiteArrayInitializer()`
  Generates bytecode to initialize the call site array field to null.
  `void`
  `makeGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis)`
  Generates a general getProperty call.
  `void`
  `makeGroovyObjectGetPropertySite(Expression receiver, String methodName, boolean safe, boolean implicitThis)`
  Generates a GroovyObject getProperty call.
  `final void`
  `makeSingleArgumentCall(Expression receiver, String message, Expression arguments)`
  Generates a single-argument method call.
  `void`
  `makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe)`
  Generates a single-argument method call with optional safe navigation.
  `void`
  `makeSiteEntry()`
  Generates bytecode to load the call site array into a local variable.
  `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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### CONSTRUCTOR

    public static final String CONSTRUCTOR
    Sentinel name for constructor calls.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### CallSiteWriter

    public CallSiteWriter(WriterController wc)
    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

    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`.
    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 expression
      `methodName` - the method name
      `implicitThis` - whether the receiver is implicit 'this'
      `lhs` - whether this is on the left-hand side of an assignment

  - ### visitBoxedArgument

    protected void visitBoxedArgument(Expression exp)
    Visits an argument expression and ensures it is boxed.
    Parameters:
      `exp` - the argument expression

  - ### makeSingleArgumentCall

    public final void makeSingleArgumentCall(Expression receiver, String message, Expression arguments)
    Generates a single-argument method call.
    Parameters:
      `receiver` - the receiver expression
      `message` - the method name
      `arguments` - 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 expression
      `message` - the method name
      `arguments` - the argument expression
      `safe` - 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 expression
      `methodName` - the property name
      `safe` - whether to use safe navigation
      `implicitThis` - 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 expression
      `methodName` - the property name
      `safe` - whether to use safe navigation
      `implicitThis` - 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 expression
      `message` - the method name
      `arguments` - the arguments expression
      `safe` - whether to use safe navigation
      `implicitThis` - whether the receiver is implicit 'this'
      `callCurrent` - whether to call on the current object
      `callStatic` - whether this is a static method call

  - ### getCallSites

    public List<String> 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 expression
      `objectExpression` - the object expression
      `name` - the property name
      `adapter` - the method caller adapter