mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-07 01:42:04 +00:00
[qfcc] Set current function for inlined functions
It improves error reporting and is even a solution for what to do with return statements in inline functions.
This commit is contained in:
parent
36c0b45bab
commit
a0f09b13cf
4 changed files with 9 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
|||
typedef struct type_s type_t;
|
||||
typedef struct expr_s expr_t;
|
||||
typedef struct algebra_s algebra_t;
|
||||
typedef struct function_s function_t;
|
||||
|
||||
/** \defgroup qfcc_expr Expressions
|
||||
\ingroup qfcc
|
||||
|
@ -404,6 +405,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
const expr_t *expr;
|
||||
function_t *function; ///< for better reporting in inline functions
|
||||
} ex_process_t;
|
||||
|
||||
typedef struct expr_s {
|
||||
|
|
|
@ -279,6 +279,7 @@ build_inline_call (symbol_t *fsym, const type_t *ftype,
|
|||
append_expr (call, expr);
|
||||
|
||||
auto proc = new_process_expr (call);
|
||||
proc->process.function = func;
|
||||
|
||||
return proc;
|
||||
}
|
||||
|
|
|
@ -717,7 +717,12 @@ expr_process (const expr_t *expr, rua_ctx_t *ctx)
|
|||
|
||||
auto proc = funcs[expr->type] (expr, ctx);
|
||||
if (proc && proc->type == ex_process) {
|
||||
auto func = current_func;
|
||||
if (proc->process.function) {
|
||||
current_func = proc->process.function;
|
||||
}
|
||||
proc = expr_process (proc->process.expr, ctx);
|
||||
current_func = func;
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
|
|
|
@ -982,6 +982,7 @@ find_function (const expr_t *fexpr, const expr_t *params)
|
|||
// the call will be inlined, so a new scope is needed every
|
||||
// time
|
||||
sym->metafunc->func = new_function (sym->name, gen->name);
|
||||
sym->metafunc->func->type = sym->type;
|
||||
build_generic_scope (sym, current_symtab, gen, ref_types);
|
||||
}
|
||||
return new_symbol_expr (sym);
|
||||
|
|
Loading…
Reference in a new issue