mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qwaq] Calculate type sizes for compound types
This commit is contained in:
parent
7275d9bbf5
commit
22b9bb29f6
2 changed files with 45 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
@interface TypeEncodings : Object
|
||||
+(qfot_type_t *)getType:(unsigned)typeAddr fromTarget:(qdb_target_t)target;
|
||||
+(int)typeSize:(qfot_type_t *)type;
|
||||
@end
|
||||
|
||||
#endif//__qwaq_debugger_typeencodings_h
|
||||
|
|
|
@ -191,4 +191,48 @@ error:
|
|||
return nil;
|
||||
}
|
||||
|
||||
+(int)typeSize:(qfot_type_t *)type
|
||||
{
|
||||
qfot_type_t *aux_type;
|
||||
int size = 0;
|
||||
|
||||
switch (type.meta) {
|
||||
case ty_basic:
|
||||
size = pr_type_size[type.type];
|
||||
break;
|
||||
case ty_array:
|
||||
aux_type = type.array.type;
|
||||
size = type.array.size * [TypeEncodings typeSize:aux_type];
|
||||
break;
|
||||
case ty_struct:
|
||||
for (int i = 0; i < type.strct.num_fields; i++) {
|
||||
aux_type = type.strct.fields[i].type;
|
||||
size += [TypeEncodings typeSize:aux_type];
|
||||
}
|
||||
break;
|
||||
case ty_union:
|
||||
for (int i = 0; i < type.strct.num_fields; i++) {
|
||||
aux_type = type.strct.fields[i].type;
|
||||
int s = [TypeEncodings typeSize:aux_type];
|
||||
if (s > size) {
|
||||
size = s;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ty_enum:
|
||||
// enums are ints
|
||||
size = pr_type_size[ev_integer];
|
||||
break;
|
||||
case ty_class:
|
||||
//FIXME
|
||||
size = 1;
|
||||
break;
|
||||
case ty_alias:
|
||||
aux_type = type.alias.aux_type;
|
||||
size = [TypeEncodings typeSize:aux_type];
|
||||
break;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue