diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-09-03 14:00:20 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2004-09-03 14:00:20 +0000 |
commit | 0e6ebb79d3872415b7cb3d41f9aa8f83aba623ba (patch) | |
tree | b51eb0c0a03c3f4c93035b066e3f226d51f3ea07 /src/main/javassist/bytecode/Bytecode.java | |
parent | 9b3b5570519634919030492e4dd9562cdd64d9a4 (diff) | |
download | javassist-0e6ebb79d3872415b7cb3d41f9aa8f83aba623ba.tar.gz javassist-0e6ebb79d3872415b7cb3d41f9aa8f83aba623ba.zip |
Now the compiler supports a switch statement.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@131 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/bytecode/Bytecode.java')
-rw-r--r-- | src/main/javassist/bytecode/Bytecode.java | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/main/javassist/bytecode/Bytecode.java b/src/main/javassist/bytecode/Bytecode.java index b606359e..d634ad26 100644 --- a/src/main/javassist/bytecode/Bytecode.java +++ b/src/main/javassist/bytecode/Bytecode.java @@ -299,6 +299,16 @@ public class Bytecode implements Opcode { } /** + * Reads a signed 32bit value at the offset from the beginning of the + * bytecode sequence. + */ + public int read32bit(int offset) { + int v1 = read16bit(offset); + int v2 = read16bit(offset + 2); + return (v1 << 16) + (v2 & 0xffff); + } + + /** * Writes an 8bit value at the offset from the beginning of the * bytecode sequence. * @@ -321,11 +331,20 @@ public class Bytecode implements Opcode { * bytecode sequence. */ public void write16bit(int offset, int value) { - write(offset, value >>> 8); + write(offset, value >> 8); write(offset + 1, value); } /** + * Writes an 32bit value at the offset from the beginning of the + * bytecode sequence. + */ + public void write32bit(int offset, int value) { + write16bit(offset, value >> 16); + write16bit(offset + 2, value); + } + + /** * Appends an 8bit value to the end of the bytecode sequence. */ public void add(int code) { @@ -340,6 +359,38 @@ public class Bytecode implements Opcode { } /** + * Appends a 32bit value to the end of the bytecode sequence. + */ + public void add32bit(int value) { + add(value >> 24); + add(value >> 16); + add(value >> 8); + add(value); + } + + /** + * Appends the length-byte gap to the end of the bytecode sequence. + * + * @param length the gap length in byte. + */ + public void addGap(int length) { + if (num < bufsize) { + num += length; + if (num <= bufsize) + return; + else { + length = num - bufsize; + num = bufsize; + } + } + + if (next == null) + next = new Bytecode(); + + next.addGap(length); + } + + /** * Appends an 8bit opcode to the end of the bytecode sequence. * The current stack depth is updated. * <code>max_stack</code> is updated if the current stack depth |