summaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2019-11-09 15:48:01 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2019-11-09 15:48:01 -0500
commit3c31cd066fb761f7fc1f7f98918ae96a55dedc4d (patch)
tree47c06d5f47ecd18a7a8756d0e89c159fc8fc68bc /types.c
parentcc5e08b53e724b425c9db31b3ee9ec445a394ae6 (diff)
fixed local functions
Diffstat (limited to 'types.c')
-rw-r--r--types.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/types.c b/types.c
index a635956..f84d9a8 100644
--- a/types.c
+++ b/types.c
@@ -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;