| ... | ... | @@ -5995,19 +5995,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 5995 | 5995 | return_type = fn_entry->type_entry->data.fn.fn_type_id.return_type; |
| 5996 | 5996 | IrInstruction *promise_init = ir_build_const_promise_init(irb, scope, node, return_type); |
| 5997 | 5997 | ir_build_var_decl(irb, scope, node, promise_var, nullptr, nullptr, promise_init); |
| 5998 | | |
| 5999 | 5998 | coro_promise_ptr = ir_build_var_ptr(irb, scope, node, promise_var, false, false); |
| 6000 | | Buf *awaiter_handle_field_name = buf_create_from_str(AWAITER_HANDLE_FIELD_NAME); |
| 6001 | | irb->exec->coro_awaiter_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| 6002 | | awaiter_handle_field_name); |
| 6003 | | if (type_has_bits(return_type)) { |
| 6004 | | Buf *result_field_name = buf_create_from_str(RESULT_FIELD_NAME); |
| 6005 | | coro_result_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, result_field_name); |
| 6006 | | result_ptr_field_name = buf_create_from_str(RESULT_PTR_FIELD_NAME); |
| 6007 | | irb->exec->coro_result_ptr_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| 6008 | | result_ptr_field_name); |
| 6009 | | ir_build_store_ptr(irb, scope, node, irb->exec->coro_result_ptr_field_ptr, coro_result_field_ptr); |
| 6010 | | } |
| 6011 | 5999 | |
| 6012 | 6000 | u8_ptr_type = ir_build_const_type(irb, scope, node, |
| 6013 | 6001 | get_pointer_to_type(irb->codegen, irb->codegen->builtin_types.entry_u8, false)); |
| ... | ... | @@ -6076,6 +6064,19 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 6076 | 6064 | |
| 6077 | 6065 | irb->exec->coro_handle = ir_build_coro_begin(irb, scope, node, coro_id, coro_mem); |
| 6078 | 6066 | |
| 6067 | Buf *awaiter_handle_field_name = buf_create_from_str(AWAITER_HANDLE_FIELD_NAME); |
| 6068 | irb->exec->coro_awaiter_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| 6069 | awaiter_handle_field_name); |
| 6070 | if (type_has_bits(return_type)) { |
| 6071 | Buf *result_field_name = buf_create_from_str(RESULT_FIELD_NAME); |
| 6072 | coro_result_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, result_field_name); |
| 6073 | result_ptr_field_name = buf_create_from_str(RESULT_PTR_FIELD_NAME); |
| 6074 | irb->exec->coro_result_ptr_field_ptr = ir_build_field_ptr(irb, scope, node, coro_promise_ptr, |
| 6075 | result_ptr_field_name); |
| 6076 | ir_build_store_ptr(irb, scope, node, irb->exec->coro_result_ptr_field_ptr, coro_result_field_ptr); |
| 6077 | } |
| 6078 | |
| 6079 | |
| 6079 | 6080 | irb->exec->coro_early_final = ir_create_basic_block(irb, scope, "CoroEarlyFinal"); |
| 6080 | 6081 | irb->exec->coro_normal_final = ir_create_basic_block(irb, scope, "CoroNormalFinal"); |
| 6081 | 6082 | } |