Class LocalVariableDiscriminator

java.lang.Object
org.spongepowered.asm.mixin.injection.modify.LocalVariableDiscriminator

public class LocalVariableDiscriminator extends Object
Encapsulates logic for identifying a local variable in a target method using 3 criteria: ordinal, index and name. This is used by the ModifyVariableInjector and its associated injection points.
  • Constructor Details

    • LocalVariableDiscriminator

      public LocalVariableDiscriminator(boolean argsOnly, int ordinal, int index, Set<String> names, boolean print)
      Parameters:
      argsOnly - true to only search within the method arguments
      ordinal - target variable ordinal
      index - target variable index
      names - target variable names
      print - true to print lvt
  • Method Details

    • isArgsOnly

      public boolean isArgsOnly()
      True if this discriminator will examine only the target method args and won't consider the rest of the LVT at the target location
    • getOrdinal

      public int getOrdinal()
      Get the local variable ordinal (nth variable of type)
    • getIndex

      public int getIndex()
      Get the local variable absolute index
    • getNames

      public Set<String> getNames()
      Get valid names for consideration
    • hasNames

      public boolean hasNames()
      Returns true if names is not empty
    • printLVT

      public boolean printLVT()
      True if the injector should print the LVT
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(LocalVariableDiscriminator.Context context)
    • isImplicit

      protected boolean isImplicit(LocalVariableDiscriminator.Context context)
      If the user specifies no values for ordinal, index or names then we are considered to be operating in "implicit mode" where only a single local variable of the specified type is expected to exist.
      Parameters:
      context - Target context
      Returns:
      true if operating in implicit mode
    • findLocal

      public int findLocal(LocalVariableDiscriminator.Context context)
      Find a local variable for the specified context
      Parameters:
      context - search context
      Returns:
      index of local or -1 if not found
    • parse

      public static LocalVariableDiscriminator parse(org.objectweb.asm.tree.AnnotationNode annotation)
      Parse a local variable discriminator from the supplied annotation
      Parameters:
      annotation - annotation to parse
      Returns:
      discriminator configured using values from the annoation