From: Brendan Hansen Date: Sat, 11 Sep 2021 23:17:38 +0000 (-0500) Subject: added passing macros as baked arguments X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=ca2809500ab90745a47e85784502e29d4fba5295;p=onyx.git added passing macros as baked arguments --- diff --git a/bin/onyx b/bin/onyx index fe7a9ff2..c187c11a 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/src/polymorph.c b/src/polymorph.c index 8320f48b..335eec9d 100644 --- a/src/polymorph.c +++ b/src/polymorph.c @@ -497,14 +497,19 @@ static void solve_for_polymorphic_param_value(PolySolveResult* resolved, AstPoly param->type = type_build_from_ast(context.ast_alloc, param->type_expr); assert(param->type); - if (!unify_node_and_type(&value, param->type)) { + AstTyped* value_to_use = value; + if (value->kind == Ast_Kind_Macro) { + value_to_use = (AstTyped *) get_function_from_node((AstNode *) value); + } + + if (!unify_node_and_type(&value_to_use, param->type)) { if (err_msg) *err_msg = bh_aprintf(global_scratch_allocator, "The procedure '%s' expects a value of type '%s' for baked %d%s parameter, got '%s'.", get_function_name(pp->base_func), type_get_name(param->type), param->idx + 1, bh_num_suffix(param->idx + 1), - node_get_type_name(value)); + node_get_type_name(value_to_use)); return; } diff --git a/src/symres.c b/src/symres.c index 4e1bcef7..ad8544e9 100644 --- a/src/symres.c +++ b/src/symres.c @@ -1185,6 +1185,8 @@ static SymresStatus symres_macro(AstMacro* macro) { SYMRES(polyproc, (AstPolyProc *) macro->body); } + macro->flags |= Ast_Flag_Comptime; + return Symres_Success; }