JVM
constantpool.c File Reference
#include "debugging.h"
#include <string.h>
#include <inttypes.h>
#include "readfunctions.h"
#include "constantpool.h"
#include "utf8.h"
Include dependency graph for constantpool.c:

Functions

char readConstantPool_Class (JavaClass *jc, cp_info *entry)
 Reads a cp_info of type CONSTANT_Class from the file. More...
 
char readConstantPool_Fieldref (JavaClass *jc, cp_info *entry)
 Reads a cp_info of type CONSTANT_Fieldref from the file. More...
 
char readConstantPool_Integer (JavaClass *jc, cp_info *entry)
 Reads a cp_info of type CONSTANT_Integer from the file. More...
 
char readConstantPool_Long (JavaClass *jc, cp_info *entry)
 Reads a cp_info of type CONSTANT_Long from the file. More...
 
char readConstantPool_Utf8 (JavaClass *jc, cp_info *entry)
 Reads a cp_info of type CONSTANT_Utf8 from the file. More...
 
char readConstantPoolEntry (JavaClass *jc, cp_info *entry)
 Reads a cp_info from the file. More...
 
const char * decodeTag (uint8_t tag)
 Decodes ConstantPoolTag enumeration elements. More...
 
void printConstantPoolEntry (JavaClass *jc, cp_info *entry)
 Print one single constant from the constant pool. More...
 
void printConstantPool (JavaClass *jc)
 Function to print all the constants from the constant pool of the class file. More...
 

Function Documentation

§ decodeTag()

const char* decodeTag ( uint8_t  tag)

Decodes ConstantPoolTag enumeration elements.

Parameters
uint8_ttag - identifier of the enumeration to be translated.
Returns
const char* - pointer to char containing the decoded tag
Here is the caller graph for this function:

§ printConstantPool()

void printConstantPool ( JavaClass jc)

Function to print all the constants from the constant pool of the class file.

Parameters
JavaClass*jc - pointer to JavaClass structure that must already be loaded
Here is the call graph for this function:
Here is the caller graph for this function:

§ printConstantPoolEntry()

void printConstantPoolEntry ( JavaClass jc,
cp_info entry 
)

Print one single constant from the constant pool.

Parameters
JavaClass*jc - pointer to JavaClass structure that must already be loaded, no checks are made.
*entry- the pointer to the constant that will be printed.
Here is the call graph for this function:
Here is the caller graph for this function:

§ readConstantPool_Class()

char readConstantPool_Class ( JavaClass jc,
cp_info entry 
)

Reads a cp_info of type CONSTANT_Class from the file.

Reads a cp_info of type CONSTANT_Class from the file Data read is written to pointer *entry. CONSTANT_Class has the same structure as CONSTANT_String, so this function could be used to read that too.

Parameters
JavaClass*jc - pointer to the structure to be read.
cp_info*entry - where the data read is written
Returns
char - retuns 0 if something unexpected happened or failure, 1 in case of success
Here is the call graph for this function:
Here is the caller graph for this function:

§ readConstantPool_Fieldref()

char readConstantPool_Fieldref ( JavaClass jc,
cp_info entry 
)

Reads a cp_info of type CONSTANT_Fieldref from the file.

CONSTANT_Fieldref has the same internal structure as CONSTANT_Methodref CONSTANT_InterfaceMethodref and CONSTANT_NameAndType, so this function can be also used to read those.

Parameters
JavaClass*jc - pointer to the structure to be read.
cp_info*entry - where the data read is written
Returns
char - retuns 0 if something unexpected happened or failure, 1 in case of success
Here is the call graph for this function:
Here is the caller graph for this function:

§ readConstantPool_Integer()

char readConstantPool_Integer ( JavaClass jc,
cp_info entry 
)

Reads a cp_info of type CONSTANT_Integer from the file.

CONSTANT_Integer has the same structure as CONSTANT_Float, so this function could be used to read that too.

Parameters
JavaClass*jc - pointer to the structure to be read.
cp_info*entry - where the data read is written
Returns
char - retuns 0 if something unexpected happened 1 in case of success
Here is the call graph for this function:
Here is the caller graph for this function:

§ readConstantPool_Long()

char readConstantPool_Long ( JavaClass jc,
cp_info entry 
)

Reads a cp_info of type CONSTANT_Long from the file.

CONSTANT_Long has the same structure as CONSTANT_Double, so this function could be used to read that too.

Parameters
JavaClass*jc - pointer to the structure to be read.
cp_info*entry - where the data read is written
Returns
char - retuns 0 if something unexpected happened or failure, 1 in case of success
Here is the call graph for this function:
Here is the caller graph for this function:

§ readConstantPool_Utf8()

char readConstantPool_Utf8 ( JavaClass jc,
cp_info entry 
)

Reads a cp_info of type CONSTANT_Utf8 from the file.

Parameters
JavaClass*jc - pointer to the structure to be read.
cp_info*entry - where the data read is written
Returns
char - retuns 0 if something unexpected happened or failure, 1 in case of success
Here is the call graph for this function:
Here is the caller graph for this function:

§ readConstantPoolEntry()

char readConstantPoolEntry ( JavaClass jc,
cp_info entry 
)

Reads a cp_info from the file.

This function identifies the structure indicated by the tag byte and selects the corresponding reading type

Parameters
JavaClass*jc - pointer to the structure to be read.
cp_info*entry - where the data read is written
Returns
char - retuns 0 if something unexpected happened or failure, 1 in case of success
Here is the call graph for this function:
Here is the caller graph for this function: