com.android.dx.dex.code
Class OutputFinisher

java.lang.Object
  extended by com.android.dx.dex.code.OutputFinisher

public final class OutputFinisher
extends Object

Processor for instruction lists, which takes a "first cut" of instruction selection as a basis and produces a "final cut" in the form of a DalvInsnList instance.


Constructor Summary
OutputFinisher(DexOptions dexOptions, int initialCapacity, int regCount)
          Constructs an instance.
 
Method Summary
 void add(DalvInsn insn)
          Adds an instruction to the output.
 void assignIndices(DalvCode.AssignIndicesCallback callback)
          Assigns indices in all instructions that need them, using the given callback to perform lookups.
 DalvInsnList finishProcessingAndGetList()
          Does final processing on this instance and gets the output as a DalvInsnList.
 HashSet<Constant> getAllConstants()
          Returns the set of all constants referred to by instructions added to this instance.
 boolean hasAnyLocalInfo()
          Returns whether this instance has any local variable information.
 boolean hasAnyPositionInfo()
          Returns whether any of the instructions added to this instance come with position info.
 void insert(int at, DalvInsn insn)
          Inserts an instruction in the output at the given offset.
 void reverseBranch(int which, CodeAddress newTarget)
          Reverses a branch which is buried a given number of instructions backward in the output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutputFinisher

public OutputFinisher(DexOptions dexOptions,
                      int initialCapacity,
                      int regCount)
Constructs an instance. It initially contains no instructions.

Parameters:
dexOptions - non-null; options for dex output
regCount - >= 0; register count for the method
initialCapacity - >= 0; initial capacity of the instructions list
Method Detail

hasAnyPositionInfo

public boolean hasAnyPositionInfo()
Returns whether any of the instructions added to this instance come with position info.

Returns:
whether any of the instructions added to this instance come with position info

hasAnyLocalInfo

public boolean hasAnyLocalInfo()
Returns whether this instance has any local variable information.

Returns:
whether this instance has any local variable information

getAllConstants

public HashSet<Constant> getAllConstants()
Returns the set of all constants referred to by instructions added to this instance.

Returns:
non-null; the set of constants

add

public void add(DalvInsn insn)
Adds an instruction to the output.

Parameters:
insn - non-null; the instruction to add

insert

public void insert(int at,
                   DalvInsn insn)
Inserts an instruction in the output at the given offset.

Parameters:
at - >= 0; what index to insert at
insn - non-null; the instruction to insert

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

assignIndices

public void assignIndices(DalvCode.AssignIndicesCallback callback)
Assigns indices in all instructions that need them, using the given callback to perform lookups. This should be called before calling finishProcessingAndGetList().

Parameters:
callback - non-null; callback object

finishProcessingAndGetList

public DalvInsnList finishProcessingAndGetList()
Does final processing on this instance and gets the output as a DalvInsnList. Final processing consists of:

Note: This method may only be called once per instance of this class.

Returns:
non-null; the output list
Throws:
UnsupportedOperationException - if this method has already been called


Copyright © 2012. All Rights Reserved.