home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
kaffe-0.5p4-src.tgz
/
tar.out
/
contrib
/
kaffe
/
kaffevm
/
readClassConfig.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-09-28
|
3KB
|
107 lines
/*
* readClassConfig.h
* Configure the class reader.
*
* Copyright (c) 1996 Systems Architecture Research Centre,
* City University, London, UK.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
*/
#ifndef __readclassconfig_h
#define __readclassconfig_h
#include "classMethod.h"
#include "errors.h"
#include "lookup.h"
#include "exception.h"
#include "code.h"
#include "slots.h"
/*
* Add a class to the system.
*/
#define ADDCLASS(this, super, access, constants) \
classThis = addClass(this, super, access, constants); \
if (classThis == 0) { \
throwException(ClassFormatError); \
}
/*
* Add the interfaces.
*/
#define READINTERFACES(fp, this, count) \
do { \
createInfo cinfo; \
classes** interfaces; \
u2 iface; \
int i; \
if (count == 0) { \
return; \
} \
interfaces = (classes**)calloc(sizeof(classes**), count);\
if (interfaces == 0) { \
throwException(OutOfMemoryError); \
} \
for (i = 0; i < count; i++) { \
readu2(&iface, fp); \
getClass(iface, this->constants, &cinfo); \
interfaces[i] = cinfo.class; \
} \
addInterfaces(this, count, interfaces); \
} while(0)
/*
* Read in a field.
*/
#define READFIELD(fp, this) \
do { \
field_info f; \
readu2(&f.access_flags, fp); \
readu2(&f.name_index, fp); \
readu2(&f.signature_index, fp); \
addField(this, &f); \
} while (0)
/*
* Read in a method.
*/
#define READMETHOD(fp, this) \
do { \
method_info m; \
readu2(&m.access_flags, fp); \
readu2(&m.name_index, fp); \
readu2(&m.signature_index, fp); \
methodThis = addMethod(this, &m); \
} while(0)
/*
* Finished reading in methods.
*/
#define READMETHOD_END() \
finishClassMethods(this)
/*
* Process the attributes.
*/
#define READATTRIBUTE(fp, this, method) \
do { \
u2 idx; \
u2 len; \
readu2(&idx, fp); \
readu4(&len, fp); \
DBG( printf("Attribute '%s'\n", this->constants->data[idx].v.tstr); )\
if (this->constants->tags[idx] == CONSTANT_Utf8 && \
strcmp(this->constants->data[idx].v.tstr, "Code") == 0) {\
addCode(method, len, fp); \
} \
else { \
seekm(fp, len); \
} \
} while(0)
#endif