From 4908b3cf10301e716c9077944befaaa2bf293e3b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 16 May 2002 21:57:03 +0000 Subject: [PATCH] `initialize' the defs for the obj constructs --- tools/qfcc/source/class.c | 7 ++++++- tools/qfcc/source/method.c | 6 ++++++ tools/qfcc/source/pr_imm.c | 18 ++++++++++++------ tools/qfcc/source/struct.c | 1 + 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/tools/qfcc/source/class.c b/tools/qfcc/source/class.c index e6d44b589..e55e7c219 100644 --- a/tools/qfcc/source/class.c +++ b/tools/qfcc/source/class.c @@ -138,6 +138,7 @@ class_finish (class_t *class) class->class_name, class->category_name), 0, &numpr_globals); + category_def->initialized = category_def->constant = 1; category = &G_STRUCT (pr_category_t, category_def->ofs); } else if (class->class_name) { def_t *meta_def; @@ -147,6 +148,7 @@ class_finish (class_t *class) meta_def = PR_GetDef (type_Class.aux_type, va ("_OBJ_METACLASS_%s", class->class_name), 0, &numpr_globals); + meta_def->initialized = meta_def->constant = 1; meta = &G_STRUCT (pr_class_t, meta_def->ofs); memset (meta, 0, sizeof (*meta)); meta->class_pointer = ReuseString (class->class_name); @@ -158,8 +160,9 @@ class_finish (class_t *class) class->class_name); class->def = PR_GetDef (type_Class.aux_type, - va ("_OBJ_METACLASS_%s", class->class_name), + va ("_OBJ_CLASS_%s", class->class_name), 0, &numpr_globals); + class->def->initialized = class->def->constant = 1; cls = &G_STRUCT (pr_class_t, class->def->ofs); cls->class_pointer = meta_def->ofs; if (class->super_class) @@ -354,6 +357,7 @@ emit_protocol (protocol_t *protocol) proto_def = PR_GetDef (type_Protocol.aux_type, va ("_OBJ_PROTOCOL_%s", protocol->name), 0, &numpr_globals); + proto_def->initialized = proto_def->constant = 1; proto = &G_STRUCT (pr_protocol_t, proto_def->ofs); proto->class_pointer = 0; proto->protocol_name = ReuseString (protocol->name); @@ -384,6 +388,7 @@ emit_protocol_list (protocollist_t *protocols, const char *name) proto_list_def = PR_GetDef (type_Protocol.aux_type, va ("_OBJ_PROTOCOLS_%s", name), 0, &numpr_globals); + proto_list_def->initialized = proto_list_def->constant = 1; proto_list = &G_STRUCT (pr_protocol_list_t, proto_list_def->ofs); proto_list->next = 0; proto_list->count = protocols->count; diff --git a/tools/qfcc/source/method.c b/tools/qfcc/source/method.c index c0bff1131..a09cf0e79 100644 --- a/tools/qfcc/source/method.c +++ b/tools/qfcc/source/method.c @@ -253,6 +253,7 @@ selector_def (const char *_sel_id, const char *_sel_types) sel_def->sel_id = sel_id; sel_def->sel_types = sel_types; sel_def->def = PR_NewDef (type_SEL.aux_type, ".imm", 0); + sel_def->def->initialized = sel_def->def->constant = 1; sel_def->def->ofs = PR_NewLocation (type_SEL.aux_type); G_INT (sel_def->def->ofs) = sel_id; G_INT (sel_def->def->ofs + 1) = sel_types; @@ -270,9 +271,13 @@ emit_methods (methodlist_t *_methods, const char *name, int instance) pr_method_list_t *methods; type_t *method_list; + if (!_methods) + return 0; for (count = 0, method = _methods->head; method; method = method->next) if (!method->instance == !instance) count++; + if (!count) + return 0; method_list = new_struct (0); new_struct_field (method_list, &type_pointer, "method_next", vis_public); new_struct_field (method_list, &type_integer, "method_count", vis_public); @@ -280,6 +285,7 @@ emit_methods (methodlist_t *_methods, const char *name, int instance) new_struct_field (method_list, type_method, 0, vis_public); methods_def = PR_GetDef (method_list, va ("_OBJ_%s_METHODS_%s", type, name), 0, &numpr_globals); + methods_def->initialized = methods_def->constant = 1; methods = &G_STRUCT (pr_method_list_t, methods_def->ofs); methods->method_next = 0; methods->method_count = count; diff --git a/tools/qfcc/source/pr_imm.c b/tools/qfcc/source/pr_imm.c index 8b8c13e84..1122a0ffd 100644 --- a/tools/qfcc/source/pr_imm.c +++ b/tools/qfcc/source/pr_imm.c @@ -93,7 +93,7 @@ int_imm_get_key (void *_def, void *_str) def_t * PR_ReuseConstant (expr_t *expr, def_t *def) { - def_t *cn = 0; + def_t *cn; char rep[60]; const char *r = rep; hashtab_t *tab = 0; @@ -112,12 +112,18 @@ PR_ReuseConstant (expr_t *expr, def_t *def) Hash_NewTable (16381, quaternion_imm_get_key, 0, 0); integer_imm_defs = Hash_NewTable (16381, int_imm_get_key, 0, "integer"); - Hash_Add (string_imm_defs, PR_NewDef (&type_string, ".imm", 0)); - Hash_Add (float_imm_defs, PR_NewDef (&type_float, ".imm", 0)); - Hash_Add (entity_imm_defs, PR_NewDef (&type_entity, ".imm", 0)); - Hash_Add (pointer_imm_defs, PR_NewDef (&type_pointer, ".imm", 0)); - Hash_Add (integer_imm_defs, PR_NewDef (&type_integer, ".imm", 0)); + Hash_Add (string_imm_defs, cn = PR_NewDef (&type_string, ".imm", 0)); + cn->initialized = cn->constant = 1; + Hash_Add (float_imm_defs, cn = PR_NewDef (&type_float, ".imm", 0)); + cn->initialized = cn->constant = 1; + Hash_Add (entity_imm_defs, cn = PR_NewDef (&type_entity, ".imm", 0)); + cn->initialized = cn->constant = 1; + Hash_Add (pointer_imm_defs, cn = PR_NewDef (&type_pointer, ".imm", 0)); + cn->initialized = cn->constant = 1; + Hash_Add (integer_imm_defs, cn = PR_NewDef (&type_integer, ".imm", 0)); + cn->initialized = cn->constant = 1; } + cn = 0; switch (e.type) { case ex_entity: snprintf (rep, sizeof (rep), "\001entity:%08X\001", diff --git a/tools/qfcc/source/struct.c b/tools/qfcc/source/struct.c index 9964c13f0..e94d77db3 100644 --- a/tools/qfcc/source/struct.c +++ b/tools/qfcc/source/struct.c @@ -191,6 +191,7 @@ emit_struct(type_t *strct, const char *name) if (ivars_def) goto done; ivars_def = PR_GetDef (ivar_list, ivars_name->str, 0, &numpr_globals); + ivars_def->initialized = ivars_def->constant = 1; ivars = &G_STRUCT (pr_ivar_list_t, ivars_def->ofs); ivars->ivar_count = count; for (i = 0, field = strct->struct_head; field; i++, field = field->next) {