| ... | @@ -427,10 +427,6 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionUnwrapErrPayload | ... | @@ -427,10 +427,6 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionUnwrapErrPayload |
| 427 | return IrInstructionIdUnwrapErrPayload; | 427 | return IrInstructionIdUnwrapErrPayload; |
| 428 | } | 428 | } |
| 429 | | 429 | |
| 430 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrUnionTypeChild *) { | | |
| 431 | return IrInstructionIdErrUnionTypeChild; | | |
| 432 | } | | |
| 433 | | | |
| 434 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMaybeWrap *) { | 430 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMaybeWrap *) { |
| 435 | return IrInstructionIdMaybeWrap; | 431 | return IrInstructionIdMaybeWrap; |
| 436 | } | 432 | } |
| ... | @@ -1830,17 +1826,6 @@ static IrInstruction *ir_build_unwrap_err_payload_from(IrBuilder *irb, IrInstruc | ... | @@ -1830,17 +1826,6 @@ static IrInstruction *ir_build_unwrap_err_payload_from(IrBuilder *irb, IrInstruc |
| 1830 | return new_instruction; | 1826 | return new_instruction; |
| 1831 | } | 1827 | } |
| 1832 | | 1828 | |
| 1833 | static IrInstruction *ir_build_err_union_type_child(IrBuilder *irb, Scope *scope, AstNode *source_node, | | |
| 1834 | IrInstruction *type_value) | | |
| 1835 | { | | |
| 1836 | IrInstructionErrUnionTypeChild *instruction = ir_build_instruction<IrInstructionErrUnionTypeChild>(irb, scope, source_node); | | |
| 1837 | instruction->type_value = type_value; | | |
| 1838 | | | |
| 1839 | ir_ref_instruction(type_value); | | |
| 1840 | | | |
| 1841 | return &instruction->base; | | |
| 1842 | } | | |
| 1843 | | | |
| 1844 | static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { | 1829 | static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { |
| 1845 | results[ReturnKindUnconditional] = 0; | 1830 | results[ReturnKindUnconditional] = 0; |
| 1846 | results[ReturnKindError] = 0; | 1831 | results[ReturnKindError] = 0; |
| ... | @@ -3841,9 +3826,8 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN | ... | @@ -3841,9 +3826,8 @@ static IrInstruction *ir_gen_err_ok_or(IrBuilder *irb, Scope *parent_scope, AstN |
| 3841 | Scope *err_scope; | 3826 | Scope *err_scope; |
| 3842 | if (var_node) { | 3827 | if (var_node) { |
| 3843 | assert(var_node->type == NodeTypeSymbol); | 3828 | assert(var_node->type == NodeTypeSymbol); |
| 3844 | IrInstruction *err_union_ptr_type = ir_build_typeof(irb, parent_scope, var_node, err_union_ptr); | 3829 | IrInstruction *var_type = ir_build_const_type(irb, parent_scope, node, |
| 3845 | IrInstruction *err_union_type = ir_build_ptr_type_child(irb, parent_scope, var_node, err_union_ptr_type); | 3830 | irb->codegen->builtin_types.entry_pure_error); |
| 3846 | IrInstruction *var_type = ir_build_err_union_type_child(irb, parent_scope, var_node, err_union_type); | | |
| 3847 | Buf *var_name = var_node->data.symbol_expr.symbol; | 3831 | Buf *var_name = var_node->data.symbol_expr.symbol; |
| 3848 | bool is_const = true; | 3832 | bool is_const = true; |
| 3849 | bool is_shadowable = false; | 3833 | bool is_shadowable = false; |
| ... | @@ -9339,27 +9323,6 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | ... | @@ -9339,27 +9323,6 @@ static TypeTableEntry *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 9339 | | 9323 | |
| 9340 | } | 9324 | } |
| 9341 | | 9325 | |
| 9342 | static TypeTableEntry *ir_analyze_instruction_err_union_type_child(IrAnalyze *ira, | | |
| 9343 | IrInstructionErrUnionTypeChild *instruction) | | |
| 9344 | { | | |
| 9345 | IrInstruction *type_value = instruction->type_value->other; | | |
| 9346 | TypeTableEntry *type_entry = ir_resolve_type(ira, type_value); | | |
| 9347 | if (type_entry->id == TypeTableEntryIdInvalid) | | |
| 9348 | return type_entry; | | |
| 9349 | | | |
| 9350 | // TODO handle typedefs | | |
| 9351 | if (type_entry->id != TypeTableEntryIdErrorUnion) { | | |
| 9352 | add_node_error(ira->codegen, instruction->base.source_node, | | |
| 9353 | buf_sprintf("expected error type, found '%s'", buf_ptr(&type_entry->name))); | | |
| 9354 | return ira->codegen->builtin_types.entry_invalid; | | |
| 9355 | } | | |
| 9356 | | | |
| 9357 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base, | | |
| 9358 | type_value->static_value.depends_on_compile_var); | | |
| 9359 | out_val->data.x_type = type_entry->data.error.child_type; | | |
| 9360 | return ira->codegen->builtin_types.entry_type; | | |
| 9361 | } | | |
| 9362 | | | |
| 9363 | static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) { | 9326 | static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstruction *instruction) { |
| 9364 | switch (instruction->id) { | 9327 | switch (instruction->id) { |
| 9365 | case IrInstructionIdInvalid: | 9328 | case IrInstructionIdInvalid: |
| ... | @@ -9500,8 +9463,6 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi | ... | @@ -9500,8 +9463,6 @@ static TypeTableEntry *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructi |
| 9500 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstructionUnwrapErrCode *)instruction); | 9463 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstructionUnwrapErrCode *)instruction); |
| 9501 | case IrInstructionIdUnwrapErrPayload: | 9464 | case IrInstructionIdUnwrapErrPayload: |
| 9502 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstructionUnwrapErrPayload *)instruction); | 9465 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstructionUnwrapErrPayload *)instruction); |
| 9503 | case IrInstructionIdErrUnionTypeChild: | | |
| 9504 | return ir_analyze_instruction_err_union_type_child(ira, (IrInstructionErrUnionTypeChild *)instruction); | | |
| 9505 | case IrInstructionIdMaybeWrap: | 9466 | case IrInstructionIdMaybeWrap: |
| 9506 | case IrInstructionIdErrWrapCode: | 9467 | case IrInstructionIdErrWrapCode: |
| 9507 | case IrInstructionIdErrWrapPayload: | 9468 | case IrInstructionIdErrWrapPayload: |
| ... | @@ -9659,7 +9620,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { | ... | @@ -9659,7 +9620,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { |
| 9659 | case IrInstructionIdTestErr: | 9620 | case IrInstructionIdTestErr: |
| 9660 | case IrInstructionIdUnwrapErrCode: | 9621 | case IrInstructionIdUnwrapErrCode: |
| 9661 | case IrInstructionIdUnwrapErrPayload: | 9622 | case IrInstructionIdUnwrapErrPayload: |
| 9662 | case IrInstructionIdErrUnionTypeChild: | | |
| 9663 | case IrInstructionIdMaybeWrap: | 9623 | case IrInstructionIdMaybeWrap: |
| 9664 | case IrInstructionIdErrWrapCode: | 9624 | case IrInstructionIdErrWrapCode: |
| 9665 | case IrInstructionIdErrWrapPayload: | 9625 | case IrInstructionIdErrWrapPayload: |