| ... | ... | @@ -24656,26 +24656,51 @@ static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, |
| 24656 | 24656 | return ir_build_suspend_finish(&ira->new_irb, instruction->base.scope, instruction->base.source_node, begin); |
| 24657 | 24657 | } |
| 24658 | 24658 | |
| 24659 | | static IrInstruction *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) { |
| 24660 | | IrInstruction *frame_ptr = instruction->frame->child; |
| 24659 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, |
| 24660 | IrInstruction *frame_ptr) |
| 24661 | { |
| 24661 | 24662 | if (type_is_invalid(frame_ptr->value.type)) |
| 24662 | 24663 | return ira->codegen->invalid_instruction; |
| 24663 | 24664 | |
| 24665 | ZigType *result_type; |
| 24664 | 24666 | IrInstruction *frame; |
| 24665 | 24667 | if (frame_ptr->value.type->id == ZigTypeIdPointer && |
| 24666 | 24668 | frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && |
| 24667 | 24669 | frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdCoroFrame) |
| 24668 | 24670 | { |
| 24671 | result_type = frame_ptr->value.type->data.pointer.child_type->data.frame.fn->type_entry->data.fn.fn_type_id.return_type; |
| 24669 | 24672 | frame = frame_ptr; |
| 24670 | 24673 | } else { |
| 24671 | | frame = ir_get_deref(ira, &instruction->base, frame_ptr, nullptr); |
| 24674 | frame = ir_get_deref(ira, source_instr, frame_ptr, nullptr); |
| 24675 | if (frame->value.type->id == ZigTypeIdPointer && |
| 24676 | frame->value.type->data.pointer.ptr_len == PtrLenSingle && |
| 24677 | frame->value.type->data.pointer.child_type->id == ZigTypeIdCoroFrame) |
| 24678 | { |
| 24679 | result_type = frame->value.type->data.pointer.child_type->data.frame.fn->type_entry->data.fn.fn_type_id.return_type; |
| 24680 | } else if (frame->value.type->id != ZigTypeIdAnyFrame || |
| 24681 | frame->value.type->data.any_frame.result_type == nullptr) |
| 24682 | { |
| 24683 | ir_add_error(ira, source_instr, |
| 24684 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value.type->name))); |
| 24685 | return ira->codegen->invalid_instruction; |
| 24686 | } else { |
| 24687 | result_type = frame->value.type->data.any_frame.result_type; |
| 24688 | } |
| 24672 | 24689 | } |
| 24673 | 24690 | |
| 24674 | | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 24691 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 24675 | 24692 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 24676 | 24693 | if (type_is_invalid(casted_frame->value.type)) |
| 24677 | 24694 | return ira->codegen->invalid_instruction; |
| 24678 | 24695 | |
| 24696 | return casted_frame; |
| 24697 | } |
| 24698 | |
| 24699 | static IrInstruction *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructionCancel *instruction) { |
| 24700 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, instruction->frame->child); |
| 24701 | if (type_is_invalid(frame->value.type)) |
| 24702 | return ira->codegen->invalid_instruction; |
| 24703 | |
| 24679 | 24704 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 24680 | 24705 | ir_assert(fn_entry != nullptr, &instruction->base); |
| 24681 | 24706 | |
| ... | ... | @@ -24683,38 +24708,15 @@ static IrInstruction *ir_analyze_instruction_cancel(IrAnalyze *ira, IrInstructio |
| 24683 | 24708 | fn_entry->inferred_async_node = instruction->base.source_node; |
| 24684 | 24709 | } |
| 24685 | 24710 | |
| 24686 | | return ir_build_cancel(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); |
| 24711 | return ir_build_cancel(&ira->new_irb, instruction->base.scope, instruction->base.source_node, frame); |
| 24687 | 24712 | } |
| 24688 | 24713 | |
| 24689 | 24714 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { |
| 24690 | | IrInstruction *frame_ptr = instruction->frame->child; |
| 24691 | | if (type_is_invalid(frame_ptr->value.type)) |
| 24715 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, instruction->frame->child); |
| 24716 | if (type_is_invalid(frame->value.type)) |
| 24692 | 24717 | return ira->codegen->invalid_instruction; |
| 24693 | 24718 | |
| 24694 | | ZigType *result_type; |
| 24695 | | IrInstruction *frame; |
| 24696 | | if (frame_ptr->value.type->id == ZigTypeIdPointer && |
| 24697 | | frame_ptr->value.type->data.pointer.ptr_len == PtrLenSingle && |
| 24698 | | frame_ptr->value.type->data.pointer.child_type->id == ZigTypeIdCoroFrame) |
| 24699 | | { |
| 24700 | | result_type = frame_ptr->value.type->data.pointer.child_type->data.frame.fn->type_entry->data.fn.fn_type_id.return_type; |
| 24701 | | frame = frame_ptr; |
| 24702 | | } else { |
| 24703 | | frame = ir_get_deref(ira, &instruction->base, frame_ptr, nullptr); |
| 24704 | | if (frame->value.type->id != ZigTypeIdAnyFrame || |
| 24705 | | frame->value.type->data.any_frame.result_type == nullptr) |
| 24706 | | { |
| 24707 | | ir_add_error(ira, &instruction->base, |
| 24708 | | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value.type->name))); |
| 24709 | | return ira->codegen->invalid_instruction; |
| 24710 | | } |
| 24711 | | result_type = frame->value.type->data.any_frame.result_type; |
| 24712 | | } |
| 24713 | | |
| 24714 | | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 24715 | | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 24716 | | if (type_is_invalid(casted_frame->value.type)) |
| 24717 | | return ira->codegen->invalid_instruction; |
| 24719 | ZigType *result_type = frame->value.type->data.any_frame.result_type; |
| 24718 | 24720 | |
| 24719 | 24721 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 24720 | 24722 | ir_assert(fn_entry != nullptr, &instruction->base); |