diff --git a/tools/qfcc/source/pr_comp.c b/tools/qfcc/source/pr_comp.c index 6e6a43652..166960177 100644 --- a/tools/qfcc/source/pr_comp.c +++ b/tools/qfcc/source/pr_comp.c @@ -730,6 +730,7 @@ PR_ParseDefs (void) def->initialized = 1; memcpy (pr_globals + def->ofs, &pr_immediate, 4 * type_size[pr_immediate_type->type]); + PR_NameImmediate (def); PR_Lex (); } diff --git a/tools/qfcc/source/pr_imm.c b/tools/qfcc/source/pr_imm.c index 3c0a6ce32..943497d3c 100644 --- a/tools/qfcc/source/pr_imm.c +++ b/tools/qfcc/source/pr_imm.c @@ -119,3 +119,42 @@ PR_ParseImmediate (void) return cn; } + +void +PR_NameImmediate (def_t *def) +{ + char rep[60]; + def_t *cn; + hashtab_t *tab; + + if (!string_imm_defs) { + string_imm_defs = Hash_NewTable (16381, string_imm_get_key, 0, 0); + float_imm_defs = Hash_NewTable (16381, float_imm_get_key, 0, 0); + vector_imm_defs = Hash_NewTable (16381, vector_imm_get_key, 0, 0); + } + if (def->type == &type_string) { + cn = Hash_Find (string_imm_defs, string_imm_get_key (def, 0)); + tab = string_imm_defs; + } else if (def->type == &type_float) { + strcpy (rep, float_imm_get_key (def, 0)); + cn = Hash_Find (float_imm_defs, rep); + tab = float_imm_defs; + } else if (def->type == &type_vector) { + strcpy (rep, vector_imm_get_key (def, 0)); + cn = Hash_Find (vector_imm_defs, rep); + tab = vector_imm_defs; + } else { + PR_ParseError ("weird immediate type"); + return; + } +/* + if (cn) { + if (strcmp (cn->name, "IMMEDIATE") != 0) { + free cn->name; + cn->name = strdup (def->name); + } + return; + } +*/ + Hash_Add (tab, def); +}