mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
immediates now seem to work
This commit is contained in:
parent
ce2f26f0b9
commit
c32bcb7262
1 changed files with 16 additions and 20 deletions
|
@ -145,12 +145,13 @@ PR_ParseImmediate (def_t *def)
|
||||||
}
|
}
|
||||||
|
|
||||||
def_t *
|
def_t *
|
||||||
PR_ReuseConstant (expr_t *e, def_t *def)
|
PR_ReuseConstant (expr_t *expr, def_t *def)
|
||||||
{
|
{
|
||||||
def_t *cn = 0;
|
def_t *cn = 0;
|
||||||
char rep[60];
|
char rep[60];
|
||||||
hashtab_t *tab = 0;
|
hashtab_t *tab = 0;
|
||||||
type_t *type;
|
type_t *type;
|
||||||
|
expr_t e = *expr;
|
||||||
|
|
||||||
if (!string_imm_defs) {
|
if (!string_imm_defs) {
|
||||||
string_imm_defs = Hash_NewTable (16381, string_imm_get_key, 0, 0);
|
string_imm_defs = Hash_NewTable (16381, string_imm_get_key, 0, 0);
|
||||||
|
@ -158,48 +159,43 @@ PR_ReuseConstant (expr_t *e, def_t *def)
|
||||||
vector_imm_defs = Hash_NewTable (16381, vector_imm_get_key, 0, 0);
|
vector_imm_defs = Hash_NewTable (16381, vector_imm_get_key, 0, 0);
|
||||||
quaternion_imm_defs = Hash_NewTable (16381, quaternion_imm_get_key, 0, 0);
|
quaternion_imm_defs = Hash_NewTable (16381, quaternion_imm_get_key, 0, 0);
|
||||||
}
|
}
|
||||||
switch (e->type) {
|
switch (e.type) {
|
||||||
case ex_int:
|
case ex_int:
|
||||||
e->e.float_val = e->e.int_val; //FIXME
|
e.e.float_val = e.e.int_val; //FIXME
|
||||||
case ex_float:
|
case ex_float:
|
||||||
sprintf (rep, "\001float:%08X\001", *(int*)&pr_immediate._float);
|
sprintf (rep, "\001float:%08X\001", e.e.int_val);
|
||||||
cn = (def_t*) Hash_Find (float_imm_defs, rep);
|
cn = (def_t*) Hash_Find (float_imm_defs, rep);
|
||||||
tab = float_imm_defs;
|
tab = float_imm_defs;
|
||||||
type = &type_float;
|
type = &type_float;
|
||||||
//printf ("%f\n",pr_immediate._float);
|
|
||||||
break;
|
break;
|
||||||
case ex_string:
|
case ex_string:
|
||||||
cn = (def_t*) Hash_Find (string_imm_defs, pr_immediate_string);
|
cn = (def_t*) Hash_Find (string_imm_defs, e.e.string_val);
|
||||||
tab = string_imm_defs;
|
tab = string_imm_defs;
|
||||||
type = &type_string;
|
type = &type_string;
|
||||||
//printf ("%s\n",pr_immediate_string);
|
|
||||||
break;
|
break;
|
||||||
case ex_vector:
|
case ex_vector:
|
||||||
sprintf (rep, "\001vector:%08X\001%08X\001%08X\001",
|
sprintf (rep, "\001vector:%08X\001%08X\001%08X\001",
|
||||||
*(int*)&e->e.vector_val[0],
|
*(int*)&e.e.vector_val[0],
|
||||||
*(int*)&e->e.vector_val[1],
|
*(int*)&e.e.vector_val[1],
|
||||||
*(int*)&e->e.vector_val[2]);
|
*(int*)&e.e.vector_val[2]);
|
||||||
cn = (def_t*) Hash_Find (vector_imm_defs, rep);
|
cn = (def_t*) Hash_Find (vector_imm_defs, rep);
|
||||||
tab = vector_imm_defs;
|
tab = vector_imm_defs;
|
||||||
type = &type_vector;
|
type = &type_vector;
|
||||||
//printf ("%f %f %f\n",pr_immediate.vector[0], pr_immediate.vector[1], pr_immediate.vector[2]);
|
|
||||||
break;
|
break;
|
||||||
case ex_quaternion:
|
case ex_quaternion:
|
||||||
sprintf (rep, "\001quaternion:%08X\001%08X\001%08X\001%08X\001",
|
sprintf (rep, "\001quaternion:%08X\001%08X\001%08X\001%08X\001",
|
||||||
*(int*)&e->e.quaternion_val[0],
|
*(int*)&e.e.quaternion_val[0],
|
||||||
*(int*)&e->e.quaternion_val[1],
|
*(int*)&e.e.quaternion_val[1],
|
||||||
*(int*)&e->e.quaternion_val[2],
|
*(int*)&e.e.quaternion_val[2],
|
||||||
*(int*)&e->e.quaternion_val[3]);
|
*(int*)&e.e.quaternion_val[3]);
|
||||||
cn = (def_t*) Hash_Find (quaternion_imm_defs, rep);
|
cn = (def_t*) Hash_Find (quaternion_imm_defs, rep);
|
||||||
tab = vector_imm_defs;
|
tab = vector_imm_defs;
|
||||||
type = &type_quaternion;
|
type = &type_quaternion;
|
||||||
//printf ("%f %f %f\n",pr_immediate.vector[0], pr_immediate.vector[1], pr_immediate.vector[2]);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
if (cn) {
|
if (cn) {
|
||||||
//printf("found\n");
|
|
||||||
if (def) {
|
if (def) {
|
||||||
PR_FreeLocation (def);
|
PR_FreeLocation (def);
|
||||||
def->ofs = cn->ofs;
|
def->ofs = cn->ofs;
|
||||||
|
@ -219,10 +215,10 @@ PR_ReuseConstant (expr_t *e, def_t *def)
|
||||||
}
|
}
|
||||||
cn->initialized = 1;
|
cn->initialized = 1;
|
||||||
// copy the immediate to the global area
|
// copy the immediate to the global area
|
||||||
if (e->type == ex_string)
|
if (e.type == ex_string)
|
||||||
e->e.int_val = CopyString (e->e.string_val);
|
e.e.int_val = CopyString (e.e.string_val);
|
||||||
|
|
||||||
memcpy (pr_globals + cn->ofs, &e->e, 4 * type_size[type->type]);
|
memcpy (pr_globals + cn->ofs, &e.e, 4 * type_size[type->type]);
|
||||||
|
|
||||||
Hash_Add (tab, cn);
|
Hash_Add (tab, cn);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue