Methods Summary |
---|
public boolean | containsTarget(com.sun.org.apache.bcel.internal.generic.InstructionHandle ih)
return (target == ih);
|
void | dispose()Inform target that it's not targeted anymore.
setTarget(null);
index=-1;
position=-1;
|
public void | dump(java.io.DataOutputStream out)Dump instruction as byte code to stream out.
out.writeByte(opcode);
index = getTargetOffset();
if(Math.abs(index) >= 32767) // too large for short
throw new ClassGenException("Branch target offset too large for short");
out.writeShort(index); // May be negative, i.e., point backwards
|
public final int | getIndex() return index;
|
public com.sun.org.apache.bcel.internal.generic.InstructionHandle | getTarget() return target;
|
protected int | getTargetOffset(com.sun.org.apache.bcel.internal.generic.InstructionHandle target)
if(target == null)
throw new ClassGenException("Target of " + super.toString(true) +
" is invalid null handle");
int t = target.getPosition();
if(t < 0)
throw new ClassGenException("Invalid branch target position offset for " +
super.toString(true) + ":" + t + ":" + target);
return t - position;
|
protected int | getTargetOffset() return getTargetOffset(target);
|
protected void | initFromFile(com.sun.org.apache.bcel.internal.util.ByteSequence bytes, boolean wide)Read needed data (e.g. index) from file. Conversion to a InstructionHandle
is done in InstructionList(byte[]).
length = 3;
index = bytes.readShort();
|
static final void | notifyTarget(com.sun.org.apache.bcel.internal.generic.InstructionHandle old_ih, com.sun.org.apache.bcel.internal.generic.InstructionHandle new_ih, com.sun.org.apache.bcel.internal.generic.InstructionTargeter t)Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
if(old_ih != null)
old_ih.removeTargeter(t);
if(new_ih != null)
new_ih.addTargeter(t);
|
public void | setTarget(com.sun.org.apache.bcel.internal.generic.InstructionHandle target)Set branch target
notifyTarget(this.target, target, this);
this.target = target;
|
public java.lang.String | toString(boolean verbose)Long output format:
<position in byte code>
<name of opcode> "["<opcode number>"]"
"("<length of instruction>")"
"<"<target instruction>">" "@"<branch target offset>
String s = super.toString(verbose);
String t = "null";
if(verbose) {
if(target != null) {
if(target.getInstruction() == this)
t = "<points to itself>";
else if(target.getInstruction() == null)
t = "<null instruction!!!?>";
else
t = target.getInstruction().toString(false); // Avoid circles
}
} else {
if(target != null) {
index = getTargetOffset();
t = "" + (index + position);
}
}
return s + " -> " + t;
|
protected int | updatePosition(int offset, int max_offset)Called by InstructionList.setPositions when setting the position for every
instruction. In the presence of variable length instructions `setPositions'
performs multiple passes over the instruction list to calculate the
correct (byte) positions and offsets by calling this function.
position += offset;
return 0;
|
public void | updateTarget(com.sun.org.apache.bcel.internal.generic.InstructionHandle old_ih, com.sun.org.apache.bcel.internal.generic.InstructionHandle new_ih)
if(target == old_ih)
setTarget(new_ih);
else
throw new ClassGenException("Not targeting " + old_ih + ", but " + target);
|