From: Brendan Hansen Date: Tue, 9 Nov 2021 04:21:27 +0000 (-0600) Subject: removed some 'should_yield' weirdness X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=d38c7d73b9ed9a827e52884cd5facb6692666d11;p=onyx.git removed some 'should_yield' weirdness --- diff --git a/include/astnodes.h b/include/astnodes.h index 1c5b0525..b8ce6bba 100644 --- a/include/astnodes.h +++ b/include/astnodes.h @@ -1438,7 +1438,7 @@ AstFunction* polymorphic_proc_build_only_header(AstPolyProc* pp, PolyProcLookupM AstFunction* polymorphic_proc_build_only_header_with_slns(AstPolyProc* pp, bh_arr(AstPolySolution) slns); void add_overload_option(bh_arr(OverloadOption)* poverloads, u64 precedence, AstTyped* overload); -AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* args, b32* should_yield); +AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* args); AstTyped* find_matching_overload_by_type(bh_arr(OverloadOption) overloads, Type* type); void report_unable_to_match_overload(AstCall* call); diff --git a/src/checker.c b/src/checker.c index cecf4f97..7500b5e8 100644 --- a/src/checker.c +++ b/src/checker.c @@ -410,20 +410,17 @@ static CheckStatus check_resolve_callee(AstCall* call, AstTyped** effective_call b32 calling_a_macro = 0; if (callee->kind == Ast_Kind_Overloaded_Function) { - b32 should_yield = 0; AstTyped* new_callee = find_matching_overload_by_arguments( ((AstOverloadedFunction *) callee)->overloads, - &call->args, - &should_yield); + &call->args); if (new_callee == NULL) { - if (callee->entity->state > Entity_State_Check_Types && !should_yield) { - report_unable_to_match_overload(call); - return Check_Error; + report_unable_to_match_overload(call); + return Check_Error; + } - } else { - YIELD(call->token->pos, "Waiting for overloaded function option to pass type-checking."); - } + if (new_callee == (AstTyped *) &node_that_signals_a_yield) { + YIELD(call->token->pos, "Waiting for overloaded function option to pass type-checking."); } callee = new_callee; @@ -635,10 +632,8 @@ static AstCall* binaryop_try_operator_overload(AstBinaryOp* binop, AstTyped* thi args.values[1] = (AstTyped *) make_argument(context.ast_alloc, binop->right); if (third_argument != NULL) args.values[2] = (AstTyped *) make_argument(context.ast_alloc, third_argument); - b32 should_yield = 0; - AstTyped* overload = find_matching_overload_by_arguments(operator_overloads[binop->operation], &args, &should_yield); - if (should_yield) return (AstCall *) &node_that_signals_a_yield; - if (overload == NULL) return NULL; + AstTyped* overload = find_matching_overload_by_arguments(operator_overloads[binop->operation], &args); + if (overload == NULL || overload == (AstTyped *) &node_that_signals_a_yield) return (AstCall *) overload; AstCall* implicit_call = onyx_ast_node_new(context.ast_alloc, sizeof(AstCall), Ast_Kind_Call); implicit_call->token = binop->token; diff --git a/src/symres.c b/src/symres.c index 38e59376..d8cd3ce4 100644 --- a/src/symres.c +++ b/src/symres.c @@ -751,7 +751,7 @@ static SymresStatus symres_directive_solidify(AstDirectiveSolidify** psolid) { } solid->resolved_proc = polymorphic_proc_try_solidify(solid->poly_proc, solid->known_polyvars, solid->token); - if (solid->resolved_proc == (AstFunction *) &node_that_signals_a_yield) { + if (solid->resolved_proc == (AstTyped *) &node_that_signals_a_yield) { solid->resolved_proc = NULL; return Symres_Yield_Macro; } diff --git a/src/utils.c b/src/utils.c index 82a43868..a4b3642e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -338,7 +338,7 @@ void build_all_overload_options(bh_arr(OverloadOption) overloads, bh_imap* all_o } } -AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* param_args, b32* should_yield) { +AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, Arguments* param_args) { Arguments args; arguments_clone(&args, param_args); arguments_ensure_length(&args, bh_arr_length(args.values) + bh_arr_length(args.named_values)); @@ -364,22 +364,15 @@ AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, // NOTE: Overload is not something that is known to be overloadable. if (overload == NULL) continue; - if (overload == (AstFunction *) &node_that_signals_a_yield) { - // If it was not possible to create the type for this procedure, tell the - // caller that this should yield and try again later. - if (should_yield) *should_yield = 1; - - return NULL; - } + if (overload == (AstFunction *) &node_that_signals_a_yield) return (AstTyped *) overload; if (overload->kind != Ast_Kind_Function) continue; if (overload->type == NULL) { // If it was not possible to create the type for this procedure, tell the // caller that this should yield and try again later. - if (should_yield) *should_yield = 1; // return and not continue because if the overload that didn't have a type will // work in the future, then it has to take precedence over the other options available. - return NULL; + return (AstTyped *) &node_that_signals_a_yield; } assert(overload->type->kind == Type_Kind_Function); @@ -397,8 +390,7 @@ AstTyped* find_matching_overload_by_arguments(bh_arr(OverloadOption) overloads, } if (tm == TYPE_MATCH_YIELD) { - if (should_yield) *should_yield = 1; - return NULL; + return (AstTyped *) &node_that_signals_a_yield; } }