Package: org.codehaus.groovy.classgen.asm.indy

## [Java] Class InvokeDynamicWriter

- org.codehaus.groovy.classgen.asm.indy.InvokeDynamicWriter

-     public class InvokeDynamicWriter
      extends InvocationWriter

  This Writer is used to generate the call invocation byte codes for usage by invokedynamic.

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class InvocationWriter` | `castToVargsArray, controller, currentCall, invokeClosureMethod, invokeMethod, invokeMethodOnCurrent, invokeMethodOnSuper, invokeStaticMethod`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `InvokeDynamicWriter(WriterController controller)` Creates an invocation writer that emits `invokedynamic` call sites.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `castNonPrimitiveToBool(ClassNode sourceType)` * Unboxes a non-primitive value on the operand stack to a primitive `boolean`. * * Parameters: `last` - the type currently on top of the operand stack
    `` | `public void` | `castToNonPrimitiveIfNecessary(ClassNode sourceType, ClassNode targetType)` * Converts sourceType to a non-primitive by using Groovy casting. * sourceType might be a primitive * This might be done using SBA#castToType
    `` | `public void` | `coerce(ClassNode from, ClassNode target)` * Emits a Groovy `as` coercion from `from` to `target`. * * Parameters: `from` - the source type currently on the operand stack * `target` - the target type to coerce to
    `` | `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). * Returns `false` if the call cannot be cached, causing the caller to * fall through to the uncached path. * * Parameters: `origin` - the original call expression * `sender` - the class from which the call is dispatched * `receiver` - the receiver expression * `message` - the method name expression * `arguments` - the arguments expression * `adapter` - the method caller adapter * `safe` - whether to use safe navigation * `spreadSafe` - whether to use spread-safe navigation * `implicitThis` - whether the receiver is implicit `this` * `containsSpreadExpression` - whether any argument uses spread * Returns: `true` if a cached call was emitted
    `` | `public void` | `makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe)` * Generates a single-argument method call via the call-site writer. * * Parameters: `receiver` - the receiver expression * `message` - the method name * `arguments` - the single argument expression * `safe` - whether to use safe navigation (`?.`)
    `` | `protected void` | `writeGetProperty(Expression receiver, String propertyName, boolean safe, boolean implicitThis, boolean groovyObject)` Emits an `invokedynamic` property-get call site with the given flags.
    `` | `protected void` | `writeNormalConstructorCall(ConstructorCallExpression call)` * Emits a normal (non-direct, non-AIC) constructor call via the call-site writer. * * Parameters: `call` - the constructor call expression to compile

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class InvocationWriter` | `castNonPrimitiveToBool, castToNonPrimitiveIfNecessary, coerce, finnishConstructorCall, getMethodName, loadArguments, makeArgumentList, makeCachedCall, makeCall, makeCall, makeClassForNameCall, makeDirectCall, makeSingleArgumentCall, makeSingleArgumentCall, makeUncachedCall, prepareConstructorCall, writeAICCall, writeDirectMethodCall, writeInvokeConstructor, writeInvokeMethod, writeInvokeStaticMethod, writeNormalConstructorCall, writeSpecialConstructorCall`

- - ### Constructor Detail

    - #### public InvokeDynamicWriter(WriterController controller)

      Creates an invocation writer that emits `invokedynamic` call sites.

  - ### Method Detail

    - #### public void castNonPrimitiveToBool(ClassNode sourceType)

      * Unboxes a non-primitive value on the operand stack to a primitive `boolean`. * *

      Parameters:
        `last` - the type currently on top of the operand stack

    - #### public void castToNonPrimitiveIfNecessary(ClassNode sourceType, ClassNode targetType)

      * Converts sourceType to a non-primitive by using Groovy casting. * sourceType might be a primitive * This might be done using SBA#castToType

    - #### public void coerce(ClassNode from, ClassNode target)

      * Emits a Groovy `as` coercion from `from` to `target`. * *

      Parameters:
        `from` - the source type currently on the operand stack *
        `target` - the target type to coerce to

    - #### 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). * Returns `false` if the call cannot be cached, causing the caller to * fall through to the uncached path. * *

      Parameters:
        `origin` - the original call expression *
        `sender` - the class from which the call is dispatched *
        `receiver` - the receiver expression *
        `message` - the method name expression *
        `arguments` - the arguments expression *
        `adapter` - the method caller adapter *
        `safe` - whether to use safe navigation *
        `spreadSafe` - whether to use spread-safe navigation *
        `implicitThis` - whether the receiver is implicit `this` *
        `containsSpreadExpression` - whether any argument uses spread *
      Returns:
        `true` if a cached call was emitted

    - #### public void makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe)

      * Generates a single-argument method call via the call-site writer. * *

      Parameters:
        `receiver` - the receiver expression *
        `message` - the method name *
        `arguments` - the single argument expression *
        `safe` - whether to use safe navigation (`?.`)

    - #### protected void writeGetProperty(Expression receiver, String propertyName, boolean safe, boolean implicitThis, boolean groovyObject)

      Emits an `invokedynamic` property-get call site with the given flags.

    - #### protected void writeNormalConstructorCall(ConstructorCallExpression call)

      * Emits a normal (non-direct, non-AIC) constructor call via the call-site writer. * *

      Parameters:
        `call` - the constructor call expression to compile