|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.claritysys.jvm.builder.ByteArray
public final class ByteArray
ByteArray is like java.util.ArrayList, except that its contents are primitive bytes. Direct access this the byte[] is provided, as well as maintenance of the "program counter".
| Field Summary | |
|---|---|
static boolean[] |
UNREACHABLES
Opcodes that cause forced change of flow control, such as ATHROW. |
| Constructor Summary | |
|---|---|
ByteArray()
Create a new byte array with the default capacity of 256. |
|
ByteArray(int capacity)
Create a new byte array with the given initialize capacity. |
|
| Method Summary | |
|---|---|
void |
adjustStack(int delta)
Adjust the stack pointer, updating maxStack if appropriate. |
byte[] |
getBytes()
Get the underlying byte[] -- this does not create a new byte[], it returns the actual byte[] being used. |
byte[] |
getCode()
Get the resulting byte[] -- this creates a NEW byte[] with only the contents! |
int |
getI2(int pc)
Get a 16-bit short from the given offset. |
int |
getMaxStack()
Return max stack size -- note that ByteArray cannot entirely compute this on its own using the opcode tables, for fields and methods the CodeBuilder must manually adjust the stack. |
int |
getPC()
Allow us to think of the size as the Program Counter. |
int |
getSize()
Return the current size. |
boolean |
isUnreachable()
Test whether the current PC is unreachable. |
void |
put1(int i)
Write an 8-bit byte to the current bytes-stream. |
void |
put2(int i)
Write a 16-bit short to the current bytes-stream |
void |
put2(int pc,
int i)
Write a 16-bit short to the given pc location. |
void |
put4(int i)
Write a 32-bit int to the current bytes-stream |
void |
putOpcode(int opcode)
Write the given opcode to the byte stream. |
void |
reserve(int increment)
EnsureCapacity, but with a smaller name :) |
void |
reset()
Reset the byte array, in preparation to re-use it. |
void |
setUnreachable(boolean isUnreachable)
Set whether the current statement is unreachable or not. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean[] UNREACHABLES
| Constructor Detail |
|---|
public ByteArray()
public ByteArray(int capacity)
| Method Detail |
|---|
public void reset()
public void reserve(int increment)
increment - ensure there is room to add at least the given number
of bytes.public void putOpcode(int opcode)
This automatically updates isUnreachable, depending on the opcode.
It also automatically adjusts maxStack for opcodes for which such is predictable (everything besides fields, methods, and multianewarray).
public void put1(int i)
i - the byte to writepublic void put2(int i)
i - the value to write
public void put2(int pc,
int i)
pc - the offset to write ati - the value to writepublic void put4(int i)
i - the value to writepublic int getI2(int pc)
public byte[] getCode()
public byte[] getBytes()
public int getSize()
public int getPC()
public void adjustStack(int delta)
public int getMaxStack()
public void setUnreachable(boolean isUnreachable)
public boolean isUnreachable()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||