static inline AstFunction* get_function_from_node(AstNode* node) {
if (node->kind == Ast_Kind_Function) return (AstFunction *) node;
if (node->kind == Ast_Kind_Polymorphic_Proc) return ((AstPolyProc *) node)->base_func;
+ if (node->kind == Ast_Kind_Macro) return get_function_from_node((AstNode*) ((AstMacro *) node)->body);
return NULL;
}
b32 should_yield = 0;
AstTyped* overload = find_matching_overload_by_arguments(operator_overloads[binop->operation], &args, &should_yield);
+ if (should_yield) {
+ bh_arr_free(args.values);
+ return (AstCall *) &node_that_signals_a_yield;
+ }
+
if (overload == NULL) {
bh_arr_free(args.values);
return NULL;
(binop->left->type->kind != Type_Kind_Basic || binop->right->type->kind != Type_Kind_Basic)) {
AstCall *implicit_call = binaryop_try_operator_overload(binop);
- if (implicit_call != NULL) {
- CHECK(call, &implicit_call);
+ if (implicit_call == (AstCall *) &node_that_signals_a_yield)
+ return Check_Yield_Macro;
+ if (implicit_call != NULL) {
// NOTE: Not a binary op
+ implicit_call->next = binop->next;
*pbinop = (AstBinaryOp *) implicit_call;
+
+ CHECK(call, (AstCall **) pbinop);
return Check_Success;
}
}
AstBinaryOp* binop = (AstBinaryOp *) sub;
AstCall *implicit_call = binaryop_try_operator_overload(binop);
- if (implicit_call != NULL) {
- CHECK(call, &implicit_call);
+ if (implicit_call == (AstCall *) &node_that_signals_a_yield)
+ return Check_Yield_Macro;
+ if (implicit_call != NULL) {
// NOTE: Not an array access
+ implicit_call->next = sub->next;
*psub = (AstSubscript *) implicit_call;
+
+ CHECK(call, (AstCall **) psub);
return Check_Success;
}
}
AstFunction* overload = NULL;
switch (node->kind) {
case Ast_Kind_Function: overload = (AstFunction *) node; break;
- case Ast_Kind_Macro: overload = (AstFunction *) ((AstMacro *) node)->body; break;
+ case Ast_Kind_Macro: overload = macro_resolve_header((AstMacro *) node, param_args, NULL); break;
case Ast_Kind_Polymorphic_Proc: overload = polymorphic_proc_build_only_header((AstPolyProc *) node, PPLM_By_Arguments, param_args); break;
}
return (AstFunction *) &node_that_signals_a_yield;
}
- onyx_report_error(callsite->pos, err_msg);
+ if (callsite) onyx_report_error(callsite->pos, err_msg);
+
return NULL;
}