|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.android.dx.cf.code.BytecodeArray
public final class BytecodeArray
Bytecode array, which is part of a standard Code attribute.
| Nested Class Summary | |
|---|---|
static class |
BytecodeArray.BaseVisitor
Base implementation of BytecodeArray.Visitor, which has empty method
bodies for all methods. |
static interface |
BytecodeArray.Visitor
Instruction visitor interface. |
| Field Summary | |
|---|---|
static BytecodeArray.Visitor |
EMPTY_VISITOR
convenient no-op implementation of BytecodeArray.Visitor |
| Constructor Summary | |
|---|---|
BytecodeArray(ByteArray bytes,
ConstantPool pool)
Constructs an instance. |
|
| Method Summary | |
|---|---|
int |
byteLength()
Gets the total length of this structure in bytes, when included in a Code attribute. |
void |
forEach(BytecodeArray.Visitor visitor)
Parses each instruction in the array, in order. |
ByteArray |
getBytes()
Gets the underlying byte array. |
int[] |
getInstructionOffsets()
Finds the offset to each instruction in the bytecode array. |
int |
parseInstruction(int offset,
BytecodeArray.Visitor visitor)
Parses the instruction at the indicated offset. |
void |
processWorkSet(int[] workSet,
BytecodeArray.Visitor visitor)
Processes the given "work set" by repeatedly finding the lowest bit in the set, clearing it, and parsing and visiting the instruction at the indicated offset (that is, the bit index), repeating until the work set is empty. |
int |
size()
Gets the size of the bytecode array, per se. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final BytecodeArray.Visitor EMPTY_VISITOR
BytecodeArray.Visitor
| Constructor Detail |
|---|
public BytecodeArray(ByteArray bytes,
ConstantPool pool)
bytes - non-null; underlying bytespool - non-null; constant pool to use when
resolving constant pool indices| Method Detail |
|---|
public ByteArray getBytes()
non-null; the byte arraypublic int size()
>= 0; the length of the bytecode arraypublic int byteLength()
Code attribute. The returned value includes the
array size plus four bytes for code_length.
>= 4; the total length, in bytespublic void forEach(BytecodeArray.Visitor visitor)
visitor - null-ok; visitor to call back to for
each instructionpublic int[] getInstructionOffsets()
non-null; appropriately constructed bit setBits
public void processWorkSet(int[] workSet,
BytecodeArray.Visitor visitor)
workSet - non-null; the work set to processvisitor - non-null; visitor to call back to for
each instruction
public int parseInstruction(int offset,
BytecodeArray.Visitor visitor)
In order to simplify further processing, the opcodes passed to the visitor are canonicalized, altering the opcode to a more universal one and making formerly implicit arguments explicit. In particular:
ldc.
E.g., fconst_0, sipush, and
lconst_0 qualify for this treatment.aconst_null becomes ldc of a
"known null."aload_2 becomes aload.goto_w and jsr_w become goto
and jsr (respectively).ldc_w becomes ldc.tableswitch becomes lookupswitch.
int variant opcode, with the type
argument set to indicate the actual type. E.g.,
fadd becomes iadd, but
type is passed as Type.FLOAT in that
case. Similarly, areturn becomes
ireturn. (However, return remains
unchanged.int
variant opcode, with the type argument set to indicate
the actual type. E.g., aload becomes iload,
but type is passed as Type.OBJECT in
that case.i2l, etc.) are left alone
to avoid too much confustion, but their type is
the pushed type. E.g., i2b gets type
Type.INT, and f2d gets type
Type.DOUBLE. Other unaltered opcodes also get
their pushed type. E.g., arraylength gets type
Type.INT.
offset - >= 0, < bytes.size(); offset to the start of the
instructionvisitor - null-ok; visitor to call back to
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||