diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-11-09 15:48:01 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-11-09 15:48:01 -0500 |
commit | 3c31cd066fb761f7fc1f7f98918ae96a55dedc4d (patch) | |
tree | 47c06d5f47ecd18a7a8756d0e89c159fc8fc68bc /types.c | |
parent | cc5e08b53e724b425c9db31b3ee9ec445a394ae6 (diff) |
fixed local functions
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -1042,6 +1042,31 @@ static bool types_expr(Typer *tr, Expression *e) { } } } + if (fn_decl) { + /* evaluate compile-time arguments */ + size_t i = 0; + arr_foreach(fn_decl->params, Declaration, param) { + if (param->flags & DECL_FLAG_CONST) { + arr_foreach(param->idents, Identifier, ident) { + Value arg_val; + if (!eval_expr(tr->evalr, &new_args[i], &arg_val)) { + if (tr->evalr->enabled) { + char *s = ident_to_str(*ident); + info_print(new_args[i].where, "(error occured while trying to evaluate compile-time argument, %s)", s); + info_print(param->where, "(%s was declared constant here)", s); + free(s); + } + return false; + } + new_args[i].kind = EXPR_VAL; + new_args[i].val = arg_val; + i++; + } + } else { + i += arr_len(param->idents); + } + } + } *t = *ret_type; c->arg_exprs = new_args; break; |