|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.janino.ClassFile.AttributeInfo | +--net.janino.ClassFile.CodeAttribute
A representation of a "Code" attribute. Supplies several "write()"
methods, similar to an OutputStream
, plus ClassFile.CodeAttribute.Offset
s and
ClassFile.CodeAttribute.Inserter
s, which allow for very flexible generation of bytecode.
Inner Class Summary | |
class |
ClassFile.CodeAttribute.Inserter
A class that implements an insertion point into a "Code" attribute. |
class |
ClassFile.CodeAttribute.Offset
A class that represents an offset within a "Code" attribute. |
Constructor Summary | |
ClassFile.CodeAttribute()
Create an empty "Code" attribute. |
Method Summary | |
(package private) void |
|
void |
addException(ClassFile.CodeAttribute.Offset startPC,
ClassFile.CodeAttribute.Offset endPC,
ClassFile.CodeAttribute.Offset handlerPC,
java.lang.String catchTypeFD)
|
short |
allocateLocalVariable(short size)
Allocate space for a local variable of the given size (1 or 2) on the local variable array. |
void |
fixUp()
|
void |
flowAnalysis()
Checks the code for consistency; updates the "maxStack" member. |
ClassFile |
getClassFile()
|
ClassFile.CodeAttribute.Inserter |
newInserter()
Allocate an ClassFile.CodeAttribute.Inserter , set it to the current offset, and
insert it before the current offset.
|
ClassFile.CodeAttribute.Offset |
newOffset()
|
void |
popInserter()
Replace the current ClassFile.CodeAttribute.Inserter with the remembered one (see
pushInserter(ClassFile.CodeAttribute.Inserter) ). |
void |
pushInserter(ClassFile.CodeAttribute.Inserter ins)
Remember the current ClassFile.CodeAttribute.Inserter , then replace it with the
new one. |
void |
relocate()
|
void |
restoreLocalVariables()
Restore the previous size of the local variables array. |
void |
saveLocalVariables()
Remember the current size of the local variables array. |
void |
store(java.io.DataOutputStream dos)
|
protected void |
storeBody(java.io.DataOutputStream dos)
|
void |
write(byte[] b)
|
void |
write(int b)
|
void |
writeBranch(int opcode,
ClassFile.CodeAttribute.Offset dst)
|
void |
writeByte(int v)
|
void |
writeChar(int v)
|
void |
writeDouble(double v)
|
void |
writeFloat(float v)
|
void |
writeInt(int v)
|
void |
writeLong(long v)
|
void |
writeOffset(ClassFile.CodeAttribute.Offset src,
ClassFile.CodeAttribute.Offset dst)
|
void |
writeOpcode(int opcode)
|
void |
writeShort(int v)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ClassFile.CodeAttribute()
Method Detail |
public short allocateLocalVariable(short size)
saveLocalVariables()
and later restoreLocalVariables()
.public void saveLocalVariables()
public void restoreLocalVariables()
protected void storeBody(java.io.DataOutputStream dos) throws java.io.IOException
storeBody
in class net.janino.ClassFile.AttributeInfo
public void flowAnalysis()
public void fixUp()
public void relocate()
public void write(byte[] b)
public void write(int b)
public void writeByte(int v)
public void writeChar(int v)
public void writeDouble(double v)
public void writeFloat(float v)
public void writeInt(int v)
public void writeLong(long v)
public void writeShort(int v)
public void writeOpcode(int opcode)
public void writeBranch(int opcode, ClassFile.CodeAttribute.Offset dst)
public void writeOffset(ClassFile.CodeAttribute.Offset src, ClassFile.CodeAttribute.Offset dst)
public ClassFile.CodeAttribute.Offset newOffset()
public ClassFile.CodeAttribute.Inserter newInserter()
ClassFile.CodeAttribute.Inserter
, set it to the current offset, and
insert it before the current offset.
In clear text, this means that you can continue writing to the
"Code" attribute, then pushInserter(ClassFile.CodeAttribute.Inserter)
the
ClassFile.CodeAttribute.Inserter
, then write again (which inserts bytes into the
"Code" attribute at the previously remembered position), and then
popInserter()
.public void pushInserter(ClassFile.CodeAttribute.Inserter ins)
ClassFile.CodeAttribute.Inserter
, then replace it with the
new one.public void popInserter()
ClassFile.CodeAttribute.Inserter
with the remembered one (see
pushInserter(ClassFile.CodeAttribute.Inserter)
).public void addException(ClassFile.CodeAttribute.Offset startPC, ClassFile.CodeAttribute.Offset endPC, ClassFile.CodeAttribute.Offset handlerPC, java.lang.String catchTypeFD)
void()
in class java.lang.Object
public ClassFile getClassFile()
public void store(java.io.DataOutputStream dos) throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |