Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

ClassEncoder::method_info Class Reference

This class holds information about a method. More...

#include <method_info.hpp>

Inheritance diagram for ClassEncoder::method_info:

Inheritance graph
[legend]
Collaboration diagram for ClassEncoder::method_info:

Collaboration graph
[legend]
List of all members.

The function name.

Default constructor.

Parameters:
constantPool Pointer to the constant pool for the class this method belongs to.


 method_info (ConstantPool *constantPool, const std::string &name)
virtual ~method_info ()
 Default destructor.

void write (std::ofstream &stream)
 Write the method to the class stream.

void setAccess (u2 flags)
 Sets the availability of this function.

void addParameter (const std::string &objectType, bool addLocal=false)
 Add class type parameter.

void setReturnType (const std::string &type)
 Set the return type of this function.

unsigned int addLocal ()
 Add a local variable.

ByteCodecode ()
 Get the pointer to the ByteCode object for this method.

void finish ()
 This function finishes writing for this class.

std::string buildMethodDescriptor ()
 Build method descriptor.


Private Attributes

ConstantPoolConstantPoolEntries
code_attributeCodeAttribute
u2 access_flags
u2 name_index
u2 descriptor_index
std::string FunctionName
std::vector< std::string > Parameters
std::string ReturnType

Detailed Description

This class holds information about a method.

The details of the method_info structure is defined by SUN: http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#1513 For each method that you specify you must set the access parameters, the parametres themselves and the return type. After you are done with this the function finish() must be called.

Definition at line 30 of file method_info.hpp.


Constructor & Destructor Documentation

ClassEncoder::method_info::~method_info  )  [virtual]
 

Default destructor.

Destroys the object

Definition at line 43 of file method_info.cpp.


Member Function Documentation

unsigned int ClassEncoder::method_info::addLocal  ) 
 

Add a local variable.

This function is a convinience function forwarding the call to the code attribute.

Returns:
The variable index.
See also:
code_attribute::addLocal
Todo:
add throw when over max locals (u2)

Definition at line 119 of file method_info.cpp.

References ClassEncoder::code_attribute::addLocal().

void ClassEncoder::method_info::addParameter const std::string &  objectType,
bool  addLocal = false
 

Add class type parameter.

Parameters:
objectType Full java typename of parameter.
addLocal Should the variable automatically be declared a local variable.

Definition at line 95 of file method_info.cpp.

References ClassEncoder::code_attribute::addLocal().

string ClassEncoder::method_info::buildMethodDescriptor  )  [private]
 

Build method descriptor.

Builds the methoddescriptor for this class based on the parameters and return types. Rules: ( ParameterDescriptor* ) ReturnDescriptor ParameterDescriptor = CZFDBSIJ for basic types, Lobject; for objects [ in front for arrays ReturnDescriptor = same as above, V for void

Returns:
The complete method-descriptor for these class.

Definition at line 133 of file method_info.cpp.

Referenced by finish().

ByteCode * ClassEncoder::method_info::code  ) 
 

Get the pointer to the ByteCode object for this method.

Returns:
The pointer to the ByteCode object for this class.

Definition at line 150 of file method_info.cpp.

References ClassEncoder::code_attribute::code().

void ClassEncoder::method_info::finish  ) 
 

This function finishes writing for this class.

Any function calls after you have called finished will not have any impact. This function makes sure all it's properties are written into the constant_pool it is important that this is done before writing.

Todo:
: make class do this? Add Valid boolean.

Definition at line 163 of file method_info.cpp.

References ClassEncoder::ConstantPool::add(), and buildMethodDescriptor().

void ClassEncoder::method_info::setAccess u2  flags  ) 
 

Sets the availability of this function.

Available flags are:

  • ACC_PUBLIC
  • ACC_PRIVATE
  • ACC_PROTECTED
  • ACC_STATIC
  • ACC_FINAL
  • ACC_SYNCHRONIZED
  • ACC_SUPER
  • ACC_NATIVE
  • ACC_INTERFACE
  • ACC_ABSTRACT
  • ACC_STRICT The availability mode (or a combination of these or'ed together)

Definition at line 84 of file method_info.cpp.

void ClassEncoder::method_info::setReturnType const std::string &  type  ) 
 

Set the return type of this function.

All functions return void until implemented

Parameters:
Full java typename of return type

Definition at line 107 of file method_info.cpp.

void ClassEncoder::method_info::write std::ofstream &  stream  ) 
 

Write the method to the class stream.

Parameters:
stream The class stream to write to.

Definition at line 53 of file method_info.cpp.

References ClassEncoder::code_attribute::write(), and ClassEncoder::ClassWriterBase::writeu2().


The documentation for this class was generated from the following files:
Generated on Mon Dec 1 14:26:31 2003 for Ck by doxygen 1.3.3