| ... | ... | @@ -18687,18 +18687,6 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18687 | 18687 | IrInstruction *fn_ref = pass1_fn_ref->child; |
| 18688 | 18688 | if (type_is_invalid(fn_ref->value->type)) |
| 18689 | 18689 | return ira->codegen->invalid_instruction; |
| 18690 | | IrInstruction *first_arg_ptr = nullptr; |
| 18691 | | ZigFn *fn = nullptr; |
| 18692 | | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 18693 | | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 18694 | | fn = fn_ref->value->data.x_bound_fn.fn; |
| 18695 | | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 18696 | | if (type_is_invalid(first_arg_ptr->value->type)) |
| 18697 | | return ira->codegen->invalid_instruction; |
| 18698 | | } else { |
| 18699 | | fn = ir_resolve_fn(ira, fn_ref); |
| 18700 | | } |
| 18701 | | ZigType *fn_type = (fn != nullptr) ? fn->type_entry : fn_ref->value->type; |
| 18702 | 18690 | |
| 18703 | 18691 | TypeStructField *modifier_field = find_struct_type_field(options->value->type, buf_create_from_str("modifier")); |
| 18704 | 18692 | ir_assert(modifier_field != nullptr, source_instr); |
| ... | ... | @@ -18733,22 +18721,52 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18733 | 18721 | } |
| 18734 | 18722 | } |
| 18735 | 18723 | |
| 18724 | IrInstruction *first_arg_ptr = nullptr; |
| 18725 | ZigFn *fn = nullptr; |
| 18726 | if (instr_is_comptime(fn_ref)) { |
| 18727 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 18728 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 18729 | fn = fn_ref->value->data.x_bound_fn.fn; |
| 18730 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 18731 | if (type_is_invalid(first_arg_ptr->value->type)) |
| 18732 | return ira->codegen->invalid_instruction; |
| 18733 | } else { |
| 18734 | fn = ir_resolve_fn(ira, fn_ref); |
| 18735 | } |
| 18736 | } |
| 18737 | |
| 18738 | // Some modifiers require the callee to be comptime-known |
| 18739 | switch (modifier) { |
| 18740 | case CallModifierCompileTime: |
| 18741 | case CallModifierAlwaysInline: |
| 18742 | case CallModifierAsync: |
| 18743 | if (fn == nullptr) { |
| 18744 | ir_add_error(ira, modifier_inst, |
| 18745 | buf_sprintf("the specified modifier requires a comptime-known function")); |
| 18746 | return ira->codegen->invalid_instruction; |
| 18747 | } |
| 18748 | default: |
| 18749 | break; |
| 18750 | } |
| 18751 | |
| 18752 | ZigType *fn_type = (fn != nullptr) ? fn->type_entry : fn_ref->value->type; |
| 18753 | |
| 18736 | 18754 | TypeStructField *stack_field = find_struct_type_field(options->value->type, buf_create_from_str("stack")); |
| 18737 | 18755 | ir_assert(stack_field != nullptr, source_instr); |
| 18738 | 18756 | IrInstruction *opt_stack = ir_analyze_struct_value_field_value(ira, source_instr, options, stack_field); |
| 18739 | 18757 | if (type_is_invalid(opt_stack->value->type)) |
| 18740 | 18758 | return ira->codegen->invalid_instruction; |
| 18759 | |
| 18741 | 18760 | IrInstruction *stack_is_non_null_inst = ir_analyze_test_non_null(ira, source_instr, opt_stack); |
| 18742 | 18761 | bool stack_is_non_null; |
| 18743 | 18762 | if (!ir_resolve_bool(ira, stack_is_non_null_inst, &stack_is_non_null)) |
| 18744 | 18763 | return ira->codegen->invalid_instruction; |
| 18745 | | IrInstruction *stack; |
| 18764 | |
| 18765 | IrInstruction *stack = nullptr; |
| 18746 | 18766 | if (stack_is_non_null) { |
| 18747 | 18767 | stack = ir_analyze_optional_value_payload_value(ira, source_instr, opt_stack, false); |
| 18748 | | if (type_is_invalid(stack->value->type)) |
| 18749 | | return ira->codegen->invalid_instruction; |
| 18750 | | } else { |
| 18751 | | stack = nullptr; |
| 18768 | if (type_is_invalid(stack->value->type)) |
| 18769 | return ira->codegen->invalid_instruction; |
| 18752 | 18770 | } |
| 18753 | 18771 | |
| 18754 | 18772 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, |