btparser/cparser/tests/CLASSTemplate2.bt

122 lines
2.5 KiB
Plaintext

BigEndian();
typedef struct {
enum <ubyte> {
CONSTANT_Class = 7,
CONSTANT_Fieldref = 9,
CONSTANT_Methodref = 10,
CONSTANT_InterfaceMethodref = 11,
CONSTANT_String = 8,
CONSTANT_Integer = 3,
CONSTANT_Float = 4,
CONSTANT_Long = 5,
CONSTANT_Double = 6,
CONSTANT_NameAndType = 12,
CONSTANT_Utf8 = 1
} tag;
switch (tag) {
case 7:
uint16 name_index;
break;
case 9:
uint16 class_index;
uint16 name_and_type_index;
break;
case 10:
uint16 class_index;
uint16 name_and_type_index;
break;
case 11:
uint16 class_index;
uint16 name_and_type_index;
break;
case 8:
uint16 string_index;
break;
case 3:
int32 int_value;
break;
case 4:
float float_value;
break;
case 5:
int64 long_value;
break;
case 6:
double double_value;
break;
case 12:
uint16 name_index;
uint16 descriptor_index;
break;
case 1:
uint16 length;
char utf8_value[length];
break;
}
} cp_info;
typedef struct {
uint16 attribute_name_index;
uint32 attribute_length;
char info[attribute_length];
} attribute_info;
typedef struct {
uint16 access_flags <format = binary>;
uint16 name_index;
uint16 descriptor_index;
uint16 attributes_count;
local int i_att2 = 0;
for ( i_att2 = 0; i_att2 < attributes_count; i_att2++) {
attribute_info attributes;
};
} field_info, method_info;
typedef struct {
uint32 magic <format = hex>;
if (magic != 0xCAFEBABE) {
Warning ("Invalid Class File.");
return -1;
}
uint16 minor_version;
uint16 major_version;
uint16 constant_pool_count;
local int i_cp = 0;
for ( i_cp = 1; i_cp < constant_pool_count; i_cp++) {
cp_info constant_pool;
if ( constant_pool.tag == 5 || constant_pool.tag == 6 ){
i_cp++;
}
};
uint16 access_flags <format = binary>;
uint16 this_class;
uint16 super_class;
uint16 interfaces_count;
local int i_if = 0;
for ( i_if = 0; i_if < interfaces_count; i_if++) {
uint16 interfaces;
};
uint16 fields_count;
local int i_fld = 0;
for ( i_fld = 0; i_fld < fields_count; i_fld++) {
field_info fields;
};
uint16 methods_count;
local int i_m = 0;
for ( i_m = 0; i_m < methods_count; i_m++) {
method_info methods;
};
uint16 attributes_count;
local int i_att = 0;
for ( i_att = 0; i_att < attributes_count; i_att++) {
attribute_info attributes;
};
} class_file;
class_file file;
if (!FEof()) {
Warning("File is not properly ended.");
};