mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[ruamoko] Add type info for algebra types
And get vector type views working in the debugger.
This commit is contained in:
parent
a88d17459f
commit
8a0246c910
15 changed files with 171 additions and 3 deletions
|
@ -96,6 +96,7 @@ void print_type (qfot_type_t *type)
|
||||||
print_type (type.alias.aux_type);
|
print_type (type.alias.aux_type);
|
||||||
break;
|
break;
|
||||||
case ty_handle:
|
case ty_handle:
|
||||||
|
case ty_algebra:
|
||||||
//printf (" %s\n", type.handle.tag);
|
//printf (" %s\n", type.handle.tag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ static string get_type_key (void *type, void *unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
case ty_algebra:
|
||||||
case ty_handle:
|
case ty_handle:
|
||||||
case ty_class:
|
case ty_class:
|
||||||
return [[Type alloc] initWithType: type];
|
return [[Type alloc] initWithType: type];
|
||||||
|
|
|
@ -17,6 +17,7 @@ typedef enum {
|
||||||
ty_class,
|
ty_class,
|
||||||
ty_alias,
|
ty_alias,
|
||||||
ty_handle,
|
ty_handle,
|
||||||
|
ty_algebra,
|
||||||
} ty_meta_e;
|
} ty_meta_e;
|
||||||
|
|
||||||
typedef struct qfot_alias_s {
|
typedef struct qfot_alias_s {
|
||||||
|
@ -66,6 +67,13 @@ typedef struct qfot_array_s {
|
||||||
int size;
|
int size;
|
||||||
} qfot_array_t;
|
} qfot_array_t;
|
||||||
|
|
||||||
|
typedef struct qfot_algebra_s {
|
||||||
|
etype_t type;
|
||||||
|
int width;
|
||||||
|
unsigned algebra;
|
||||||
|
unsigned element;
|
||||||
|
} qfot_algebra_t;
|
||||||
|
|
||||||
typedef struct qfot_type_s {
|
typedef struct qfot_type_s {
|
||||||
ty_meta_e meta;
|
ty_meta_e meta;
|
||||||
int size;
|
int size;
|
||||||
|
@ -91,7 +99,7 @@ typedef struct qfot_type_encodings_s {
|
||||||
int size;
|
int size;
|
||||||
} qfot_type_encodings_t;
|
} qfot_type_encodings_t;
|
||||||
|
|
||||||
@extern string ty_meta_name[7];
|
@extern string ty_meta_name[9];
|
||||||
@extern string pr_type_name[ev_type_count];
|
@extern string pr_type_name[ev_type_count];
|
||||||
@extern int pr_type_size[ev_type_count];
|
@extern int pr_type_size[ev_type_count];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <runtime.h>
|
#include <runtime.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
string ty_meta_name[7] = {
|
string ty_meta_name[9] = {
|
||||||
"basic",
|
"basic",
|
||||||
"struct",
|
"struct",
|
||||||
"union",
|
"union",
|
||||||
|
@ -9,6 +9,8 @@ string ty_meta_name[7] = {
|
||||||
"array",
|
"array",
|
||||||
"class",
|
"class",
|
||||||
"alias",
|
"alias",
|
||||||
|
"handle",
|
||||||
|
"algebra",
|
||||||
};
|
};
|
||||||
|
|
||||||
//FIXME use pr_type_names.h, but need to fix unsigned, and add missing types
|
//FIXME use pr_type_names.h, but need to fix unsigned, and add missing types
|
||||||
|
|
|
@ -30,6 +30,7 @@ r_depfiles_remade += $(ruamoko_qwaq_libui_a_dep)
|
||||||
|
|
||||||
qwaq_app_dat_src= \
|
qwaq_app_dat_src= \
|
||||||
ruamoko/qwaq/qwaq-app.r \
|
ruamoko/qwaq/qwaq-app.r \
|
||||||
|
ruamoko/qwaq/debugger/views/algebraview.r \
|
||||||
ruamoko/qwaq/debugger/views/arrayview.r \
|
ruamoko/qwaq/debugger/views/arrayview.r \
|
||||||
ruamoko/qwaq/debugger/views/basicview.r \
|
ruamoko/qwaq/debugger/views/basicview.r \
|
||||||
ruamoko/qwaq/debugger/views/defview.r \
|
ruamoko/qwaq/debugger/views/defview.r \
|
||||||
|
@ -38,6 +39,7 @@ qwaq_app_dat_src= \
|
||||||
ruamoko/qwaq/debugger/views/fieldview.r \
|
ruamoko/qwaq/debugger/views/fieldview.r \
|
||||||
ruamoko/qwaq/debugger/views/floatview.r \
|
ruamoko/qwaq/debugger/views/floatview.r \
|
||||||
ruamoko/qwaq/debugger/views/funcview.r \
|
ruamoko/qwaq/debugger/views/funcview.r \
|
||||||
|
ruamoko/qwaq/debugger/views/handleview.r\
|
||||||
ruamoko/qwaq/debugger/views/indexview.r \
|
ruamoko/qwaq/debugger/views/indexview.r \
|
||||||
ruamoko/qwaq/debugger/views/intview.r \
|
ruamoko/qwaq/debugger/views/intview.r \
|
||||||
ruamoko/qwaq/debugger/views/nameview.r \
|
ruamoko/qwaq/debugger/views/nameview.r \
|
||||||
|
@ -168,6 +170,7 @@ EXTRA_DIST += \
|
||||||
ruamoko/qwaq/debugger/debugger.h \
|
ruamoko/qwaq/debugger/debugger.h \
|
||||||
ruamoko/qwaq/debugger/localsdata.h \
|
ruamoko/qwaq/debugger/localsdata.h \
|
||||||
ruamoko/qwaq/debugger/typeencodings.h \
|
ruamoko/qwaq/debugger/typeencodings.h \
|
||||||
|
ruamoko/qwaq/debugger/views/algebraview.h \
|
||||||
ruamoko/qwaq/debugger/views/arrayview.h \
|
ruamoko/qwaq/debugger/views/arrayview.h \
|
||||||
ruamoko/qwaq/debugger/views/basicview.h \
|
ruamoko/qwaq/debugger/views/basicview.h \
|
||||||
ruamoko/qwaq/debugger/views/defview.h \
|
ruamoko/qwaq/debugger/views/defview.h \
|
||||||
|
@ -176,6 +179,7 @@ EXTRA_DIST += \
|
||||||
ruamoko/qwaq/debugger/views/fieldview.h \
|
ruamoko/qwaq/debugger/views/fieldview.h \
|
||||||
ruamoko/qwaq/debugger/views/floatview.h \
|
ruamoko/qwaq/debugger/views/floatview.h \
|
||||||
ruamoko/qwaq/debugger/views/funcview.h \
|
ruamoko/qwaq/debugger/views/funcview.h \
|
||||||
|
ruamoko/qwaq/debugger/views/handleview.h \
|
||||||
ruamoko/qwaq/debugger/views/indexview.h \
|
ruamoko/qwaq/debugger/views/indexview.h \
|
||||||
ruamoko/qwaq/debugger/views/intview.h \
|
ruamoko/qwaq/debugger/views/intview.h \
|
||||||
ruamoko/qwaq/debugger/views/nameview.h \
|
ruamoko/qwaq/debugger/views/nameview.h \
|
||||||
|
|
|
@ -56,6 +56,10 @@ static void type_free (void *t, void *unused)
|
||||||
case ty_handle:
|
case ty_handle:
|
||||||
str_free (type.handle.tag);
|
str_free (type.handle.tag);
|
||||||
break;
|
break;
|
||||||
|
case ty_algebra:
|
||||||
|
if (type.type == ev_invalid) {
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
obj_free (t);
|
obj_free (t);
|
||||||
}
|
}
|
||||||
|
@ -187,6 +191,13 @@ static void type_free (void *t, void *unused)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
goto hash_type;
|
goto hash_type;
|
||||||
|
case ty_algebra:
|
||||||
|
if (type.type == ev_invalid) {
|
||||||
|
// full algebra
|
||||||
|
} else {
|
||||||
|
goto hash_type;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
goto error;
|
goto error;
|
||||||
hash_type:
|
hash_type:
|
||||||
|
@ -206,9 +217,11 @@ error:
|
||||||
|
|
||||||
switch (type.meta) {
|
switch (type.meta) {
|
||||||
case ty_handle:
|
case ty_handle:
|
||||||
case ty_basic:
|
|
||||||
size = pr_type_size[type.type];
|
size = pr_type_size[type.type];
|
||||||
break;
|
break;
|
||||||
|
case ty_basic:
|
||||||
|
size = pr_type_size[type.type] * type.basic.width;
|
||||||
|
break;
|
||||||
case ty_array:
|
case ty_array:
|
||||||
aux_type = type.array.type;
|
aux_type = type.array.type;
|
||||||
size = type.array.size * [TypeEncodings typeSize:aux_type];
|
size = type.array.size * [TypeEncodings typeSize:aux_type];
|
||||||
|
@ -240,6 +253,13 @@ error:
|
||||||
aux_type = type.alias.aux_type;
|
aux_type = type.alias.aux_type;
|
||||||
size = [TypeEncodings typeSize:aux_type];
|
size = [TypeEncodings typeSize:aux_type];
|
||||||
break;
|
break;
|
||||||
|
case ty_algebra:
|
||||||
|
if (type.type == ev_invalid) {
|
||||||
|
// full algebra
|
||||||
|
} else {
|
||||||
|
size = pr_type_size[type.type] * type.basic.width;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
10
ruamoko/qwaq/debugger/views/algebraview.h
Normal file
10
ruamoko/qwaq/debugger/views/algebraview.h
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef __qwaq_debugger_algebraview_h
|
||||||
|
#define __qwaq_debugger_algebraview_h
|
||||||
|
|
||||||
|
#include "ruamoko/qwaq/debugger/views/basicview.h"
|
||||||
|
|
||||||
|
@interface AlgebraView : BasicView
|
||||||
|
+(DefView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type;
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif//__qwaq_debugger_algebraview_h
|
67
ruamoko/qwaq/debugger/views/algebraview.r
Normal file
67
ruamoko/qwaq/debugger/views/algebraview.r
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "ruamoko/qwaq/debugger/views/algebraview.h"
|
||||||
|
#include "ruamoko/qwaq/debugger/views/nameview.h"
|
||||||
|
|
||||||
|
static string type_views[] = {
|
||||||
|
"VoidView",
|
||||||
|
"StringView",
|
||||||
|
"FloatView",
|
||||||
|
"VectorView",
|
||||||
|
"EntityView",
|
||||||
|
"FieldView",
|
||||||
|
"FuncView",
|
||||||
|
"PointerView",
|
||||||
|
"QuatView",
|
||||||
|
"IntView",
|
||||||
|
"UIntView", // uinteger
|
||||||
|
"IntView", // short
|
||||||
|
"DoubleView",
|
||||||
|
};
|
||||||
|
|
||||||
|
@implementation AlgebraView
|
||||||
|
|
||||||
|
-init
|
||||||
|
{
|
||||||
|
if (!(self = [super init])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(DefView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||||
|
{
|
||||||
|
string typename = nil;
|
||||||
|
if (type.type == ty_alias) {
|
||||||
|
type = type.alias.aux_type;
|
||||||
|
}
|
||||||
|
if (type.type >= 0
|
||||||
|
&& type.type < sizeof(type_views) / sizeof (type_views[0])) {
|
||||||
|
typename = type_views[type.type];
|
||||||
|
}
|
||||||
|
printf ("AlgebraView: %s\n", typename);
|
||||||
|
id class = obj_lookup_class (typename);
|
||||||
|
if (class) {
|
||||||
|
return [class withDef:def in:data type:type];
|
||||||
|
}
|
||||||
|
return [NameView withName:"Invalid Type"];
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
+(DefView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||||
|
{
|
||||||
|
string typename = nil;
|
||||||
|
if (type.type == ty_alias) {
|
||||||
|
type = type.alias.aux_type;
|
||||||
|
}
|
||||||
|
if (type.type >= 0
|
||||||
|
&& type.type < sizeof(type_views) / sizeof (type_views[0])) {
|
||||||
|
typename = type_views[type.type];
|
||||||
|
}
|
||||||
|
printf ("AlgebraView: %s\n", typename);
|
||||||
|
id class = obj_lookup_class (typename);
|
||||||
|
if (class) {
|
||||||
|
return [class withDef:def in:data type:type];
|
||||||
|
}
|
||||||
|
return [NameView withName:"Invalid Type"];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@end
|
|
@ -12,6 +12,8 @@ static string meta_views[] = {
|
||||||
"ArrayView",
|
"ArrayView",
|
||||||
"ClassView",
|
"ClassView",
|
||||||
"AliasView", // shouldn't happen, but...
|
"AliasView", // shouldn't happen, but...
|
||||||
|
"HandleView",
|
||||||
|
"AlgebraView",
|
||||||
};
|
};
|
||||||
|
|
||||||
@implementation DefView
|
@implementation DefView
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
{
|
{
|
||||||
[super draw];
|
[super draw];
|
||||||
string val = sprintf ("%.17g", data[0]);
|
string val = sprintf ("%.17g", data[0]);
|
||||||
|
for (int i = 1; i < type.basic.width; i++) {
|
||||||
|
val = sprintf ("%s %.17g", val, data[i]);
|
||||||
|
}
|
||||||
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
{
|
{
|
||||||
[super draw];
|
[super draw];
|
||||||
string val = sprintf ("%.9g", data[0]);
|
string val = sprintf ("%.9g", data[0]);
|
||||||
|
for (int i = 1; i < type.basic.width; i++) {
|
||||||
|
val = sprintf ("%s %.9g", val, data[i]);
|
||||||
|
}
|
||||||
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
13
ruamoko/qwaq/debugger/views/handleview.h
Normal file
13
ruamoko/qwaq/debugger/views/handleview.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef __qwaq_debugger_handleview_h
|
||||||
|
#define __qwaq_debugger_handleview_h
|
||||||
|
|
||||||
|
#include "ruamoko/qwaq/debugger/views/defview.h"
|
||||||
|
|
||||||
|
@interface HandleView : DefView
|
||||||
|
{
|
||||||
|
int *data;
|
||||||
|
}
|
||||||
|
+(DefView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type;
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif//__qwaq_debugger_handleview_h
|
28
ruamoko/qwaq/debugger/views/handleview.r
Normal file
28
ruamoko/qwaq/debugger/views/handleview.r
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "ruamoko/qwaq/debugger/views/handleview.h"
|
||||||
|
|
||||||
|
@implementation HandleView
|
||||||
|
|
||||||
|
-initWithDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||||
|
{
|
||||||
|
if (!(self = [super initWithDef:def type:type])) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
self.data = (int *)(data + def.offset);
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(DefView *)withDef:(qdb_def_t)def in:(void *)data type:(qfot_type_t *)type
|
||||||
|
{
|
||||||
|
return [[[self alloc] initWithDef:def in:data type:type] autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
-draw
|
||||||
|
{
|
||||||
|
[super draw];
|
||||||
|
string val = sprintf ("%d", data[0]);
|
||||||
|
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -21,6 +21,9 @@
|
||||||
{
|
{
|
||||||
[super draw];
|
[super draw];
|
||||||
string val = sprintf ("%d", data[0]);
|
string val = sprintf ("%d", data[0]);
|
||||||
|
for (int i = 1; i < type.basic.width; i++) {
|
||||||
|
val = sprintf ("%s %d", val, data[i]);
|
||||||
|
}
|
||||||
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
{
|
{
|
||||||
[super draw];
|
[super draw];
|
||||||
string val = sprintf ("%u", data[0]);
|
string val = sprintf ("%u", data[0]);
|
||||||
|
for (int i = 1; i < type.basic.width; i++) {
|
||||||
|
val = sprintf ("%s %u", val, data[i]);
|
||||||
|
}
|
||||||
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
[self mvprintf:{0, 0}, "%*.*s", xlen, xlen, val];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue