|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.wala.util.bytecode.BytecodeStream
public class BytecodeStream
Provides minimal abstraction layer to a stream of bytecodes from the code attribute of a method.
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
BytecodeStream(IMethod m,
byte[] bc)
|
|
| Method Summary | |
|---|---|
void |
alignInvokeInterface()
Skips the extra stuff after an invokeinterface instruction Used for invokeinterface |
void |
alignSwitch()
Skips the padding of a switch instruction Used for tableswitch, lookupswitch |
int |
computeLookupSwitchOffset(int value,
int num)
Returns the offset for a given value of the lookupswitch (as a signed int) or 0 if the value is not in the table. |
int |
computeTableSwitchOffset(int value,
int low,
int high)
Returns the offset for a given value of the tableswitch (as a signed int) or 0 if the value is out of range. |
IClass |
declaringClass()
Returns the declaring class that this bytecode stream is from |
int |
getArrayDimension()
Returns the dimension of the array (as an unsigned byte) Used for multianewarray |
int |
getArrayElementType()
Returns the element type (primitive) of the array (as an unsigned byte) Used for newarray |
int |
getBranchOffset()
Returns the offset of the branch (as a signed short) Used for if |
int |
getByteValue()
Returns a signed byte value Used for bipush |
int |
getConstantIndex()
Returns the constant pool index of a constant (as an unsigned byte) Used for ldc |
byte |
getConstantType(int index)
Returns the type of a constant at a given constant pool index (as a byte) Used for ldc, ldc_w, ldc2_w |
int |
getDefaultSwitchOffset()
Returns the default offset of the switch (as a signed int) Used for tableswitch, lookupswitch |
int |
getHighSwitchValue()
Returns the highest value of the tableswitch (as a signed int) Used for tableswitch |
int |
getIncrement()
Returns an increment value (as a signed byte) Used for iinc |
int |
getIntConstant(int index)
Returns the constant at a given constant pool index (as an int) Used for ldc, ldc_w |
int |
getLocalNumber()
Returns the number of the local (as an unsigned byte) Used for iload, lload, fload, dload, aload, istore, lstore, fstore, dstore, astore, iinc, ret |
int |
getLookupSwitchOffset(int num)
Returns the numbered offset of the lookupswitch (as a signed int) Used for lookupswitch The "cursor" has to be positioned at the start of the pair table NOTE: Will NOT advance cursor |
int |
getLookupSwitchValue(int num)
Returns the numbered value of the lookupswitch (as a signed int) Used for lookupswitch The "cursor" has to be positioned at the start of the pair table NOTE: Will NOT advance cursor |
int |
getLowSwitchValue()
Returns the lowest value of the tableswitch (as a signed int) Used for tableswitch |
int |
getOpcode()
Returns the opcode of the current instruction in the sequence Note: if skipInstruction has been called, but nextInstruction has not, this method will return the opcode of the skipped instruction! |
int |
getShortValue()
Returns a signed short value Used for sipush |
int |
getSwitchLength()
Returns the number of match-offset pairs in the lookupswitch (as a signed int) Used for lookupswitch |
int |
getTableSwitchOffset(int num)
Returns the numbered offset of the tableswitch (as a signed int) Used for tableswitch The "cursor" has to be positioned at the start of the offset table NOTE: Will NOT advance cursor |
int |
getWideBranchOffset()
Returns the wide offset of the branch (as a signed int) Used for goto_w, jsr_w |
int |
getWideConstantIndex()
Returns the wide constant pool index of a constant (as an unsigned short) Used for ldc_w, ldc2_w |
int |
getWideIncrement()
Returns an increment value (as a signed short) Used for iinc prefixed by wide |
int |
getWideLocalNumber()
Returns the wide number of the local (as an unsigned short) Used for iload, lload, fload, dload, aload, istore, lstore, fstore, dstore, astore, iinc prefixed by wide |
int |
getWideOpcode()
Returns the opcode of the wide instruction Used for wide Can be one of iload, lload, fload, dload, aload, istore, lstore, fstore, dstore, astore, iinc |
boolean |
hasMoreBytecodes()
Does the stream have more bytecodes in it? |
int |
index()
Returns the current bytecode index |
boolean |
isWide()
Are we currently processing a wide instruction? |
int |
length()
Returns the length of the bytecode stream Returns 0 if the method doesn't have any bytecodes (i.e. |
IMethod |
method()
Returns the method that this bytecode stream is from |
int |
nextInstruction()
Sets up the next instruction in the sequence |
int |
peekNextOpcode()
Returns the opcode of the next instruction in the sequence without advancing to it |
void |
reset()
Resets the stream to the beginning |
void |
reset(int index)
Resets the stream to a given position Use with caution |
void |
skipInstruction()
Skips the current instruction |
void |
skipInstruction(int opcode,
boolean wide)
Skips the current instruction (without using the opcode field) A slightly optimized version of skipInstruction() |
void |
skipLookupSwitchPairs(int num)
Skips the match-offset pairs of a lookupswitch instruction Used for lookupswitch |
void |
skipTableSwitchOffsets(int num)
Skips the offsets of a tableswitch instruction Used for tableswitch |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BytecodeStream(IMethod m,
byte[] bc)
m - the method containing the bytecodesbc - the array of bytecodes
java.lang.IllegalArgumentException - if bc is null
java.lang.IllegalArgumentException - if m is null| Method Detail |
|---|
public final IMethod method()
public final IClass declaringClass()
public final int length()
public final int index()
public final void reset()
reset(int)public final void reset(int index)
index - the position to reset the stream toreset()public final boolean hasMoreBytecodes()
public final int peekNextOpcode()
nextInstruction()public final int nextInstruction()
peekNextOpcode()public final int getOpcode()
nextInstruction(),
isWide()public final boolean isWide()
nextInstruction(),
getOpcode()public final void skipInstruction()
skipInstruction(int,boolean)
public final void skipInstruction(int opcode,
boolean wide)
opcode - current opcodewide - whether current instruction follows wideskipInstruction()public final int getByteValue()
public final int getShortValue()
public final int getLocalNumber()
getWideLocalNumber()public final int getWideLocalNumber()
getLocalNumber()public final int getIncrement()
getWideIncrement()public final int getWideIncrement()
getIncrement()public final int getBranchOffset()
getWideBranchOffset()public final int getWideBranchOffset()
getBranchOffset()public final void alignSwitch()
public final int getDefaultSwitchOffset()
public final int getLowSwitchValue()
getHighSwitchValue()public final int getHighSwitchValue()
getLowSwitchValue()public final void skipTableSwitchOffsets(int num)
num - the number of offsets to skipgetTableSwitchOffset(int)public final int getTableSwitchOffset(int num)
num - the number of the offset to retrieve
public final int computeTableSwitchOffset(int value,
int low,
int high)
value - the value to retrieve offset forlow - the lowest value of the tableswitchhigh - the highest value of the tableswitch
public final int getSwitchLength()
public final void skipLookupSwitchPairs(int num)
num - the number of match-offset pairs to skipgetLookupSwitchValue(int),
getLookupSwitchOffset(int)public final int getLookupSwitchOffset(int num)
num - the number of the offset to retrieve
getLookupSwitchValue(int)public final int getLookupSwitchValue(int num)
num - the number of the value to retrieve
getLookupSwitchOffset(int)
public final int computeLookupSwitchOffset(int value,
int num)
value - the value to retrieve offset fornum - the number of match-offset pairs in the lookupswitch
public final void alignInvokeInterface()
public final int getArrayElementType()
public final int getArrayDimension()
public final int getWideOpcode()
public final int getConstantIndex()
getWideConstantIndex(),
getConstantType(int),
getIntConstant(int)public final int getWideConstantIndex()
getConstantIndex(),
getConstantType(int),
getIntConstant(int)
public final byte getConstantType(int index)
throws UnimplementedError
UnimplementedError - unconditionallygetConstantIndex(),
getWideConstantIndex(),
getIntConstant(int)
public final int getIntConstant(int index)
throws UnimplementedError
UnimplementedError - unconditionallygetConstantIndex(),
getWideConstantIndex(),
getConstantType(int)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||