mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
Extract values from constant defs.
This commit is contained in:
parent
cc714864a8
commit
57ed603658
1 changed files with 16 additions and 2 deletions
|
@ -620,17 +620,31 @@ expr_t *
|
||||||
constant_expr (expr_t *e)
|
constant_expr (expr_t *e)
|
||||||
{
|
{
|
||||||
expr_t *new;
|
expr_t *new;
|
||||||
|
symbol_t *sym;
|
||||||
|
ex_value_t value;
|
||||||
|
|
||||||
if (!is_constant (e))
|
if (!is_constant (e))
|
||||||
return e;
|
return e;
|
||||||
if (e->type == ex_nil || e->type == ex_value)
|
if (e->type == ex_nil || e->type == ex_value)
|
||||||
return e;
|
return e;
|
||||||
if (e->type != ex_symbol || e->e.symbol->sy_type != sy_const)
|
if (e->type != ex_symbol)
|
||||||
return e;
|
return e;
|
||||||
|
sym = e->e.symbol;
|
||||||
|
if (sym->sy_type == sy_const) {
|
||||||
|
value = sym->s.value;
|
||||||
|
} else if (sym->sy_type == sy_var && sym->s.def->constant) {
|
||||||
|
//FIXME pointers and fields
|
||||||
|
memset (&value, 0, sizeof (value));
|
||||||
|
memcpy (&value.v, &D_INT (sym->s.def),
|
||||||
|
type_size (sym->s.def->type) * sizeof (pr_type_t));
|
||||||
|
} else {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
new = new_expr ();
|
new = new_expr ();
|
||||||
new->type = ex_value;
|
new->type = ex_value;
|
||||||
new->line = e->line;
|
new->line = e->line;
|
||||||
new->file = e->file;
|
new->file = e->file;
|
||||||
new->e.value = e->e.symbol->s.value;
|
new->e.value = value;
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue