Class LabelRange

java.lang.Object
net.covers1624.coffeegrinder.util.asm.LabelRange

public class LabelRange extends Object
Represents a logical list of Labels as described in Bytecode.

Created by covers1624 on 6/4/21.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final org.objectweb.asm.Label
     
    final List<org.objectweb.asm.Label>
     
    final org.objectweb.asm.Label
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    LabelRange(List<org.objectweb.asm.Label> range)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static LabelRange
    compute(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.Label start, org.objectweb.asm.Label end, boolean exclusiveEnd)
    Computes a LabelRange from the given InsnList.
    boolean
    containsLabel(org.objectweb.asm.Label label)
    Checks if a given label is contained within the range.
    boolean
     
    static @Nullable LabelRange
    extractRange(org.objectweb.asm.tree.InsnList list)
     
    org.objectweb.asm.Label
    Gets the last label included in this range.
    static org.objectweb.asm.Label
    getLabelAfter(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.Label target)
    Get the label declared immediately after the target label.
    List<org.objectweb.asm.Label>
    Gets the ordered list of labels included in this range.
    org.objectweb.asm.Label
    Gets the first label included in this range.
    int
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • start

      public final org.objectweb.asm.Label start
    • end

      public final org.objectweb.asm.Label end
    • range

      public final List<org.objectweb.asm.Label> range
  • Constructor Details

    • LabelRange

      public LabelRange(List<org.objectweb.asm.Label> range)
  • Method Details

    • getStart

      public org.objectweb.asm.Label getStart()
      Gets the first label included in this range.
      Returns:
      The Label.
    • getEnd

      public org.objectweb.asm.Label getEnd()
      Gets the last label included in this range. This may be the same as getStart()
      Returns:
      The Label.
    • getRange

      public List<org.objectweb.asm.Label> getRange()
      Gets the ordered list of labels included in this range. This is exactly how they appear in Bytecode, and are not sorted.
      Returns:
      The range.
    • containsLabel

      public boolean containsLabel(org.objectweb.asm.Label label)
      Checks if a given label is contained within the range.
      Parameters:
      label - The label to check.
      Returns:
      If the label is contained within the range.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compute

      public static LabelRange compute(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.Label start, org.objectweb.asm.Label end, boolean exclusiveEnd)
      Computes a LabelRange from the given InsnList.
      Parameters:
      list - The InsnList to extract the range from.
      start - The first Label to be included in the range.
      end - The last Label to be included in the range.
      exclusiveEnd - If the provided end Label should be exclusive or inclusive.
      Returns:
      The built range.
      Throws:
      IllegalStateException - If either the start or end label are not included in the provided InsnList.
    • getLabelAfter

      public static org.objectweb.asm.Label getLabelAfter(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.Label target)
      Get the label declared immediately after the target label.
      Parameters:
      list - The InsnList to search.
      target - The target label to search for.
      Returns:
      The label after the target.
    • extractRange

      @Nullable public static @Nullable LabelRange extractRange(org.objectweb.asm.tree.InsnList list)