Class LocalVariableDiscriminator

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

public class LocalVariableDiscriminator
extends java.lang.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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  LocalVariableDiscriminator.Context
    Discriminator context information, wraps all relevant information about a target location for use when performing discrimination
  • Constructor Summary

    Constructors
    Constructor Description
    LocalVariableDiscriminator​(boolean argsOnly, int ordinal, int index, java.util.Set<java.lang.String> names, boolean print)  
  • Method Summary

    Modifier and Type Method Description
    int findLocal​(LocalVariableDiscriminator.Context context)
    Find a local variable for the specified context
    int getIndex()
    Get the local variable absolute index
    java.util.Set<java.lang.String> getNames()
    Get valid names for consideration
    int getOrdinal()
    Get the local variable ordinal (nth variable of type)
    boolean hasNames()
    Returns true if names is not empty
    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
    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.
    static LocalVariableDiscriminator parse​(org.objectweb.asm.tree.AnnotationNode annotation)
    Parse a local variable discriminator from the supplied annotation
    boolean printLVT()
    True if the injector should print the LVT
    java.lang.String toString()  
    java.lang.String toString​(LocalVariableDiscriminator.Context context)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LocalVariableDiscriminator

      public LocalVariableDiscriminator​(boolean argsOnly, int ordinal, int index, java.util.Set<java.lang.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 java.util.Set<java.lang.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 java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • toString

      public java.lang.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