Package com.android.dx.dex.code
Class OutputFinisher
java.lang.Object
com.android.dx.dex.code.OutputFinisher
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
ConstructorDescriptionOutputFinisher
(DexOptions dexOptions, int initialCapacity, int regCount, int paramSize) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Does final processing on this instance and gets the output as aDalvInsnList
.get
(int at) Returns the set of all constants referred to by instructions added to this instance.boolean
Returns whether this instance has any local variable information.boolean
Returns whether any of the instructions added to this instance come with position info.void
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.int
size()
-
Constructor Details
-
OutputFinisher
Constructs an instance. It initially contains no instructions.- Parameters:
dexOptions
-non-null;
options for dex outputinitialCapacity
->= 0;
initial capacity of the instructions listregCount
->= 0;
register count for the methodparamSize
- size, in register units, of all the parameters for this method
-
-
Method Details
-
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
Returns the set of all constants referred to by instructions added to this instance.- Returns:
non-null;
the set of constants
-
add
Adds an instruction to the output.- Parameters:
insn
-non-null;
the instruction to add
-
insert
Inserts an instruction in the output at the given offset.- Parameters:
at
-at >= 0;
what index to insert atinsn
-non-null;
the instruction to insert
-
get
-
size
public int size() -
reverseBranch
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
Assigns indices in all instructions that need them, using the given callback to perform lookups. This should be called before callingfinishProcessingAndGetList()
.- Parameters:
callback
-non-null;
callback object
-
finishProcessingAndGetList
Does final processing on this instance and gets the output as aDalvInsnList
. Final processing consists of:- optionally renumbering registers (to make room as needed for expanded instructions)
- picking a final opcode for each instruction
- rewriting instructions, because of register number, constant pool index, or branch target size issues
- assigning final addresses
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
-