allow named constants to be checked for immediate constants. qfcc now produces
the same number of globals etc as it used to
This commit is contained in:
parent
f517dc6ce6
commit
b7aba0b643
|
@ -730,6 +730,7 @@ PR_ParseDefs (void)
|
||||||
def->initialized = 1;
|
def->initialized = 1;
|
||||||
memcpy (pr_globals + def->ofs, &pr_immediate,
|
memcpy (pr_globals + def->ofs, &pr_immediate,
|
||||||
4 * type_size[pr_immediate_type->type]);
|
4 * type_size[pr_immediate_type->type]);
|
||||||
|
PR_NameImmediate (def);
|
||||||
PR_Lex ();
|
PR_Lex ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,3 +119,42 @@ PR_ParseImmediate (void)
|
||||||
|
|
||||||
return cn;
|
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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue