Class SwitchData


public final class SwitchData extends VariableSizeInsn
Pseudo-instruction which holds switch data. The switch data is a map of values to target addresses, and this class writes the data in either a "packed" or "sparse" form.
  • Constructor Details

    • SwitchData

      public SwitchData(SourcePosition position, CodeAddress user, IntList cases, CodeAddress[] targets)
      Constructs an instance. The output address of this instance is initially unknown (-1).
      Parameters:
      position - non-null; source position
      user - non-null; address representing the instruction that uses this instance
      cases - non-null; sorted list of switch cases (keys)
      targets - non-null; corresponding list of code addresses; the branch target for each case
  • Method Details

    • codeSize

      public int codeSize()
      Gets the size of this instruction, in 16-bit code units.
      Specified by:
      codeSize in class DalvInsn
      Returns:
      >= 0; the code size of this instruction
    • writeTo

      public void writeTo(AnnotatedOutput out)
      Writes this instance to the given output. This method should never annotate the output.
      Specified by:
      writeTo in class DalvInsn
      Parameters:
      out - non-null; where to write to
    • withRegisters

      public DalvInsn withRegisters(RegisterSpecList registers)
      Returns an instance that is just like this one, except that the register list is replaced by the given one, and its address is reset.
      Specified by:
      withRegisters in class DalvInsn
      Parameters:
      registers - non-null; new register list
      Returns:
      non-null; an appropriately-constructed instance
    • isPacked

      public boolean isPacked()
      Returns whether or not this instance's data will be output as packed.
      Returns:
      true iff the data is to be packed
    • argString

      protected String argString()
      Gets the string form for any arguments to this instance. Subclasses must override this.
      Specified by:
      argString in class DalvInsn
      Returns:
      null-ok; the string version of any arguments or null if there are none
    • listingString0

      protected String listingString0(boolean noteIndices)
      Helper for DalvInsn.listingString(java.lang.String, int, boolean), which returns the string form of this instance suitable for inclusion in a human-oriented listing dump, not including the instruction address and without respect for any output formatting. This method should return null if this instance should not appear in a listing.
      Specified by:
      listingString0 in class DalvInsn
      Parameters:
      noteIndices - whether to include an explicit notation of constant pool indices
      Returns:
      null-ok; the listing string