mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-16 06:11:15 +00:00
[qfcc] Support aliasing constants
This takes advantage of evaluate_constexpr to do all the work. Necessary for use of basis blade constants in algebra contexts (avoids an internal error).
This commit is contained in:
parent
ec9e2c12b8
commit
5c22ba118c
2 changed files with 9 additions and 3 deletions
|
@ -40,9 +40,9 @@
|
|||
|
||||
#include "tools/qfcc/include/codespace.h"
|
||||
#include "tools/qfcc/include/defspace.h"
|
||||
#include "tools/qfcc/include/evaluate.h"
|
||||
#include "tools/qfcc/include/diagnostic.h"
|
||||
#include "tools/qfcc/include/dot.h"
|
||||
#include "tools/qfcc/include/evaluate.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/opcodes.h"
|
||||
#include "tools/qfcc/include/options.h"
|
||||
|
@ -235,6 +235,11 @@ evaluate_constexpr (const expr_t *e)
|
|||
if (!is_constant (e->expr.e1) || !is_constant (e->expr.e2)) {
|
||||
return e;
|
||||
}
|
||||
} else if (e->type == ex_alias) {
|
||||
// offsets are always constant
|
||||
if (!is_constant (e->alias.expr)) {
|
||||
return e;
|
||||
}
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
|
@ -275,7 +280,7 @@ evaluate_constexpr (const expr_t *e)
|
|||
options.code.progsversion = saved_version;
|
||||
value_pr.pr_trace = options.verbosity > 1;
|
||||
PR_ExecuteProgram (&value_pr, vf_foldconst);
|
||||
auto val = new_type_value (e->expr.type, value_pr.pr_return_buffer);
|
||||
auto val = new_type_value (get_type (e), value_pr.pr_return_buffer);
|
||||
e = new_value_expr (val);
|
||||
return e;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "tools/qfcc/include/defspace.h"
|
||||
#include "tools/qfcc/include/diagnostic.h"
|
||||
#include "tools/qfcc/include/emit.h"
|
||||
#include "tools/qfcc/include/evaluate.h"
|
||||
#include "tools/qfcc/include/expr.h"
|
||||
#include "tools/qfcc/include/function.h"
|
||||
#include "tools/qfcc/include/idstuff.h"
|
||||
|
@ -1284,7 +1285,7 @@ new_offset_alias_expr (type_t *type, const expr_t *expr, int offset)
|
|||
alias->alias.offset = edag_add_expr (new_int_expr (offset));
|
||||
alias->file = expr->file;
|
||||
alias->line = expr->line;
|
||||
return edag_add_expr (alias);
|
||||
return edag_add_expr (evaluate_constexpr (alias));
|
||||
}
|
||||
|
||||
expr_t *
|
||||
|
|
Loading…
Reference in a new issue