mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 21:20:33 +00:00
[qfcc] Encode the new vector types
Thanks to the size of the type encoding being explicit in the encoding, anything that tries to read the encodings without expecting the width will simply skip over the width, as it is placed after the ev type in the encoding. Any code that needs to read both the old encodings and the new can check the size of the basic encodings to see if the width field is present.
This commit is contained in:
parent
4b8fdf3696
commit
e1a0c31e3f
4 changed files with 49 additions and 8 deletions
|
@ -62,6 +62,12 @@ typedef struct qfot_fldptr_s {
|
|||
pr_ptr_t aux_type; ///< referenced type
|
||||
} qfot_fldptr_t;
|
||||
|
||||
typedef struct qfot_basic_s {
|
||||
etype_t type; ///< integral and fp scalar types
|
||||
pr_int_t width; ///< components in vector (1 for vector or
|
||||
///< quaternion)
|
||||
} qfot_basic_t;
|
||||
|
||||
typedef struct qfot_func_s {
|
||||
etype_t type; ///< always ev_func
|
||||
pr_ptr_t return_type; ///< return type of the function
|
||||
|
@ -106,6 +112,7 @@ typedef struct qfot_type_s {
|
|||
pr_string_t encoding; ///< Objective-QC encoding
|
||||
union {
|
||||
etype_t type; ///< ty_basic: etype_t
|
||||
qfot_basic_t basic; ///< ty_basic: int/float/double/long etc
|
||||
qfot_fldptr_t fldptr; ///< ty_basic, ev_ptr/ev_field
|
||||
qfot_func_t func; ///< ty_basic, ev_func
|
||||
qfot_struct_t strct; ///< ty_struct/ty_union/ty_enum
|
||||
|
|
|
@ -513,6 +513,12 @@ static const char *ty_meta_names[] = {
|
|||
"ty_alias",
|
||||
};
|
||||
#define NUM_META ((int)(sizeof (ty_meta_names) / sizeof (ty_meta_names[0])))
|
||||
const int vector_types = (1 << ev_float)
|
||||
| (1 << ev_int)
|
||||
| (1 << ev_uint)
|
||||
| (1 << ev_double)
|
||||
| (1 << ev_long)
|
||||
| (1 << ev_ulong);
|
||||
|
||||
static void
|
||||
dump_qfo_types (qfo_t *qfo, int base_address)
|
||||
|
@ -563,6 +569,9 @@ dump_qfo_types (qfo_t *qfo, int base_address)
|
|||
} else if (type->type == ev_ptr
|
||||
|| type->type == ev_field) {
|
||||
printf (" %4x", type->fldptr.aux_type);
|
||||
} else if ((1 << type->type) & vector_types
|
||||
&& type->basic.width > 1) {
|
||||
printf ("[%d]", type->basic.width);
|
||||
}
|
||||
printf ("\n");
|
||||
break;
|
||||
|
|
|
@ -152,9 +152,10 @@ qfo_encode_basic (type_t *type, defspace_t *space)
|
|||
else if (type->type == ev_ptr || type->type == ev_field)
|
||||
return qfo_encode_fldptr (type, space);
|
||||
|
||||
def = qfo_new_encoding (type, sizeof (enc->type), space);
|
||||
def = qfo_new_encoding (type, sizeof (enc->basic), space);
|
||||
enc = D_POINTER (qfot_type_t, def);
|
||||
enc->type = type->type;
|
||||
enc->basic.type = type->type;
|
||||
enc->basic.width = type->width;
|
||||
return def;
|
||||
}
|
||||
|
||||
|
|
|
@ -829,10 +829,18 @@ encode_type (dstring_t *encoding, const type_t *type)
|
|||
dasprintf (encoding, "*");
|
||||
return;
|
||||
case ev_double:
|
||||
dasprintf (encoding, "d");
|
||||
if (type->width > 1) {
|
||||
dasprintf (encoding, "d%d", type->width);
|
||||
} else {
|
||||
dasprintf (encoding, "d");
|
||||
}
|
||||
return;
|
||||
case ev_float:
|
||||
dasprintf (encoding, "f");
|
||||
if (type->width > 1) {
|
||||
dasprintf (encoding, "f%d", type->width);
|
||||
} else {
|
||||
dasprintf (encoding, "f");
|
||||
}
|
||||
return;
|
||||
case ev_vector:
|
||||
dasprintf (encoding, "V");
|
||||
|
@ -870,16 +878,32 @@ encode_type (dstring_t *encoding, const type_t *type)
|
|||
dasprintf (encoding, "Q");
|
||||
return;
|
||||
case ev_int:
|
||||
dasprintf (encoding, "i");
|
||||
if (type->width > 1) {
|
||||
dasprintf (encoding, "i%d", type->width);
|
||||
} else {
|
||||
dasprintf (encoding, "i");
|
||||
}
|
||||
return;
|
||||
case ev_uint:
|
||||
dasprintf (encoding, "I");
|
||||
if (type->width > 1) {
|
||||
dasprintf (encoding, "I%d", type->width);
|
||||
} else {
|
||||
dasprintf (encoding, "I");
|
||||
}
|
||||
return;
|
||||
case ev_long:
|
||||
dasprintf (encoding, "l");
|
||||
if (type->width > 1) {
|
||||
dasprintf (encoding, "l%d", type->width);
|
||||
} else {
|
||||
dasprintf (encoding, "l");
|
||||
}
|
||||
return;
|
||||
case ev_ulong:
|
||||
dasprintf (encoding, "L");
|
||||
if (type->width > 1) {
|
||||
dasprintf (encoding, "L%d", type->width);
|
||||
} else {
|
||||
dasprintf (encoding, "L");
|
||||
}
|
||||
return;
|
||||
case ev_short:
|
||||
dasprintf (encoding, "s");
|
||||
|
|
Loading…
Reference in a new issue