Class OutputCollector

java.lang.Object
com.android.dx.dex.code.OutputCollector

public final class OutputCollector extends Object
Destination for DalvInsn instances being output. This class receives and collects instructions in two pieces — a primary list and a suffix (generally consisting of adjunct data referred to by the primary list, such as switch case tables) — which it merges and emits back out in the form of a DalvInsnList instance.
  • Constructor Details

    • OutputCollector

      public OutputCollector(DexOptions dexOptions, int initialCapacity, int suffixInitialCapacity, int regCount, int paramSize)
      Constructs an instance.
      Parameters:
      dexOptions - non-null; options for dex output
      initialCapacity - >= 0; initial capacity of the output list
      suffixInitialCapacity - >= 0; initial capacity of the output suffix
      regCount - >= 0; register count for the method
      paramSize - size, in register units, of all the parameters for this method
  • Method Details

    • add

      public void add(DalvInsn insn)
      Adds an instruction to the output.
      Parameters:
      insn - non-null; the instruction to add
    • get

      public DalvInsn get(int at)
    • size

      public int size()
    • reverseBranch

      public void reverseBranch(int which, CodeAddress newTarget)
      Reverses a branch which is buried a given number of instructions backward in the output. It is illegal to call this unless the indicated instruction really is a reversible branch.
      Parameters:
      which - how many instructions back to find the branch; 0 is the most recently added instruction, 1 is the instruction before that, etc.
      newTarget - non-null; the new target for the reversed branch
    • addSuffix

      public void addSuffix(DalvInsn insn)
      Adds an instruction to the output suffix.
      Parameters:
      insn - non-null; the instruction to add
    • getFinisher

      public OutputFinisher getFinisher()
      Gets the results of all the calls on this instance, in the form of an OutputFinisher.
      Returns:
      non-null; the output finisher
      Throws:
      UnsupportedOperationException - if this method has already been called