Package org.codehaus.groovy.classgen.asm

# Class MopWriter

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

Direct Known Subclasses:
  `StaticCompilationMopWriter`

public class MopWriter extends Object
Generates bytecode for Meta Object Protocol (MOP) methods.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `MopWriter.Factory`
  Factory interface for creating MopWriter instances.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final WriterController`
  `controller`
  The controller coordinating all bytecode writers for the current class.
  `static final MopWriter.Factory`
  `FACTORY`
  Default factory for MopWriter instances.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MopWriter(WriterController controller)`
  Creates a MopWriter with the given controller.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `createMopMethods()`
  Generates MOP methods for the current class.
  `static boolean`
  `equalParameterTypes(Parameter[] p1, Parameter[] p2)`
  Deprecated.
  Use `ParameterUtils.parametersEqual(Parameter[], Parameter[])` instead
  `protected void`
  `generateMopCalls(LinkedList<MethodNode> methods, boolean useThis)`
  Generates a Meta Object Protocol method that is used to call a non-public method or to make a call to super.
  `static String`
  `getMopMethodName(MethodNode method, boolean useThis)`
  Creates a MOP method name from a method.
  `static boolean`
  `isMopMethod(String methodName)`
  Determines if a method is a MOP method.

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

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

- ## Field Details

  - ### FACTORY

    public static final MopWriter.Factory FACTORY
    Default factory for MopWriter instances.

  - ### controller

    protected final WriterController controller
    The controller coordinating all bytecode writers for the current class.

- ## Constructor Details

  - ### MopWriter

    public MopWriter(WriterController controller)
    Creates a MopWriter with the given controller.
    Parameters:
      `controller` - the writer controller

- ## Method Details

  - ### createMopMethods

    public void createMopMethods()
    Generates MOP methods for the current class.

  - ### generateMopCalls

    protected void generateMopCalls(LinkedList<MethodNode> methods, boolean useThis)
    Generates a Meta Object Protocol method that is used to call a non-public method or to make a call to super.
    Parameters:
      `methods` - list of methods a MOP call method should be generated for
      `useThis` - indicates if "this" should be used for the name and call

  - ### getMopMethodName

    public static String getMopMethodName(MethodNode method, boolean useThis)
    Creates a MOP method name from a method.
    Parameters:
      `method` - the method to be called by the mop method
      `useThis` - if true, then it is a call on "this", "super" else
    Returns:
      the mop method name

  - ### isMopMethod

    public static boolean isMopMethod(String methodName)
    Determines if a method is a MOP method. This is done by the method name. If the name starts with "this$" or "super$" but does not contain "$dist$", then it is an MOP method.
    Parameters:
      `methodName` - name of the method to test
    Returns:
      true if the method is a MOP method

  - ### equalParameterTypes

    @Deprecated public static boolean equalParameterTypes(Parameter[] p1, Parameter[] p2)
    Deprecated.
    Use `ParameterUtils.parametersEqual(Parameter[], Parameter[])` instead
    Checks if two parameter arrays are equal.
    Parameters:
      `p1` - first parameter array
      `p2` - second parameter array
    Returns:
      true if parameters are equal