#include <code_attribute.hpp>
Inheritance diagram for ClassEncoder::code_attribute:
Public Member Functions | |
code_attribute (ConstantPool *pool) | |
Standard constructor. | |
virtual | ~code_attribute () |
Default destructor. | |
virtual void | write (std::ofstream &stream) |
Write contents to class stream. | |
virtual unsigned int | size () |
Compute size. | |
ByteCode * | code () |
Get the bytecode object. | |
unsigned int | addLocal () |
Add a local variable. | |
Private Member Functions | |
code_attribute () | |
Default constructor. | |
Private Attributes | |
ConstantPool * | ConstantPoolEntries |
ByteCode * | Code |
u2 | max_locals |
This class represents a code attribute used by the method_info class as defined by the SUN documentation: http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#1546 It is responsible for holding the code for one method and information about this code such as the maximum number of locals and the maximum stack size.
Definition at line 27 of file code_attribute.hpp.
|
Standard constructor. Creates the ByteCode entry initialises the other variables and sets our name to Code via attribute_info::setNameIndex.
Definition at line 23 of file code_attribute.cpp. References ClassEncoder::attribute_info::setNameIndex(). |
|
Default destructor. Delete the ByteCode entry located in the constructor. Definition at line 36 of file code_attribute.cpp. |
|
Default constructor. Should never be used and is therefore private. Definition at line 60 of file code_attribute.hpp. |
|
Add a local variable. A single local variable can hold a value of type boolean, byte, char, short, int, float, reference, or returnAddress. A pair of local variables can hold a value of type long or double. Local variables are addressed by indexing. The index of the first local variable is zero. An integer is be considered to be an index into the local variable array if and only if that integer is between zero and one less than the size of the local variable array.
Definition at line 53 of file code_attribute.hpp. Referenced by ClassEncoder::method_info::addLocal(), and ClassEncoder::method_info::addParameter(). |
|
Get the bytecode object. This function returns a pointer to the bytecode object. This object is used to manipulate the code for this code_attribute.
Definition at line 40 of file code_attribute.hpp. Referenced by ClassEncoder::method_info::code(). |
|
Compute size. Computes the total number of bytes the elements of the code_attribute use. This corresponds to 2 + 2 + 4 + the size of the code + 2 + 2. Implements ClassEncoder::attribute_info. Definition at line 71 of file code_attribute.cpp. References ClassEncoder::ByteCode::nextInstrAddr(). |
|
Write contents to class stream. Writes the contents of this attribute to the class stream.
Reimplemented from ClassEncoder::attribute_info. Definition at line 46 of file code_attribute.cpp. References ClassEncoder::ByteCode::maxStackSize(), ClassEncoder::ByteCode::nextInstrAddr(), ClassEncoder::ByteCode::write(), ClassEncoder::ClassWriterBase::writeu2(), and ClassEncoder::ClassWriterBase::writeu4(). Referenced by ClassEncoder::method_info::write(). |