Methods Summary |
---|
public void | dump(java.io.DataOutputStream out)Dump instruction as byte code to stream out.
if(wide()) // Need WIDE prefix ?
out.writeByte(Constants.WIDE);
out.writeByte(opcode);
if(length > 1) { // Otherwise ILOAD_n, instruction, e.g.
if(wide())
out.writeShort(n);
else
out.writeByte(n);
}
|
public short | getCanonicalTag()
return canon_tag;
|
public final int | getIndex() return n;
|
public com.sun.org.apache.bcel.internal.generic.Type | getType(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cp)Returns the type associated with the instruction -
in case of ALOAD or ASTORE Type.OBJECT is returned.
This is just a bit incorrect, because ALOAD and ASTORE
may work on every ReferenceType (including Type.NULL) and
ASTORE may even work on a ReturnaddressType .
switch(canon_tag) {
case Constants.ILOAD: case Constants.ISTORE:
return Type.INT;
case Constants.LLOAD: case Constants.LSTORE:
return Type.LONG;
case Constants.DLOAD: case Constants.DSTORE:
return Type.DOUBLE;
case Constants.FLOAD: case Constants.FSTORE:
return Type.FLOAT;
case Constants.ALOAD: case Constants.ASTORE:
return Type.OBJECT;
default: throw new ClassGenException("Oops: unknown case in switch" + canon_tag);
}
|
protected void | initFromFile(com.sun.org.apache.bcel.internal.util.ByteSequence bytes, boolean wide)Read needed data (e.g. index) from file.
PRE: (ILOAD <= tag <= ALOAD_3) || (ISTORE <= tag <= ASTORE_3)
if(wide) {
n = bytes.readUnsignedShort();
length = 4;
} else if(((opcode >= Constants.ILOAD) &&
(opcode <= Constants.ALOAD)) ||
((opcode >= Constants.ISTORE) &&
(opcode <= Constants.ASTORE))) {
n = bytes.readUnsignedByte();
length = 2;
} else if(opcode <= Constants.ALOAD_3) { // compact load instruction such as ILOAD_2
n = (opcode - Constants.ILOAD_0) % 4;
length = 1;
} else { // Assert ISTORE_0 <= tag <= ASTORE_3
n = (opcode - Constants.ISTORE_0) % 4;
length = 1;
}
|
public void | setIndex(int n)Set the local variable index
if((n < 0) || (n > Constants.MAX_SHORT))
throw new ClassGenException("Illegal value: " + n);
this.n = n;
if(n >= 0 && n <= 3) { // Use more compact instruction xLOAD_n
opcode = (short)(c_tag + n);
length = 1;
} else {
opcode = canon_tag;
if(wide()) // Need WIDE prefix ?
length = 4;
else
length = 2;
}
|
public java.lang.String | toString(boolean verbose)Long output format:
<name of opcode> "["<opcode number>"]"
"("<length of instruction>")" "<"< local variable index>">"
if(((opcode >= Constants.ILOAD_0) &&
(opcode <= Constants.ALOAD_3)) ||
((opcode >= Constants.ISTORE_0) &&
(opcode <= Constants.ASTORE_3)))
return super.toString(verbose);
else
return super.toString(verbose) + " " + n;
|
private final boolean | wide() // canonical tag such as ILOAD
return n > Constants.MAX_BYTE;
|