mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
Rename ty_none to ty_basic
This far better reflects the actual meaning. It is very likely that ty_none is a holdover from long before there was full type encoding and it meant that the union in qfcc's type_t had no data. This is still true for basic types, but only if not a function, field or pointer type. If the type was function, field or pointer, it was not true, so it was misnamed pretty much from the start.
This commit is contained in:
parent
1b43046c8a
commit
caf78b5422
8 changed files with 35 additions and 31 deletions
|
@ -94,9 +94,9 @@ typedef struct qfot_type_s {
|
|||
pr_int_t size; ///< total word size of this encoding
|
||||
string_t encoding; ///< Objective-QC encoding
|
||||
union {
|
||||
pr_int_t type; ///< basic type: etype_t
|
||||
qfot_fldptr_t fldptr; ///< ty_none, ev_pointer/ev_field
|
||||
qfot_func_t func; ///< ty_none, ev_func
|
||||
pr_int_t type; ///< ty_basic: etype_t
|
||||
qfot_fldptr_t fldptr; ///< ty_basic, ev_pointer/ev_field
|
||||
qfot_func_t func; ///< ty_basic, ev_func
|
||||
qfot_struct_t strct; ///< ty_struct/ty_union/ty_enum
|
||||
qfot_array_t array; ///< ty_array
|
||||
pointer_t class; ///< ty_class
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef enum {
|
|||
} etype_t;
|
||||
|
||||
typedef enum {
|
||||
ty_none, ///< func/field/pointer or not used
|
||||
ty_basic, ///< VM type (float, int, pointer, field, etc)
|
||||
ty_struct,
|
||||
ty_union,
|
||||
ty_enum,
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct ty_alias_s {
|
|||
} ty_alias_t;
|
||||
|
||||
typedef enum {
|
||||
ty_none, ///< func/field/pointer or not used
|
||||
ty_basic, ///< VM type (float, int, pointer, field, etc)
|
||||
ty_struct,
|
||||
ty_union,
|
||||
ty_enum,
|
||||
|
@ -72,6 +72,7 @@ typedef struct type_s {
|
|||
/// function/pointer/array/struct types are more complex
|
||||
ty_meta_e meta;
|
||||
union {
|
||||
// no data for ty_basic when not a func, field or pointer
|
||||
ty_func_t func;
|
||||
ty_fldptr_t fldptr;
|
||||
ty_array_t array;
|
||||
|
|
|
@ -69,30 +69,31 @@ static hashtab_t *protocol_hash;
|
|||
|
||||
// these will be built up further
|
||||
type_t type_obj_selector = { ev_invalid, 0, 0, ty_struct};
|
||||
type_t type_SEL = { ev_pointer, "SEL", 1, ty_none, {{&type_obj_selector}}};
|
||||
type_t type_SEL = { ev_pointer, "SEL", 1, ty_basic,
|
||||
{{&type_obj_selector}}};
|
||||
type_t *IMP_params[] = {&type_id, &type_SEL};
|
||||
type_t type_IMP = { ev_func, "IMP", 1, ty_none,
|
||||
type_t type_IMP = { ev_func, "IMP", 1, ty_basic,
|
||||
{{&type_id, -3, IMP_params}}};
|
||||
type_t type_obj_super = { ev_invalid, 0, 0 };
|
||||
type_t type_SuperPtr = { ev_pointer, 0, 1, ty_none, {{&type_obj_super}}};
|
||||
type_t type_SuperPtr = { ev_pointer, 0, 1, ty_basic, {{&type_obj_super}}};
|
||||
type_t *supermsg_params[] = {&type_SuperPtr, &type_SEL};
|
||||
type_t type_supermsg = { ev_func, ".supermsg", 1, ty_none,
|
||||
type_t type_supermsg = { ev_func, ".supermsg", 1, ty_basic,
|
||||
{{&type_id, -3, supermsg_params}}};
|
||||
type_t type_obj_method = { ev_invalid, 0, 0, ty_struct };
|
||||
type_t type_obj_method_description = { ev_invalid, 0, 0, ty_struct };
|
||||
type_t type_obj_category = { ev_invalid, 0, 0, ty_struct};
|
||||
type_t type_obj_ivar = { ev_invalid, 0, 0, ty_struct};
|
||||
type_t type_obj_module = { ev_invalid, 0, 0, ty_struct};
|
||||
type_t type_moduleptr = { ev_pointer, 0, 1, ty_none,
|
||||
type_t type_moduleptr = { ev_pointer, 0, 1, ty_basic,
|
||||
{{&type_obj_module}}};
|
||||
type_t *obj_exec_class_params[] = { &type_moduleptr };
|
||||
type_t type_obj_exec_class = { ev_func, 0, 1, ty_none,
|
||||
type_t type_obj_exec_class = { ev_func, 0, 1, ty_basic,
|
||||
{{&type_void, 1, obj_exec_class_params}}};
|
||||
|
||||
type_t type_obj_object = {ev_invalid, 0, 0, ty_struct};
|
||||
type_t type_id = { ev_pointer, "id", 1, ty_none, {{&type_obj_object}}};
|
||||
type_t type_id = { ev_pointer, "id", 1, ty_basic, {{&type_obj_object}}};
|
||||
type_t type_obj_class = { ev_invalid, 0, 0, ty_struct};
|
||||
type_t type_Class = { ev_pointer, 0, 1, ty_none, {{&type_obj_class}}};
|
||||
type_t type_Class = { ev_pointer, 0, 1, ty_basic, {{&type_obj_class}}};
|
||||
type_t type_obj_protocol = { ev_invalid, 0, 0, ty_struct};
|
||||
|
||||
int obj_initialized = 0;
|
||||
|
|
|
@ -417,7 +417,7 @@ qfo_functions (qfo_t *qfo)
|
|||
}
|
||||
|
||||
static const char *ty_meta_names[] = {
|
||||
"ty_none",
|
||||
"ty_basic",
|
||||
"ty_struct",
|
||||
"ty_union",
|
||||
"ty_enum",
|
||||
|
@ -461,7 +461,7 @@ dump_qfo_types (qfo_t *qfo, int base_address)
|
|||
break;
|
||||
}
|
||||
switch ((ty_meta_e) type->meta) {
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
printf (" %-10s", (type->t.type < 0
|
||||
|| type->t.type >= ev_type_count)
|
||||
? "invalid type"
|
||||
|
|
|
@ -1164,7 +1164,7 @@ check_defs (void)
|
|||
defref_t *_d = Hash_Find (defined_data_defs, "self");
|
||||
if (_d) {
|
||||
qfo_def_t *d = REF (_d);
|
||||
if (QFO_TYPEMETA (work, d->type) == ty_none
|
||||
if (QFO_TYPEMETA (work, d->type) == ty_basic
|
||||
&& QFO_TYPETYPE (work, d->type) == ev_entity)
|
||||
def_warning (d, "@self and self used together");
|
||||
}
|
||||
|
|
|
@ -647,7 +647,7 @@ get_def_type (qfo_t *qfo, pointer_t type)
|
|||
return ev_void;
|
||||
type_def = QFO_POINTER (qfo, qfo_type_space, qfot_type_t, type);
|
||||
switch ((ty_meta_e)type_def->meta) {
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
case ty_alias:
|
||||
// field, pointer and function types store their basic type in
|
||||
// the same location.
|
||||
|
@ -678,7 +678,7 @@ get_type_size (qfo_t *qfo, pointer_t type)
|
|||
switch ((ty_meta_e)type_def->meta) {
|
||||
case ty_alias:
|
||||
return get_type_size (qfo, type_def->t.alias.aux_type);
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
// field, pointer and function types store their basic type in
|
||||
// the same location.
|
||||
return pr_type_size[type_def->t.type];
|
||||
|
@ -728,7 +728,7 @@ get_type_alignment_log (qfo_t *qfo, pointer_t type)
|
|||
switch ((ty_meta_e)type_def->meta) {
|
||||
case ty_alias:
|
||||
return get_type_alignment_log (qfo, type_def->t.alias.aux_type);
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
// field, pointer and function types store their basic type in
|
||||
// the same location.
|
||||
return qfo_log2 (ev_types[type_def->t.type]->alignment);
|
||||
|
@ -773,7 +773,7 @@ function_params (qfo_t *qfo, qfo_func_t *func, dfunction_t *df)
|
|||
if (func->type >= qfo->spaces[qfo_type_space].data_size)
|
||||
return;
|
||||
type = QFO_POINTER (qfo, qfo_type_space, qfot_type_t, func->type);
|
||||
if (type->meta != ty_none && type->t.type != ev_func)
|
||||
if (type->meta != ty_basic && type->t.type != ev_func)
|
||||
return;
|
||||
df->numparms = num_params = type->t.func.num_params;
|
||||
if (num_params < 0)
|
||||
|
|
|
@ -67,11 +67,13 @@ type_t type_string = { ev_string, "string", 1 };
|
|||
type_t type_float = { ev_float, "float", 1 };
|
||||
type_t type_vector = { ev_vector, "vector", 1 };
|
||||
type_t type_entity = { ev_entity, "entity", 1 };
|
||||
type_t type_field = {ev_field, "field", 1, ty_none, {{&type_void}} };
|
||||
type_t type_field = {ev_field, "field", 1, ty_basic, {{&type_void}} };
|
||||
|
||||
// type_function is a void() function used for state defs
|
||||
type_t type_function = { ev_func, "function", 1, ty_none, {{&type_void}} };
|
||||
type_t type_pointer = { ev_pointer, "pointer", 1, ty_none, {{&type_void}} };
|
||||
type_t type_function = { ev_func, "function", 1, ty_basic,
|
||||
{{&type_void}} };
|
||||
type_t type_pointer = { ev_pointer, "pointer", 1, ty_basic,
|
||||
{{&type_void}} };
|
||||
type_t type_quaternion = { ev_quat, "quaternion", 1 };
|
||||
type_t type_integer = { ev_integer, "int", 1 };
|
||||
type_t type_uinteger = { ev_uinteger, "uint", 1 };
|
||||
|
@ -88,7 +90,7 @@ type_t type_zero = { ev_invalid, 0, 0, ty_struct };
|
|||
type_t type_type_encodings = { ev_invalid, "@type_encodings", 0,
|
||||
ty_struct };
|
||||
|
||||
type_t type_floatfield = { ev_field, ".float", 1, ty_none,
|
||||
type_t type_floatfield = { ev_field, ".float", 1, ty_basic,
|
||||
{{&type_float}} };
|
||||
|
||||
type_t *ev_types[ev_type_count] = {
|
||||
|
@ -252,7 +254,7 @@ types_same (type_t *a, type_t *b)
|
|||
if (a->type != b->type || a->meta != b->meta)
|
||||
return 0;
|
||||
switch (a->meta) {
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
switch (a->type) {
|
||||
case ev_field:
|
||||
case ev_pointer:
|
||||
|
@ -315,7 +317,7 @@ find_type (type_t *type)
|
|||
|
||||
if (type->freeable) {
|
||||
switch (type->meta) {
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
switch (type->type) {
|
||||
case ev_field:
|
||||
case ev_pointer:
|
||||
|
@ -500,7 +502,7 @@ print_type_str (dstring_t *str, const type_t *type)
|
|||
print_type_str (str, type->t.alias.type);
|
||||
dstring_appendstr (str, "})");
|
||||
return;
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
switch (type->type) {
|
||||
case ev_field:
|
||||
dasprintf (str, ".(");
|
||||
|
@ -658,7 +660,7 @@ encode_type (dstring_t *encoding, const type_t *type)
|
|||
encode_type (encoding, type->t.alias.type);
|
||||
dasprintf (encoding, "}");
|
||||
return;
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
switch (type->type) {
|
||||
case ev_void:
|
||||
dasprintf (encoding, "v");
|
||||
|
@ -984,7 +986,7 @@ type_size (const type_t *type)
|
|||
return type->t.array.size * type_size (type->t.array.type);
|
||||
case ty_alias:
|
||||
return type_size (type->t.alias.type);
|
||||
case ty_none:
|
||||
case ty_basic:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1060,7 +1062,7 @@ init_types (void)
|
|||
make_structure ("@param", 'u', param_struct, &type_param);
|
||||
make_structure ("@vector", 's', vector_struct, &type_vector);
|
||||
type_vector.type = ev_vector;
|
||||
type_vector.meta = ty_none;
|
||||
type_vector.meta = ty_basic;
|
||||
|
||||
make_structure ("@type_encodings", 's', type_encoding_struct,
|
||||
&type_type_encodings);
|
||||
|
@ -1070,7 +1072,7 @@ init_types (void)
|
|||
|
||||
make_structure ("@quaternion", 's', quaternion_struct, &type_quaternion);
|
||||
type_quaternion.type = ev_quat;
|
||||
type_quaternion.meta = ty_none;
|
||||
type_quaternion.meta = ty_basic;
|
||||
{
|
||||
symbol_t *sym;
|
||||
sym = new_symbol_type ("x", &type_float);
|
||||
|
|
Loading…
Reference in a new issue