mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Clean up array expression processing
And make sure constants are folded since fold_constants is no longer recursive.
This commit is contained in:
parent
f70801fa52
commit
227ac46ffe
1 changed files with 6 additions and 6 deletions
|
@ -2106,6 +2106,8 @@ array_expr (expr_t *array, expr_t *index)
|
|||
type_t *array_type = get_type (array);
|
||||
type_t *index_type = get_type (index);
|
||||
expr_t *scale;
|
||||
expr_t *offset;
|
||||
expr_t *base;
|
||||
expr_t *e;
|
||||
int ind = 0;
|
||||
|
||||
|
@ -2128,12 +2130,10 @@ array_expr (expr_t *array, expr_t *index)
|
|||
|| ind - array_type->t.array.base >= array_type->t.array.size))
|
||||
return error (index, "array index out of bounds");
|
||||
scale = new_integer_expr (type_size (array_type->t.array.type));
|
||||
index = binary_expr ('*', index, scale);
|
||||
index = binary_expr ('-', index,
|
||||
binary_expr ('*',
|
||||
new_integer_expr (array_type->t.array.base),
|
||||
scale));
|
||||
index = fold_constants (index);
|
||||
index = fold_constants (binary_expr ('*', index, scale));
|
||||
base = new_integer_expr (array_type->t.array.base);
|
||||
offset = fold_constants (binary_expr ('*', base, scale));
|
||||
index = fold_constants (binary_expr ('-', index, offset));
|
||||
if (is_short_val (index))
|
||||
ind = expr_short (index);
|
||||
if (is_integer_val (index))
|
||||
|
|
Loading…
Reference in a new issue