Class InvokeDynamicWriter

java.lang.Object
org.codehaus.groovy.classgen.asm.InvocationWriter
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.
  • Constructor Details

    • InvokeDynamicWriter

      public InvokeDynamicWriter(WriterController controller)
      Creates an invocation writer that emits invokedynamic call sites.
  • Method Details

    • 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). Returns false if the call cannot be cached, causing the caller to fall through to the uncached path.
      Overrides:
      makeCachedCall in class InvocationWriter
      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
    • makeSingleArgumentCall

      public void makeSingleArgumentCall(Expression receiver, String message, Expression arguments, boolean safe)
      Generates a single-argument method call via the call-site writer.
      Overrides:
      makeSingleArgumentCall in class InvocationWriter
      Parameters:
      receiver - the receiver expression
      message - the method name
      arguments - the single argument expression
      safe - whether to use safe navigation (?.)
    • writeGetProperty

      protected void writeGetProperty(Expression receiver, String propertyName, boolean safe, boolean implicitThis, boolean groovyObject)
      Emits an invokedynamic property-get call site with the given flags.
    • writeNormalConstructorCall

      protected void writeNormalConstructorCall(ConstructorCallExpression call)
      Emits a normal (non-direct, non-AIC) constructor call via the call-site writer.
      Overrides:
      writeNormalConstructorCall in class InvocationWriter
      Parameters:
      call - the constructor call expression to compile
    • coerce

      public void coerce(ClassNode from, ClassNode target)
      Emits a Groovy as coercion from from to target.
      Overrides:
      coerce in class InvocationWriter
      Parameters:
      from - the source type currently on the operand stack
      target - the target type to coerce to
    • castToNonPrimitiveIfNecessary

      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
      Overrides:
      castToNonPrimitiveIfNecessary in class InvocationWriter
    • castNonPrimitiveToBool

      public void castNonPrimitiveToBool(ClassNode sourceType)
      Unboxes a non-primitive value on the operand stack to a primitive boolean.
      Overrides:
      castNonPrimitiveToBool in class InvocationWriter
      Parameters:
      sourceType - the type currently on top of the operand stack