| ... | ... | @@ -5565,6 +5565,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 5565 | 5565 | case ContainerInitKindStruct: { |
| 5566 | 5566 | src_assert(result_loc->scope_elide == nullptr, node); |
| 5567 | 5567 | result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope); |
| 5568 | |
| 5569 | src_assert(result_loc != nullptr, node); |
| 5570 | IrInstruction *container_ptr = ir_build_resolve_result(irb, &result_loc->scope_elide->base, |
| 5571 | node, result_loc, container_type); |
| 5572 | |
| 5568 | 5573 | size_t field_count = container_init_expr->entries.length; |
| 5569 | 5574 | IrInstructionContainerInitFieldsField *fields = allocate<IrInstructionContainerInitFieldsField>(field_count); |
| 5570 | 5575 | for (size_t i = 0; i < field_count; i += 1) { |
| ... | ... | @@ -5574,18 +5579,13 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 5574 | 5579 | Buf *name = entry_node->data.struct_val_field.name; |
| 5575 | 5580 | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 5576 | 5581 | |
| 5577 | | ResultLoc *child_result_loc = nullptr; |
| 5578 | | if (result_loc != nullptr) { |
| 5579 | | IrInstruction *container_ptr = ir_build_resolve_result(irb, &result_loc->scope_elide->base, |
| 5580 | | expr_node, result_loc, container_type); |
| 5581 | | IrInstruction *field_ptr = ir_build_field_ptr(irb, &result_loc->scope_elide->base, expr_node, |
| 5582 | | container_ptr, name); |
| 5583 | | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 5584 | | result_loc_inst->base.id = ResultLocIdInstruction; |
| 5585 | | result_loc_inst->base.source_instruction = field_ptr; |
| 5586 | | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 5587 | | child_result_loc = &result_loc_inst->base; |
| 5588 | | } |
| 5582 | IrInstruction *field_ptr = ir_build_field_ptr(irb, &result_loc->scope_elide->base, expr_node, |
| 5583 | container_ptr, name); |
| 5584 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 5585 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 5586 | result_loc_inst->base.source_instruction = field_ptr; |
| 5587 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 5588 | ResultLoc *child_result_loc = &result_loc_inst->base; |
| 5589 | 5589 | |
| 5590 | 5590 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, &result_loc->scope_elide->base, |
| 5591 | 5591 | LValNone, child_result_loc); |
| ... | ... | @@ -5601,11 +5601,28 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 5601 | 5601 | return ir_lval_wrap(irb, scope, init_fields, lval, result_loc); |
| 5602 | 5602 | } |
| 5603 | 5603 | case ContainerInitKindArray: { |
| 5604 | src_assert(result_loc->scope_elide == nullptr, node); |
| 5605 | result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope); |
| 5606 | |
| 5607 | src_assert(result_loc != nullptr, node); |
| 5608 | IrInstruction *container_ptr = ir_build_resolve_result(irb, &result_loc->scope_elide->base, |
| 5609 | node, result_loc, container_type); |
| 5610 | |
| 5604 | 5611 | size_t item_count = container_init_expr->entries.length; |
| 5605 | 5612 | IrInstruction **values = allocate<IrInstruction *>(item_count); |
| 5606 | 5613 | for (size_t i = 0; i < item_count; i += 1) { |
| 5607 | 5614 | AstNode *expr_node = container_init_expr->entries.at(i); |
| 5608 | | IrInstruction *expr_value = ir_gen_node(irb, expr_node, scope); |
| 5615 | |
| 5616 | IrInstruction *elem_index = ir_build_const_usize(irb, &result_loc->scope_elide->base, expr_node, i); |
| 5617 | IrInstruction *elem_ptr = ir_build_elem_ptr(irb, &result_loc->scope_elide->base, expr_node, |
| 5618 | container_ptr, elem_index, false, PtrLenSingle); |
| 5619 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 5620 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 5621 | result_loc_inst->base.source_instruction = elem_ptr; |
| 5622 | ir_ref_instruction(elem_ptr, irb->current_basic_block); |
| 5623 | ResultLoc *child_result_loc = &result_loc_inst->base; |
| 5624 | |
| 5625 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, child_result_loc); |
| 5609 | 5626 | if (expr_value == irb->codegen->invalid_instruction) |
| 5610 | 5627 | return expr_value; |
| 5611 | 5628 | |
| ... | ... | @@ -18594,11 +18611,10 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 18594 | 18611 | return ira->codegen->invalid_instruction; |
| 18595 | 18612 | } |
| 18596 | 18613 | |
| 18597 | | IrInstruction *new_instruction = ir_build_container_init_list(&ira->new_irb, |
| 18598 | | instruction->base.scope, instruction->base.source_node, |
| 18599 | | nullptr, elem_count, new_items); |
| 18600 | | new_instruction->value.type = fixed_size_array_type; |
| 18601 | | ir_add_alloca(ira, new_instruction, fixed_size_array_type); |
| 18614 | // this instruction should not get to codegen |
| 18615 | IrInstruction *new_instruction = ir_const(ira, &instruction->base, fixed_size_array_type); |
| 18616 | // this is how we signal to EndExpr the value is not comptime known |
| 18617 | new_instruction->value.special = ConstValSpecialRuntime; |
| 18602 | 18618 | return new_instruction; |
| 18603 | 18619 | } else if (container_type->id == ZigTypeIdVoid) { |
| 18604 | 18620 | if (elem_count != 0) { |