| java.lang.Object org.codehaus.janino.CodeContext
CodeContext | public class CodeContext (Code) | | The context of the compilation of a function (constructor or method). Manages generation of
byte code, the exception table, generation of line number tables, allocation of local variables,
determining of stack size and local variable table size and flow analysis.
|
Inner Class :public class Offset | |
Inner Class :public class Inserter extends Offset | |
Inner Class :public class LineNumberOffset extends Offset | |
Inner Class :public interface FixUp | |
Method Summary | |
public void | addExceptionTableEntry(Offset startPC, Offset endPC, Offset handlerPC, String catchTypeFD) Add another entry to the "exception_table" of this code attribute (see JVMS 4.7.3). | public short | allocateLocalVariable(short size) Allocate space for a local variable of the given size (1 or 2)
on the local variable array. | public void | fixUp() Fix up all offsets. | public void | flowAnalysis(String functionName) Checks the code for consistency; updates the "maxStack" member. | public ClassFile | getClassFile() | public Inserter | newInserter() Allocate an
Inserter , set it to the current offset, and
insert it before the current offset. | public Offset | newOffset() | public void | popInserter() Replace the current
Inserter with the remembered one (see
CodeContext.pushInserter(CodeContext.Inserter) ). | public void | pushInserter(Inserter ins) Remember the current
Inserter , then replace it with the
new one. | public void | relocate() | public void | restoreLocalVariables() Restore the previous size of the local variables array. | public void | saveLocalVariables() Remember the current size of the local variables array. | protected void | storeCodeAttributeBody(DataOutputStream dos, short lineNumberTableAttributeNameIndex) | public void | write(short lineNumber, byte[] b) Inserts a sequence of bytes at the current insertion position. | public void | writeBranch(short lineNumber, int opcode, Offset dst) | public void | writeOffset(short lineNumber, Offset src, Offset dst) | public void | writeShort(short lineNumber, int v) |
CodeContext | public CodeContext(ClassFile classFile)(Code) | | Create an empty "Code" attribute.
|
addExceptionTableEntry | public void addExceptionTableEntry(Offset startPC, Offset endPC, Offset handlerPC, String catchTypeFD)(Code) | | Add another entry to the "exception_table" of this code attribute (see JVMS 4.7.3).
Parameters: startPC - Parameters: endPC - Parameters: handlerPC - Parameters: catchTypeFD - |
allocateLocalVariable | public short allocateLocalVariable(short size)(Code) | | Allocate space for a local variable of the given size (1 or 2)
on the local variable array.
As a side effect, the "max_locals" field of the "Code" attribute
is updated.
The only way to deallocate local variables is to
CodeContext.saveLocalVariables() and later
CodeContext.restoreLocalVariables() .
|
fixUp | public void fixUp()(Code) | | Fix up all offsets.
|
flowAnalysis | public void flowAnalysis(String functionName)(Code) | | Checks the code for consistency; updates the "maxStack" member.
Notice: On inconsistencies, a "RuntimeException" is thrown (KLUDGE).
|
newInserter | public Inserter newInserter()(Code) | | Allocate an
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
CodeContext.pushInserter(CodeContext.Inserter) the
Inserter , then write again (which inserts bytes into the
"Code" attribute at the previously remembered position), and then
CodeContext.popInserter() .
|
newOffset | public Offset newOffset()(Code) | | |
pushInserter | public void pushInserter(Inserter ins)(Code) | | Remember the current
Inserter , then replace it with the
new one.
|
relocate | public void relocate()(Code) | | |
restoreLocalVariables | public void restoreLocalVariables()(Code) | | Restore the previous size of the local variables array.
|
saveLocalVariables | public void saveLocalVariables()(Code) | | Remember the current size of the local variables array.
|
storeCodeAttributeBody | protected void storeCodeAttributeBody(DataOutputStream dos, short lineNumberTableAttributeNameIndex) throws IOException(Code) | | Parameters: dos - Parameters: lineNumberTableAttributeNameIndex - 0 == don't generate a "LineNumberTable" attribute throws: IOException - |
write | public void write(short lineNumber, byte[] b)(Code) | | Inserts a sequence of bytes at the current insertion position. Creates
LineNumberOffset s as necessary.
Parameters: lineNumber - The line number that corresponds to the byte code, or -1 Parameters: b - |
writeBranch | public void writeBranch(short lineNumber, int opcode, Offset dst)(Code) | | |
writeOffset | public void writeOffset(short lineNumber, Offset src, Offset dst)(Code) | | |
writeShort | public void writeShort(short lineNumber, int v)(Code) | | |
|
|