java.lang.Object
org.spongepowered.asm.mixin.injection.struct.Target
org.spongepowered.asm.mixin.injection.struct.Constructor
All Implemented Interfaces:
Comparable<Target>, Iterable<org.objectweb.asm.tree.AbstractInsnNode>

public class Constructor extends Target
A Target which is a constructor
  • Constructor Details

    • Constructor

      public Constructor(ClassInfo classInfo, org.objectweb.asm.tree.ClassNode classNode, org.objectweb.asm.tree.MethodNode method)
  • Method Details

    • findDelegateInitNode

      public Bytecode.DelegateInitialiser findDelegateInitNode()
      Find the call to super() or this() in a constructor. This attempts to locate the first call to <init> which isn't an inline call to another object ctor being passed into the super invocation.
      Returns:
      Call to super(), this() or DelegateInitialiser.NONE if not found
    • isInjectable

      public boolean isInjectable()
      Get whether this constructor should have mixin initialisers injected into it based on whether a delegate initialiser call is absent or is a call to super()
    • inspect

      public void inspect(Initialiser initialiser)
      Inspect an incoming initialiser to determine which fields are touched by the mixin. This is then used in findInitialiserInjectionPoint(org.spongepowered.asm.mixin.transformer.struct.Initialiser.InjectionMode) to determine the instruction after which the mixin initialisers will be placed
      Parameters:
      initialiser - the initialiser to inspect
    • findInitialiserInjectionPoint

      public org.objectweb.asm.tree.AbstractInsnNode findInitialiserInjectionPoint(Initialiser.InjectionMode mode)
      Find the injection point for injected initialiser insns in the target ctor. This starts by assuming that initialiser instructions should be placed immediately after the delegate initialiser call, but then searches for field assignments and selects the last unique field assignment in the ctor body which represents a reasonable heuristic for the end of the existing initialisers.
      Parameters:
      mode - Injection mode for this specific environment
      Returns:
      target node
    • findFirstBodyInsn

      public org.objectweb.asm.tree.AbstractInsnNode findFirstBodyInsn()
      Find the injection point
    • getRange

      public static InsnRange getRange(org.objectweb.asm.tree.MethodNode ctor)
      Identifies line numbers in the supplied ctor which correspond to the start and end of the method body.
      Parameters:
      ctor - constructor to scan
      Returns:
      range indicating the line numbers of the specified constructor and the position of the superclass ctor invocation