| ... | @@ -198,7 +198,7 @@ static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) { | ... | @@ -198,7 +198,7 @@ static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) { |
| 198 | | 198 | |
| 199 | ConstExprValue *const_ptr_pointee(CodeGen *g, ConstExprValue *const_val) { | 199 | ConstExprValue *const_ptr_pointee(CodeGen *g, ConstExprValue *const_val) { |
| 200 | ConstExprValue *result = const_ptr_pointee_unchecked(g, const_val); | 200 | ConstExprValue *result = const_ptr_pointee_unchecked(g, const_val); |
| 201 | if (const_val->type->id == TypeTableEntryIdPointer) { | 201 | if (const_val->type->id == ZigTypeIdPointer) { |
| 202 | assert(types_have_same_zig_comptime_repr(const_val->type->data.pointer.child_type, result->type)); | 202 | assert(types_have_same_zig_comptime_repr(const_val->type->data.pointer.child_type, result->type)); |
| 203 | } | 203 | } |
| 204 | return result; | 204 | return result; |
| ... | @@ -253,7 +253,7 @@ static bool instr_is_comptime(IrInstruction *instruction) { | ... | @@ -253,7 +253,7 @@ static bool instr_is_comptime(IrInstruction *instruction) { |
| 253 | } | 253 | } |
| 254 | | 254 | |
| 255 | static bool instr_is_unreachable(IrInstruction *instruction) { | 255 | static bool instr_is_unreachable(IrInstruction *instruction) { |
| 256 | return instruction->value.type && instruction->value.type->id == TypeTableEntryIdUnreachable; | 256 | return instruction->value.type && instruction->value.type->id == ZigTypeIdUnreachable; |
| 257 | } | 257 | } |
| 258 | | 258 | |
| 259 | static void ir_link_new_instruction(IrInstruction *new_instruction, IrInstruction *old_instruction) { | 259 | static void ir_link_new_instruction(IrInstruction *new_instruction, IrInstruction *old_instruction) { |
| ... | @@ -3072,7 +3072,7 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -3072,7 +3072,7 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 3072 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; | 3072 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; |
| 3073 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); | 3073 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); |
| 3074 | if (defer_expr_value != irb->codegen->invalid_instruction) { | 3074 | if (defer_expr_value != irb->codegen->invalid_instruction) { |
| 3075 | if (defer_expr_value->value.type != nullptr && defer_expr_value->value.type->id == TypeTableEntryIdUnreachable) { | 3075 | if (defer_expr_value->value.type != nullptr && defer_expr_value->value.type->id == ZigTypeIdUnreachable) { |
| 3076 | is_noreturn = true; | 3076 | is_noreturn = true; |
| 3077 | } else { | 3077 | } else { |
| 3078 | ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node, defer_expr_value)); | 3078 | ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node, defer_expr_value)); |
| ... | @@ -6587,10 +6587,10 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, | ... | @@ -6587,10 +6587,10 @@ static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, |
| 6587 | | 6587 | |
| 6588 | // errors should be populated with set1's values | 6588 | // errors should be populated with set1's values |
| 6589 | static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigType *set1, ZigType *set2) { | 6589 | static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigType *set1, ZigType *set2) { |
| 6590 | assert(set1->id == TypeTableEntryIdErrorSet); | 6590 | assert(set1->id == ZigTypeIdErrorSet); |
| 6591 | assert(set2->id == TypeTableEntryIdErrorSet); | 6591 | assert(set2->id == ZigTypeIdErrorSet); |
| 6592 | | 6592 | |
| 6593 | ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); | 6593 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| 6594 | buf_resize(&err_set_type->name, 0); | 6594 | buf_resize(&err_set_type->name, 0); |
| 6595 | buf_appendf(&err_set_type->name, "error{"); | 6595 | buf_appendf(&err_set_type->name, "error{"); |
| 6596 | | 6596 | |
| ... | @@ -6642,7 +6642,7 @@ static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigTyp | ... | @@ -6642,7 +6642,7 @@ static ZigType *get_error_set_union(CodeGen *g, ErrorTableEntry **errors, ZigTyp |
| 6642 | static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstNode *node, | 6642 | static ZigType *make_err_set_with_one_item(CodeGen *g, Scope *parent_scope, AstNode *node, |
| 6643 | ErrorTableEntry *err_entry) | 6643 | ErrorTableEntry *err_entry) |
| 6644 | { | 6644 | { |
| 6645 | ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); | 6645 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| 6646 | buf_resize(&err_set_type->name, 0); | 6646 | buf_resize(&err_set_type->name, 0); |
| 6647 | buf_appendf(&err_set_type->name, "error{%s}", buf_ptr(&err_entry->name)); | 6647 | buf_appendf(&err_set_type->name, "error{%s}", buf_ptr(&err_entry->name)); |
| 6648 | err_set_type->is_copyable = true; | 6648 | err_set_type->is_copyable = true; |
| ... | @@ -6664,7 +6664,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A | ... | @@ -6664,7 +6664,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A |
| 6664 | uint32_t err_count = node->data.err_set_decl.decls.length; | 6664 | uint32_t err_count = node->data.err_set_decl.decls.length; |
| 6665 | | 6665 | |
| 6666 | Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error set", node); | 6666 | Buf *type_name = get_anon_type_name(irb->codegen, irb->exec, "error set", node); |
| 6667 | ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); | 6667 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| 6668 | buf_init_from_buf(&err_set_type->name, type_name); | 6668 | buf_init_from_buf(&err_set_type->name, type_name); |
| 6669 | err_set_type->is_copyable = true; | 6669 | err_set_type->is_copyable = true; |
| 6670 | err_set_type->data.error_set.err_count = err_count; | 6670 | err_set_type->data.error_set.err_count = err_count; |
| ... | @@ -7628,7 +7628,7 @@ static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, | ... | @@ -7628,7 +7628,7 @@ static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, |
| 7628 | static ConstExprValue *ir_const_ptr_pointee(IrAnalyze *ira, ConstExprValue *const_val, AstNode *source_node) { | 7628 | static ConstExprValue *ir_const_ptr_pointee(IrAnalyze *ira, ConstExprValue *const_val, AstNode *source_node) { |
| 7629 | ConstExprValue *val = const_ptr_pointee_unchecked(ira->codegen, const_val); | 7629 | ConstExprValue *val = const_ptr_pointee_unchecked(ira->codegen, const_val); |
| 7630 | assert(val != nullptr); | 7630 | assert(val != nullptr); |
| 7631 | assert(const_val->type->id == TypeTableEntryIdPointer); | 7631 | assert(const_val->type->id == ZigTypeIdPointer); |
| 7632 | ZigType *expected_type = const_val->type->data.pointer.child_type; | 7632 | ZigType *expected_type = const_val->type->data.pointer.child_type; |
| 7633 | if (!types_have_same_zig_comptime_repr(val->type, expected_type)) { | 7633 | if (!types_have_same_zig_comptime_repr(val->type, expected_type)) { |
| 7634 | ir_add_error_node(ira, source_node, | 7634 | ir_add_error_node(ira, source_node, |
| ... | @@ -7669,16 +7669,16 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so | ... | @@ -7669,16 +7669,16 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so |
| 7669 | } | 7669 | } |
| 7670 | | 7670 | |
| 7671 | static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) { | 7671 | static bool const_val_fits_in_num_lit(ConstExprValue *const_val, ZigType *num_lit_type) { |
| 7672 | return ((num_lit_type->id == TypeTableEntryIdComptimeFloat && | 7672 | return ((num_lit_type->id == ZigTypeIdComptimeFloat && |
| 7673 | (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) || | 7673 | (const_val->type->id == ZigTypeIdFloat || const_val->type->id == ZigTypeIdComptimeFloat)) || |
| 7674 | (num_lit_type->id == TypeTableEntryIdComptimeInt && | 7674 | (num_lit_type->id == ZigTypeIdComptimeInt && |
| 7675 | (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdComptimeInt))); | 7675 | (const_val->type->id == ZigTypeIdInt || const_val->type->id == ZigTypeIdComptimeInt))); |
| 7676 | } | 7676 | } |
| 7677 | | 7677 | |
| 7678 | static bool float_has_fraction(ConstExprValue *const_val) { | 7678 | static bool float_has_fraction(ConstExprValue *const_val) { |
| 7679 | if (const_val->type->id == TypeTableEntryIdComptimeFloat) { | 7679 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 7680 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); | 7680 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); |
| 7681 | } else if (const_val->type->id == TypeTableEntryIdFloat) { | 7681 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| 7682 | switch (const_val->type->data.floating.bit_count) { | 7682 | switch (const_val->type->data.floating.bit_count) { |
| 7683 | case 16: | 7683 | case 16: |
| 7684 | { | 7684 | { |
| ... | @@ -7704,9 +7704,9 @@ static bool float_has_fraction(ConstExprValue *const_val) { | ... | @@ -7704,9 +7704,9 @@ static bool float_has_fraction(ConstExprValue *const_val) { |
| 7704 | } | 7704 | } |
| 7705 | | 7705 | |
| 7706 | static void float_append_buf(Buf *buf, ConstExprValue *const_val) { | 7706 | static void float_append_buf(Buf *buf, ConstExprValue *const_val) { |
| 7707 | if (const_val->type->id == TypeTableEntryIdComptimeFloat) { | 7707 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 7708 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); | 7708 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); |
| 7709 | } else if (const_val->type->id == TypeTableEntryIdFloat) { | 7709 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| 7710 | switch (const_val->type->data.floating.bit_count) { | 7710 | switch (const_val->type->data.floating.bit_count) { |
| 7711 | case 16: | 7711 | case 16: |
| 7712 | buf_appendf(buf, "%f", zig_f16_to_double(const_val->data.x_f16)); | 7712 | buf_appendf(buf, "%f", zig_f16_to_double(const_val->data.x_f16)); |
| ... | @@ -7742,9 +7742,9 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { | ... | @@ -7742,9 +7742,9 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { |
| 7742 | } | 7742 | } |
| 7743 | | 7743 | |
| 7744 | static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { | 7744 | static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { |
| 7745 | if (const_val->type->id == TypeTableEntryIdComptimeFloat) { | 7745 | if (const_val->type->id == ZigTypeIdComptimeFloat) { |
| 7746 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); | 7746 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); |
| 7747 | } else if (const_val->type->id == TypeTableEntryIdFloat) { | 7747 | } else if (const_val->type->id == ZigTypeIdFloat) { |
| 7748 | switch (const_val->type->data.floating.bit_count) { | 7748 | switch (const_val->type->data.floating.bit_count) { |
| 7749 | case 16: | 7749 | case 16: |
| 7750 | { | 7750 | { |
| ... | @@ -7789,9 +7789,9 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { | ... | @@ -7789,9 +7789,9 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { |
| 7789 | } | 7789 | } |
| 7790 | | 7790 | |
| 7791 | static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { | 7791 | static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { |
| 7792 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { | 7792 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 7793 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); | 7793 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); |
| 7794 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { | 7794 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| 7795 | switch (dest_val->type->data.floating.bit_count) { | 7795 | switch (dest_val->type->data.floating.bit_count) { |
| 7796 | case 16: | 7796 | case 16: |
| 7797 | dest_val->data.x_f16 = bigfloat_to_f16(bigfloat); | 7797 | dest_val->data.x_f16 = bigfloat_to_f16(bigfloat); |
| ... | @@ -7814,9 +7814,9 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { | ... | @@ -7814,9 +7814,9 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { |
| 7814 | } | 7814 | } |
| 7815 | | 7815 | |
| 7816 | static void float_init_f16(ConstExprValue *dest_val, float16_t x) { | 7816 | static void float_init_f16(ConstExprValue *dest_val, float16_t x) { |
| 7817 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { | 7817 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 7818 | bigfloat_init_16(&dest_val->data.x_bigfloat, x); | 7818 | bigfloat_init_16(&dest_val->data.x_bigfloat, x); |
| 7819 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { | 7819 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| 7820 | switch (dest_val->type->data.floating.bit_count) { | 7820 | switch (dest_val->type->data.floating.bit_count) { |
| 7821 | case 16: | 7821 | case 16: |
| 7822 | dest_val->data.x_f16 = x; | 7822 | dest_val->data.x_f16 = x; |
| ... | @@ -7839,9 +7839,9 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) { | ... | @@ -7839,9 +7839,9 @@ static void float_init_f16(ConstExprValue *dest_val, float16_t x) { |
| 7839 | } | 7839 | } |
| 7840 | | 7840 | |
| 7841 | static void float_init_f32(ConstExprValue *dest_val, float x) { | 7841 | static void float_init_f32(ConstExprValue *dest_val, float x) { |
| 7842 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { | 7842 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 7843 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); | 7843 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); |
| 7844 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { | 7844 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| 7845 | switch (dest_val->type->data.floating.bit_count) { | 7845 | switch (dest_val->type->data.floating.bit_count) { |
| 7846 | case 16: | 7846 | case 16: |
| 7847 | dest_val->data.x_f16 = zig_double_to_f16(x); | 7847 | dest_val->data.x_f16 = zig_double_to_f16(x); |
| ... | @@ -7868,9 +7868,9 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { | ... | @@ -7868,9 +7868,9 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { |
| 7868 | } | 7868 | } |
| 7869 | | 7869 | |
| 7870 | static void float_init_f64(ConstExprValue *dest_val, double x) { | 7870 | static void float_init_f64(ConstExprValue *dest_val, double x) { |
| 7871 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { | 7871 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 7872 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); | 7872 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); |
| 7873 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { | 7873 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| 7874 | switch (dest_val->type->data.floating.bit_count) { | 7874 | switch (dest_val->type->data.floating.bit_count) { |
| 7875 | case 16: | 7875 | case 16: |
| 7876 | dest_val->data.x_f16 = zig_double_to_f16(x); | 7876 | dest_val->data.x_f16 = zig_double_to_f16(x); |
| ... | @@ -7897,9 +7897,9 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { | ... | @@ -7897,9 +7897,9 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { |
| 7897 | } | 7897 | } |
| 7898 | | 7898 | |
| 7899 | static void float_init_f128(ConstExprValue *dest_val, float128_t x) { | 7899 | static void float_init_f128(ConstExprValue *dest_val, float128_t x) { |
| 7900 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { | 7900 | if (dest_val->type->id == ZigTypeIdComptimeFloat) { |
| 7901 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); | 7901 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); |
| 7902 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { | 7902 | } else if (dest_val->type->id == ZigTypeIdFloat) { |
| 7903 | switch (dest_val->type->data.floating.bit_count) { | 7903 | switch (dest_val->type->data.floating.bit_count) { |
| 7904 | case 16: | 7904 | case 16: |
| 7905 | dest_val->data.x_f16 = f128M_to_f16(&x); | 7905 | dest_val->data.x_f16 = f128M_to_f16(&x); |
| ... | @@ -7930,9 +7930,9 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { | ... | @@ -7930,9 +7930,9 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { |
| 7930 | } | 7930 | } |
| 7931 | | 7931 | |
| 7932 | static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) { | 7932 | static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) { |
| 7933 | if (src_val->type->id == TypeTableEntryIdComptimeFloat) { | 7933 | if (src_val->type->id == ZigTypeIdComptimeFloat) { |
| 7934 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); | 7934 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); |
| 7935 | } else if (src_val->type->id == TypeTableEntryIdFloat) { | 7935 | } else if (src_val->type->id == ZigTypeIdFloat) { |
| 7936 | switch (src_val->type->data.floating.bit_count) { | 7936 | switch (src_val->type->data.floating.bit_count) { |
| 7937 | case 16: | 7937 | case 16: |
| 7938 | float_init_f16(dest_val, src_val->data.x_f16); | 7938 | float_init_f16(dest_val, src_val->data.x_f16); |
| ... | @@ -7956,9 +7956,9 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) | ... | @@ -7956,9 +7956,9 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) |
| 7956 | | 7956 | |
| 7957 | static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { | 7957 | static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { |
| 7958 | assert(op1->type == op2->type); | 7958 | assert(op1->type == op2->type); |
| 7959 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 7959 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 7960 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); | 7960 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7961 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 7961 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 7962 | switch (op1->type->data.floating.bit_count) { | 7962 | switch (op1->type->data.floating.bit_count) { |
| 7963 | case 16: | 7963 | case 16: |
| 7964 | if (f16_lt(op1->data.x_f16, op2->data.x_f16)) { | 7964 | if (f16_lt(op1->data.x_f16, op2->data.x_f16)) { |
| ... | @@ -8001,9 +8001,9 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { | ... | @@ -8001,9 +8001,9 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { |
| 8001 | } | 8001 | } |
| 8002 | | 8002 | |
| 8003 | static Cmp float_cmp_zero(ConstExprValue *op) { | 8003 | static Cmp float_cmp_zero(ConstExprValue *op) { |
| 8004 | if (op->type->id == TypeTableEntryIdComptimeFloat) { | 8004 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 8005 | return bigfloat_cmp_zero(&op->data.x_bigfloat); | 8005 | return bigfloat_cmp_zero(&op->data.x_bigfloat); |
| 8006 | } else if (op->type->id == TypeTableEntryIdFloat) { | 8006 | } else if (op->type->id == ZigTypeIdFloat) { |
| 8007 | switch (op->type->data.floating.bit_count) { | 8007 | switch (op->type->data.floating.bit_count) { |
| 8008 | case 16: | 8008 | case 16: |
| 8009 | { | 8009 | { |
| ... | @@ -8053,9 +8053,9 @@ static Cmp float_cmp_zero(ConstExprValue *op) { | ... | @@ -8053,9 +8053,9 @@ static Cmp float_cmp_zero(ConstExprValue *op) { |
| 8053 | static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8053 | static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8054 | assert(op1->type == op2->type); | 8054 | assert(op1->type == op2->type); |
| 8055 | out_val->type = op1->type; | 8055 | out_val->type = op1->type; |
| 8056 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8056 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8057 | bigfloat_add(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8057 | bigfloat_add(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8058 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8058 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8059 | switch (op1->type->data.floating.bit_count) { | 8059 | switch (op1->type->data.floating.bit_count) { |
| 8060 | case 16: | 8060 | case 16: |
| 8061 | out_val->data.x_f16 = f16_add(op1->data.x_f16, op2->data.x_f16); | 8061 | out_val->data.x_f16 = f16_add(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8080,9 +8080,9 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -8080,9 +8080,9 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 8080 | static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8080 | static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8081 | assert(op1->type == op2->type); | 8081 | assert(op1->type == op2->type); |
| 8082 | out_val->type = op1->type; | 8082 | out_val->type = op1->type; |
| 8083 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8083 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8084 | bigfloat_sub(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8084 | bigfloat_sub(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8085 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8085 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8086 | switch (op1->type->data.floating.bit_count) { | 8086 | switch (op1->type->data.floating.bit_count) { |
| 8087 | case 16: | 8087 | case 16: |
| 8088 | out_val->data.x_f16 = f16_sub(op1->data.x_f16, op2->data.x_f16); | 8088 | out_val->data.x_f16 = f16_sub(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8107,9 +8107,9 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -8107,9 +8107,9 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 8107 | static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8107 | static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8108 | assert(op1->type == op2->type); | 8108 | assert(op1->type == op2->type); |
| 8109 | out_val->type = op1->type; | 8109 | out_val->type = op1->type; |
| 8110 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8110 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8111 | bigfloat_mul(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8111 | bigfloat_mul(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8112 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8112 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8113 | switch (op1->type->data.floating.bit_count) { | 8113 | switch (op1->type->data.floating.bit_count) { |
| 8114 | case 16: | 8114 | case 16: |
| 8115 | out_val->data.x_f16 = f16_mul(op1->data.x_f16, op2->data.x_f16); | 8115 | out_val->data.x_f16 = f16_mul(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8134,9 +8134,9 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -8134,9 +8134,9 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 8134 | static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8134 | static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8135 | assert(op1->type == op2->type); | 8135 | assert(op1->type == op2->type); |
| 8136 | out_val->type = op1->type; | 8136 | out_val->type = op1->type; |
| 8137 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8137 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8138 | bigfloat_div(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8138 | bigfloat_div(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8139 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8139 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8140 | switch (op1->type->data.floating.bit_count) { | 8140 | switch (op1->type->data.floating.bit_count) { |
| 8141 | case 16: | 8141 | case 16: |
| 8142 | out_val->data.x_f16 = f16_div(op1->data.x_f16, op2->data.x_f16); | 8142 | out_val->data.x_f16 = f16_div(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8161,9 +8161,9 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -8161,9 +8161,9 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 8161 | static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8161 | static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8162 | assert(op1->type == op2->type); | 8162 | assert(op1->type == op2->type); |
| 8163 | out_val->type = op1->type; | 8163 | out_val->type = op1->type; |
| 8164 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8164 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8165 | bigfloat_div_trunc(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8165 | bigfloat_div_trunc(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8166 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8166 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8167 | switch (op1->type->data.floating.bit_count) { | 8167 | switch (op1->type->data.floating.bit_count) { |
| 8168 | case 16: | 8168 | case 16: |
| 8169 | out_val->data.x_f16 = f16_div(op1->data.x_f16, op2->data.x_f16); | 8169 | out_val->data.x_f16 = f16_div(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8190,9 +8190,9 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE | ... | @@ -8190,9 +8190,9 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 8190 | static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8190 | static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8191 | assert(op1->type == op2->type); | 8191 | assert(op1->type == op2->type); |
| 8192 | out_val->type = op1->type; | 8192 | out_val->type = op1->type; |
| 8193 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8193 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8194 | bigfloat_div_floor(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8194 | bigfloat_div_floor(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8195 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8195 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8196 | switch (op1->type->data.floating.bit_count) { | 8196 | switch (op1->type->data.floating.bit_count) { |
| 8197 | case 16: | 8197 | case 16: |
| 8198 | out_val->data.x_f16 = f16_div(op1->data.x_f16, op2->data.x_f16); | 8198 | out_val->data.x_f16 = f16_div(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8219,9 +8219,9 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE | ... | @@ -8219,9 +8219,9 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 8219 | static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8219 | static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8220 | assert(op1->type == op2->type); | 8220 | assert(op1->type == op2->type); |
| 8221 | out_val->type = op1->type; | 8221 | out_val->type = op1->type; |
| 8222 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8222 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8223 | bigfloat_rem(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8223 | bigfloat_rem(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8224 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8224 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8225 | switch (op1->type->data.floating.bit_count) { | 8225 | switch (op1->type->data.floating.bit_count) { |
| 8226 | case 16: | 8226 | case 16: |
| 8227 | out_val->data.x_f16 = f16_rem(op1->data.x_f16, op2->data.x_f16); | 8227 | out_val->data.x_f16 = f16_rem(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8264,9 +8264,9 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t* | ... | @@ -8264,9 +8264,9 @@ static void zig_f128M_mod(const float128_t* a, const float128_t* b, float128_t* |
| 8264 | static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { | 8264 | static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 8265 | assert(op1->type == op2->type); | 8265 | assert(op1->type == op2->type); |
| 8266 | out_val->type = op1->type; | 8266 | out_val->type = op1->type; |
| 8267 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { | 8267 | if (op1->type->id == ZigTypeIdComptimeFloat) { |
| 8268 | bigfloat_mod(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); | 8268 | bigfloat_mod(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 8269 | } else if (op1->type->id == TypeTableEntryIdFloat) { | 8269 | } else if (op1->type->id == ZigTypeIdFloat) { |
| 8270 | switch (op1->type->data.floating.bit_count) { | 8270 | switch (op1->type->data.floating.bit_count) { |
| 8271 | case 16: | 8271 | case 16: |
| 8272 | out_val->data.x_f16 = zig_f16_mod(op1->data.x_f16, op2->data.x_f16); | 8272 | out_val->data.x_f16 = zig_f16_mod(op1->data.x_f16, op2->data.x_f16); |
| ... | @@ -8290,9 +8290,9 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal | ... | @@ -8290,9 +8290,9 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 8290 | | 8290 | |
| 8291 | static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { | 8291 | static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { |
| 8292 | out_val->type = op->type; | 8292 | out_val->type = op->type; |
| 8293 | if (op->type->id == TypeTableEntryIdComptimeFloat) { | 8293 | if (op->type->id == ZigTypeIdComptimeFloat) { |
| 8294 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); | 8294 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); |
| 8295 | } else if (op->type->id == TypeTableEntryIdFloat) { | 8295 | } else if (op->type->id == ZigTypeIdFloat) { |
| 8296 | switch (op->type->data.floating.bit_count) { | 8296 | switch (op->type->data.floating.bit_count) { |
| 8297 | case 16: | 8297 | case 16: |
| 8298 | { | 8298 | { |
| ... | @@ -8320,7 +8320,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { | ... | @@ -8320,7 +8320,7 @@ static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { |
| 8320 | } | 8320 | } |
| 8321 | | 8321 | |
| 8322 | void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { | 8322 | void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { |
| 8323 | if (op->type->id == TypeTableEntryIdFloat) { | 8323 | if (op->type->id == ZigTypeIdFloat) { |
| 8324 | switch (op->type->data.floating.bit_count) { | 8324 | switch (op->type->data.floating.bit_count) { |
| 8325 | case 16: | 8325 | case 16: |
| 8326 | memcpy(buf, &op->data.x_f16, 2); // TODO wrong when compiler is big endian | 8326 | memcpy(buf, &op->data.x_f16, 2); // TODO wrong when compiler is big endian |
| ... | @@ -8343,7 +8343,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { | ... | @@ -8343,7 +8343,7 @@ void float_write_ieee597(ConstExprValue *op, uint8_t *buf, bool is_big_endian) { |
| 8343 | } | 8343 | } |
| 8344 | | 8344 | |
| 8345 | void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) { | 8345 | void float_read_ieee597(ConstExprValue *val, uint8_t *buf, bool is_big_endian) { |
| 8346 | if (val->type->id == TypeTableEntryIdFloat) { | 8346 | if (val->type->id == ZigTypeIdFloat) { |
| 8347 | switch (val->type->data.floating.bit_count) { | 8347 | switch (val->type->data.floating.bit_count) { |
| 8348 | case 16: | 8348 | case 16: |
| 8349 | memcpy(&val->data.x_f16, buf, 2); // TODO wrong when compiler is big endian | 8349 | memcpy(&val->data.x_f16, buf, 2); // TODO wrong when compiler is big endian |
| ... | @@ -8375,13 +8375,13 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -8375,13 +8375,13 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 8375 | ConstExprValue *const_val = &instruction->value; | 8375 | ConstExprValue *const_val = &instruction->value; |
| 8376 | assert(const_val->special != ConstValSpecialRuntime); | 8376 | assert(const_val->special != ConstValSpecialRuntime); |
| 8377 | | 8377 | |
| 8378 | bool const_val_is_int = (const_val->type->id == TypeTableEntryIdInt || | 8378 | bool const_val_is_int = (const_val->type->id == ZigTypeIdInt || |
| 8379 | const_val->type->id == TypeTableEntryIdComptimeInt); | 8379 | const_val->type->id == ZigTypeIdComptimeInt); |
| 8380 | bool const_val_is_float = (const_val->type->id == TypeTableEntryIdFloat || | 8380 | bool const_val_is_float = (const_val->type->id == ZigTypeIdFloat || |
| 8381 | const_val->type->id == TypeTableEntryIdComptimeFloat); | 8381 | const_val->type->id == ZigTypeIdComptimeFloat); |
| 8382 | if (other_type->id == TypeTableEntryIdFloat) { | 8382 | if (other_type->id == ZigTypeIdFloat) { |
| 8383 | return true; | 8383 | return true; |
| 8384 | } else if (other_type->id == TypeTableEntryIdInt && const_val_is_int) { | 8384 | } else if (other_type->id == ZigTypeIdInt && const_val_is_int) { |
| 8385 | if (!other_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { | 8385 | if (!other_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { |
| 8386 | Buf *val_buf = buf_alloc(); | 8386 | Buf *val_buf = buf_alloc(); |
| 8387 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 8387 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| ... | @@ -8398,11 +8398,11 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -8398,11 +8398,11 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 8398 | } | 8398 | } |
| 8399 | } else if (const_val_fits_in_num_lit(const_val, other_type)) { | 8399 | } else if (const_val_fits_in_num_lit(const_val, other_type)) { |
| 8400 | return true; | 8400 | return true; |
| 8401 | } else if (other_type->id == TypeTableEntryIdOptional) { | 8401 | } else if (other_type->id == ZigTypeIdOptional) { |
| 8402 | ZigType *child_type = other_type->data.maybe.child_type; | 8402 | ZigType *child_type = other_type->data.maybe.child_type; |
| 8403 | if (const_val_fits_in_num_lit(const_val, child_type)) { | 8403 | if (const_val_fits_in_num_lit(const_val, child_type)) { |
| 8404 | return true; | 8404 | return true; |
| 8405 | } else if (child_type->id == TypeTableEntryIdInt && const_val_is_int) { | 8405 | } else if (child_type->id == ZigTypeIdInt && const_val_is_int) { |
| 8406 | if (!child_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { | 8406 | if (!child_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { |
| 8407 | Buf *val_buf = buf_alloc(); | 8407 | Buf *val_buf = buf_alloc(); |
| 8408 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 8408 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| ... | @@ -8418,11 +8418,11 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -8418,11 +8418,11 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 8418 | { | 8418 | { |
| 8419 | return true; | 8419 | return true; |
| 8420 | } | 8420 | } |
| 8421 | } else if (child_type->id == TypeTableEntryIdFloat && const_val_is_float) { | 8421 | } else if (child_type->id == ZigTypeIdFloat && const_val_is_float) { |
| 8422 | return true; | 8422 | return true; |
| 8423 | } | 8423 | } |
| 8424 | } | 8424 | } |
| 8425 | if (explicit_cast && (other_type->id == TypeTableEntryIdInt || other_type->id == TypeTableEntryIdComptimeInt) && | 8425 | if (explicit_cast && (other_type->id == ZigTypeIdInt || other_type->id == ZigTypeIdComptimeInt) && |
| 8426 | const_val_is_float) | 8426 | const_val_is_float) |
| 8427 | { | 8427 | { |
| 8428 | if (float_has_fraction(const_val)) { | 8428 | if (float_has_fraction(const_val)) { |
| ... | @@ -8435,7 +8435,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -8435,7 +8435,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 8435 | buf_ptr(&other_type->name))); | 8435 | buf_ptr(&other_type->name))); |
| 8436 | return false; | 8436 | return false; |
| 8437 | } else { | 8437 | } else { |
| 8438 | if (other_type->id == TypeTableEntryIdComptimeInt) { | 8438 | if (other_type->id == ZigTypeIdComptimeInt) { |
| 8439 | return true; | 8439 | return true; |
| 8440 | } else { | 8440 | } else { |
| 8441 | BigInt bigint; | 8441 | BigInt bigint; |
| ... | @@ -8468,7 +8468,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -8468,7 +8468,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 8468 | } | 8468 | } |
| 8469 | | 8469 | |
| 8470 | static bool is_slice(ZigType *type) { | 8470 | static bool is_slice(ZigType *type) { |
| 8471 | return type->id == TypeTableEntryIdStruct && type->data.structure.is_slice; | 8471 | return type->id == ZigTypeIdStruct && type->data.structure.is_slice; |
| 8472 | } | 8472 | } |
| 8473 | | 8473 | |
| 8474 | static bool slice_is_const(ZigType *type) { | 8474 | static bool slice_is_const(ZigType *type) { |
| ... | @@ -8479,8 +8479,8 @@ static bool slice_is_const(ZigType *type) { | ... | @@ -8479,8 +8479,8 @@ static bool slice_is_const(ZigType *type) { |
| 8479 | static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigType *set2, | 8479 | static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigType *set2, |
| 8480 | AstNode *source_node) | 8480 | AstNode *source_node) |
| 8481 | { | 8481 | { |
| 8482 | assert(set1->id == TypeTableEntryIdErrorSet); | 8482 | assert(set1->id == ZigTypeIdErrorSet); |
| 8483 | assert(set2->id == TypeTableEntryIdErrorSet); | 8483 | assert(set2->id == ZigTypeIdErrorSet); |
| 8484 | | 8484 | |
| 8485 | if (!resolve_inferred_error_set(ira->codegen, set1, source_node)) { | 8485 | if (!resolve_inferred_error_set(ira->codegen, set1, source_node)) { |
| 8486 | return ira->codegen->builtin_types.entry_invalid; | 8486 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -8502,7 +8502,7 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp | ... | @@ -8502,7 +8502,7 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp |
| 8502 | } | 8502 | } |
| 8503 | ZigList<ErrorTableEntry *> intersection_list = {}; | 8503 | ZigList<ErrorTableEntry *> intersection_list = {}; |
| 8504 | | 8504 | |
| 8505 | ZigType *err_set_type = new_type_table_entry(TypeTableEntryIdErrorSet); | 8505 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| 8506 | buf_resize(&err_set_type->name, 0); | 8506 | buf_resize(&err_set_type->name, 0); |
| 8507 | buf_appendf(&err_set_type->name, "error{"); | 8507 | buf_appendf(&err_set_type->name, "error{"); |
| 8508 | | 8508 | |
| ... | @@ -8544,9 +8544,9 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8544,9 +8544,9 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8544 | // *T and [*]T may const-cast-only to ?*U and ?[*]U, respectively | 8544 | // *T and [*]T may const-cast-only to ?*U and ?[*]U, respectively |
| 8545 | // but not if we want a mutable pointer | 8545 | // but not if we want a mutable pointer |
| 8546 | // and not if the actual pointer has zero bits | 8546 | // and not if the actual pointer has zero bits |
| 8547 | if (!wanted_is_mutable && wanted_type->id == TypeTableEntryIdOptional && | 8547 | if (!wanted_is_mutable && wanted_type->id == ZigTypeIdOptional && |
| 8548 | wanted_type->data.maybe.child_type->id == TypeTableEntryIdPointer && | 8548 | wanted_type->data.maybe.child_type->id == ZigTypeIdPointer && |
| 8549 | actual_type->id == TypeTableEntryIdPointer && type_has_bits(actual_type)) | 8549 | actual_type->id == ZigTypeIdPointer && type_has_bits(actual_type)) |
| 8550 | { | 8550 | { |
| 8551 | ConstCastOnly child = types_match_const_cast_only(ira, | 8551 | ConstCastOnly child = types_match_const_cast_only(ira, |
| 8552 | wanted_type->data.maybe.child_type, actual_type, source_node, wanted_is_mutable); | 8552 | wanted_type->data.maybe.child_type, actual_type, source_node, wanted_is_mutable); |
| ... | @@ -8559,10 +8559,10 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8559,10 +8559,10 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8559 | } | 8559 | } |
| 8560 | | 8560 | |
| 8561 | // *T and [*]T can always cast to *c_void | 8561 | // *T and [*]T can always cast to *c_void |
| 8562 | if (wanted_type->id == TypeTableEntryIdPointer && | 8562 | if (wanted_type->id == ZigTypeIdPointer && |
| 8563 | wanted_type->data.pointer.ptr_len == PtrLenSingle && | 8563 | wanted_type->data.pointer.ptr_len == PtrLenSingle && |
| 8564 | wanted_type->data.pointer.child_type == g->builtin_types.entry_c_void && | 8564 | wanted_type->data.pointer.child_type == g->builtin_types.entry_c_void && |
| 8565 | actual_type->id == TypeTableEntryIdPointer && | 8565 | actual_type->id == ZigTypeIdPointer && |
| 8566 | (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) && | 8566 | (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) && |
| 8567 | (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile)) | 8567 | (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile)) |
| 8568 | { | 8568 | { |
| ... | @@ -8571,7 +8571,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8571,7 +8571,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8571 | } | 8571 | } |
| 8572 | | 8572 | |
| 8573 | // pointer const | 8573 | // pointer const |
| 8574 | if (wanted_type->id == TypeTableEntryIdPointer && actual_type->id == TypeTableEntryIdPointer) { | 8574 | if (wanted_type->id == ZigTypeIdPointer && actual_type->id == ZigTypeIdPointer) { |
| 8575 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, | 8575 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 8576 | actual_type->data.pointer.child_type, source_node, !wanted_type->data.pointer.is_const); | 8576 | actual_type->data.pointer.child_type, source_node, !wanted_type->data.pointer.is_const); |
| 8577 | if (child.id != ConstCastResultIdOk) { | 8577 | if (child.id != ConstCastResultIdOk) { |
| ... | @@ -8617,7 +8617,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8617,7 +8617,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8617 | } | 8617 | } |
| 8618 | | 8618 | |
| 8619 | // maybe | 8619 | // maybe |
| 8620 | if (wanted_type->id == TypeTableEntryIdOptional && actual_type->id == TypeTableEntryIdOptional) { | 8620 | if (wanted_type->id == ZigTypeIdOptional && actual_type->id == ZigTypeIdOptional) { |
| 8621 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_type->data.maybe.child_type, | 8621 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_type->data.maybe.child_type, |
| 8622 | actual_type->data.maybe.child_type, source_node, wanted_is_mutable); | 8622 | actual_type->data.maybe.child_type, source_node, wanted_is_mutable); |
| 8623 | if (child.id != ConstCastResultIdOk) { | 8623 | if (child.id != ConstCastResultIdOk) { |
| ... | @@ -8631,7 +8631,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8631,7 +8631,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8631 | } | 8631 | } |
| 8632 | | 8632 | |
| 8633 | // error union | 8633 | // error union |
| 8634 | if (wanted_type->id == TypeTableEntryIdErrorUnion && actual_type->id == TypeTableEntryIdErrorUnion) { | 8634 | if (wanted_type->id == ZigTypeIdErrorUnion && actual_type->id == ZigTypeIdErrorUnion) { |
| 8635 | ConstCastOnly payload_child = types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, | 8635 | ConstCastOnly payload_child = types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, |
| 8636 | actual_type->data.error_union.payload_type, source_node, wanted_is_mutable); | 8636 | actual_type->data.error_union.payload_type, source_node, wanted_is_mutable); |
| 8637 | if (payload_child.id != ConstCastResultIdOk) { | 8637 | if (payload_child.id != ConstCastResultIdOk) { |
| ... | @@ -8656,7 +8656,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8656,7 +8656,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8656 | } | 8656 | } |
| 8657 | | 8657 | |
| 8658 | // error set | 8658 | // error set |
| 8659 | if (wanted_type->id == TypeTableEntryIdErrorSet && actual_type->id == TypeTableEntryIdErrorSet) { | 8659 | if (wanted_type->id == ZigTypeIdErrorSet && actual_type->id == ZigTypeIdErrorSet) { |
| 8660 | ZigType *contained_set = actual_type; | 8660 | ZigType *contained_set = actual_type; |
| 8661 | ZigType *container_set = wanted_type; | 8661 | ZigType *container_set = wanted_type; |
| 8662 | | 8662 | |
| ... | @@ -8701,14 +8701,14 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8701,14 +8701,14 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8701 | } | 8701 | } |
| 8702 | | 8702 | |
| 8703 | if (wanted_type == ira->codegen->builtin_types.entry_promise && | 8703 | if (wanted_type == ira->codegen->builtin_types.entry_promise && |
| 8704 | actual_type->id == TypeTableEntryIdPromise) | 8704 | actual_type->id == ZigTypeIdPromise) |
| 8705 | { | 8705 | { |
| 8706 | return result; | 8706 | return result; |
| 8707 | } | 8707 | } |
| 8708 | | 8708 | |
| 8709 | // fn | 8709 | // fn |
| 8710 | if (wanted_type->id == TypeTableEntryIdFn && | 8710 | if (wanted_type->id == ZigTypeIdFn && |
| 8711 | actual_type->id == TypeTableEntryIdFn) | 8711 | actual_type->id == ZigTypeIdFn) |
| 8712 | { | 8712 | { |
| 8713 | if (wanted_type->data.fn.fn_type_id.alignment > actual_type->data.fn.fn_type_id.alignment) { | 8713 | if (wanted_type->data.fn.fn_type_id.alignment > actual_type->data.fn.fn_type_id.alignment) { |
| 8714 | result.id = ConstCastResultIdFnAlign; | 8714 | result.id = ConstCastResultIdFnAlign; |
| ... | @@ -8727,7 +8727,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted | ... | @@ -8727,7 +8727,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8727 | return result; | 8727 | return result; |
| 8728 | } | 8728 | } |
| 8729 | if (!wanted_type->data.fn.is_generic && | 8729 | if (!wanted_type->data.fn.is_generic && |
| 8730 | actual_type->data.fn.fn_type_id.return_type->id != TypeTableEntryIdUnreachable) | 8730 | actual_type->data.fn.fn_type_id.return_type->id != ZigTypeIdUnreachable) |
| 8731 | { | 8731 | { |
| 8732 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_type->data.fn.fn_type_id.return_type, | 8732 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_type->data.fn.fn_type_id.return_type, |
| 8733 | actual_type->data.fn.fn_type_id.return_type, source_node, false); | 8733 | actual_type->data.fn.fn_type_id.return_type, source_node, false); |
| ... | @@ -8807,7 +8807,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -8807,7 +8807,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 8807 | ErrorTableEntry **errors = nullptr; | 8807 | ErrorTableEntry **errors = nullptr; |
| 8808 | size_t errors_count = 0; | 8808 | size_t errors_count = 0; |
| 8809 | ZigType *err_set_type = nullptr; | 8809 | ZigType *err_set_type = nullptr; |
| 8810 | if (prev_inst->value.type->id == TypeTableEntryIdErrorSet) { | 8810 | if (prev_inst->value.type->id == ZigTypeIdErrorSet) { |
| 8811 | if (type_is_global_error_set(prev_inst->value.type)) { | 8811 | if (type_is_global_error_set(prev_inst->value.type)) { |
| 8812 | err_set_type = ira->codegen->builtin_types.entry_global_error_set; | 8812 | err_set_type = ira->codegen->builtin_types.entry_global_error_set; |
| 8813 | } else { | 8813 | } else { |
| ... | @@ -8825,7 +8825,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -8825,7 +8825,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 8825 | } | 8825 | } |
| 8826 | } | 8826 | } |
| 8827 | | 8827 | |
| 8828 | bool any_are_null = (prev_inst->value.type->id == TypeTableEntryIdNull); | 8828 | bool any_are_null = (prev_inst->value.type->id == ZigTypeIdNull); |
| 8829 | bool convert_to_const_slice = false; | 8829 | bool convert_to_const_slice = false; |
| 8830 | for (size_t i = 1; i < instruction_count; i += 1) { | 8830 | for (size_t i = 1; i < instruction_count; i += 1) { |
| 8831 | IrInstruction *cur_inst = instructions[i]; | 8831 | IrInstruction *cur_inst = instructions[i]; |
| ... | @@ -8836,18 +8836,18 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -8836,18 +8836,18 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 8836 | return cur_type; | 8836 | return cur_type; |
| 8837 | } | 8837 | } |
| 8838 | | 8838 | |
| 8839 | if (prev_type->id == TypeTableEntryIdUnreachable) { | 8839 | if (prev_type->id == ZigTypeIdUnreachable) { |
| 8840 | prev_inst = cur_inst; | 8840 | prev_inst = cur_inst; |
| 8841 | continue; | 8841 | continue; |
| 8842 | } | 8842 | } |
| 8843 | | 8843 | |
| 8844 | if (cur_type->id == TypeTableEntryIdUnreachable) { | 8844 | if (cur_type->id == ZigTypeIdUnreachable) { |
| 8845 | continue; | 8845 | continue; |
| 8846 | } | 8846 | } |
| 8847 | | 8847 | |
| 8848 | if (prev_type->id == TypeTableEntryIdErrorSet) { | 8848 | if (prev_type->id == ZigTypeIdErrorSet) { |
| 8849 | assert(err_set_type != nullptr); | 8849 | assert(err_set_type != nullptr); |
| 8850 | if (cur_type->id == TypeTableEntryIdErrorSet) { | 8850 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 8851 | if (type_is_global_error_set(err_set_type)) { | 8851 | if (type_is_global_error_set(err_set_type)) { |
| 8852 | continue; | 8852 | continue; |
| 8853 | } | 8853 | } |
| ... | @@ -8911,7 +8911,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -8911,7 +8911,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 8911 | err_set_type = get_error_set_union(ira->codegen, errors, cur_type, err_set_type); | 8911 | err_set_type = get_error_set_union(ira->codegen, errors, cur_type, err_set_type); |
| 8912 | assert(errors != nullptr); | 8912 | assert(errors != nullptr); |
| 8913 | continue; | 8913 | continue; |
| 8914 | } else if (cur_type->id == TypeTableEntryIdErrorUnion) { | 8914 | } else if (cur_type->id == ZigTypeIdErrorUnion) { |
| 8915 | if (type_is_global_error_set(err_set_type)) { | 8915 | if (type_is_global_error_set(err_set_type)) { |
| 8916 | prev_inst = cur_inst; | 8916 | prev_inst = cur_inst; |
| 8917 | continue; | 8917 | continue; |
| ... | @@ -8969,8 +8969,8 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -8969,8 +8969,8 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 8969 | } | 8969 | } |
| 8970 | } | 8970 | } |
| 8971 | | 8971 | |
| 8972 | if (cur_type->id == TypeTableEntryIdErrorSet) { | 8972 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 8973 | if (prev_type->id == TypeTableEntryIdArray) { | 8973 | if (prev_type->id == ZigTypeIdArray) { |
| 8974 | convert_to_const_slice = true; | 8974 | convert_to_const_slice = true; |
| 8975 | } | 8975 | } |
| 8976 | if (type_is_global_error_set(cur_type)) { | 8976 | if (type_is_global_error_set(cur_type)) { |
| ... | @@ -8987,7 +8987,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -8987,7 +8987,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 8987 | update_errors_helper(ira->codegen, &errors, &errors_count); | 8987 | update_errors_helper(ira->codegen, &errors, &errors_count); |
| 8988 | | 8988 | |
| 8989 | if (err_set_type == nullptr) { | 8989 | if (err_set_type == nullptr) { |
| 8990 | if (prev_type->id == TypeTableEntryIdErrorUnion) { | 8990 | if (prev_type->id == ZigTypeIdErrorUnion) { |
| 8991 | err_set_type = prev_type->data.error_union.err_set_type; | 8991 | err_set_type = prev_type->data.error_union.err_set_type; |
| 8992 | } else { | 8992 | } else { |
| 8993 | err_set_type = cur_type; | 8993 | err_set_type = cur_type; |
| ... | @@ -9020,7 +9020,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9020,7 +9020,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9020 | continue; | 9020 | continue; |
| 9021 | } | 9021 | } |
| 9022 | | 9022 | |
| 9023 | if (prev_type->id == TypeTableEntryIdErrorUnion && cur_type->id == TypeTableEntryIdErrorUnion) { | 9023 | if (prev_type->id == ZigTypeIdErrorUnion && cur_type->id == ZigTypeIdErrorUnion) { |
| 9024 | ZigType *prev_payload_type = prev_type->data.error_union.payload_type; | 9024 | ZigType *prev_payload_type = prev_type->data.error_union.payload_type; |
| 9025 | ZigType *cur_payload_type = cur_type->data.error_union.payload_type; | 9025 | ZigType *cur_payload_type = cur_type->data.error_union.payload_type; |
| 9026 | | 9026 | |
| ... | @@ -9104,12 +9104,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9104,12 +9104,12 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9104 | } | 9104 | } |
| 9105 | } | 9105 | } |
| 9106 | | 9106 | |
| 9107 | if (prev_type->id == TypeTableEntryIdNull) { | 9107 | if (prev_type->id == ZigTypeIdNull) { |
| 9108 | prev_inst = cur_inst; | 9108 | prev_inst = cur_inst; |
| 9109 | continue; | 9109 | continue; |
| 9110 | } | 9110 | } |
| 9111 | | 9111 | |
| 9112 | if (cur_type->id == TypeTableEntryIdNull) { | 9112 | if (cur_type->id == ZigTypeIdNull) { |
| 9113 | any_are_null = true; | 9113 | any_are_null = true; |
| 9114 | continue; | 9114 | continue; |
| 9115 | } | 9115 | } |
| ... | @@ -9123,8 +9123,8 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9123,8 +9123,8 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9123 | continue; | 9123 | continue; |
| 9124 | } | 9124 | } |
| 9125 | | 9125 | |
| 9126 | if (prev_type->id == TypeTableEntryIdInt && | 9126 | if (prev_type->id == ZigTypeIdInt && |
| 9127 | cur_type->id == TypeTableEntryIdInt && | 9127 | cur_type->id == ZigTypeIdInt && |
| 9128 | prev_type->data.integral.is_signed == cur_type->data.integral.is_signed) | 9128 | prev_type->data.integral.is_signed == cur_type->data.integral.is_signed) |
| 9129 | { | 9129 | { |
| 9130 | if (cur_type->data.integral.bit_count > prev_type->data.integral.bit_count) { | 9130 | if (cur_type->data.integral.bit_count > prev_type->data.integral.bit_count) { |
| ... | @@ -9133,21 +9133,21 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9133,21 +9133,21 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9133 | continue; | 9133 | continue; |
| 9134 | } | 9134 | } |
| 9135 | | 9135 | |
| 9136 | if (prev_type->id == TypeTableEntryIdFloat && cur_type->id == TypeTableEntryIdFloat) { | 9136 | if (prev_type->id == ZigTypeIdFloat && cur_type->id == ZigTypeIdFloat) { |
| 9137 | if (cur_type->data.floating.bit_count > prev_type->data.floating.bit_count) { | 9137 | if (cur_type->data.floating.bit_count > prev_type->data.floating.bit_count) { |
| 9138 | prev_inst = cur_inst; | 9138 | prev_inst = cur_inst; |
| 9139 | } | 9139 | } |
| 9140 | continue; | 9140 | continue; |
| 9141 | } | 9141 | } |
| 9142 | | 9142 | |
| 9143 | if (prev_type->id == TypeTableEntryIdErrorUnion && | 9143 | if (prev_type->id == ZigTypeIdErrorUnion && |
| 9144 | types_match_const_cast_only(ira, prev_type->data.error_union.payload_type, cur_type, | 9144 | types_match_const_cast_only(ira, prev_type->data.error_union.payload_type, cur_type, |
| 9145 | source_node, false).id == ConstCastResultIdOk) | 9145 | source_node, false).id == ConstCastResultIdOk) |
| 9146 | { | 9146 | { |
| 9147 | continue; | 9147 | continue; |
| 9148 | } | 9148 | } |
| 9149 | | 9149 | |
| 9150 | if (cur_type->id == TypeTableEntryIdErrorUnion && | 9150 | if (cur_type->id == ZigTypeIdErrorUnion && |
| 9151 | types_match_const_cast_only(ira, cur_type->data.error_union.payload_type, prev_type, | 9151 | types_match_const_cast_only(ira, cur_type->data.error_union.payload_type, prev_type, |
| 9152 | source_node, false).id == ConstCastResultIdOk) | 9152 | source_node, false).id == ConstCastResultIdOk) |
| 9153 | { | 9153 | { |
| ... | @@ -9170,14 +9170,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9170,14 +9170,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9170 | continue; | 9170 | continue; |
| 9171 | } | 9171 | } |
| 9172 | | 9172 | |
| 9173 | if (prev_type->id == TypeTableEntryIdOptional && | 9173 | if (prev_type->id == ZigTypeIdOptional && |
| 9174 | types_match_const_cast_only(ira, prev_type->data.maybe.child_type, cur_type, | 9174 | types_match_const_cast_only(ira, prev_type->data.maybe.child_type, cur_type, |
| 9175 | source_node, false).id == ConstCastResultIdOk) | 9175 | source_node, false).id == ConstCastResultIdOk) |
| 9176 | { | 9176 | { |
| 9177 | continue; | 9177 | continue; |
| 9178 | } | 9178 | } |
| 9179 | | 9179 | |
| 9180 | if (cur_type->id == TypeTableEntryIdOptional && | 9180 | if (cur_type->id == ZigTypeIdOptional && |
| 9181 | types_match_const_cast_only(ira, cur_type->data.maybe.child_type, prev_type, | 9181 | types_match_const_cast_only(ira, cur_type->data.maybe.child_type, prev_type, |
| 9182 | source_node, false).id == ConstCastResultIdOk) | 9182 | source_node, false).id == ConstCastResultIdOk) |
| 9183 | { | 9183 | { |
| ... | @@ -9185,17 +9185,17 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9185,17 +9185,17 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9185 | continue; | 9185 | continue; |
| 9186 | } | 9186 | } |
| 9187 | | 9187 | |
| 9188 | if (cur_type->id == TypeTableEntryIdUndefined) { | 9188 | if (cur_type->id == ZigTypeIdUndefined) { |
| 9189 | continue; | 9189 | continue; |
| 9190 | } | 9190 | } |
| 9191 | | 9191 | |
| 9192 | if (prev_type->id == TypeTableEntryIdUndefined) { | 9192 | if (prev_type->id == ZigTypeIdUndefined) { |
| 9193 | prev_inst = cur_inst; | 9193 | prev_inst = cur_inst; |
| 9194 | continue; | 9194 | continue; |
| 9195 | } | 9195 | } |
| 9196 | | 9196 | |
| 9197 | if (prev_type->id == TypeTableEntryIdComptimeInt || | 9197 | if (prev_type->id == ZigTypeIdComptimeInt || |
| 9198 | prev_type->id == TypeTableEntryIdComptimeFloat) | 9198 | prev_type->id == ZigTypeIdComptimeFloat) |
| 9199 | { | 9199 | { |
| 9200 | if (ir_num_lit_fits_in_other_type(ira, prev_inst, cur_type, false)) { | 9200 | if (ir_num_lit_fits_in_other_type(ira, prev_inst, cur_type, false)) { |
| 9201 | prev_inst = cur_inst; | 9201 | prev_inst = cur_inst; |
| ... | @@ -9205,8 +9205,8 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9205,8 +9205,8 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9205 | } | 9205 | } |
| 9206 | } | 9206 | } |
| 9207 | | 9207 | |
| 9208 | if (cur_type->id == TypeTableEntryIdComptimeInt || | 9208 | if (cur_type->id == ZigTypeIdComptimeInt || |
| 9209 | cur_type->id == TypeTableEntryIdComptimeFloat) | 9209 | cur_type->id == ZigTypeIdComptimeFloat) |
| 9210 | { | 9210 | { |
| 9211 | if (ir_num_lit_fits_in_other_type(ira, cur_inst, prev_type, false)) { | 9211 | if (ir_num_lit_fits_in_other_type(ira, cur_inst, prev_type, false)) { |
| 9212 | continue; | 9212 | continue; |
| ... | @@ -9215,7 +9215,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9215,7 +9215,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9215 | } | 9215 | } |
| 9216 | } | 9216 | } |
| 9217 | | 9217 | |
| 9218 | if (cur_type->id == TypeTableEntryIdArray && prev_type->id == TypeTableEntryIdArray && | 9218 | if (cur_type->id == ZigTypeIdArray && prev_type->id == ZigTypeIdArray && |
| 9219 | cur_type->data.array.len != prev_type->data.array.len && | 9219 | cur_type->data.array.len != prev_type->data.array.len && |
| 9220 | types_match_const_cast_only(ira, cur_type->data.array.child_type, prev_type->data.array.child_type, | 9220 | types_match_const_cast_only(ira, cur_type->data.array.child_type, prev_type->data.array.child_type, |
| 9221 | source_node, false).id == ConstCastResultIdOk) | 9221 | source_node, false).id == ConstCastResultIdOk) |
| ... | @@ -9225,7 +9225,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9225,7 +9225,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9225 | continue; | 9225 | continue; |
| 9226 | } | 9226 | } |
| 9227 | | 9227 | |
| 9228 | if (cur_type->id == TypeTableEntryIdArray && prev_type->id == TypeTableEntryIdArray && | 9228 | if (cur_type->id == ZigTypeIdArray && prev_type->id == ZigTypeIdArray && |
| 9229 | cur_type->data.array.len != prev_type->data.array.len && | 9229 | cur_type->data.array.len != prev_type->data.array.len && |
| 9230 | types_match_const_cast_only(ira, prev_type->data.array.child_type, cur_type->data.array.child_type, | 9230 | types_match_const_cast_only(ira, prev_type->data.array.child_type, cur_type->data.array.child_type, |
| 9231 | source_node, false).id == ConstCastResultIdOk) | 9231 | source_node, false).id == ConstCastResultIdOk) |
| ... | @@ -9234,7 +9234,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9234,7 +9234,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9234 | continue; | 9234 | continue; |
| 9235 | } | 9235 | } |
| 9236 | | 9236 | |
| 9237 | if (cur_type->id == TypeTableEntryIdArray && is_slice(prev_type) && | 9237 | if (cur_type->id == ZigTypeIdArray && is_slice(prev_type) && |
| 9238 | (prev_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const || | 9238 | (prev_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const || |
| 9239 | cur_type->data.array.len == 0) && | 9239 | cur_type->data.array.len == 0) && |
| 9240 | types_match_const_cast_only(ira, | 9240 | types_match_const_cast_only(ira, |
| ... | @@ -9245,7 +9245,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9245,7 +9245,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9245 | continue; | 9245 | continue; |
| 9246 | } | 9246 | } |
| 9247 | | 9247 | |
| 9248 | if (prev_type->id == TypeTableEntryIdArray && is_slice(cur_type) && | 9248 | if (prev_type->id == ZigTypeIdArray && is_slice(cur_type) && |
| 9249 | (cur_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const || | 9249 | (cur_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const || |
| 9250 | prev_type->data.array.len == 0) && | 9250 | prev_type->data.array.len == 0) && |
| 9251 | types_match_const_cast_only(ira, | 9251 | types_match_const_cast_only(ira, |
| ... | @@ -9257,7 +9257,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9257,7 +9257,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9257 | continue; | 9257 | continue; |
| 9258 | } | 9258 | } |
| 9259 | | 9259 | |
| 9260 | if (prev_type->id == TypeTableEntryIdEnum && cur_type->id == TypeTableEntryIdUnion && | 9260 | if (prev_type->id == ZigTypeIdEnum && cur_type->id == ZigTypeIdUnion && |
| 9261 | (cur_type->data.unionation.decl_node->data.container_decl.auto_enum || cur_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) | 9261 | (cur_type->data.unionation.decl_node->data.container_decl.auto_enum || cur_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) |
| 9262 | { | 9262 | { |
| 9263 | if ((err = type_ensure_zero_bits_known(ira->codegen, cur_type))) | 9263 | if ((err = type_ensure_zero_bits_known(ira->codegen, cur_type))) |
| ... | @@ -9267,7 +9267,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9267,7 +9267,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9267 | } | 9267 | } |
| 9268 | } | 9268 | } |
| 9269 | | 9269 | |
| 9270 | if (cur_type->id == TypeTableEntryIdEnum && prev_type->id == TypeTableEntryIdUnion && | 9270 | if (cur_type->id == ZigTypeIdEnum && prev_type->id == ZigTypeIdUnion && |
| 9271 | (prev_type->data.unionation.decl_node->data.container_decl.auto_enum || prev_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) | 9271 | (prev_type->data.unionation.decl_node->data.container_decl.auto_enum || prev_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) |
| 9272 | { | 9272 | { |
| 9273 | if ((err = type_ensure_zero_bits_known(ira->codegen, prev_type))) | 9273 | if ((err = type_ensure_zero_bits_known(ira->codegen, prev_type))) |
| ... | @@ -9292,7 +9292,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9292,7 +9292,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9292 | free(errors); | 9292 | free(errors); |
| 9293 | | 9293 | |
| 9294 | if (convert_to_const_slice) { | 9294 | if (convert_to_const_slice) { |
| 9295 | assert(prev_inst->value.type->id == TypeTableEntryIdArray); | 9295 | assert(prev_inst->value.type->id == ZigTypeIdArray); |
| 9296 | ZigType *ptr_type = get_pointer_to_type_extra( | 9296 | ZigType *ptr_type = get_pointer_to_type_extra( |
| 9297 | ira->codegen, prev_inst->value.type->data.array.child_type, | 9297 | ira->codegen, prev_inst->value.type->data.array.child_type, |
| 9298 | true, false, PtrLenUnknown, | 9298 | true, false, PtrLenUnknown, |
| ... | @@ -9305,20 +9305,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9305,20 +9305,20 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9305 | return slice_type; | 9305 | return slice_type; |
| 9306 | } | 9306 | } |
| 9307 | } else if (err_set_type != nullptr) { | 9307 | } else if (err_set_type != nullptr) { |
| 9308 | if (prev_inst->value.type->id == TypeTableEntryIdErrorSet) { | 9308 | if (prev_inst->value.type->id == ZigTypeIdErrorSet) { |
| 9309 | return err_set_type; | 9309 | return err_set_type; |
| 9310 | } else if (prev_inst->value.type->id == TypeTableEntryIdErrorUnion) { | 9310 | } else if (prev_inst->value.type->id == ZigTypeIdErrorUnion) { |
| 9311 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type->data.error_union.payload_type); | 9311 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type->data.error_union.payload_type); |
| 9312 | } else if (expected_type != nullptr && expected_type->id == TypeTableEntryIdErrorUnion) { | 9312 | } else if (expected_type != nullptr && expected_type->id == ZigTypeIdErrorUnion) { |
| 9313 | return get_error_union_type(ira->codegen, err_set_type, expected_type->data.error_union.payload_type); | 9313 | return get_error_union_type(ira->codegen, err_set_type, expected_type->data.error_union.payload_type); |
| 9314 | } else { | 9314 | } else { |
| 9315 | if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt || | 9315 | if (prev_inst->value.type->id == ZigTypeIdComptimeInt || |
| 9316 | prev_inst->value.type->id == TypeTableEntryIdComptimeFloat) | 9316 | prev_inst->value.type->id == ZigTypeIdComptimeFloat) |
| 9317 | { | 9317 | { |
| 9318 | ir_add_error_node(ira, source_node, | 9318 | ir_add_error_node(ira, source_node, |
| 9319 | buf_sprintf("unable to make error union out of number literal")); | 9319 | buf_sprintf("unable to make error union out of number literal")); |
| 9320 | return ira->codegen->builtin_types.entry_invalid; | 9320 | return ira->codegen->builtin_types.entry_invalid; |
| 9321 | } else if (prev_inst->value.type->id == TypeTableEntryIdNull) { | 9321 | } else if (prev_inst->value.type->id == ZigTypeIdNull) { |
| 9322 | ir_add_error_node(ira, source_node, | 9322 | ir_add_error_node(ira, source_node, |
| 9323 | buf_sprintf("unable to make error union out of null literal")); | 9323 | buf_sprintf("unable to make error union out of null literal")); |
| 9324 | return ira->codegen->builtin_types.entry_invalid; | 9324 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -9326,14 +9326,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -9326,14 +9326,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 9326 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type); | 9326 | return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type); |
| 9327 | } | 9327 | } |
| 9328 | } | 9328 | } |
| 9329 | } else if (any_are_null && prev_inst->value.type->id != TypeTableEntryIdNull) { | 9329 | } else if (any_are_null && prev_inst->value.type->id != ZigTypeIdNull) { |
| 9330 | if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt || | 9330 | if (prev_inst->value.type->id == ZigTypeIdComptimeInt || |
| 9331 | prev_inst->value.type->id == TypeTableEntryIdComptimeFloat) | 9331 | prev_inst->value.type->id == ZigTypeIdComptimeFloat) |
| 9332 | { | 9332 | { |
| 9333 | ir_add_error_node(ira, source_node, | 9333 | ir_add_error_node(ira, source_node, |
| 9334 | buf_sprintf("unable to make maybe out of number literal")); | 9334 | buf_sprintf("unable to make maybe out of number literal")); |
| 9335 | return ira->codegen->builtin_types.entry_invalid; | 9335 | return ira->codegen->builtin_types.entry_invalid; |
| 9336 | } else if (prev_inst->value.type->id == TypeTableEntryIdOptional) { | 9336 | } else if (prev_inst->value.type->id == ZigTypeIdOptional) { |
| 9337 | return prev_inst->value.type; | 9337 | return prev_inst->value.type; |
| 9338 | } else { | 9338 | } else { |
| 9339 | return get_optional_type(ira->codegen, prev_inst->value.type); | 9339 | return get_optional_type(ira->codegen, prev_inst->value.type); |
| ... | @@ -9357,7 +9357,7 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ | ... | @@ -9357,7 +9357,7 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ |
| 9357 | *dest = *src; | 9357 | *dest = *src; |
| 9358 | if (!same_global_refs) { | 9358 | if (!same_global_refs) { |
| 9359 | dest->global_refs = global_refs; | 9359 | dest->global_refs = global_refs; |
| 9360 | if (dest->type->id == TypeTableEntryIdStruct) { | 9360 | if (dest->type->id == ZigTypeIdStruct) { |
| 9361 | dest->data.x_struct.fields = allocate_nonzero<ConstExprValue>(dest->type->data.structure.src_field_count); | 9361 | dest->data.x_struct.fields = allocate_nonzero<ConstExprValue>(dest->type->data.structure.src_field_count); |
| 9362 | memcpy(dest->data.x_struct.fields, src->data.x_struct.fields, sizeof(ConstExprValue) * dest->type->data.structure.src_field_count); | 9362 | memcpy(dest->data.x_struct.fields, src->data.x_struct.fields, sizeof(ConstExprValue) * dest->type->data.structure.src_field_count); |
| 9363 | } | 9363 | } |
| ... | @@ -9387,8 +9387,8 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -9387,8 +9387,8 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 9387 | break; | 9387 | break; |
| 9388 | } | 9388 | } |
| 9389 | case CastOpNumLitToConcrete: | 9389 | case CastOpNumLitToConcrete: |
| 9390 | if (other_val->type->id == TypeTableEntryIdComptimeFloat) { | 9390 | if (other_val->type->id == ZigTypeIdComptimeFloat) { |
| 9391 | assert(new_type->id == TypeTableEntryIdFloat); | 9391 | assert(new_type->id == ZigTypeIdFloat); |
| 9392 | switch (new_type->data.floating.bit_count) { | 9392 | switch (new_type->data.floating.bit_count) { |
| 9393 | case 16: | 9393 | case 16: |
| 9394 | const_val->data.x_f16 = bigfloat_to_f16(&other_val->data.x_bigfloat); | 9394 | const_val->data.x_f16 = bigfloat_to_f16(&other_val->data.x_bigfloat); |
| ... | @@ -9405,7 +9405,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -9405,7 +9405,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 9405 | default: | 9405 | default: |
| 9406 | zig_unreachable(); | 9406 | zig_unreachable(); |
| 9407 | } | 9407 | } |
| 9408 | } else if (other_val->type->id == TypeTableEntryIdComptimeInt) { | 9408 | } else if (other_val->type->id == ZigTypeIdComptimeInt) { |
| 9409 | bigint_init_bigint(&const_val->data.x_bigint, &other_val->data.x_bigint); | 9409 | bigint_init_bigint(&const_val->data.x_bigint, &other_val->data.x_bigint); |
| 9410 | } else { | 9410 | } else { |
| 9411 | zig_unreachable(); | 9411 | zig_unreachable(); |
| ... | @@ -9418,7 +9418,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -9418,7 +9418,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 9418 | zig_unreachable(); | 9418 | zig_unreachable(); |
| 9419 | case CastOpIntToFloat: | 9419 | case CastOpIntToFloat: |
| 9420 | { | 9420 | { |
| 9421 | assert(new_type->id == TypeTableEntryIdFloat); | 9421 | assert(new_type->id == ZigTypeIdFloat); |
| 9422 | | 9422 | |
| 9423 | BigFloat bigfloat; | 9423 | BigFloat bigfloat; |
| 9424 | bigfloat_init_bigint(&bigfloat, &other_val->data.x_bigint); | 9424 | bigfloat_init_bigint(&bigfloat, &other_val->data.x_bigint); |
| ... | @@ -9443,7 +9443,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -9443,7 +9443,7 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 9443 | } | 9443 | } |
| 9444 | case CastOpFloatToInt: | 9444 | case CastOpFloatToInt: |
| 9445 | float_init_bigint(&const_val->data.x_bigint, other_val); | 9445 | float_init_bigint(&const_val->data.x_bigint, other_val); |
| 9446 | if (new_type->id == TypeTableEntryIdInt) { | 9446 | if (new_type->id == ZigTypeIdInt) { |
| 9447 | if (!bigint_fits_in_bits(&const_val->data.x_bigint, new_type->data.integral.bit_count, | 9447 | if (!bigint_fits_in_bits(&const_val->data.x_bigint, new_type->data.integral.bit_count, |
| 9448 | new_type->data.integral.is_signed)) | 9448 | new_type->data.integral.is_signed)) |
| 9449 | { | 9449 | { |
| ... | @@ -9493,7 +9493,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -9493,7 +9493,7 @@ static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 9493 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 9493 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, |
| 9494 | IrInstruction *value, ZigType *wanted_type) | 9494 | IrInstruction *value, ZigType *wanted_type) |
| 9495 | { | 9495 | { |
| 9496 | assert(value->value.type->id == TypeTableEntryIdPointer); | 9496 | assert(value->value.type->id == ZigTypeIdPointer); |
| 9497 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment); | 9497 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, value->value.type->data.pointer.alignment); |
| 9498 | | 9498 | |
| 9499 | if (instr_is_comptime(value)) { | 9499 | if (instr_is_comptime(value)) { |
| ... | @@ -9529,7 +9529,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -9529,7 +9529,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 9529 | if (pointee == nullptr) | 9529 | if (pointee == nullptr) |
| 9530 | return ira->codegen->invalid_instruction; | 9530 | return ira->codegen->invalid_instruction; |
| 9531 | if (pointee->special != ConstValSpecialRuntime) { | 9531 | if (pointee->special != ConstValSpecialRuntime) { |
| 9532 | assert(value->value.type->id == TypeTableEntryIdPointer); | 9532 | assert(value->value.type->id == ZigTypeIdPointer); |
| 9533 | ZigType *array_type = value->value.type->data.pointer.child_type; | 9533 | ZigType *array_type = value->value.type->data.pointer.child_type; |
| 9534 | assert(is_slice(wanted_type)); | 9534 | assert(is_slice(wanted_type)); |
| 9535 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const; | 9535 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const; |
| ... | @@ -9552,9 +9552,9 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -9552,9 +9552,9 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 9552 | } | 9552 | } |
| 9553 | | 9553 | |
| 9554 | static bool is_container(ZigType *type) { | 9554 | static bool is_container(ZigType *type) { |
| 9555 | return type->id == TypeTableEntryIdStruct || | 9555 | return type->id == ZigTypeIdStruct || |
| 9556 | type->id == TypeTableEntryIdEnum || | 9556 | type->id == ZigTypeIdEnum || |
| 9557 | type->id == TypeTableEntryIdUnion; | 9557 | type->id == ZigTypeIdUnion; |
| 9558 | } | 9558 | } |
| 9559 | | 9559 | |
| 9560 | static IrBasicBlock *ir_get_new_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrInstruction *ref_old_instruction) { | 9560 | static IrBasicBlock *ir_get_new_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrInstruction *ref_old_instruction) { |
| ... | @@ -9665,7 +9665,7 @@ static ZigType *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, | ... | @@ -9665,7 +9665,7 @@ static ZigType *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, |
| 9665 | } | 9665 | } |
| 9666 | | 9666 | |
| 9667 | static ZigType *ir_finish_anal(IrAnalyze *ira, ZigType *result_type) { | 9667 | static ZigType *ir_finish_anal(IrAnalyze *ira, ZigType *result_type) { |
| 9668 | if (result_type->id == TypeTableEntryIdUnreachable) | 9668 | if (result_type->id == ZigTypeIdUnreachable) |
| 9669 | ir_finish_bb(ira); | 9669 | ir_finish_bb(ira); |
| 9670 | return result_type; | 9670 | return result_type; |
| 9671 | } | 9671 | } |
| ... | @@ -9803,7 +9803,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -9803,7 +9803,7 @@ static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 9803 | if (type_is_invalid(type_value->value.type)) | 9803 | if (type_is_invalid(type_value->value.type)) |
| 9804 | return ira->codegen->builtin_types.entry_invalid; | 9804 | return ira->codegen->builtin_types.entry_invalid; |
| 9805 | | 9805 | |
| 9806 | if (type_value->value.type->id != TypeTableEntryIdMetaType) { | 9806 | if (type_value->value.type->id != ZigTypeIdMetaType) { |
| 9807 | ir_add_error(ira, type_value, | 9807 | ir_add_error(ira, type_value, |
| 9808 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name))); | 9808 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value.type->name))); |
| 9809 | return ira->codegen->builtin_types.entry_invalid; | 9809 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -9823,7 +9823,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -9823,7 +9823,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 9823 | if (type_is_invalid(fn_value->value.type)) | 9823 | if (type_is_invalid(fn_value->value.type)) |
| 9824 | return nullptr; | 9824 | return nullptr; |
| 9825 | | 9825 | |
| 9826 | if (fn_value->value.type->id != TypeTableEntryIdFn) { | 9826 | if (fn_value->value.type->id != ZigTypeIdFn) { |
| 9827 | ir_add_error_node(ira, fn_value->source_node, | 9827 | ir_add_error_node(ira, fn_value->source_node, |
| 9828 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value.type->name))); | 9828 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value.type->name))); |
| 9829 | return nullptr; | 9829 | return nullptr; |
| ... | @@ -9838,7 +9838,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -9838,7 +9838,7 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 9838 | } | 9838 | } |
| 9839 | | 9839 | |
| 9840 | static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { | 9840 | static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { |
| 9841 | assert(wanted_type->id == TypeTableEntryIdOptional); | 9841 | assert(wanted_type->id == ZigTypeIdOptional); |
| 9842 | | 9842 | |
| 9843 | if (instr_is_comptime(value)) { | 9843 | if (instr_is_comptime(value)) { |
| 9844 | ZigType *payload_type = wanted_type->data.maybe.child_type; | 9844 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| ... | @@ -9872,7 +9872,7 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -9872,7 +9872,7 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc |
| 9872 | static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr, | 9872 | static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr, |
| 9873 | IrInstruction *value, ZigType *wanted_type) | 9873 | IrInstruction *value, ZigType *wanted_type) |
| 9874 | { | 9874 | { |
| 9875 | assert(wanted_type->id == TypeTableEntryIdErrorUnion); | 9875 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 9876 | | 9876 | |
| 9877 | if (instr_is_comptime(value)) { | 9877 | if (instr_is_comptime(value)) { |
| 9878 | ZigType *payload_type = wanted_type->data.error_union.payload_type; | 9878 | ZigType *payload_type = wanted_type->data.error_union.payload_type; |
| ... | @@ -9903,8 +9903,8 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -9903,8 +9903,8 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 9903 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 9903 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, |
| 9904 | ZigType *wanted_type) | 9904 | ZigType *wanted_type) |
| 9905 | { | 9905 | { |
| 9906 | assert(value->value.type->id == TypeTableEntryIdErrorSet); | 9906 | assert(value->value.type->id == ZigTypeIdErrorSet); |
| 9907 | assert(wanted_type->id == TypeTableEntryIdErrorSet); | 9907 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 9908 | | 9908 | |
| 9909 | if (instr_is_comptime(value)) { | 9909 | if (instr_is_comptime(value)) { |
| 9910 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 9910 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); |
| ... | @@ -9944,7 +9944,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -9944,7 +9944,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 9944 | } | 9944 | } |
| 9945 | | 9945 | |
| 9946 | static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { | 9946 | static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { |
| 9947 | assert(wanted_type->id == TypeTableEntryIdErrorUnion); | 9947 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 9948 | | 9948 | |
| 9949 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); | 9949 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); |
| 9950 | | 9950 | |
| ... | @@ -10006,7 +10006,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -10006,7 +10006,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ |
| 10006 | } | 10006 | } |
| 10007 | | 10007 | |
| 10008 | static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { | 10008 | static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { |
| 10009 | assert(wanted_type->id == TypeTableEntryIdOptional); | 10009 | assert(wanted_type->id == ZigTypeIdOptional); |
| 10010 | assert(instr_is_comptime(value)); | 10010 | assert(instr_is_comptime(value)); |
| 10011 | | 10011 | |
| 10012 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 10012 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); |
| ... | @@ -10062,14 +10062,14 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s | ... | @@ -10062,14 +10062,14 @@ static IrInstruction *ir_analyze_array_to_slice(IrAnalyze *ira, IrInstruction *s |
| 10062 | | 10062 | |
| 10063 | IrInstruction *array_ptr = nullptr; | 10063 | IrInstruction *array_ptr = nullptr; |
| 10064 | IrInstruction *array; | 10064 | IrInstruction *array; |
| 10065 | if (array_arg->value.type->id == TypeTableEntryIdPointer) { | 10065 | if (array_arg->value.type->id == ZigTypeIdPointer) { |
| 10066 | array = ir_get_deref(ira, source_instr, array_arg); | 10066 | array = ir_get_deref(ira, source_instr, array_arg); |
| 10067 | array_ptr = array_arg; | 10067 | array_ptr = array_arg; |
| 10068 | } else { | 10068 | } else { |
| 10069 | array = array_arg; | 10069 | array = array_arg; |
| 10070 | } | 10070 | } |
| 10071 | ZigType *array_type = array->value.type; | 10071 | ZigType *array_type = array->value.type; |
| 10072 | assert(array_type->id == TypeTableEntryIdArray); | 10072 | assert(array_type->id == ZigTypeIdArray); |
| 10073 | | 10073 | |
| 10074 | if (instr_is_comptime(array)) { | 10074 | if (instr_is_comptime(array)) { |
| 10075 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 10075 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| ... | @@ -10103,7 +10103,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -10103,7 +10103,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 10103 | IrInstruction *target, ZigType *wanted_type) | 10103 | IrInstruction *target, ZigType *wanted_type) |
| 10104 | { | 10104 | { |
| 10105 | Error err; | 10105 | Error err; |
| 10106 | assert(wanted_type->id == TypeTableEntryIdInt); | 10106 | assert(wanted_type->id == ZigTypeIdInt); |
| 10107 | | 10107 | |
| 10108 | ZigType *actual_type = target->value.type; | 10108 | ZigType *actual_type = target->value.type; |
| 10109 | if ((err = ensure_complete_type(ira->codegen, actual_type))) | 10109 | if ((err = ensure_complete_type(ira->codegen, actual_type))) |
| ... | @@ -10117,7 +10117,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -10117,7 +10117,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 10117 | return ira->codegen->invalid_instruction; | 10117 | return ira->codegen->invalid_instruction; |
| 10118 | } | 10118 | } |
| 10119 | | 10119 | |
| 10120 | assert(actual_type->id == TypeTableEntryIdEnum); | 10120 | assert(actual_type->id == ZigTypeIdEnum); |
| 10121 | | 10121 | |
| 10122 | if (instr_is_comptime(target)) { | 10122 | if (instr_is_comptime(target)) { |
| 10123 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 10123 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| ... | @@ -10138,8 +10138,8 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -10138,8 +10138,8 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 10138 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, | 10138 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, |
| 10139 | IrInstruction *target, ZigType *wanted_type) | 10139 | IrInstruction *target, ZigType *wanted_type) |
| 10140 | { | 10140 | { |
| 10141 | assert(target->value.type->id == TypeTableEntryIdUnion); | 10141 | assert(target->value.type->id == ZigTypeIdUnion); |
| 10142 | assert(wanted_type->id == TypeTableEntryIdEnum); | 10142 | assert(wanted_type->id == ZigTypeIdEnum); |
| 10143 | assert(wanted_type == target->value.type->data.unionation.tag_type); | 10143 | assert(wanted_type == target->value.type->data.unionation.tag_type); |
| 10144 | | 10144 | |
| 10145 | if (instr_is_comptime(target)) { | 10145 | if (instr_is_comptime(target)) { |
| ... | @@ -10173,8 +10173,8 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -10173,8 +10173,8 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 10173 | IrInstruction *target, ZigType *wanted_type) | 10173 | IrInstruction *target, ZigType *wanted_type) |
| 10174 | { | 10174 | { |
| 10175 | Error err; | 10175 | Error err; |
| 10176 | assert(wanted_type->id == TypeTableEntryIdUnion); | 10176 | assert(wanted_type->id == ZigTypeIdUnion); |
| 10177 | assert(target->value.type->id == TypeTableEntryIdEnum); | 10177 | assert(target->value.type->id == ZigTypeIdEnum); |
| 10178 | | 10178 | |
| 10179 | if (instr_is_comptime(target)) { | 10179 | if (instr_is_comptime(target)) { |
| 10180 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 10180 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| ... | @@ -10231,13 +10231,13 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -10231,13 +10231,13 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 10231 | static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr, | 10231 | static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr, |
| 10232 | IrInstruction *target, ZigType *wanted_type) | 10232 | IrInstruction *target, ZigType *wanted_type) |
| 10233 | { | 10233 | { |
| 10234 | assert(wanted_type->id == TypeTableEntryIdInt || wanted_type->id == TypeTableEntryIdFloat); | 10234 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); |
| 10235 | | 10235 | |
| 10236 | if (instr_is_comptime(target)) { | 10236 | if (instr_is_comptime(target)) { |
| 10237 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 10237 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| 10238 | if (!val) | 10238 | if (!val) |
| 10239 | return ira->codegen->invalid_instruction; | 10239 | return ira->codegen->invalid_instruction; |
| 10240 | if (wanted_type->id == TypeTableEntryIdInt) { | 10240 | if (wanted_type->id == ZigTypeIdInt) { |
| 10241 | if (bigint_cmp_zero(&val->data.x_bigint) == CmpLT && !wanted_type->data.integral.is_signed) { | 10241 | if (bigint_cmp_zero(&val->data.x_bigint) == CmpLT && !wanted_type->data.integral.is_signed) { |
| 10242 | ir_add_error(ira, source_instr, | 10242 | ir_add_error(ira, source_instr, |
| 10243 | buf_sprintf("attempt to cast negative value to unsigned integer")); | 10243 | buf_sprintf("attempt to cast negative value to unsigned integer")); |
| ... | @@ -10255,7 +10255,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -10255,7 +10255,7 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 10255 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 10255 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 10256 | source_instr->source_node, wanted_type); | 10256 | source_instr->source_node, wanted_type); |
| 10257 | result->value.type = wanted_type; | 10257 | result->value.type = wanted_type; |
| 10258 | if (wanted_type->id == TypeTableEntryIdInt) { | 10258 | if (wanted_type->id == ZigTypeIdInt) { |
| 10259 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); | 10259 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); |
| 10260 | } else { | 10260 | } else { |
| 10261 | float_init_float(&result->value, val); | 10261 | float_init_float(&result->value, val); |
| ... | @@ -10273,7 +10273,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -10273,7 +10273,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 10273 | IrInstruction *target, ZigType *wanted_type) | 10273 | IrInstruction *target, ZigType *wanted_type) |
| 10274 | { | 10274 | { |
| 10275 | Error err; | 10275 | Error err; |
| 10276 | assert(wanted_type->id == TypeTableEntryIdEnum); | 10276 | assert(wanted_type->id == ZigTypeIdEnum); |
| 10277 | | 10277 | |
| 10278 | ZigType *actual_type = target->value.type; | 10278 | ZigType *actual_type = target->value.type; |
| 10279 | | 10279 | |
| ... | @@ -10288,7 +10288,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -10288,7 +10288,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 10288 | return ira->codegen->invalid_instruction; | 10288 | return ira->codegen->invalid_instruction; |
| 10289 | } | 10289 | } |
| 10290 | | 10290 | |
| 10291 | assert(actual_type->id == TypeTableEntryIdInt); | 10291 | assert(actual_type->id == ZigTypeIdInt); |
| 10292 | | 10292 | |
| 10293 | if (instr_is_comptime(target)) { | 10293 | if (instr_is_comptime(target)) { |
| 10294 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 10294 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| ... | @@ -10328,9 +10328,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -10328,9 +10328,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 10328 | | 10328 | |
| 10329 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, | 10329 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 10330 | source_instr->source_node, wanted_type); | 10330 | source_instr->source_node, wanted_type); |
| 10331 | if (wanted_type->id == TypeTableEntryIdComptimeFloat) { | 10331 | if (wanted_type->id == ZigTypeIdComptimeFloat) { |
| 10332 | float_init_float(&result->value, val); | 10332 | float_init_float(&result->value, val); |
| 10333 | } else if (wanted_type->id == TypeTableEntryIdComptimeInt) { | 10333 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { |
| 10334 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); | 10334 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); |
| 10335 | } else { | 10335 | } else { |
| 10336 | zig_unreachable(); | 10336 | zig_unreachable(); |
| ... | @@ -10341,9 +10341,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -10341,9 +10341,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 10341 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 10341 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 10342 | ZigType *wanted_type) | 10342 | ZigType *wanted_type) |
| 10343 | { | 10343 | { |
| 10344 | assert(target->value.type->id == TypeTableEntryIdInt); | 10344 | assert(target->value.type->id == ZigTypeIdInt); |
| 10345 | assert(!target->value.type->data.integral.is_signed); | 10345 | assert(!target->value.type->data.integral.is_signed); |
| 10346 | assert(wanted_type->id == TypeTableEntryIdErrorSet); | 10346 | assert(wanted_type->id == ZigTypeIdErrorSet); |
| 10347 | | 10347 | |
| 10348 | if (instr_is_comptime(target)) { | 10348 | if (instr_is_comptime(target)) { |
| 10349 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 10349 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| ... | @@ -10406,7 +10406,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -10406,7 +10406,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 10406 | static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 10406 | static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 10407 | ZigType *wanted_type) | 10407 | ZigType *wanted_type) |
| 10408 | { | 10408 | { |
| 10409 | assert(wanted_type->id == TypeTableEntryIdInt); | 10409 | assert(wanted_type->id == ZigTypeIdInt); |
| 10410 | | 10410 | |
| 10411 | ZigType *err_type = target->value.type; | 10411 | ZigType *err_type = target->value.type; |
| 10412 | | 10412 | |
| ... | @@ -10419,9 +10419,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -10419,9 +10419,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 10419 | source_instr->source_node, wanted_type); | 10419 | source_instr->source_node, wanted_type); |
| 10420 | | 10420 | |
| 10421 | ErrorTableEntry *err; | 10421 | ErrorTableEntry *err; |
| 10422 | if (err_type->id == TypeTableEntryIdErrorUnion) { | 10422 | if (err_type->id == ZigTypeIdErrorUnion) { |
| 10423 | err = val->data.x_err_union.err; | 10423 | err = val->data.x_err_union.err; |
| 10424 | } else if (err_type->id == TypeTableEntryIdErrorSet) { | 10424 | } else if (err_type->id == ZigTypeIdErrorSet) { |
| 10425 | err = val->data.x_err_set; | 10425 | err = val->data.x_err_set; |
| 10426 | } else { | 10426 | } else { |
| 10427 | zig_unreachable(); | 10427 | zig_unreachable(); |
| ... | @@ -10443,9 +10443,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -10443,9 +10443,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 10443 | } | 10443 | } |
| 10444 | | 10444 | |
| 10445 | ZigType *err_set_type; | 10445 | ZigType *err_set_type; |
| 10446 | if (err_type->id == TypeTableEntryIdErrorUnion) { | 10446 | if (err_type->id == ZigTypeIdErrorUnion) { |
| 10447 | err_set_type = err_type->data.error_union.err_set_type; | 10447 | err_set_type = err_type->data.error_union.err_set_type; |
| 10448 | } else if (err_type->id == TypeTableEntryIdErrorSet) { | 10448 | } else if (err_type->id == ZigTypeIdErrorSet) { |
| 10449 | err_set_type = err_type; | 10449 | err_set_type = err_type; |
| 10450 | } else { | 10450 | } else { |
| 10451 | zig_unreachable(); | 10451 | zig_unreachable(); |
| ... | @@ -10486,10 +10486,10 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -10486,10 +10486,10 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 10486 | static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 10486 | static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 10487 | ZigType *wanted_type) | 10487 | ZigType *wanted_type) |
| 10488 | { | 10488 | { |
| 10489 | assert(wanted_type->id == TypeTableEntryIdPointer); | 10489 | assert(wanted_type->id == ZigTypeIdPointer); |
| 10490 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, target->value.type->data.pointer.alignment); | 10490 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, target->value.type->data.pointer.alignment); |
| 10491 | ZigType *array_type = wanted_type->data.pointer.child_type; | 10491 | ZigType *array_type = wanted_type->data.pointer.child_type; |
| 10492 | assert(array_type->id == TypeTableEntryIdArray); | 10492 | assert(array_type->id == ZigTypeIdArray); |
| 10493 | assert(array_type->data.array.len == 1); | 10493 | assert(array_type->data.array.len == 1); |
| 10494 | | 10494 | |
| 10495 | if (instr_is_comptime(target)) { | 10495 | if (instr_is_comptime(target)) { |
| ... | @@ -10497,7 +10497,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -10497,7 +10497,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 10497 | if (!val) | 10497 | if (!val) |
| 10498 | return ira->codegen->invalid_instruction; | 10498 | return ira->codegen->invalid_instruction; |
| 10499 | | 10499 | |
| 10500 | assert(val->type->id == TypeTableEntryIdPointer); | 10500 | assert(val->type->id == ZigTypeIdPointer); |
| 10501 | ConstExprValue *pointee = ir_const_ptr_pointee(ira, val, source_instr->source_node); | 10501 | ConstExprValue *pointee = ir_const_ptr_pointee(ira, val, source_instr->source_node); |
| 10502 | if (pointee == nullptr) | 10502 | if (pointee == nullptr) |
| 10503 | return ira->codegen->invalid_instruction; | 10503 | return ira->codegen->invalid_instruction; |
| ... | @@ -10638,8 +10638,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10638,8 +10638,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10638 | } | 10638 | } |
| 10639 | | 10639 | |
| 10640 | // widening conversion | 10640 | // widening conversion |
| 10641 | if (wanted_type->id == TypeTableEntryIdInt && | 10641 | if (wanted_type->id == ZigTypeIdInt && |
| 10642 | actual_type->id == TypeTableEntryIdInt && | 10642 | actual_type->id == ZigTypeIdInt && |
| 10643 | wanted_type->data.integral.is_signed == actual_type->data.integral.is_signed && | 10643 | wanted_type->data.integral.is_signed == actual_type->data.integral.is_signed && |
| 10644 | wanted_type->data.integral.bit_count >= actual_type->data.integral.bit_count) | 10644 | wanted_type->data.integral.bit_count >= actual_type->data.integral.bit_count) |
| 10645 | { | 10645 | { |
| ... | @@ -10647,16 +10647,16 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10647,16 +10647,16 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10647 | } | 10647 | } |
| 10648 | | 10648 | |
| 10649 | // small enough unsigned ints can get casted to large enough signed ints | 10649 | // small enough unsigned ints can get casted to large enough signed ints |
| 10650 | if (wanted_type->id == TypeTableEntryIdInt && wanted_type->data.integral.is_signed && | 10650 | if (wanted_type->id == ZigTypeIdInt && wanted_type->data.integral.is_signed && |
| 10651 | actual_type->id == TypeTableEntryIdInt && !actual_type->data.integral.is_signed && | 10651 | actual_type->id == ZigTypeIdInt && !actual_type->data.integral.is_signed && |
| 10652 | wanted_type->data.integral.bit_count > actual_type->data.integral.bit_count) | 10652 | wanted_type->data.integral.bit_count > actual_type->data.integral.bit_count) |
| 10653 | { | 10653 | { |
| 10654 | return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type); | 10654 | return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type); |
| 10655 | } | 10655 | } |
| 10656 | | 10656 | |
| 10657 | // float widening conversion | 10657 | // float widening conversion |
| 10658 | if (wanted_type->id == TypeTableEntryIdFloat && | 10658 | if (wanted_type->id == ZigTypeIdFloat && |
| 10659 | actual_type->id == TypeTableEntryIdFloat && | 10659 | actual_type->id == ZigTypeIdFloat && |
| 10660 | wanted_type->data.floating.bit_count >= actual_type->data.floating.bit_count) | 10660 | wanted_type->data.floating.bit_count >= actual_type->data.floating.bit_count) |
| 10661 | { | 10661 | { |
| 10662 | return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type); | 10662 | return ir_analyze_widen_or_shorten(ira, source_instr, value, wanted_type); |
| ... | @@ -10664,9 +10664,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10664,9 +10664,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10664 | | 10664 | |
| 10665 | | 10665 | |
| 10666 | // cast from [N]T to []const T | 10666 | // cast from [N]T to []const T |
| 10667 | if (is_slice(wanted_type) && actual_type->id == TypeTableEntryIdArray) { | 10667 | if (is_slice(wanted_type) && actual_type->id == ZigTypeIdArray) { |
| 10668 | ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry; | 10668 | ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10669 | assert(ptr_type->id == TypeTableEntryIdPointer); | 10669 | assert(ptr_type->id == ZigTypeIdPointer); |
| 10670 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | 10670 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && |
| 10671 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | 10671 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 10672 | source_node, false).id == ConstCastResultIdOk) | 10672 | source_node, false).id == ConstCastResultIdOk) |
| ... | @@ -10677,12 +10677,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10677,12 +10677,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10677 | | 10677 | |
| 10678 | // cast from *const [N]T to []const T | 10678 | // cast from *const [N]T to []const T |
| 10679 | if (is_slice(wanted_type) && | 10679 | if (is_slice(wanted_type) && |
| 10680 | actual_type->id == TypeTableEntryIdPointer && | 10680 | actual_type->id == ZigTypeIdPointer && |
| 10681 | actual_type->data.pointer.is_const && | 10681 | actual_type->data.pointer.is_const && |
| 10682 | actual_type->data.pointer.child_type->id == TypeTableEntryIdArray) | 10682 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 10683 | { | 10683 | { |
| 10684 | ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry; | 10684 | ZigType *ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10685 | assert(ptr_type->id == TypeTableEntryIdPointer); | 10685 | assert(ptr_type->id == ZigTypeIdPointer); |
| 10686 | | 10686 | |
| 10687 | ZigType *array_type = actual_type->data.pointer.child_type; | 10687 | ZigType *array_type = actual_type->data.pointer.child_type; |
| 10688 | | 10688 | |
| ... | @@ -10695,14 +10695,14 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10695,14 +10695,14 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10695 | } | 10695 | } |
| 10696 | | 10696 | |
| 10697 | // cast from [N]T to *const []const T | 10697 | // cast from [N]T to *const []const T |
| 10698 | if (wanted_type->id == TypeTableEntryIdPointer && | 10698 | if (wanted_type->id == ZigTypeIdPointer && |
| 10699 | wanted_type->data.pointer.is_const && | 10699 | wanted_type->data.pointer.is_const && |
| 10700 | is_slice(wanted_type->data.pointer.child_type) && | 10700 | is_slice(wanted_type->data.pointer.child_type) && |
| 10701 | actual_type->id == TypeTableEntryIdArray) | 10701 | actual_type->id == ZigTypeIdArray) |
| 10702 | { | 10702 | { |
| 10703 | ZigType *ptr_type = | 10703 | ZigType *ptr_type = |
| 10704 | wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry; | 10704 | wanted_type->data.pointer.child_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10705 | assert(ptr_type->id == TypeTableEntryIdPointer); | 10705 | assert(ptr_type->id == ZigTypeIdPointer); |
| 10706 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | 10706 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && |
| 10707 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | 10707 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 10708 | source_node, false).id == ConstCastResultIdOk) | 10708 | source_node, false).id == ConstCastResultIdOk) |
| ... | @@ -10720,13 +10720,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10720,13 +10720,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10720 | } | 10720 | } |
| 10721 | | 10721 | |
| 10722 | // cast from [N]T to ?[]const T | 10722 | // cast from [N]T to ?[]const T |
| 10723 | if (wanted_type->id == TypeTableEntryIdOptional && | 10723 | if (wanted_type->id == ZigTypeIdOptional && |
| 10724 | is_slice(wanted_type->data.maybe.child_type) && | 10724 | is_slice(wanted_type->data.maybe.child_type) && |
| 10725 | actual_type->id == TypeTableEntryIdArray) | 10725 | actual_type->id == ZigTypeIdArray) |
| 10726 | { | 10726 | { |
| 10727 | ZigType *ptr_type = | 10727 | ZigType *ptr_type = |
| 10728 | wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index].type_entry; | 10728 | wanted_type->data.maybe.child_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10729 | assert(ptr_type->id == TypeTableEntryIdPointer); | 10729 | assert(ptr_type->id == ZigTypeIdPointer); |
| 10730 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | 10730 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && |
| 10731 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | 10731 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 10732 | source_node, false).id == ConstCastResultIdOk) | 10732 | source_node, false).id == ConstCastResultIdOk) |
| ... | @@ -10744,11 +10744,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10744,11 +10744,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10744 | } | 10744 | } |
| 10745 | | 10745 | |
| 10746 | // *[N]T to [*]T | 10746 | // *[N]T to [*]T |
| 10747 | if (wanted_type->id == TypeTableEntryIdPointer && | 10747 | if (wanted_type->id == ZigTypeIdPointer && |
| 10748 | wanted_type->data.pointer.ptr_len == PtrLenUnknown && | 10748 | wanted_type->data.pointer.ptr_len == PtrLenUnknown && |
| 10749 | actual_type->id == TypeTableEntryIdPointer && | 10749 | actual_type->id == ZigTypeIdPointer && |
| 10750 | actual_type->data.pointer.ptr_len == PtrLenSingle && | 10750 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 10751 | actual_type->data.pointer.child_type->id == TypeTableEntryIdArray && | 10751 | actual_type->data.pointer.child_type->id == ZigTypeIdArray && |
| 10752 | actual_type->data.pointer.alignment >= wanted_type->data.pointer.alignment && | 10752 | actual_type->data.pointer.alignment >= wanted_type->data.pointer.alignment && |
| 10753 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, | 10753 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 10754 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 10754 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| ... | @@ -10759,12 +10759,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10759,12 +10759,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10759 | | 10759 | |
| 10760 | // *[N]T to []T | 10760 | // *[N]T to []T |
| 10761 | if (is_slice(wanted_type) && | 10761 | if (is_slice(wanted_type) && |
| 10762 | actual_type->id == TypeTableEntryIdPointer && | 10762 | actual_type->id == ZigTypeIdPointer && |
| 10763 | actual_type->data.pointer.ptr_len == PtrLenSingle && | 10763 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 10764 | actual_type->data.pointer.child_type->id == TypeTableEntryIdArray) | 10764 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 10765 | { | 10765 | { |
| 10766 | ZigType *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry; | 10766 | ZigType *slice_ptr_type = wanted_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10767 | assert(slice_ptr_type->id == TypeTableEntryIdPointer); | 10767 | assert(slice_ptr_type->id == ZigTypeIdPointer); |
| 10768 | if (types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type, | 10768 | if (types_match_const_cast_only(ira, slice_ptr_type->data.pointer.child_type, |
| 10769 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 10769 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| 10770 | !slice_ptr_type->data.pointer.is_const).id == ConstCastResultIdOk) | 10770 | !slice_ptr_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| ... | @@ -10776,23 +10776,23 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10776,23 +10776,23 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10776 | | 10776 | |
| 10777 | // cast from T to ?T | 10777 | // cast from T to ?T |
| 10778 | // note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism | 10778 | // note that the *T to ?*T case is handled via the "ConstCastOnly" mechanism |
| 10779 | if (wanted_type->id == TypeTableEntryIdOptional) { | 10779 | if (wanted_type->id == ZigTypeIdOptional) { |
| 10780 | ZigType *wanted_child_type = wanted_type->data.maybe.child_type; | 10780 | ZigType *wanted_child_type = wanted_type->data.maybe.child_type; |
| 10781 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, | 10781 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, |
| 10782 | false).id == ConstCastResultIdOk) | 10782 | false).id == ConstCastResultIdOk) |
| 10783 | { | 10783 | { |
| 10784 | return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type); | 10784 | return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type); |
| 10785 | } else if (actual_type->id == TypeTableEntryIdComptimeInt || | 10785 | } else if (actual_type->id == ZigTypeIdComptimeInt || |
| 10786 | actual_type->id == TypeTableEntryIdComptimeFloat) | 10786 | actual_type->id == ZigTypeIdComptimeFloat) |
| 10787 | { | 10787 | { |
| 10788 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { | 10788 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { |
| 10789 | return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type); | 10789 | return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type); |
| 10790 | } else { | 10790 | } else { |
| 10791 | return ira->codegen->invalid_instruction; | 10791 | return ira->codegen->invalid_instruction; |
| 10792 | } | 10792 | } |
| 10793 | } else if (wanted_child_type->id == TypeTableEntryIdPointer && | 10793 | } else if (wanted_child_type->id == ZigTypeIdPointer && |
| 10794 | wanted_child_type->data.pointer.is_const && | 10794 | wanted_child_type->data.pointer.is_const && |
| 10795 | (actual_type->id == TypeTableEntryIdPointer || is_container(actual_type))) | 10795 | (actual_type->id == ZigTypeIdPointer || is_container(actual_type))) |
| 10796 | { | 10796 | { |
| 10797 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_child_type, value); | 10797 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_child_type, value); |
| 10798 | if (type_is_invalid(cast1->value.type)) | 10798 | if (type_is_invalid(cast1->value.type)) |
| ... | @@ -10804,11 +10804,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10804,11 +10804,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10804 | | 10804 | |
| 10805 | return cast2; | 10805 | return cast2; |
| 10806 | } else if ( | 10806 | } else if ( |
| 10807 | wanted_child_type->id == TypeTableEntryIdPointer && | 10807 | wanted_child_type->id == ZigTypeIdPointer && |
| 10808 | wanted_child_type->data.pointer.ptr_len == PtrLenUnknown && | 10808 | wanted_child_type->data.pointer.ptr_len == PtrLenUnknown && |
| 10809 | actual_type->id == TypeTableEntryIdPointer && | 10809 | actual_type->id == ZigTypeIdPointer && |
| 10810 | actual_type->data.pointer.ptr_len == PtrLenSingle && | 10810 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 10811 | actual_type->data.pointer.child_type->id == TypeTableEntryIdArray && | 10811 | actual_type->data.pointer.child_type->id == ZigTypeIdArray && |
| 10812 | actual_type->data.pointer.alignment >= wanted_child_type->data.pointer.alignment && | 10812 | actual_type->data.pointer.alignment >= wanted_child_type->data.pointer.alignment && |
| 10813 | types_match_const_cast_only(ira, wanted_child_type->data.pointer.child_type, | 10813 | types_match_const_cast_only(ira, wanted_child_type->data.pointer.child_type, |
| 10814 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 10814 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| ... | @@ -10822,20 +10822,20 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10822,20 +10822,20 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10822 | } | 10822 | } |
| 10823 | | 10823 | |
| 10824 | // cast from null literal to maybe type | 10824 | // cast from null literal to maybe type |
| 10825 | if (wanted_type->id == TypeTableEntryIdOptional && | 10825 | if (wanted_type->id == ZigTypeIdOptional && |
| 10826 | actual_type->id == TypeTableEntryIdNull) | 10826 | actual_type->id == ZigTypeIdNull) |
| 10827 | { | 10827 | { |
| 10828 | return ir_analyze_null_to_maybe(ira, source_instr, value, wanted_type); | 10828 | return ir_analyze_null_to_maybe(ira, source_instr, value, wanted_type); |
| 10829 | } | 10829 | } |
| 10830 | | 10830 | |
| 10831 | // cast from child type of error type to error type | 10831 | // cast from child type of error type to error type |
| 10832 | if (wanted_type->id == TypeTableEntryIdErrorUnion) { | 10832 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 10833 | if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, | 10833 | if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, |
| 10834 | source_node, false).id == ConstCastResultIdOk) | 10834 | source_node, false).id == ConstCastResultIdOk) |
| 10835 | { | 10835 | { |
| 10836 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type); | 10836 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type); |
| 10837 | } else if (actual_type->id == TypeTableEntryIdComptimeInt || | 10837 | } else if (actual_type->id == ZigTypeIdComptimeInt || |
| 10838 | actual_type->id == TypeTableEntryIdComptimeFloat) | 10838 | actual_type->id == ZigTypeIdComptimeFloat) |
| 10839 | { | 10839 | { |
| 10840 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { | 10840 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { |
| 10841 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type); | 10841 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type); |
| ... | @@ -10846,13 +10846,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10846,13 +10846,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10846 | } | 10846 | } |
| 10847 | | 10847 | |
| 10848 | // cast from [N]T to E![]const T | 10848 | // cast from [N]T to E![]const T |
| 10849 | if (wanted_type->id == TypeTableEntryIdErrorUnion && | 10849 | if (wanted_type->id == ZigTypeIdErrorUnion && |
| 10850 | is_slice(wanted_type->data.error_union.payload_type) && | 10850 | is_slice(wanted_type->data.error_union.payload_type) && |
| 10851 | actual_type->id == TypeTableEntryIdArray) | 10851 | actual_type->id == ZigTypeIdArray) |
| 10852 | { | 10852 | { |
| 10853 | ZigType *ptr_type = | 10853 | ZigType *ptr_type = |
| 10854 | wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index].type_entry; | 10854 | wanted_type->data.error_union.payload_type->data.structure.fields[slice_ptr_index].type_entry; |
| 10855 | assert(ptr_type->id == TypeTableEntryIdPointer); | 10855 | assert(ptr_type->id == ZigTypeIdPointer); |
| 10856 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && | 10856 | if ((ptr_type->data.pointer.is_const || actual_type->data.array.len == 0) && |
| 10857 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, | 10857 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 10858 | source_node, false).id == ConstCastResultIdOk) | 10858 | source_node, false).id == ConstCastResultIdOk) |
| ... | @@ -10870,22 +10870,22 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10870,22 +10870,22 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10870 | } | 10870 | } |
| 10871 | | 10871 | |
| 10872 | // cast from error set to error union type | 10872 | // cast from error set to error union type |
| 10873 | if (wanted_type->id == TypeTableEntryIdErrorUnion && | 10873 | if (wanted_type->id == ZigTypeIdErrorUnion && |
| 10874 | actual_type->id == TypeTableEntryIdErrorSet) | 10874 | actual_type->id == ZigTypeIdErrorSet) |
| 10875 | { | 10875 | { |
| 10876 | return ir_analyze_err_wrap_code(ira, source_instr, value, wanted_type); | 10876 | return ir_analyze_err_wrap_code(ira, source_instr, value, wanted_type); |
| 10877 | } | 10877 | } |
| 10878 | | 10878 | |
| 10879 | // cast from T to E!?T | 10879 | // cast from T to E!?T |
| 10880 | if (wanted_type->id == TypeTableEntryIdErrorUnion && | 10880 | if (wanted_type->id == ZigTypeIdErrorUnion && |
| 10881 | wanted_type->data.error_union.payload_type->id == TypeTableEntryIdOptional && | 10881 | wanted_type->data.error_union.payload_type->id == ZigTypeIdOptional && |
| 10882 | actual_type->id != TypeTableEntryIdOptional) | 10882 | actual_type->id != ZigTypeIdOptional) |
| 10883 | { | 10883 | { |
| 10884 | ZigType *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type; | 10884 | ZigType *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type; |
| 10885 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, false).id == ConstCastResultIdOk || | 10885 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, false).id == ConstCastResultIdOk || |
| 10886 | actual_type->id == TypeTableEntryIdNull || | 10886 | actual_type->id == ZigTypeIdNull || |
| 10887 | actual_type->id == TypeTableEntryIdComptimeInt || | 10887 | actual_type->id == ZigTypeIdComptimeInt || |
| 10888 | actual_type->id == TypeTableEntryIdComptimeFloat) | 10888 | actual_type->id == ZigTypeIdComptimeFloat) |
| 10889 | { | 10889 | { |
| 10890 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 10890 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 10891 | if (type_is_invalid(cast1->value.type)) | 10891 | if (type_is_invalid(cast1->value.type)) |
| ... | @@ -10901,12 +10901,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10901,12 +10901,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10901 | | 10901 | |
| 10902 | // cast from number literal to another type | 10902 | // cast from number literal to another type |
| 10903 | // cast from number literal to *const integer | 10903 | // cast from number literal to *const integer |
| 10904 | if (actual_type->id == TypeTableEntryIdComptimeFloat || | 10904 | if (actual_type->id == ZigTypeIdComptimeFloat || |
| 10905 | actual_type->id == TypeTableEntryIdComptimeInt) | 10905 | actual_type->id == ZigTypeIdComptimeInt) |
| 10906 | { | 10906 | { |
| 10907 | if ((err = ensure_complete_type(ira->codegen, wanted_type))) | 10907 | if ((err = ensure_complete_type(ira->codegen, wanted_type))) |
| 10908 | return ira->codegen->invalid_instruction; | 10908 | return ira->codegen->invalid_instruction; |
| 10909 | if (wanted_type->id == TypeTableEntryIdEnum) { | 10909 | if (wanted_type->id == ZigTypeIdEnum) { |
| 10910 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.enumeration.tag_int_type, value); | 10910 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.enumeration.tag_int_type, value); |
| 10911 | if (type_is_invalid(cast1->value.type)) | 10911 | if (type_is_invalid(cast1->value.type)) |
| 10912 | return ira->codegen->invalid_instruction; | 10912 | return ira->codegen->invalid_instruction; |
| ... | @@ -10916,7 +10916,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10916,7 +10916,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10916 | return ira->codegen->invalid_instruction; | 10916 | return ira->codegen->invalid_instruction; |
| 10917 | | 10917 | |
| 10918 | return cast2; | 10918 | return cast2; |
| 10919 | } else if (wanted_type->id == TypeTableEntryIdPointer && | 10919 | } else if (wanted_type->id == ZigTypeIdPointer && |
| 10920 | wanted_type->data.pointer.is_const) | 10920 | wanted_type->data.pointer.is_const) |
| 10921 | { | 10921 | { |
| 10922 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.pointer.child_type, value); | 10922 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.pointer.child_type, value); |
| ... | @@ -10930,15 +10930,15 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10930,15 +10930,15 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10930 | return cast2; | 10930 | return cast2; |
| 10931 | } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { | 10931 | } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 10932 | CastOp op; | 10932 | CastOp op; |
| 10933 | if ((actual_type->id == TypeTableEntryIdComptimeFloat && | 10933 | if ((actual_type->id == ZigTypeIdComptimeFloat && |
| 10934 | wanted_type->id == TypeTableEntryIdFloat) || | 10934 | wanted_type->id == ZigTypeIdFloat) || |
| 10935 | (actual_type->id == TypeTableEntryIdComptimeInt && | 10935 | (actual_type->id == ZigTypeIdComptimeInt && |
| 10936 | wanted_type->id == TypeTableEntryIdInt)) | 10936 | wanted_type->id == ZigTypeIdInt)) |
| 10937 | { | 10937 | { |
| 10938 | op = CastOpNumLitToConcrete; | 10938 | op = CastOpNumLitToConcrete; |
| 10939 | } else if (wanted_type->id == TypeTableEntryIdInt) { | 10939 | } else if (wanted_type->id == ZigTypeIdInt) { |
| 10940 | op = CastOpFloatToInt; | 10940 | op = CastOpFloatToInt; |
| 10941 | } else if (wanted_type->id == TypeTableEntryIdFloat) { | 10941 | } else if (wanted_type->id == ZigTypeIdFloat) { |
| 10942 | op = CastOpIntToFloat; | 10942 | op = CastOpIntToFloat; |
| 10943 | } else { | 10943 | } else { |
| 10944 | zig_unreachable(); | 10944 | zig_unreachable(); |
| ... | @@ -10952,14 +10952,14 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10952,14 +10952,14 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10952 | // cast from typed number to integer or float literal. | 10952 | // cast from typed number to integer or float literal. |
| 10953 | // works when the number is known at compile time | 10953 | // works when the number is known at compile time |
| 10954 | if (instr_is_comptime(value) && | 10954 | if (instr_is_comptime(value) && |
| 10955 | ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdComptimeInt) || | 10955 | ((actual_type->id == ZigTypeIdInt && wanted_type->id == ZigTypeIdComptimeInt) || |
| 10956 | (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdComptimeFloat))) | 10956 | (actual_type->id == ZigTypeIdFloat && wanted_type->id == ZigTypeIdComptimeFloat))) |
| 10957 | { | 10957 | { |
| 10958 | return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type); | 10958 | return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type); |
| 10959 | } | 10959 | } |
| 10960 | | 10960 | |
| 10961 | // cast from union to the enum type of the union | 10961 | // cast from union to the enum type of the union |
| 10962 | if (actual_type->id == TypeTableEntryIdUnion && wanted_type->id == TypeTableEntryIdEnum) { | 10962 | if (actual_type->id == ZigTypeIdUnion && wanted_type->id == ZigTypeIdEnum) { |
| 10963 | if ((err = type_ensure_zero_bits_known(ira->codegen, actual_type))) | 10963 | if ((err = type_ensure_zero_bits_known(ira->codegen, actual_type))) |
| 10964 | return ira->codegen->invalid_instruction; | 10964 | return ira->codegen->invalid_instruction; |
| 10965 | | 10965 | |
| ... | @@ -10969,7 +10969,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10969,7 +10969,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10969 | } | 10969 | } |
| 10970 | | 10970 | |
| 10971 | // enum to union which has the enum as the tag type | 10971 | // enum to union which has the enum as the tag type |
| 10972 | if (wanted_type->id == TypeTableEntryIdUnion && actual_type->id == TypeTableEntryIdEnum && | 10972 | if (wanted_type->id == ZigTypeIdUnion && actual_type->id == ZigTypeIdEnum && |
| 10973 | (wanted_type->data.unionation.decl_node->data.container_decl.auto_enum || | 10973 | (wanted_type->data.unionation.decl_node->data.container_decl.auto_enum || |
| 10974 | wanted_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) | 10974 | wanted_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)) |
| 10975 | { | 10975 | { |
| ... | @@ -10982,7 +10982,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -10982,7 +10982,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10982 | } | 10982 | } |
| 10983 | | 10983 | |
| 10984 | // enum to &const union which has the enum as the tag type | 10984 | // enum to &const union which has the enum as the tag type |
| 10985 | if (actual_type->id == TypeTableEntryIdEnum && wanted_type->id == TypeTableEntryIdPointer) { | 10985 | if (actual_type->id == ZigTypeIdEnum && wanted_type->id == ZigTypeIdPointer) { |
| 10986 | ZigType *union_type = wanted_type->data.pointer.child_type; | 10986 | ZigType *union_type = wanted_type->data.pointer.child_type; |
| 10987 | if (union_type->data.unionation.decl_node->data.container_decl.auto_enum || | 10987 | if (union_type->data.unionation.decl_node->data.container_decl.auto_enum || |
| 10988 | union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr) | 10988 | union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr) |
| ... | @@ -11005,11 +11005,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11005,11 +11005,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11005 | } | 11005 | } |
| 11006 | | 11006 | |
| 11007 | // cast from *T to *[1]T | 11007 | // cast from *T to *[1]T |
| 11008 | if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle && | 11008 | if (wanted_type->id == ZigTypeIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle && |
| 11009 | actual_type->id == TypeTableEntryIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle) | 11009 | actual_type->id == ZigTypeIdPointer && actual_type->data.pointer.ptr_len == PtrLenSingle) |
| 11010 | { | 11010 | { |
| 11011 | ZigType *array_type = wanted_type->data.pointer.child_type; | 11011 | ZigType *array_type = wanted_type->data.pointer.child_type; |
| 11012 | if (array_type->id == TypeTableEntryIdArray && array_type->data.array.len == 1 && | 11012 | if (array_type->id == ZigTypeIdArray && array_type->data.array.len == 1 && |
| 11013 | types_match_const_cast_only(ira, array_type->data.array.child_type, | 11013 | types_match_const_cast_only(ira, array_type->data.array.child_type, |
| 11014 | actual_type->data.pointer.child_type, source_node, | 11014 | actual_type->data.pointer.child_type, source_node, |
| 11015 | !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) | 11015 | !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| ... | @@ -11029,7 +11029,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11029,7 +11029,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11029 | } | 11029 | } |
| 11030 | | 11030 | |
| 11031 | // cast from T to *T where T is zero bits | 11031 | // cast from T to *T where T is zero bits |
| 11032 | if (wanted_type->id == TypeTableEntryIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle && | 11032 | if (wanted_type->id == ZigTypeIdPointer && wanted_type->data.pointer.ptr_len == PtrLenSingle && |
| 11033 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, | 11033 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 11034 | actual_type, source_node, !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) | 11034 | actual_type, source_node, !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| 11035 | { | 11035 | { |
| ... | @@ -11043,7 +11043,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -11043,7 +11043,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 11043 | | 11043 | |
| 11044 | | 11044 | |
| 11045 | // cast from undefined to anything | 11045 | // cast from undefined to anything |
| 11046 | if (actual_type->id == TypeTableEntryIdUndefined) { | 11046 | if (actual_type->id == ZigTypeIdUndefined) { |
| 11047 | return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type); | 11047 | return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type); |
| 11048 | } | 11048 | } |
| 11049 | | 11049 | |
| ... | @@ -11073,7 +11073,7 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, Zig | ... | @@ -11073,7 +11073,7 @@ static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, Zig |
| 11073 | return value; // anything will do | 11073 | return value; // anything will do |
| 11074 | if (expected_type == value->value.type) | 11074 | if (expected_type == value->value.type) |
| 11075 | return value; // match | 11075 | return value; // match |
| 11076 | if (value->value.type->id == TypeTableEntryIdUnreachable) | 11076 | if (value->value.type->id == ZigTypeIdUnreachable) |
| 11077 | return value; | 11077 | return value; |
| 11078 | | 11078 | |
| 11079 | return ir_analyze_cast(ira, value, expected_type, value); | 11079 | return ir_analyze_cast(ira, value, expected_type, value); |
| ... | @@ -11083,7 +11083,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -11083,7 +11083,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 11083 | ZigType *type_entry = ptr->value.type; | 11083 | ZigType *type_entry = ptr->value.type; |
| 11084 | if (type_is_invalid(type_entry)) { | 11084 | if (type_is_invalid(type_entry)) { |
| 11085 | return ira->codegen->invalid_instruction; | 11085 | return ira->codegen->invalid_instruction; |
| 11086 | } else if (type_entry->id == TypeTableEntryIdPointer) { | 11086 | } else if (type_entry->id == ZigTypeIdPointer) { |
| 11087 | ZigType *child_type = type_entry->data.pointer.child_type; | 11087 | ZigType *child_type = type_entry->data.pointer.child_type; |
| 11088 | if (instr_is_comptime(ptr)) { | 11088 | if (instr_is_comptime(ptr)) { |
| 11089 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst || | 11089 | if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst || |
| ... | @@ -11198,7 +11198,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -11198,7 +11198,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 11198 | return false; | 11198 | return false; |
| 11199 | | 11199 | |
| 11200 | ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); | 11200 | ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); |
| 11201 | assert(atomic_order_val->type->id == TypeTableEntryIdMetaType); | 11201 | assert(atomic_order_val->type->id == ZigTypeIdMetaType); |
| 11202 | ZigType *atomic_order_type = atomic_order_val->data.x_type; | 11202 | ZigType *atomic_order_type = atomic_order_val->data.x_type; |
| 11203 | | 11203 | |
| 11204 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | 11204 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| ... | @@ -11218,7 +11218,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -11218,7 +11218,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 11218 | return false; | 11218 | return false; |
| 11219 | | 11219 | |
| 11220 | ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); | 11220 | ConstExprValue *atomic_rmw_op_val = get_builtin_value(ira->codegen, "AtomicRmwOp"); |
| 11221 | assert(atomic_rmw_op_val->type->id == TypeTableEntryIdMetaType); | 11221 | assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType); |
| 11222 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; | 11222 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; |
| 11223 | | 11223 | |
| 11224 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | 11224 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); |
| ... | @@ -11238,7 +11238,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -11238,7 +11238,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 11238 | return false; | 11238 | return false; |
| 11239 | | 11239 | |
| 11240 | ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); | 11240 | ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); |
| 11241 | assert(global_linkage_val->type->id == TypeTableEntryIdMetaType); | 11241 | assert(global_linkage_val->type->id == ZigTypeIdMetaType); |
| 11242 | ZigType *global_linkage_type = global_linkage_val->data.x_type; | 11242 | ZigType *global_linkage_type = global_linkage_val->data.x_type; |
| 11243 | | 11243 | |
| 11244 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | 11244 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| ... | @@ -11258,7 +11258,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -11258,7 +11258,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 11258 | return false; | 11258 | return false; |
| 11259 | | 11259 | |
| 11260 | ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); | 11260 | ConstExprValue *float_mode_val = get_builtin_value(ira->codegen, "FloatMode"); |
| 11261 | assert(float_mode_val->type->id == TypeTableEntryIdMetaType); | 11261 | assert(float_mode_val->type->id == ZigTypeIdMetaType); |
| 11262 | ZigType *float_mode_type = float_mode_val->data.x_type; | 11262 | ZigType *float_mode_type = float_mode_val->data.x_type; |
| 11263 | | 11263 | |
| 11264 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); | 11264 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); |
| ... | @@ -11340,7 +11340,7 @@ static ZigType *ir_analyze_instruction_return(IrAnalyze *ira, | ... | @@ -11340,7 +11340,7 @@ static ZigType *ir_analyze_instruction_return(IrAnalyze *ira, |
| 11340 | return ir_unreach_error(ira); | 11340 | return ir_unreach_error(ira); |
| 11341 | | 11341 | |
| 11342 | if (casted_value->value.special == ConstValSpecialRuntime && | 11342 | if (casted_value->value.special == ConstValSpecialRuntime && |
| 11343 | casted_value->value.type->id == TypeTableEntryIdPointer && | 11343 | casted_value->value.type->id == ZigTypeIdPointer && |
| 11344 | casted_value->value.data.rh_ptr == RuntimeHintPtrStack) | 11344 | casted_value->value.data.rh_ptr == RuntimeHintPtrStack) |
| 11345 | { | 11345 | { |
| 11346 | ir_add_error(ira, casted_value, buf_sprintf("function returns address of local variable")); | 11346 | ir_add_error(ira, casted_value, buf_sprintf("function returns address of local variable")); |
| ... | @@ -11388,8 +11388,8 @@ static ZigType *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_o | ... | @@ -11388,8 +11388,8 @@ static ZigType *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_o |
| 11388 | if (op2_val == nullptr) | 11388 | if (op2_val == nullptr) |
| 11389 | return ira->codegen->builtin_types.entry_invalid; | 11389 | return ira->codegen->builtin_types.entry_invalid; |
| 11390 | | 11390 | |
| 11391 | assert(casted_op1->value.type->id == TypeTableEntryIdBool); | 11391 | assert(casted_op1->value.type->id == ZigTypeIdBool); |
| 11392 | assert(casted_op2->value.type->id == TypeTableEntryIdBool); | 11392 | assert(casted_op2->value.type->id == ZigTypeIdBool); |
| 11393 | if (bin_op_instruction->op_id == IrBinOpBoolOr) { | 11393 | if (bin_op_instruction->op_id == IrBinOpBoolOr) { |
| 11394 | out_val->data.x_bool = op1_val->data.x_bool || op2_val->data.x_bool; | 11394 | out_val->data.x_bool = op1_val->data.x_bool || op2_val->data.x_bool; |
| 11395 | } else if (bin_op_instruction->op_id == IrBinOpBoolAnd) { | 11395 | } else if (bin_op_instruction->op_id == IrBinOpBoolAnd) { |
| ... | @@ -11442,19 +11442,19 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op | ... | @@ -11442,19 +11442,19 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11442 | IrBinOp op_id = bin_op_instruction->op_id; | 11442 | IrBinOp op_id = bin_op_instruction->op_id; |
| 11443 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); | 11443 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); |
| 11444 | if (is_equality_cmp && | 11444 | if (is_equality_cmp && |
| 11445 | ((op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdOptional) || | 11445 | ((op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdOptional) || |
| 11446 | (op2->value.type->id == TypeTableEntryIdNull && op1->value.type->id == TypeTableEntryIdOptional) || | 11446 | (op2->value.type->id == ZigTypeIdNull && op1->value.type->id == ZigTypeIdOptional) || |
| 11447 | (op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdNull))) | 11447 | (op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdNull))) |
| 11448 | { | 11448 | { |
| 11449 | if (op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdNull) { | 11449 | if (op1->value.type->id == ZigTypeIdNull && op2->value.type->id == ZigTypeIdNull) { |
| 11450 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); | 11450 | ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base); |
| 11451 | out_val->data.x_bool = (op_id == IrBinOpCmpEq); | 11451 | out_val->data.x_bool = (op_id == IrBinOpCmpEq); |
| 11452 | return ira->codegen->builtin_types.entry_bool; | 11452 | return ira->codegen->builtin_types.entry_bool; |
| 11453 | } | 11453 | } |
| 11454 | IrInstruction *maybe_op; | 11454 | IrInstruction *maybe_op; |
| 11455 | if (op1->value.type->id == TypeTableEntryIdNull) { | 11455 | if (op1->value.type->id == ZigTypeIdNull) { |
| 11456 | maybe_op = op2; | 11456 | maybe_op = op2; |
| 11457 | } else if (op2->value.type->id == TypeTableEntryIdNull) { | 11457 | } else if (op2->value.type->id == ZigTypeIdNull) { |
| 11458 | maybe_op = op1; | 11458 | maybe_op = op1; |
| 11459 | } else { | 11459 | } else { |
| 11460 | zig_unreachable(); | 11460 | zig_unreachable(); |
| ... | @@ -11481,7 +11481,7 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op | ... | @@ -11481,7 +11481,7 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11481 | return ira->codegen->builtin_types.entry_bool; | 11481 | return ira->codegen->builtin_types.entry_bool; |
| 11482 | } | 11482 | } |
| 11483 | | 11483 | |
| 11484 | if (op1->value.type->id == TypeTableEntryIdErrorSet && op2->value.type->id == TypeTableEntryIdErrorSet) { | 11484 | if (op1->value.type->id == ZigTypeIdErrorSet && op2->value.type->id == ZigTypeIdErrorSet) { |
| 11485 | if (!is_equality_cmp) { | 11485 | if (!is_equality_cmp) { |
| 11486 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); | 11486 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); |
| 11487 | return ira->codegen->builtin_types.entry_invalid; | 11487 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -11575,42 +11575,42 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op | ... | @@ -11575,42 +11575,42 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11575 | | 11575 | |
| 11576 | bool operator_allowed; | 11576 | bool operator_allowed; |
| 11577 | switch (resolved_type->id) { | 11577 | switch (resolved_type->id) { |
| 11578 | case TypeTableEntryIdInvalid: | 11578 | case ZigTypeIdInvalid: |
| 11579 | zig_unreachable(); // handled above | 11579 | zig_unreachable(); // handled above |
| 11580 | | 11580 | |
| 11581 | case TypeTableEntryIdComptimeFloat: | 11581 | case ZigTypeIdComptimeFloat: |
| 11582 | case TypeTableEntryIdComptimeInt: | 11582 | case ZigTypeIdComptimeInt: |
| 11583 | case TypeTableEntryIdInt: | 11583 | case ZigTypeIdInt: |
| 11584 | case TypeTableEntryIdFloat: | 11584 | case ZigTypeIdFloat: |
| 11585 | operator_allowed = true; | 11585 | operator_allowed = true; |
| 11586 | break; | 11586 | break; |
| 11587 | | 11587 | |
| 11588 | case TypeTableEntryIdBool: | 11588 | case ZigTypeIdBool: |
| 11589 | case TypeTableEntryIdMetaType: | 11589 | case ZigTypeIdMetaType: |
| 11590 | case TypeTableEntryIdVoid: | 11590 | case ZigTypeIdVoid: |
| 11591 | case TypeTableEntryIdPointer: | 11591 | case ZigTypeIdPointer: |
| 11592 | case TypeTableEntryIdErrorSet: | 11592 | case ZigTypeIdErrorSet: |
| 11593 | case TypeTableEntryIdFn: | 11593 | case ZigTypeIdFn: |
| 11594 | case TypeTableEntryIdOpaque: | 11594 | case ZigTypeIdOpaque: |
| 11595 | case TypeTableEntryIdNamespace: | 11595 | case ZigTypeIdNamespace: |
| 11596 | case TypeTableEntryIdBlock: | 11596 | case ZigTypeIdBlock: |
| 11597 | case TypeTableEntryIdBoundFn: | 11597 | case ZigTypeIdBoundFn: |
| 11598 | case TypeTableEntryIdArgTuple: | 11598 | case ZigTypeIdArgTuple: |
| 11599 | case TypeTableEntryIdPromise: | 11599 | case ZigTypeIdPromise: |
| 11600 | case TypeTableEntryIdEnum: | 11600 | case ZigTypeIdEnum: |
| 11601 | operator_allowed = is_equality_cmp; | 11601 | operator_allowed = is_equality_cmp; |
| 11602 | break; | 11602 | break; |
| 11603 | | 11603 | |
| 11604 | case TypeTableEntryIdUnreachable: | 11604 | case ZigTypeIdUnreachable: |
| 11605 | case TypeTableEntryIdArray: | 11605 | case ZigTypeIdArray: |
| 11606 | case TypeTableEntryIdStruct: | 11606 | case ZigTypeIdStruct: |
| 11607 | case TypeTableEntryIdUndefined: | 11607 | case ZigTypeIdUndefined: |
| 11608 | case TypeTableEntryIdNull: | 11608 | case ZigTypeIdNull: |
| 11609 | case TypeTableEntryIdErrorUnion: | 11609 | case ZigTypeIdErrorUnion: |
| 11610 | case TypeTableEntryIdUnion: | 11610 | case ZigTypeIdUnion: |
| 11611 | operator_allowed = false; | 11611 | operator_allowed = false; |
| 11612 | break; | 11612 | break; |
| 11613 | case TypeTableEntryIdOptional: | 11613 | case ZigTypeIdOptional: |
| 11614 | operator_allowed = is_equality_cmp && get_codegen_ptr_type(resolved_type) != nullptr; | 11614 | operator_allowed = is_equality_cmp && get_codegen_ptr_type(resolved_type) != nullptr; |
| 11615 | break; | 11615 | break; |
| 11616 | } | 11616 | } |
| ... | @@ -11638,10 +11638,10 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op | ... | @@ -11638,10 +11638,10 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11638 | return ira->codegen->builtin_types.entry_invalid; | 11638 | return ira->codegen->builtin_types.entry_invalid; |
| 11639 | | 11639 | |
| 11640 | bool answer; | 11640 | bool answer; |
| 11641 | if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) { | 11641 | if (resolved_type->id == ZigTypeIdComptimeFloat || resolved_type->id == ZigTypeIdFloat) { |
| 11642 | Cmp cmp_result = float_cmp(op1_val, op2_val); | 11642 | Cmp cmp_result = float_cmp(op1_val, op2_val); |
| 11643 | answer = resolve_cmp_op_id(op_id, cmp_result); | 11643 | answer = resolve_cmp_op_id(op_id, cmp_result); |
| 11644 | } else if (resolved_type->id == TypeTableEntryIdComptimeInt || resolved_type->id == TypeTableEntryIdInt) { | 11644 | } else if (resolved_type->id == ZigTypeIdComptimeInt || resolved_type->id == ZigTypeIdInt) { |
| 11645 | Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint); | 11645 | Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint); |
| 11646 | answer = resolve_cmp_op_id(op_id, cmp_result); | 11646 | answer = resolve_cmp_op_id(op_id, cmp_result); |
| 11647 | } else { | 11647 | } else { |
| ... | @@ -11661,7 +11661,7 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op | ... | @@ -11661,7 +11661,7 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11661 | } | 11661 | } |
| 11662 | | 11662 | |
| 11663 | // some comparisons with unsigned numbers can be evaluated | 11663 | // some comparisons with unsigned numbers can be evaluated |
| 11664 | if (resolved_type->id == TypeTableEntryIdInt && !resolved_type->data.integral.is_signed) { | 11664 | if (resolved_type->id == ZigTypeIdInt && !resolved_type->data.integral.is_signed) { |
| 11665 | ConstExprValue *known_left_val; | 11665 | ConstExprValue *known_left_val; |
| 11666 | IrBinOp flipped_op_id; | 11666 | IrBinOp flipped_op_id; |
| 11667 | if (instr_is_comptime(casted_op1)) { | 11667 | if (instr_is_comptime(casted_op1)) { |
| ... | @@ -11711,12 +11711,12 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, | ... | @@ -11711,12 +11711,12 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, |
| 11711 | bool is_int; | 11711 | bool is_int; |
| 11712 | bool is_float; | 11712 | bool is_float; |
| 11713 | Cmp op2_zcmp; | 11713 | Cmp op2_zcmp; |
| 11714 | if (type_entry->id == TypeTableEntryIdInt || type_entry->id == TypeTableEntryIdComptimeInt) { | 11714 | if (type_entry->id == ZigTypeIdInt || type_entry->id == ZigTypeIdComptimeInt) { |
| 11715 | is_int = true; | 11715 | is_int = true; |
| 11716 | is_float = false; | 11716 | is_float = false; |
| 11717 | op2_zcmp = bigint_cmp_zero(&op2_val->data.x_bigint); | 11717 | op2_zcmp = bigint_cmp_zero(&op2_val->data.x_bigint); |
| 11718 | } else if (type_entry->id == TypeTableEntryIdFloat || | 11718 | } else if (type_entry->id == ZigTypeIdFloat || |
| 11719 | type_entry->id == TypeTableEntryIdComptimeFloat) | 11719 | type_entry->id == ZigTypeIdComptimeFloat) |
| 11720 | { | 11720 | { |
| 11721 | is_int = false; | 11721 | is_int = false; |
| 11722 | is_float = true; | 11722 | is_float = true; |
| ... | @@ -11766,7 +11766,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, | ... | @@ -11766,7 +11766,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, |
| 11766 | bigint_shl(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint); | 11766 | bigint_shl(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint); |
| 11767 | break; | 11767 | break; |
| 11768 | case IrBinOpBitShiftLeftLossy: | 11768 | case IrBinOpBitShiftLeftLossy: |
| 11769 | assert(type_entry->id == TypeTableEntryIdInt); | 11769 | assert(type_entry->id == ZigTypeIdInt); |
| 11770 | bigint_shl_trunc(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, | 11770 | bigint_shl_trunc(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, |
| 11771 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); | 11771 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); |
| 11772 | break; | 11772 | break; |
| ... | @@ -11793,7 +11793,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, | ... | @@ -11793,7 +11793,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, |
| 11793 | } | 11793 | } |
| 11794 | break; | 11794 | break; |
| 11795 | case IrBinOpAddWrap: | 11795 | case IrBinOpAddWrap: |
| 11796 | assert(type_entry->id == TypeTableEntryIdInt); | 11796 | assert(type_entry->id == ZigTypeIdInt); |
| 11797 | bigint_add_wrap(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, | 11797 | bigint_add_wrap(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, |
| 11798 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); | 11798 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); |
| 11799 | break; | 11799 | break; |
| ... | @@ -11805,7 +11805,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, | ... | @@ -11805,7 +11805,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, |
| 11805 | } | 11805 | } |
| 11806 | break; | 11806 | break; |
| 11807 | case IrBinOpSubWrap: | 11807 | case IrBinOpSubWrap: |
| 11808 | assert(type_entry->id == TypeTableEntryIdInt); | 11808 | assert(type_entry->id == ZigTypeIdInt); |
| 11809 | bigint_sub_wrap(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, | 11809 | bigint_sub_wrap(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, |
| 11810 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); | 11810 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); |
| 11811 | break; | 11811 | break; |
| ... | @@ -11817,7 +11817,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, | ... | @@ -11817,7 +11817,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, |
| 11817 | } | 11817 | } |
| 11818 | break; | 11818 | break; |
| 11819 | case IrBinOpMultWrap: | 11819 | case IrBinOpMultWrap: |
| 11820 | assert(type_entry->id == TypeTableEntryIdInt); | 11820 | assert(type_entry->id == ZigTypeIdInt); |
| 11821 | bigint_mul_wrap(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, | 11821 | bigint_mul_wrap(&out_val->data.x_bigint, &op1_val->data.x_bigint, &op2_val->data.x_bigint, |
| 11822 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); | 11822 | type_entry->data.integral.bit_count, type_entry->data.integral.is_signed); |
| 11823 | break; | 11823 | break; |
| ... | @@ -11872,7 +11872,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, | ... | @@ -11872,7 +11872,7 @@ static int ir_eval_math_op(ZigType *type_entry, ConstExprValue *op1_val, |
| 11872 | break; | 11872 | break; |
| 11873 | } | 11873 | } |
| 11874 | | 11874 | |
| 11875 | if (type_entry->id == TypeTableEntryIdInt) { | 11875 | if (type_entry->id == ZigTypeIdInt) { |
| 11876 | if (!bigint_fits_in_bits(&out_val->data.x_bigint, type_entry->data.integral.bit_count, | 11876 | if (!bigint_fits_in_bits(&out_val->data.x_bigint, type_entry->data.integral.bit_count, |
| 11877 | type_entry->data.integral.is_signed)) | 11877 | type_entry->data.integral.is_signed)) |
| 11878 | { | 11878 | { |
| ... | @@ -11890,7 +11890,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ | ... | @@ -11890,7 +11890,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ |
| 11890 | if (type_is_invalid(op1->value.type)) | 11890 | if (type_is_invalid(op1->value.type)) |
| 11891 | return ira->codegen->builtin_types.entry_invalid; | 11891 | return ira->codegen->builtin_types.entry_invalid; |
| 11892 | | 11892 | |
| 11893 | if (op1->value.type->id != TypeTableEntryIdInt && op1->value.type->id != TypeTableEntryIdComptimeInt) { | 11893 | if (op1->value.type->id != ZigTypeIdInt && op1->value.type->id != ZigTypeIdComptimeInt) { |
| 11894 | ir_add_error(ira, &bin_op_instruction->base, | 11894 | ir_add_error(ira, &bin_op_instruction->base, |
| 11895 | buf_sprintf("bit shifting operation expected integer type, found '%s'", | 11895 | buf_sprintf("bit shifting operation expected integer type, found '%s'", |
| 11896 | buf_ptr(&op1->value.type->name))); | 11896 | buf_ptr(&op1->value.type->name))); |
| ... | @@ -11903,7 +11903,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ | ... | @@ -11903,7 +11903,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ |
| 11903 | | 11903 | |
| 11904 | IrInstruction *casted_op2; | 11904 | IrInstruction *casted_op2; |
| 11905 | IrBinOp op_id = bin_op_instruction->op_id; | 11905 | IrBinOp op_id = bin_op_instruction->op_id; |
| 11906 | if (op1->value.type->id == TypeTableEntryIdComptimeInt) { | 11906 | if (op1->value.type->id == ZigTypeIdComptimeInt) { |
| 11907 | casted_op2 = op2; | 11907 | casted_op2 = op2; |
| 11908 | | 11908 | |
| 11909 | if (op_id == IrBinOpBitShiftLeftLossy) { | 11909 | if (op_id == IrBinOpBitShiftLeftLossy) { |
| ... | @@ -11920,7 +11920,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ | ... | @@ -11920,7 +11920,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ |
| 11920 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 11920 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 11921 | op1->value.type->data.integral.bit_count - 1); | 11921 | op1->value.type->data.integral.bit_count - 1); |
| 11922 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && | 11922 | if (bin_op_instruction->op_id == IrBinOpBitShiftLeftLossy && |
| 11923 | op2->value.type->id == TypeTableEntryIdComptimeInt) { | 11923 | op2->value.type->id == ZigTypeIdComptimeInt) { |
| 11924 | if (!bigint_fits_in_bits(&op2->value.data.x_bigint, | 11924 | if (!bigint_fits_in_bits(&op2->value.data.x_bigint, |
| 11925 | shift_amt_type->data.integral.bit_count, | 11925 | shift_amt_type->data.integral.bit_count, |
| 11926 | op2->value.data.x_bigint.is_negative)) { | 11926 | op2->value.data.x_bigint.is_negative)) { |
| ... | @@ -11974,7 +11974,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ | ... | @@ -11974,7 +11974,7 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ |
| 11974 | | 11974 | |
| 11975 | ir_num_lit_fits_in_other_type(ira, result_instruction, op1->value.type, false); | 11975 | ir_num_lit_fits_in_other_type(ira, result_instruction, op1->value.type, false); |
| 11976 | return op1->value.type; | 11976 | return op1->value.type; |
| 11977 | } else if (op1->value.type->id == TypeTableEntryIdComptimeInt) { | 11977 | } else if (op1->value.type->id == ZigTypeIdComptimeInt) { |
| 11978 | ir_add_error(ira, &bin_op_instruction->base, | 11978 | ir_add_error(ira, &bin_op_instruction->base, |
| 11979 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); | 11979 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); |
| 11980 | return ira->codegen->builtin_types.entry_invalid; | 11980 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -11997,7 +11997,7 @@ static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_o | ... | @@ -11997,7 +11997,7 @@ static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_o |
| 11997 | IrBinOp op_id = bin_op_instruction->op_id; | 11997 | IrBinOp op_id = bin_op_instruction->op_id; |
| 11998 | | 11998 | |
| 11999 | // look for pointer math | 11999 | // look for pointer math |
| 12000 | if (op1->value.type->id == TypeTableEntryIdPointer && op1->value.type->data.pointer.ptr_len == PtrLenUnknown && | 12000 | if (op1->value.type->id == ZigTypeIdPointer && op1->value.type->data.pointer.ptr_len == PtrLenUnknown && |
| 12001 | (op_id == IrBinOpAdd || op_id == IrBinOpSub)) | 12001 | (op_id == IrBinOpAdd || op_id == IrBinOpSub)) |
| 12002 | { | 12002 | { |
| 12003 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | 12003 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); |
| ... | @@ -12016,15 +12016,15 @@ static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_o | ... | @@ -12016,15 +12016,15 @@ static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_o |
| 12016 | if (type_is_invalid(resolved_type)) | 12016 | if (type_is_invalid(resolved_type)) |
| 12017 | return resolved_type; | 12017 | return resolved_type; |
| 12018 | | 12018 | |
| 12019 | bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdComptimeInt; | 12019 | bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt; |
| 12020 | bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdComptimeFloat; | 12020 | bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat; |
| 12021 | bool is_signed_div = ( | 12021 | bool is_signed_div = ( |
| 12022 | (resolved_type->id == TypeTableEntryIdInt && resolved_type->data.integral.is_signed) || | 12022 | (resolved_type->id == ZigTypeIdInt && resolved_type->data.integral.is_signed) || |
| 12023 | resolved_type->id == TypeTableEntryIdFloat || | 12023 | resolved_type->id == ZigTypeIdFloat || |
| 12024 | (resolved_type->id == TypeTableEntryIdComptimeFloat && | 12024 | (resolved_type->id == ZigTypeIdComptimeFloat && |
| 12025 | ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) != | 12025 | ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) != |
| 12026 | (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) || | 12026 | (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) || |
| 12027 | (resolved_type->id == TypeTableEntryIdComptimeInt && | 12027 | (resolved_type->id == ZigTypeIdComptimeInt && |
| 12028 | ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) != | 12028 | ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) != |
| 12029 | (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT))) | 12029 | (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT))) |
| 12030 | ); | 12030 | ); |
| ... | @@ -12146,7 +12146,7 @@ static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_o | ... | @@ -12146,7 +12146,7 @@ static ZigType *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_o |
| 12146 | return ira->codegen->builtin_types.entry_invalid; | 12146 | return ira->codegen->builtin_types.entry_invalid; |
| 12147 | } | 12147 | } |
| 12148 | | 12148 | |
| 12149 | if (resolved_type->id == TypeTableEntryIdComptimeInt) { | 12149 | if (resolved_type->id == ZigTypeIdComptimeInt) { |
| 12150 | if (op_id == IrBinOpAddWrap) { | 12150 | if (op_id == IrBinOpAddWrap) { |
| 12151 | op_id = IrBinOpAdd; | 12151 | op_id = IrBinOpAdd; |
| 12152 | } else if (op_id == IrBinOpSubWrap) { | 12152 | } else if (op_id == IrBinOpSubWrap) { |
| ... | @@ -12229,12 +12229,12 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc | ... | @@ -12229,12 +12229,12 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc |
| 12229 | size_t op1_array_index; | 12229 | size_t op1_array_index; |
| 12230 | size_t op1_array_end; | 12230 | size_t op1_array_end; |
| 12231 | ZigType *child_type; | 12231 | ZigType *child_type; |
| 12232 | if (op1_type->id == TypeTableEntryIdArray) { | 12232 | if (op1_type->id == ZigTypeIdArray) { |
| 12233 | child_type = op1_type->data.array.child_type; | 12233 | child_type = op1_type->data.array.child_type; |
| 12234 | op1_array_val = op1_val; | 12234 | op1_array_val = op1_val; |
| 12235 | op1_array_index = 0; | 12235 | op1_array_index = 0; |
| 12236 | op1_array_end = op1_type->data.array.len; | 12236 | op1_array_end = op1_type->data.array.len; |
| 12237 | } else if (op1_type->id == TypeTableEntryIdPointer && | 12237 | } else if (op1_type->id == ZigTypeIdPointer && |
| 12238 | op1_type->data.pointer.child_type == ira->codegen->builtin_types.entry_u8 && | 12238 | op1_type->data.pointer.child_type == ira->codegen->builtin_types.entry_u8 && |
| 12239 | op1_val->data.x_ptr.special == ConstPtrSpecialBaseArray && | 12239 | op1_val->data.x_ptr.special == ConstPtrSpecialBaseArray && |
| 12240 | op1_val->data.x_ptr.data.base_array.is_cstr) | 12240 | op1_val->data.x_ptr.data.base_array.is_cstr) |
| ... | @@ -12260,7 +12260,7 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc | ... | @@ -12260,7 +12260,7 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc |
| 12260 | ConstExprValue *op2_array_val; | 12260 | ConstExprValue *op2_array_val; |
| 12261 | size_t op2_array_index; | 12261 | size_t op2_array_index; |
| 12262 | size_t op2_array_end; | 12262 | size_t op2_array_end; |
| 12263 | if (op2_type->id == TypeTableEntryIdArray) { | 12263 | if (op2_type->id == ZigTypeIdArray) { |
| 12264 | if (op2_type->data.array.child_type != child_type) { | 12264 | if (op2_type->data.array.child_type != child_type) { |
| 12265 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 12265 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", |
| 12266 | buf_ptr(&child_type->name), | 12266 | buf_ptr(&child_type->name), |
| ... | @@ -12270,7 +12270,7 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc | ... | @@ -12270,7 +12270,7 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc |
| 12270 | op2_array_val = op2_val; | 12270 | op2_array_val = op2_val; |
| 12271 | op2_array_index = 0; | 12271 | op2_array_index = 0; |
| 12272 | op2_array_end = op2_array_val->type->data.array.len; | 12272 | op2_array_end = op2_array_val->type->data.array.len; |
| 12273 | } else if (op2_type->id == TypeTableEntryIdPointer && | 12273 | } else if (op2_type->id == ZigTypeIdPointer && |
| 12274 | op2_type->data.pointer.child_type == ira->codegen->builtin_types.entry_u8 && | 12274 | op2_type->data.pointer.child_type == ira->codegen->builtin_types.entry_u8 && |
| 12275 | op2_val->data.x_ptr.special == ConstPtrSpecialBaseArray && | 12275 | op2_val->data.x_ptr.special == ConstPtrSpecialBaseArray && |
| 12276 | op2_val->data.x_ptr.data.base_array.is_cstr) | 12276 | op2_val->data.x_ptr.data.base_array.is_cstr) |
| ... | @@ -12308,7 +12308,7 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc | ... | @@ -12308,7 +12308,7 @@ static ZigType *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruc |
| 12308 | ZigType *result_type; | 12308 | ZigType *result_type; |
| 12309 | ConstExprValue *out_array_val; | 12309 | ConstExprValue *out_array_val; |
| 12310 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); | 12310 | size_t new_len = (op1_array_end - op1_array_index) + (op2_array_end - op2_array_index); |
| 12311 | if (op1_type->id == TypeTableEntryIdArray || op2_type->id == TypeTableEntryIdArray) { | 12311 | if (op1_type->id == ZigTypeIdArray || op2_type->id == ZigTypeIdArray) { |
| 12312 | result_type = get_array_type(ira->codegen, child_type, new_len); | 12312 | result_type = get_array_type(ira->codegen, child_type, new_len); |
| 12313 | | 12313 | |
| 12314 | out_array_val = out_val; | 12314 | out_array_val = out_val; |
| ... | @@ -12392,7 +12392,7 @@ static ZigType *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instru | ... | @@ -12392,7 +12392,7 @@ static ZigType *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instru |
| 12392 | return ira->codegen->builtin_types.entry_invalid; | 12392 | return ira->codegen->builtin_types.entry_invalid; |
| 12393 | | 12393 | |
| 12394 | ZigType *array_type = op1->value.type; | 12394 | ZigType *array_type = op1->value.type; |
| 12395 | if (array_type->id != TypeTableEntryIdArray) { | 12395 | if (array_type->id != ZigTypeIdArray) { |
| 12396 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name))); | 12396 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value.type->name))); |
| 12397 | return ira->codegen->builtin_types.entry_invalid; | 12397 | return ira->codegen->builtin_types.entry_invalid; |
| 12398 | } | 12398 | } |
| ... | @@ -12555,8 +12555,8 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec | ... | @@ -12555,8 +12555,8 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec |
| 12555 | } | 12555 | } |
| 12556 | | 12556 | |
| 12557 | if (!type_is_invalid(result_type)) { | 12557 | if (!type_is_invalid(result_type)) { |
| 12558 | if (result_type->id == TypeTableEntryIdUnreachable || | 12558 | if (result_type->id == ZigTypeIdUnreachable || |
| 12559 | result_type->id == TypeTableEntryIdOpaque) | 12559 | result_type->id == ZigTypeIdOpaque) |
| 12560 | { | 12560 | { |
| 12561 | ir_add_error_node(ira, source_node, | 12561 | ir_add_error_node(ira, source_node, |
| 12562 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&result_type->name))); | 12562 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&result_type->name))); |
| ... | @@ -12571,7 +12571,7 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec | ... | @@ -12571,7 +12571,7 @@ static ZigType *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstructionDec |
| 12571 | } | 12571 | } |
| 12572 | } else { | 12572 | } else { |
| 12573 | if (casted_init_value->value.special == ConstValSpecialStatic && | 12573 | if (casted_init_value->value.special == ConstValSpecialStatic && |
| 12574 | casted_init_value->value.type->id == TypeTableEntryIdFn && | 12574 | casted_init_value->value.type->id == ZigTypeIdFn && |
| 12575 | casted_init_value->value.data.x_ptr.data.fn.fn_entry->fn_inline == FnInlineAlways) | 12575 | casted_init_value->value.data.x_ptr.data.fn.fn_entry->fn_inline == FnInlineAlways) |
| 12576 | { | 12576 | { |
| 12577 | var_class_requires_const = true; | 12577 | var_class_requires_const = true; |
| ... | @@ -12680,10 +12680,10 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor | ... | @@ -12680,10 +12680,10 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12680 | } | 12680 | } |
| 12681 | | 12681 | |
| 12682 | switch (target->value.type->id) { | 12682 | switch (target->value.type->id) { |
| 12683 | case TypeTableEntryIdInvalid: | 12683 | case ZigTypeIdInvalid: |
| 12684 | case TypeTableEntryIdUnreachable: | 12684 | case ZigTypeIdUnreachable: |
| 12685 | zig_unreachable(); | 12685 | zig_unreachable(); |
| 12686 | case TypeTableEntryIdFn: { | 12686 | case ZigTypeIdFn: { |
| 12687 | assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); | 12687 | assert(target->value.data.x_ptr.special == ConstPtrSpecialFunction); |
| 12688 | ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; | 12688 | ZigFn *fn_entry = target->value.data.x_ptr.data.fn.fn_entry; |
| 12689 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; | 12689 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; |
| ... | @@ -12706,7 +12706,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor | ... | @@ -12706,7 +12706,7 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12706 | break; | 12706 | break; |
| 12707 | } | 12707 | } |
| 12708 | } break; | 12708 | } break; |
| 12709 | case TypeTableEntryIdStruct: | 12709 | case ZigTypeIdStruct: |
| 12710 | if (is_slice(target->value.type)) { | 12710 | if (is_slice(target->value.type)) { |
| 12711 | ir_add_error(ira, target, | 12711 | ir_add_error(ira, target, |
| 12712 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value.type->name))); | 12712 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value.type->name))); |
| ... | @@ -12716,26 +12716,26 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor | ... | @@ -12716,26 +12716,26 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12716 | add_error_note(ira->codegen, msg, target->value.type->data.structure.decl_node, buf_sprintf("declared here")); | 12716 | add_error_note(ira->codegen, msg, target->value.type->data.structure.decl_node, buf_sprintf("declared here")); |
| 12717 | } | 12717 | } |
| 12718 | break; | 12718 | break; |
| 12719 | case TypeTableEntryIdUnion: | 12719 | case ZigTypeIdUnion: |
| 12720 | if (target->value.type->data.unionation.layout != ContainerLayoutExtern) { | 12720 | if (target->value.type->data.unionation.layout != ContainerLayoutExtern) { |
| 12721 | ErrorMsg *msg = ir_add_error(ira, target, | 12721 | ErrorMsg *msg = ir_add_error(ira, target, |
| 12722 | buf_sprintf("exported union value must be declared extern")); | 12722 | buf_sprintf("exported union value must be declared extern")); |
| 12723 | add_error_note(ira->codegen, msg, target->value.type->data.unionation.decl_node, buf_sprintf("declared here")); | 12723 | add_error_note(ira->codegen, msg, target->value.type->data.unionation.decl_node, buf_sprintf("declared here")); |
| 12724 | } | 12724 | } |
| 12725 | break; | 12725 | break; |
| 12726 | case TypeTableEntryIdEnum: | 12726 | case ZigTypeIdEnum: |
| 12727 | if (target->value.type->data.enumeration.layout != ContainerLayoutExtern) { | 12727 | if (target->value.type->data.enumeration.layout != ContainerLayoutExtern) { |
| 12728 | ErrorMsg *msg = ir_add_error(ira, target, | 12728 | ErrorMsg *msg = ir_add_error(ira, target, |
| 12729 | buf_sprintf("exported enum value must be declared extern")); | 12729 | buf_sprintf("exported enum value must be declared extern")); |
| 12730 | add_error_note(ira->codegen, msg, target->value.type->data.enumeration.decl_node, buf_sprintf("declared here")); | 12730 | add_error_note(ira->codegen, msg, target->value.type->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 12731 | } | 12731 | } |
| 12732 | break; | 12732 | break; |
| 12733 | case TypeTableEntryIdMetaType: { | 12733 | case ZigTypeIdMetaType: { |
| 12734 | ZigType *type_value = target->value.data.x_type; | 12734 | ZigType *type_value = target->value.data.x_type; |
| 12735 | switch (type_value->id) { | 12735 | switch (type_value->id) { |
| 12736 | case TypeTableEntryIdInvalid: | 12736 | case ZigTypeIdInvalid: |
| 12737 | zig_unreachable(); | 12737 | zig_unreachable(); |
| 12738 | case TypeTableEntryIdStruct: | 12738 | case ZigTypeIdStruct: |
| 12739 | if (is_slice(type_value)) { | 12739 | if (is_slice(type_value)) { |
| 12740 | ir_add_error(ira, target, | 12740 | ir_add_error(ira, target, |
| 12741 | buf_sprintf("unable to export type '%s'", buf_ptr(&type_value->name))); | 12741 | buf_sprintf("unable to export type '%s'", buf_ptr(&type_value->name))); |
| ... | @@ -12745,73 +12745,73 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor | ... | @@ -12745,73 +12745,73 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12745 | add_error_note(ira->codegen, msg, type_value->data.structure.decl_node, buf_sprintf("declared here")); | 12745 | add_error_note(ira->codegen, msg, type_value->data.structure.decl_node, buf_sprintf("declared here")); |
| 12746 | } | 12746 | } |
| 12747 | break; | 12747 | break; |
| 12748 | case TypeTableEntryIdUnion: | 12748 | case ZigTypeIdUnion: |
| 12749 | if (type_value->data.unionation.layout != ContainerLayoutExtern) { | 12749 | if (type_value->data.unionation.layout != ContainerLayoutExtern) { |
| 12750 | ErrorMsg *msg = ir_add_error(ira, target, | 12750 | ErrorMsg *msg = ir_add_error(ira, target, |
| 12751 | buf_sprintf("exported union must be declared extern")); | 12751 | buf_sprintf("exported union must be declared extern")); |
| 12752 | add_error_note(ira->codegen, msg, type_value->data.unionation.decl_node, buf_sprintf("declared here")); | 12752 | add_error_note(ira->codegen, msg, type_value->data.unionation.decl_node, buf_sprintf("declared here")); |
| 12753 | } | 12753 | } |
| 12754 | break; | 12754 | break; |
| 12755 | case TypeTableEntryIdEnum: | 12755 | case ZigTypeIdEnum: |
| 12756 | if (type_value->data.enumeration.layout != ContainerLayoutExtern) { | 12756 | if (type_value->data.enumeration.layout != ContainerLayoutExtern) { |
| 12757 | ErrorMsg *msg = ir_add_error(ira, target, | 12757 | ErrorMsg *msg = ir_add_error(ira, target, |
| 12758 | buf_sprintf("exported enum must be declared extern")); | 12758 | buf_sprintf("exported enum must be declared extern")); |
| 12759 | add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here")); | 12759 | add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 12760 | } | 12760 | } |
| 12761 | break; | 12761 | break; |
| 12762 | case TypeTableEntryIdFn: { | 12762 | case ZigTypeIdFn: { |
| 12763 | if (type_value->data.fn.fn_type_id.cc == CallingConventionUnspecified) { | 12763 | if (type_value->data.fn.fn_type_id.cc == CallingConventionUnspecified) { |
| 12764 | ir_add_error(ira, target, | 12764 | ir_add_error(ira, target, |
| 12765 | buf_sprintf("exported function type must specify calling convention")); | 12765 | buf_sprintf("exported function type must specify calling convention")); |
| 12766 | } | 12766 | } |
| 12767 | } break; | 12767 | } break; |
| 12768 | case TypeTableEntryIdInt: | 12768 | case ZigTypeIdInt: |
| 12769 | case TypeTableEntryIdFloat: | 12769 | case ZigTypeIdFloat: |
| 12770 | case TypeTableEntryIdPointer: | 12770 | case ZigTypeIdPointer: |
| 12771 | case TypeTableEntryIdArray: | 12771 | case ZigTypeIdArray: |
| 12772 | case TypeTableEntryIdBool: | 12772 | case ZigTypeIdBool: |
| 12773 | break; | 12773 | break; |
| 12774 | case TypeTableEntryIdMetaType: | 12774 | case ZigTypeIdMetaType: |
| 12775 | case TypeTableEntryIdVoid: | 12775 | case ZigTypeIdVoid: |
| 12776 | case TypeTableEntryIdUnreachable: | 12776 | case ZigTypeIdUnreachable: |
| 12777 | case TypeTableEntryIdComptimeFloat: | 12777 | case ZigTypeIdComptimeFloat: |
| 12778 | case TypeTableEntryIdComptimeInt: | 12778 | case ZigTypeIdComptimeInt: |
| 12779 | case TypeTableEntryIdUndefined: | 12779 | case ZigTypeIdUndefined: |
| 12780 | case TypeTableEntryIdNull: | 12780 | case ZigTypeIdNull: |
| 12781 | case TypeTableEntryIdOptional: | 12781 | case ZigTypeIdOptional: |
| 12782 | case TypeTableEntryIdErrorUnion: | 12782 | case ZigTypeIdErrorUnion: |
| 12783 | case TypeTableEntryIdErrorSet: | 12783 | case ZigTypeIdErrorSet: |
| 12784 | case TypeTableEntryIdNamespace: | 12784 | case ZigTypeIdNamespace: |
| 12785 | case TypeTableEntryIdBlock: | 12785 | case ZigTypeIdBlock: |
| 12786 | case TypeTableEntryIdBoundFn: | 12786 | case ZigTypeIdBoundFn: |
| 12787 | case TypeTableEntryIdArgTuple: | 12787 | case ZigTypeIdArgTuple: |
| 12788 | case TypeTableEntryIdOpaque: | 12788 | case ZigTypeIdOpaque: |
| 12789 | case TypeTableEntryIdPromise: | 12789 | case ZigTypeIdPromise: |
| 12790 | ir_add_error(ira, target, | 12790 | ir_add_error(ira, target, |
| 12791 | buf_sprintf("invalid export target '%s'", buf_ptr(&type_value->name))); | 12791 | buf_sprintf("invalid export target '%s'", buf_ptr(&type_value->name))); |
| 12792 | break; | 12792 | break; |
| 12793 | } | 12793 | } |
| 12794 | } break; | 12794 | } break; |
| 12795 | case TypeTableEntryIdVoid: | 12795 | case ZigTypeIdVoid: |
| 12796 | case TypeTableEntryIdBool: | 12796 | case ZigTypeIdBool: |
| 12797 | case TypeTableEntryIdInt: | 12797 | case ZigTypeIdInt: |
| 12798 | case TypeTableEntryIdFloat: | 12798 | case ZigTypeIdFloat: |
| 12799 | case TypeTableEntryIdPointer: | 12799 | case ZigTypeIdPointer: |
| 12800 | case TypeTableEntryIdArray: | 12800 | case ZigTypeIdArray: |
| 12801 | case TypeTableEntryIdComptimeFloat: | 12801 | case ZigTypeIdComptimeFloat: |
| 12802 | case TypeTableEntryIdComptimeInt: | 12802 | case ZigTypeIdComptimeInt: |
| 12803 | case TypeTableEntryIdUndefined: | 12803 | case ZigTypeIdUndefined: |
| 12804 | case TypeTableEntryIdNull: | 12804 | case ZigTypeIdNull: |
| 12805 | case TypeTableEntryIdOptional: | 12805 | case ZigTypeIdOptional: |
| 12806 | case TypeTableEntryIdErrorUnion: | 12806 | case ZigTypeIdErrorUnion: |
| 12807 | case TypeTableEntryIdErrorSet: | 12807 | case ZigTypeIdErrorSet: |
| 12808 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name)); | 12808 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name)); |
| 12809 | case TypeTableEntryIdNamespace: | 12809 | case ZigTypeIdNamespace: |
| 12810 | case TypeTableEntryIdBlock: | 12810 | case ZigTypeIdBlock: |
| 12811 | case TypeTableEntryIdBoundFn: | 12811 | case ZigTypeIdBoundFn: |
| 12812 | case TypeTableEntryIdArgTuple: | 12812 | case ZigTypeIdArgTuple: |
| 12813 | case TypeTableEntryIdOpaque: | 12813 | case ZigTypeIdOpaque: |
| 12814 | case TypeTableEntryIdPromise: | 12814 | case ZigTypeIdPromise: |
| 12815 | ir_add_error(ira, target, | 12815 | ir_add_error(ira, target, |
| 12816 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name))); | 12816 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name))); |
| 12817 | break; | 12817 | break; |
| ... | @@ -12863,7 +12863,7 @@ static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -12863,7 +12863,7 @@ static ZigType *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 12863 | if (type_is_invalid(payload_type)) | 12863 | if (type_is_invalid(payload_type)) |
| 12864 | return ira->codegen->builtin_types.entry_invalid; | 12864 | return ira->codegen->builtin_types.entry_invalid; |
| 12865 | | 12865 | |
| 12866 | if (err_set_type->id != TypeTableEntryIdErrorSet) { | 12866 | if (err_set_type->id != ZigTypeIdErrorSet) { |
| 12867 | ir_add_error(ira, instruction->err_set->other, | 12867 | ir_add_error(ira, instruction->err_set->other, |
| 12868 | buf_sprintf("expected error set type, found type '%s'", | 12868 | buf_sprintf("expected error set type, found type '%s'", |
| 12869 | buf_ptr(&err_set_type->name))); | 12869 | buf_ptr(&err_set_type->name))); |
| ... | @@ -12918,7 +12918,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -12918,7 +12918,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c |
| 12918 | { | 12918 | { |
| 12919 | Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME); | 12919 | Buf *alloc_field_name = buf_create_from_str(ASYNC_ALLOC_FIELD_NAME); |
| 12920 | //Buf *free_field_name = buf_create_from_str("freeFn"); | 12920 | //Buf *free_field_name = buf_create_from_str("freeFn"); |
| 12921 | assert(async_allocator_inst->value.type->id == TypeTableEntryIdPointer); | 12921 | assert(async_allocator_inst->value.type->id == ZigTypeIdPointer); |
| 12922 | ZigType *container_type = async_allocator_inst->value.type->data.pointer.child_type; | 12922 | ZigType *container_type = async_allocator_inst->value.type->data.pointer.child_type; |
| 12923 | IrInstruction *field_ptr_inst = ir_analyze_container_field_ptr(ira, alloc_field_name, &call_instruction->base, | 12923 | IrInstruction *field_ptr_inst = ir_analyze_container_field_ptr(ira, alloc_field_name, &call_instruction->base, |
| 12924 | async_allocator_inst, container_type); | 12924 | async_allocator_inst, container_type); |
| ... | @@ -12926,17 +12926,17 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -12926,17 +12926,17 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c |
| 12926 | return ira->codegen->invalid_instruction; | 12926 | return ira->codegen->invalid_instruction; |
| 12927 | } | 12927 | } |
| 12928 | ZigType *ptr_to_alloc_fn_type = field_ptr_inst->value.type; | 12928 | ZigType *ptr_to_alloc_fn_type = field_ptr_inst->value.type; |
| 12929 | assert(ptr_to_alloc_fn_type->id == TypeTableEntryIdPointer); | 12929 | assert(ptr_to_alloc_fn_type->id == ZigTypeIdPointer); |
| 12930 | | 12930 | |
| 12931 | ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type; | 12931 | ZigType *alloc_fn_type = ptr_to_alloc_fn_type->data.pointer.child_type; |
| 12932 | if (alloc_fn_type->id != TypeTableEntryIdFn) { | 12932 | if (alloc_fn_type->id != ZigTypeIdFn) { |
| 12933 | ir_add_error(ira, &call_instruction->base, | 12933 | ir_add_error(ira, &call_instruction->base, |
| 12934 | buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name))); | 12934 | buf_sprintf("expected allocation function, found '%s'", buf_ptr(&alloc_fn_type->name))); |
| 12935 | return ira->codegen->invalid_instruction; | 12935 | return ira->codegen->invalid_instruction; |
| 12936 | } | 12936 | } |
| 12937 | | 12937 | |
| 12938 | ZigType *alloc_fn_return_type = alloc_fn_type->data.fn.fn_type_id.return_type; | 12938 | ZigType *alloc_fn_return_type = alloc_fn_type->data.fn.fn_type_id.return_type; |
| 12939 | if (alloc_fn_return_type->id != TypeTableEntryIdErrorUnion) { | 12939 | if (alloc_fn_return_type->id != ZigTypeIdErrorUnion) { |
| 12940 | ir_add_error(ira, fn_ref, | 12940 | ir_add_error(ira, fn_ref, |
| 12941 | buf_sprintf("expected allocation function to return error union, but it returns '%s'", buf_ptr(&alloc_fn_return_type->name))); | 12941 | buf_sprintf("expected allocation function to return error union, but it returns '%s'", buf_ptr(&alloc_fn_return_type->name))); |
| 12942 | return ira->codegen->invalid_instruction; | 12942 | return ira->codegen->invalid_instruction; |
| ... | @@ -13015,7 +13015,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -13015,7 +13015,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 13015 | } | 13015 | } |
| 13016 | | 13016 | |
| 13017 | bool comptime_arg = param_decl_node->data.param_decl.is_inline || | 13017 | bool comptime_arg = param_decl_node->data.param_decl.is_inline || |
| 13018 | casted_arg->value.type->id == TypeTableEntryIdComptimeInt || casted_arg->value.type->id == TypeTableEntryIdComptimeFloat; | 13018 | casted_arg->value.type->id == ZigTypeIdComptimeInt || casted_arg->value.type->id == ZigTypeIdComptimeFloat; |
| 13019 | | 13019 | |
| 13020 | ConstExprValue *arg_val; | 13020 | ConstExprValue *arg_val; |
| 13021 | | 13021 | |
| ... | @@ -13041,8 +13041,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -13041,8 +13041,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 13041 | var->shadowable = !comptime_arg; | 13041 | var->shadowable = !comptime_arg; |
| 13042 | | 13042 | |
| 13043 | *next_proto_i += 1; | 13043 | *next_proto_i += 1; |
| 13044 | } else if (casted_arg->value.type->id == TypeTableEntryIdComptimeInt || | 13044 | } else if (casted_arg->value.type->id == ZigTypeIdComptimeInt || |
| 13045 | casted_arg->value.type->id == TypeTableEntryIdComptimeFloat) | 13045 | casted_arg->value.type->id == ZigTypeIdComptimeFloat) |
| 13046 | { | 13046 | { |
| 13047 | ir_add_error(ira, casted_arg, | 13047 | ir_add_error(ira, casted_arg, |
| 13048 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); | 13048 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); |
| ... | @@ -13177,7 +13177,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13177,7 +13177,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13177 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; | 13177 | size_t call_param_count = call_instruction->arg_count + first_arg_1_or_0; |
| 13178 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { | 13178 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 13179 | ConstExprValue *arg_tuple_value = &call_instruction->args[i]->other->value; | 13179 | ConstExprValue *arg_tuple_value = &call_instruction->args[i]->other->value; |
| 13180 | if (arg_tuple_value->type->id == TypeTableEntryIdArgTuple) { | 13180 | if (arg_tuple_value->type->id == ZigTypeIdArgTuple) { |
| 13181 | call_param_count -= 1; | 13181 | call_param_count -= 1; |
| 13182 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - | 13182 | call_param_count += arg_tuple_value->data.x_arg_tuple.end_index - |
| 13183 | arg_tuple_value->data.x_arg_tuple.start_index; | 13183 | arg_tuple_value->data.x_arg_tuple.start_index; |
| ... | @@ -13245,14 +13245,14 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13245,14 +13245,14 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13245 | | 13245 | |
| 13246 | size_t next_proto_i = 0; | 13246 | size_t next_proto_i = 0; |
| 13247 | if (first_arg_ptr) { | 13247 | if (first_arg_ptr) { |
| 13248 | assert(first_arg_ptr->value.type->id == TypeTableEntryIdPointer); | 13248 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); |
| 13249 | | 13249 | |
| 13250 | bool first_arg_known_bare = false; | 13250 | bool first_arg_known_bare = false; |
| 13251 | if (fn_type_id->next_param_index >= 1) { | 13251 | if (fn_type_id->next_param_index >= 1) { |
| 13252 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; | 13252 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; |
| 13253 | if (type_is_invalid(param_type)) | 13253 | if (type_is_invalid(param_type)) |
| 13254 | return ira->codegen->builtin_types.entry_invalid; | 13254 | return ira->codegen->builtin_types.entry_invalid; |
| 13255 | first_arg_known_bare = param_type->id != TypeTableEntryIdPointer; | 13255 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 13256 | } | 13256 | } |
| 13257 | | 13257 | |
| 13258 | IrInstruction *first_arg; | 13258 | IrInstruction *first_arg; |
| ... | @@ -13314,7 +13314,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13314,7 +13314,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13314 | | 13314 | |
| 13315 | if (inferred_err_set_type != nullptr) { | 13315 | if (inferred_err_set_type != nullptr) { |
| 13316 | inferred_err_set_type->data.error_set.infer_fn = nullptr; | 13316 | inferred_err_set_type->data.error_set.infer_fn = nullptr; |
| 13317 | if (result->value.type->id == TypeTableEntryIdErrorUnion) { | 13317 | if (result->value.type->id == ZigTypeIdErrorUnion) { |
| 13318 | if (result->value.data.x_err_union.err != nullptr) { | 13318 | if (result->value.data.x_err_union.err != nullptr) { |
| 13319 | inferred_err_set_type->data.error_set.err_count = 1; | 13319 | inferred_err_set_type->data.error_set.err_count = 1; |
| 13320 | inferred_err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1); | 13320 | inferred_err_set_type->data.error_set.errors = allocate<ErrorTableEntry *>(1); |
| ... | @@ -13323,7 +13323,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13323,7 +13323,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13323 | ZigType *fn_inferred_err_set_type = result->value.type->data.error_union.err_set_type; | 13323 | ZigType *fn_inferred_err_set_type = result->value.type->data.error_union.err_set_type; |
| 13324 | inferred_err_set_type->data.error_set.err_count = fn_inferred_err_set_type->data.error_set.err_count; | 13324 | inferred_err_set_type->data.error_set.err_count = fn_inferred_err_set_type->data.error_set.err_count; |
| 13325 | inferred_err_set_type->data.error_set.errors = fn_inferred_err_set_type->data.error_set.errors; | 13325 | inferred_err_set_type->data.error_set.errors = fn_inferred_err_set_type->data.error_set.errors; |
| 13326 | } else if (result->value.type->id == TypeTableEntryIdErrorSet) { | 13326 | } else if (result->value.type->id == ZigTypeIdErrorSet) { |
| 13327 | inferred_err_set_type->data.error_set.err_count = result->value.type->data.error_set.err_count; | 13327 | inferred_err_set_type->data.error_set.err_count = result->value.type->data.error_set.err_count; |
| 13328 | inferred_err_set_type->data.error_set.errors = result->value.type->data.error_set.errors; | 13328 | inferred_err_set_type->data.error_set.errors = result->value.type->data.error_set.errors; |
| 13329 | } | 13329 | } |
| ... | @@ -13371,7 +13371,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13371,7 +13371,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13371 | if (type_is_invalid(arg->value.type)) | 13371 | if (type_is_invalid(arg->value.type)) |
| 13372 | return ira->codegen->builtin_types.entry_invalid; | 13372 | return ira->codegen->builtin_types.entry_invalid; |
| 13373 | | 13373 | |
| 13374 | if (arg->value.type->id == TypeTableEntryIdArgTuple) { | 13374 | if (arg->value.type->id == ZigTypeIdArgTuple) { |
| 13375 | new_fn_arg_count += arg->value.data.x_arg_tuple.end_index - arg->value.data.x_arg_tuple.start_index; | 13375 | new_fn_arg_count += arg->value.data.x_arg_tuple.end_index - arg->value.data.x_arg_tuple.start_index; |
| 13376 | } else { | 13376 | } else { |
| 13377 | new_fn_arg_count += 1; | 13377 | new_fn_arg_count += 1; |
| ... | @@ -13401,14 +13401,14 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13401,14 +13401,14 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13401 | size_t next_proto_i = 0; | 13401 | size_t next_proto_i = 0; |
| 13402 | | 13402 | |
| 13403 | if (first_arg_ptr) { | 13403 | if (first_arg_ptr) { |
| 13404 | assert(first_arg_ptr->value.type->id == TypeTableEntryIdPointer); | 13404 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); |
| 13405 | | 13405 | |
| 13406 | bool first_arg_known_bare = false; | 13406 | bool first_arg_known_bare = false; |
| 13407 | if (fn_type_id->next_param_index >= 1) { | 13407 | if (fn_type_id->next_param_index >= 1) { |
| 13408 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; | 13408 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; |
| 13409 | if (type_is_invalid(param_type)) | 13409 | if (type_is_invalid(param_type)) |
| 13410 | return ira->codegen->builtin_types.entry_invalid; | 13410 | return ira->codegen->builtin_types.entry_invalid; |
| 13411 | first_arg_known_bare = param_type->id != TypeTableEntryIdPointer; | 13411 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 13412 | } | 13412 | } |
| 13413 | | 13413 | |
| 13414 | IrInstruction *first_arg; | 13414 | IrInstruction *first_arg; |
| ... | @@ -13437,7 +13437,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13437,7 +13437,7 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13437 | if (type_is_invalid(arg->value.type)) | 13437 | if (type_is_invalid(arg->value.type)) |
| 13438 | return ira->codegen->builtin_types.entry_invalid; | 13438 | return ira->codegen->builtin_types.entry_invalid; |
| 13439 | | 13439 | |
| 13440 | if (arg->value.type->id == TypeTableEntryIdArgTuple) { | 13440 | if (arg->value.type->id == ZigTypeIdArgTuple) { |
| 13441 | for (size_t arg_tuple_i = arg->value.data.x_arg_tuple.start_index; | 13441 | for (size_t arg_tuple_i = arg->value.data.x_arg_tuple.start_index; |
| 13442 | arg_tuple_i < arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1) | 13442 | arg_tuple_i < arg->value.data.x_arg_tuple.end_index; arg_tuple_i += 1) |
| 13443 | { | 13443 | { |
| ... | @@ -13616,14 +13616,14 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr | ... | @@ -13616,14 +13616,14 @@ static ZigType *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *call_instr |
| 13616 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); | 13616 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); |
| 13617 | size_t next_arg_index = 0; | 13617 | size_t next_arg_index = 0; |
| 13618 | if (first_arg_ptr) { | 13618 | if (first_arg_ptr) { |
| 13619 | assert(first_arg_ptr->value.type->id == TypeTableEntryIdPointer); | 13619 | assert(first_arg_ptr->value.type->id == ZigTypeIdPointer); |
| 13620 | | 13620 | |
| 13621 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 13621 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 13622 | if (type_is_invalid(param_type)) | 13622 | if (type_is_invalid(param_type)) |
| 13623 | return ira->codegen->builtin_types.entry_invalid; | 13623 | return ira->codegen->builtin_types.entry_invalid; |
| 13624 | | 13624 | |
| 13625 | IrInstruction *first_arg; | 13625 | IrInstruction *first_arg; |
| 13626 | if (param_type->id == TypeTableEntryIdPointer && | 13626 | if (param_type->id == ZigTypeIdPointer && |
| 13627 | handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) | 13627 | handle_is_ptr(first_arg_ptr->value.type->data.pointer.child_type)) |
| 13628 | { | 13628 | { |
| 13629 | first_arg = first_arg_ptr; | 13629 | first_arg = first_arg_ptr; |
| ... | @@ -13712,7 +13712,7 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -13712,7 +13712,7 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c |
| 13712 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); | 13712 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); |
| 13713 | | 13713 | |
| 13714 | if (is_comptime || instr_is_comptime(fn_ref)) { | 13714 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 13715 | if (fn_ref->value.type->id == TypeTableEntryIdMetaType) { | 13715 | if (fn_ref->value.type->id == ZigTypeIdMetaType) { |
| 13716 | ZigType *dest_type = ir_resolve_type(ira, fn_ref); | 13716 | ZigType *dest_type = ir_resolve_type(ira, fn_ref); |
| 13717 | if (type_is_invalid(dest_type)) | 13717 | if (type_is_invalid(dest_type)) |
| 13718 | return ira->codegen->builtin_types.entry_invalid; | 13718 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -13733,13 +13733,13 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -13733,13 +13733,13 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c |
| 13733 | | 13733 | |
| 13734 | ir_link_new_instruction(cast_instruction, &call_instruction->base); | 13734 | ir_link_new_instruction(cast_instruction, &call_instruction->base); |
| 13735 | return ir_finish_anal(ira, cast_instruction->value.type); | 13735 | return ir_finish_anal(ira, cast_instruction->value.type); |
| 13736 | } else if (fn_ref->value.type->id == TypeTableEntryIdFn) { | 13736 | } else if (fn_ref->value.type->id == ZigTypeIdFn) { |
| 13737 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); | 13737 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); |
| 13738 | if (fn_table_entry == nullptr) | 13738 | if (fn_table_entry == nullptr) |
| 13739 | return ira->codegen->builtin_types.entry_invalid; | 13739 | return ira->codegen->builtin_types.entry_invalid; |
| 13740 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 13740 | return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 13741 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); | 13741 | fn_ref, nullptr, is_comptime, call_instruction->fn_inline); |
| 13742 | } else if (fn_ref->value.type->id == TypeTableEntryIdBoundFn) { | 13742 | } else if (fn_ref->value.type->id == ZigTypeIdBoundFn) { |
| 13743 | assert(fn_ref->value.special == ConstValSpecialStatic); | 13743 | assert(fn_ref->value.special == ConstValSpecialStatic); |
| 13744 | ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn; | 13744 | ZigFn *fn_table_entry = fn_ref->value.data.x_bound_fn.fn; |
| 13745 | IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg; | 13745 | IrInstruction *first_arg_ptr = fn_ref->value.data.x_bound_fn.first_arg; |
| ... | @@ -13752,7 +13752,7 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c | ... | @@ -13752,7 +13752,7 @@ static ZigType *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCall *c |
| 13752 | } | 13752 | } |
| 13753 | } | 13753 | } |
| 13754 | | 13754 | |
| 13755 | if (fn_ref->value.type->id == TypeTableEntryIdFn) { | 13755 | if (fn_ref->value.type->id == ZigTypeIdFn) { |
| 13756 | return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value.type, | 13756 | return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value.type, |
| 13757 | fn_ref, nullptr, false, FnInlineAuto); | 13757 | fn_ref, nullptr, false, FnInlineAuto); |
| 13758 | } else { | 13758 | } else { |
| ... | @@ -13801,7 +13801,7 @@ static ZigType *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp *un_op_ | ... | @@ -13801,7 +13801,7 @@ static ZigType *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp *un_op_ |
| 13801 | ZigType *child_type; | 13801 | ZigType *child_type; |
| 13802 | if (type_is_invalid(ptr_type)) { | 13802 | if (type_is_invalid(ptr_type)) { |
| 13803 | return ira->codegen->builtin_types.entry_invalid; | 13803 | return ira->codegen->builtin_types.entry_invalid; |
| 13804 | } else if (ptr_type->id == TypeTableEntryIdPointer) { | 13804 | } else if (ptr_type->id == ZigTypeIdPointer) { |
| 13805 | if (ptr_type->data.pointer.ptr_len == PtrLenUnknown) { | 13805 | if (ptr_type->data.pointer.ptr_len == PtrLenUnknown) { |
| 13806 | ir_add_error_node(ira, un_op_instruction->base.source_node, | 13806 | ir_add_error_node(ira, un_op_instruction->base.source_node, |
| 13807 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", | 13807 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", |
| ... | @@ -13845,38 +13845,38 @@ static ZigType *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instru | ... | @@ -13845,38 +13845,38 @@ static ZigType *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instru |
| 13845 | return ira->codegen->builtin_types.entry_invalid; | 13845 | return ira->codegen->builtin_types.entry_invalid; |
| 13846 | | 13846 | |
| 13847 | switch (type_entry->id) { | 13847 | switch (type_entry->id) { |
| 13848 | case TypeTableEntryIdInvalid: | 13848 | case ZigTypeIdInvalid: |
| 13849 | zig_unreachable(); | 13849 | zig_unreachable(); |
| 13850 | case TypeTableEntryIdMetaType: | 13850 | case ZigTypeIdMetaType: |
| 13851 | case TypeTableEntryIdVoid: | 13851 | case ZigTypeIdVoid: |
| 13852 | case TypeTableEntryIdBool: | 13852 | case ZigTypeIdBool: |
| 13853 | case TypeTableEntryIdInt: | 13853 | case ZigTypeIdInt: |
| 13854 | case TypeTableEntryIdFloat: | 13854 | case ZigTypeIdFloat: |
| 13855 | case TypeTableEntryIdPointer: | 13855 | case ZigTypeIdPointer: |
| 13856 | case TypeTableEntryIdArray: | 13856 | case ZigTypeIdArray: |
| 13857 | case TypeTableEntryIdStruct: | 13857 | case ZigTypeIdStruct: |
| 13858 | case TypeTableEntryIdComptimeFloat: | 13858 | case ZigTypeIdComptimeFloat: |
| 13859 | case TypeTableEntryIdComptimeInt: | 13859 | case ZigTypeIdComptimeInt: |
| 13860 | case TypeTableEntryIdUndefined: | 13860 | case ZigTypeIdUndefined: |
| 13861 | case TypeTableEntryIdNull: | 13861 | case ZigTypeIdNull: |
| 13862 | case TypeTableEntryIdOptional: | 13862 | case ZigTypeIdOptional: |
| 13863 | case TypeTableEntryIdErrorUnion: | 13863 | case ZigTypeIdErrorUnion: |
| 13864 | case TypeTableEntryIdErrorSet: | 13864 | case ZigTypeIdErrorSet: |
| 13865 | case TypeTableEntryIdEnum: | 13865 | case ZigTypeIdEnum: |
| 13866 | case TypeTableEntryIdUnion: | 13866 | case ZigTypeIdUnion: |
| 13867 | case TypeTableEntryIdFn: | 13867 | case ZigTypeIdFn: |
| 13868 | case TypeTableEntryIdNamespace: | 13868 | case ZigTypeIdNamespace: |
| 13869 | case TypeTableEntryIdBlock: | 13869 | case ZigTypeIdBlock: |
| 13870 | case TypeTableEntryIdBoundFn: | 13870 | case ZigTypeIdBoundFn: |
| 13871 | case TypeTableEntryIdArgTuple: | 13871 | case ZigTypeIdArgTuple: |
| 13872 | case TypeTableEntryIdPromise: | 13872 | case ZigTypeIdPromise: |
| 13873 | { | 13873 | { |
| 13874 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); | 13874 | ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base); |
| 13875 | out_val->data.x_type = get_optional_type(ira->codegen, type_entry); | 13875 | out_val->data.x_type = get_optional_type(ira->codegen, type_entry); |
| 13876 | return ira->codegen->builtin_types.entry_type; | 13876 | return ira->codegen->builtin_types.entry_type; |
| 13877 | } | 13877 | } |
| 13878 | case TypeTableEntryIdUnreachable: | 13878 | case ZigTypeIdUnreachable: |
| 13879 | case TypeTableEntryIdOpaque: | 13879 | case ZigTypeIdOpaque: |
| 13880 | ir_add_error_node(ira, un_op_instruction->base.source_node, | 13880 | ir_add_error_node(ira, un_op_instruction->base.source_node, |
| 13881 | buf_sprintf("type '%s' not optional", buf_ptr(&type_entry->name))); | 13881 | buf_sprintf("type '%s' not optional", buf_ptr(&type_entry->name))); |
| 13882 | return ira->codegen->builtin_types.entry_invalid; | 13882 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -13892,10 +13892,10 @@ static ZigType *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_ins | ... | @@ -13892,10 +13892,10 @@ static ZigType *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_ins |
| 13892 | | 13892 | |
| 13893 | bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap); | 13893 | bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap); |
| 13894 | | 13894 | |
| 13895 | bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdComptimeFloat); | 13895 | bool is_float = (expr_type->id == ZigTypeIdFloat || expr_type->id == ZigTypeIdComptimeFloat); |
| 13896 | | 13896 | |
| 13897 | if ((expr_type->id == TypeTableEntryIdInt && expr_type->data.integral.is_signed) || | 13897 | if ((expr_type->id == ZigTypeIdInt && expr_type->data.integral.is_signed) || |
| 13898 | expr_type->id == TypeTableEntryIdComptimeInt || (is_float && !is_wrap_op)) | 13898 | expr_type->id == ZigTypeIdComptimeInt || (is_float && !is_wrap_op)) |
| 13899 | { | 13899 | { |
| 13900 | if (instr_is_comptime(value)) { | 13900 | if (instr_is_comptime(value)) { |
| 13901 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); | 13901 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| ... | @@ -13911,7 +13911,7 @@ static ZigType *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_ins | ... | @@ -13911,7 +13911,7 @@ static ZigType *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un_op_ins |
| 13911 | } else { | 13911 | } else { |
| 13912 | bigint_negate(&out_val->data.x_bigint, &target_const_val->data.x_bigint); | 13912 | bigint_negate(&out_val->data.x_bigint, &target_const_val->data.x_bigint); |
| 13913 | } | 13913 | } |
| 13914 | if (is_wrap_op || is_float || expr_type->id == TypeTableEntryIdComptimeInt) { | 13914 | if (is_wrap_op || is_float || expr_type->id == ZigTypeIdComptimeInt) { |
| 13915 | return expr_type; | 13915 | return expr_type; |
| 13916 | } | 13916 | } |
| 13917 | | 13917 | |
| ... | @@ -13937,7 +13937,7 @@ static ZigType *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instructio | ... | @@ -13937,7 +13937,7 @@ static ZigType *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instructio |
| 13937 | if (type_is_invalid(expr_type)) | 13937 | if (type_is_invalid(expr_type)) |
| 13938 | return ira->codegen->builtin_types.entry_invalid; | 13938 | return ira->codegen->builtin_types.entry_invalid; |
| 13939 | | 13939 | |
| 13940 | if (expr_type->id == TypeTableEntryIdInt) { | 13940 | if (expr_type->id == ZigTypeIdInt) { |
| 13941 | if (instr_is_comptime(value)) { | 13941 | if (instr_is_comptime(value)) { |
| 13942 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); | 13942 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| 13943 | if (target_const_val == nullptr) | 13943 | if (target_const_val == nullptr) |
| ... | @@ -14082,7 +14082,7 @@ static ZigType *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi | ... | @@ -14082,7 +14082,7 @@ static ZigType *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi |
| 14082 | IrInstruction *old_value = phi_instruction->incoming_values[i]; | 14082 | IrInstruction *old_value = phi_instruction->incoming_values[i]; |
| 14083 | assert(old_value); | 14083 | assert(old_value); |
| 14084 | IrInstruction *new_value = old_value->other; | 14084 | IrInstruction *new_value = old_value->other; |
| 14085 | if (!new_value || new_value->value.type->id == TypeTableEntryIdUnreachable || predecessor->other == nullptr) | 14085 | if (!new_value || new_value->value.type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) |
| 14086 | continue; | 14086 | continue; |
| 14087 | | 14087 | |
| 14088 | if (type_is_invalid(new_value->value.type)) | 14088 | if (type_is_invalid(new_value->value.type)) |
| ... | @@ -14110,17 +14110,17 @@ static ZigType *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi | ... | @@ -14110,17 +14110,17 @@ static ZigType *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi |
| 14110 | if (type_is_invalid(resolved_type)) | 14110 | if (type_is_invalid(resolved_type)) |
| 14111 | return resolved_type; | 14111 | return resolved_type; |
| 14112 | | 14112 | |
| 14113 | if (resolved_type->id == TypeTableEntryIdComptimeFloat || | 14113 | if (resolved_type->id == ZigTypeIdComptimeFloat || |
| 14114 | resolved_type->id == TypeTableEntryIdComptimeInt || | 14114 | resolved_type->id == ZigTypeIdComptimeInt || |
| 14115 | resolved_type->id == TypeTableEntryIdNull || | 14115 | resolved_type->id == ZigTypeIdNull || |
| 14116 | resolved_type->id == TypeTableEntryIdUndefined) | 14116 | resolved_type->id == ZigTypeIdUndefined) |
| 14117 | { | 14117 | { |
| 14118 | ir_add_error_node(ira, phi_instruction->base.source_node, | 14118 | ir_add_error_node(ira, phi_instruction->base.source_node, |
| 14119 | buf_sprintf("unable to infer expression type")); | 14119 | buf_sprintf("unable to infer expression type")); |
| 14120 | return ira->codegen->builtin_types.entry_invalid; | 14120 | return ira->codegen->builtin_types.entry_invalid; |
| 14121 | } | 14121 | } |
| 14122 | | 14122 | |
| 14123 | bool all_stack_ptrs = (resolved_type->id == TypeTableEntryIdPointer); | 14123 | bool all_stack_ptrs = (resolved_type->id == ZigTypeIdPointer); |
| 14124 | | 14124 | |
| 14125 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. | 14125 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. |
| 14126 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and | 14126 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and |
| ... | @@ -14171,7 +14171,7 @@ static ZigType *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarP | ... | @@ -14171,7 +14171,7 @@ static ZigType *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarP |
| 14171 | } | 14171 | } |
| 14172 | | 14172 | |
| 14173 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align) { | 14173 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align) { |
| 14174 | assert(ptr_type->id == TypeTableEntryIdPointer); | 14174 | assert(ptr_type->id == ZigTypeIdPointer); |
| 14175 | return get_pointer_to_type_extra(g, | 14175 | return get_pointer_to_type_extra(g, |
| 14176 | ptr_type->data.pointer.child_type, | 14176 | ptr_type->data.pointer.child_type, |
| 14177 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 14177 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| ... | @@ -14188,7 +14188,7 @@ static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new | ... | @@ -14188,7 +14188,7 @@ static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new |
| 14188 | } | 14188 | } |
| 14189 | | 14189 | |
| 14190 | static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { | 14190 | static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { |
| 14191 | assert(ptr_type->id == TypeTableEntryIdPointer); | 14191 | assert(ptr_type->id == ZigTypeIdPointer); |
| 14192 | return get_pointer_to_type_extra(g, | 14192 | return get_pointer_to_type_extra(g, |
| 14193 | ptr_type->data.pointer.child_type, | 14193 | ptr_type->data.pointer.child_type, |
| 14194 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 14194 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| ... | @@ -14210,7 +14210,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14210,7 +14210,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14210 | return ira->codegen->builtin_types.entry_invalid; | 14210 | return ira->codegen->builtin_types.entry_invalid; |
| 14211 | | 14211 | |
| 14212 | ZigType *ptr_type = orig_array_ptr_val->type; | 14212 | ZigType *ptr_type = orig_array_ptr_val->type; |
| 14213 | assert(ptr_type->id == TypeTableEntryIdPointer); | 14213 | assert(ptr_type->id == ZigTypeIdPointer); |
| 14214 | | 14214 | |
| 14215 | ZigType *array_type = ptr_type->data.pointer.child_type; | 14215 | ZigType *array_type = ptr_type->data.pointer.child_type; |
| 14216 | | 14216 | |
| ... | @@ -14220,12 +14220,12 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14220,12 +14220,12 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14220 | | 14220 | |
| 14221 | if (type_is_invalid(array_type)) { | 14221 | if (type_is_invalid(array_type)) { |
| 14222 | return array_type; | 14222 | return array_type; |
| 14223 | } else if (array_type->id == TypeTableEntryIdArray || | 14223 | } else if (array_type->id == ZigTypeIdArray || |
| 14224 | (array_type->id == TypeTableEntryIdPointer && | 14224 | (array_type->id == ZigTypeIdPointer && |
| 14225 | array_type->data.pointer.ptr_len == PtrLenSingle && | 14225 | array_type->data.pointer.ptr_len == PtrLenSingle && |
| 14226 | array_type->data.pointer.child_type->id == TypeTableEntryIdArray)) | 14226 | array_type->data.pointer.child_type->id == ZigTypeIdArray)) |
| 14227 | { | 14227 | { |
| 14228 | if (array_type->id == TypeTableEntryIdPointer) { | 14228 | if (array_type->id == ZigTypeIdPointer) { |
| 14229 | array_type = array_type->data.pointer.child_type; | 14229 | array_type = array_type->data.pointer.child_type; |
| 14230 | ptr_type = ptr_type->data.pointer.child_type; | 14230 | ptr_type = ptr_type->data.pointer.child_type; |
| 14231 | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { | 14231 | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { |
| ... | @@ -14259,7 +14259,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14259,7 +14259,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14259 | elem_ptr_instruction->ptr_len, | 14259 | elem_ptr_instruction->ptr_len, |
| 14260 | 1, (uint32_t)bit_offset, (uint32_t)bit_width); | 14260 | 1, (uint32_t)bit_offset, (uint32_t)bit_width); |
| 14261 | } | 14261 | } |
| 14262 | } else if (array_type->id == TypeTableEntryIdPointer) { | 14262 | } else if (array_type->id == ZigTypeIdPointer) { |
| 14263 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { | 14263 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { |
| 14264 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 14264 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, |
| 14265 | buf_sprintf("index of single-item pointer")); | 14265 | buf_sprintf("index of single-item pointer")); |
| ... | @@ -14269,7 +14269,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14269,7 +14269,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14269 | } else if (is_slice(array_type)) { | 14269 | } else if (is_slice(array_type)) { |
| 14270 | return_type = adjust_ptr_len(ira->codegen, array_type->data.structure.fields[slice_ptr_index].type_entry, | 14270 | return_type = adjust_ptr_len(ira->codegen, array_type->data.structure.fields[slice_ptr_index].type_entry, |
| 14271 | elem_ptr_instruction->ptr_len); | 14271 | elem_ptr_instruction->ptr_len); |
| 14272 | } else if (array_type->id == TypeTableEntryIdArgTuple) { | 14272 | } else if (array_type->id == ZigTypeIdArgTuple) { |
| 14273 | ConstExprValue *ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); | 14273 | ConstExprValue *ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); |
| 14274 | if (!ptr_val) | 14274 | if (!ptr_val) |
| 14275 | return ira->codegen->builtin_types.entry_invalid; | 14275 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -14320,7 +14320,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14320,7 +14320,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14320 | uint64_t ptr_align = return_type->data.pointer.alignment; | 14320 | uint64_t ptr_align = return_type->data.pointer.alignment; |
| 14321 | if (instr_is_comptime(casted_elem_index)) { | 14321 | if (instr_is_comptime(casted_elem_index)) { |
| 14322 | uint64_t index = bigint_as_unsigned(&casted_elem_index->value.data.x_bigint); | 14322 | uint64_t index = bigint_as_unsigned(&casted_elem_index->value.data.x_bigint); |
| 14323 | if (array_type->id == TypeTableEntryIdArray) { | 14323 | if (array_type->id == ZigTypeIdArray) { |
| 14324 | uint64_t array_len = array_type->data.array.len; | 14324 | uint64_t array_len = array_type->data.array.len; |
| 14325 | if (index >= array_len) { | 14325 | if (index >= array_len) { |
| 14326 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 14326 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, |
| ... | @@ -14353,7 +14353,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14353,7 +14353,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14353 | | 14353 | |
| 14354 | if (orig_array_ptr_val->special != ConstValSpecialRuntime && | 14354 | if (orig_array_ptr_val->special != ConstValSpecialRuntime && |
| 14355 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || | 14355 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || |
| 14356 | array_type->id == TypeTableEntryIdArray)) | 14356 | array_type->id == ZigTypeIdArray)) |
| 14357 | { | 14357 | { |
| 14358 | ConstExprValue *array_ptr_val = ir_const_ptr_pointee(ira, orig_array_ptr_val, | 14358 | ConstExprValue *array_ptr_val = ir_const_ptr_pointee(ira, orig_array_ptr_val, |
| 14359 | elem_ptr_instruction->base.source_node); | 14359 | elem_ptr_instruction->base.source_node); |
| ... | @@ -14361,10 +14361,10 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14361,10 +14361,10 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14361 | return ira->codegen->builtin_types.entry_invalid; | 14361 | return ira->codegen->builtin_types.entry_invalid; |
| 14362 | | 14362 | |
| 14363 | if (array_ptr_val->special != ConstValSpecialRuntime && | 14363 | if (array_ptr_val->special != ConstValSpecialRuntime && |
| 14364 | (array_type->id != TypeTableEntryIdPointer || | 14364 | (array_type->id != ZigTypeIdPointer || |
| 14365 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) | 14365 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) |
| 14366 | { | 14366 | { |
| 14367 | if (array_type->id == TypeTableEntryIdPointer) { | 14367 | if (array_type->id == ZigTypeIdPointer) { |
| 14368 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); | 14368 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 14369 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 14369 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 14370 | size_t new_index; | 14370 | size_t new_index; |
| ... | @@ -14461,7 +14461,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle | ... | @@ -14461,7 +14461,7 @@ static ZigType *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionEle |
| 14461 | zig_panic("TODO elem ptr on a slice that was ptrcast from a function"); | 14461 | zig_panic("TODO elem ptr on a slice that was ptrcast from a function"); |
| 14462 | } | 14462 | } |
| 14463 | return return_type; | 14463 | return return_type; |
| 14464 | } else if (array_type->id == TypeTableEntryIdArray) { | 14464 | } else if (array_type->id == ZigTypeIdArray) { |
| 14465 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); | 14465 | ConstExprValue *out_val = ir_build_const_from(ira, &elem_ptr_instruction->base); |
| 14466 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 14466 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 14467 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; | 14467 | out_val->data.x_ptr.mut = orig_array_ptr_val->data.x_ptr.mut; |
| ... | @@ -14521,11 +14521,11 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -14521,11 +14521,11 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 14521 | const char *prefix_name; | 14521 | const char *prefix_name; |
| 14522 | if (is_slice(bare_struct_type)) { | 14522 | if (is_slice(bare_struct_type)) { |
| 14523 | prefix_name = ""; | 14523 | prefix_name = ""; |
| 14524 | } else if (bare_struct_type->id == TypeTableEntryIdStruct) { | 14524 | } else if (bare_struct_type->id == ZigTypeIdStruct) { |
| 14525 | prefix_name = "struct "; | 14525 | prefix_name = "struct "; |
| 14526 | } else if (bare_struct_type->id == TypeTableEntryIdEnum) { | 14526 | } else if (bare_struct_type->id == ZigTypeIdEnum) { |
| 14527 | prefix_name = "enum "; | 14527 | prefix_name = "enum "; |
| 14528 | } else if (bare_struct_type->id == TypeTableEntryIdUnion) { | 14528 | } else if (bare_struct_type->id == ZigTypeIdUnion) { |
| 14529 | prefix_name = "union "; | 14529 | prefix_name = "union "; |
| 14530 | } else { | 14530 | } else { |
| 14531 | prefix_name = ""; | 14531 | prefix_name = ""; |
| ... | @@ -14544,10 +14544,10 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -14544,10 +14544,10 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 14544 | if ((err = ensure_complete_type(ira->codegen, bare_type))) | 14544 | if ((err = ensure_complete_type(ira->codegen, bare_type))) |
| 14545 | return ira->codegen->invalid_instruction; | 14545 | return ira->codegen->invalid_instruction; |
| 14546 | | 14546 | |
| 14547 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | 14547 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 14548 | bool is_const = container_ptr->value.type->data.pointer.is_const; | 14548 | bool is_const = container_ptr->value.type->data.pointer.is_const; |
| 14549 | bool is_volatile = container_ptr->value.type->data.pointer.is_volatile; | 14549 | bool is_volatile = container_ptr->value.type->data.pointer.is_volatile; |
| 14550 | if (bare_type->id == TypeTableEntryIdStruct) { | 14550 | if (bare_type->id == ZigTypeIdStruct) { |
| 14551 | TypeStructField *field = find_struct_type_field(bare_type, field_name); | 14551 | TypeStructField *field = find_struct_type_field(bare_type, field_name); |
| 14552 | if (field) { | 14552 | if (field) { |
| 14553 | bool is_packed = (bare_type->data.structure.layout == ContainerLayoutPacked); | 14553 | bool is_packed = (bare_type->data.structure.layout == ContainerLayoutPacked); |
| ... | @@ -14594,10 +14594,10 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -14594,10 +14594,10 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 14594 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, | 14594 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 14595 | source_instr, container_ptr, container_type); | 14595 | source_instr, container_ptr, container_type); |
| 14596 | } | 14596 | } |
| 14597 | } else if (bare_type->id == TypeTableEntryIdEnum) { | 14597 | } else if (bare_type->id == ZigTypeIdEnum) { |
| 14598 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, | 14598 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 14599 | source_instr, container_ptr, container_type); | 14599 | source_instr, container_ptr, container_type); |
| 14600 | } else if (bare_type->id == TypeTableEntryIdUnion) { | 14600 | } else if (bare_type->id == ZigTypeIdUnion) { |
| 14601 | TypeUnionField *field = find_union_type_field(bare_type, field_name); | 14601 | TypeUnionField *field = find_union_type_field(bare_type, field_name); |
| 14602 | if (field) { | 14602 | if (field) { |
| 14603 | if (instr_is_comptime(container_ptr)) { | 14603 | if (instr_is_comptime(container_ptr)) { |
| ... | @@ -14626,7 +14626,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -14626,7 +14626,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 14626 | ConstExprValue *payload_val = union_val->data.x_union.payload; | 14626 | ConstExprValue *payload_val = union_val->data.x_union.payload; |
| 14627 | | 14627 | |
| 14628 | ZigType *field_type = field->type_entry; | 14628 | ZigType *field_type = field->type_entry; |
| 14629 | if (field_type->id == TypeTableEntryIdVoid) { | 14629 | if (field_type->id == ZigTypeIdVoid) { |
| 14630 | assert(payload_val == nullptr); | 14630 | assert(payload_val == nullptr); |
| 14631 | payload_val = create_const_vals(1); | 14631 | payload_val = create_const_vals(1); |
| 14632 | payload_val->special = ConstValSpecialStatic; | 14632 | payload_val->special = ConstValSpecialStatic; |
| ... | @@ -14732,7 +14732,7 @@ static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instru | ... | @@ -14732,7 +14732,7 @@ static ZigType *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instru |
| 14732 | } | 14732 | } |
| 14733 | | 14733 | |
| 14734 | static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_name) { | 14734 | static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_name) { |
| 14735 | assert(err_set_type->id == TypeTableEntryIdErrorSet); | 14735 | assert(err_set_type->id == ZigTypeIdErrorSet); |
| 14736 | for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { | 14736 | for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { |
| 14737 | ErrorTableEntry *err_table_entry = err_set_type->data.error_set.errors[i]; | 14737 | ErrorTableEntry *err_table_entry = err_set_type->data.error_set.errors[i]; |
| 14738 | if (buf_eql_buf(&err_table_entry->name, field_name)) { | 14738 | if (buf_eql_buf(&err_table_entry->name, field_name)) { |
| ... | @@ -14749,7 +14749,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14749,7 +14749,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14749 | return ira->codegen->builtin_types.entry_invalid; | 14749 | return ira->codegen->builtin_types.entry_invalid; |
| 14750 | | 14750 | |
| 14751 | ZigType *container_type = container_ptr->value.type->data.pointer.child_type; | 14751 | ZigType *container_type = container_ptr->value.type->data.pointer.child_type; |
| 14752 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | 14752 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 14753 | | 14753 | |
| 14754 | Buf *field_name = field_ptr_instruction->field_name_buffer; | 14754 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 14755 | if (!field_name) { | 14755 | if (!field_name) { |
| ... | @@ -14765,8 +14765,8 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14765,8 +14765,8 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14765 | if (type_is_invalid(container_type)) { | 14765 | if (type_is_invalid(container_type)) { |
| 14766 | return container_type; | 14766 | return container_type; |
| 14767 | } else if (is_container_ref(container_type)) { | 14767 | } else if (is_container_ref(container_type)) { |
| 14768 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | 14768 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 14769 | if (container_type->id == TypeTableEntryIdPointer) { | 14769 | if (container_type->id == ZigTypeIdPointer) { |
| 14770 | ZigType *bare_type = container_ref_type(container_type); | 14770 | ZigType *bare_type = container_ref_type(container_type); |
| 14771 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr); | 14771 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr); |
| 14772 | IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type); | 14772 | IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type); |
| ... | @@ -14780,7 +14780,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14780,7 +14780,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14780 | } else if (is_array_ref(container_type)) { | 14780 | } else if (is_array_ref(container_type)) { |
| 14781 | if (buf_eql_str(field_name, "len")) { | 14781 | if (buf_eql_str(field_name, "len")) { |
| 14782 | ConstExprValue *len_val = create_const_vals(1); | 14782 | ConstExprValue *len_val = create_const_vals(1); |
| 14783 | if (container_type->id == TypeTableEntryIdPointer) { | 14783 | if (container_type->id == ZigTypeIdPointer) { |
| 14784 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); | 14784 | init_const_usize(ira->codegen, len_val, container_type->data.pointer.child_type->data.array.len); |
| 14785 | } else { | 14785 | } else { |
| 14786 | init_const_usize(ira->codegen, len_val, container_type->data.array.len); | 14786 | init_const_usize(ira->codegen, len_val, container_type->data.array.len); |
| ... | @@ -14797,12 +14797,12 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14797,12 +14797,12 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14797 | buf_ptr(&container_type->name))); | 14797 | buf_ptr(&container_type->name))); |
| 14798 | return ira->codegen->builtin_types.entry_invalid; | 14798 | return ira->codegen->builtin_types.entry_invalid; |
| 14799 | } | 14799 | } |
| 14800 | } else if (container_type->id == TypeTableEntryIdArgTuple) { | 14800 | } else if (container_type->id == ZigTypeIdArgTuple) { |
| 14801 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 14801 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 14802 | if (!container_ptr_val) | 14802 | if (!container_ptr_val) |
| 14803 | return ira->codegen->builtin_types.entry_invalid; | 14803 | return ira->codegen->builtin_types.entry_invalid; |
| 14804 | | 14804 | |
| 14805 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | 14805 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 14806 | ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node); | 14806 | ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node); |
| 14807 | if (child_val == nullptr) | 14807 | if (child_val == nullptr) |
| 14808 | return ira->codegen->builtin_types.entry_invalid; | 14808 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -14823,12 +14823,12 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14823,12 +14823,12 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14823 | buf_ptr(&container_type->name))); | 14823 | buf_ptr(&container_type->name))); |
| 14824 | return ira->codegen->builtin_types.entry_invalid; | 14824 | return ira->codegen->builtin_types.entry_invalid; |
| 14825 | } | 14825 | } |
| 14826 | } else if (container_type->id == TypeTableEntryIdMetaType) { | 14826 | } else if (container_type->id == ZigTypeIdMetaType) { |
| 14827 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 14827 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 14828 | if (!container_ptr_val) | 14828 | if (!container_ptr_val) |
| 14829 | return ira->codegen->builtin_types.entry_invalid; | 14829 | return ira->codegen->builtin_types.entry_invalid; |
| 14830 | | 14830 | |
| 14831 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | 14831 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 14832 | ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node); | 14832 | ConstExprValue *child_val = ir_const_ptr_pointee(ira, container_ptr_val, source_node); |
| 14833 | if (child_val == nullptr) | 14833 | if (child_val == nullptr) |
| 14834 | return ira->codegen->builtin_types.entry_invalid; | 14834 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -14841,14 +14841,14 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14841,14 +14841,14 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14841 | bool ptr_is_const = true; | 14841 | bool ptr_is_const = true; |
| 14842 | bool ptr_is_volatile = false; | 14842 | bool ptr_is_volatile = false; |
| 14843 | TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index]; | 14843 | TypeStructField *ptr_field = &child_type->data.structure.fields[slice_ptr_index]; |
| 14844 | assert(ptr_field->type_entry->id == TypeTableEntryIdPointer); | 14844 | assert(ptr_field->type_entry->id == ZigTypeIdPointer); |
| 14845 | ZigType *child_type = ptr_field->type_entry->data.pointer.child_type; | 14845 | ZigType *child_type = ptr_field->type_entry->data.pointer.child_type; |
| 14846 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, | 14846 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, |
| 14847 | create_const_type(ira->codegen, child_type), | 14847 | create_const_type(ira->codegen, child_type), |
| 14848 | ira->codegen->builtin_types.entry_type, | 14848 | ira->codegen->builtin_types.entry_type, |
| 14849 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); | 14849 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); |
| 14850 | } | 14850 | } |
| 14851 | if (child_type->id == TypeTableEntryIdEnum) { | 14851 | if (child_type->id == ZigTypeIdEnum) { |
| 14852 | if ((err = ensure_complete_type(ira->codegen, child_type))) | 14852 | if ((err = ensure_complete_type(ira->codegen, child_type))) |
| 14853 | return ira->codegen->builtin_types.entry_invalid; | 14853 | return ira->codegen->builtin_types.entry_invalid; |
| 14854 | | 14854 | |
| ... | @@ -14869,7 +14869,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14869,7 +14869,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14869 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld); | 14869 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld); |
| 14870 | } | 14870 | } |
| 14871 | } | 14871 | } |
| 14872 | if (child_type->id == TypeTableEntryIdUnion && | 14872 | if (child_type->id == ZigTypeIdUnion && |
| 14873 | (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr || | 14873 | (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr || |
| 14874 | child_type->data.unionation.decl_node->data.container_decl.auto_enum)) | 14874 | child_type->data.unionation.decl_node->data.container_decl.auto_enum)) |
| 14875 | { | 14875 | { |
| ... | @@ -14889,7 +14889,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14889,7 +14889,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14889 | buf_sprintf("container '%s' has no member called '%s'", | 14889 | buf_sprintf("container '%s' has no member called '%s'", |
| 14890 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 14890 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 14891 | return ira->codegen->builtin_types.entry_invalid; | 14891 | return ira->codegen->builtin_types.entry_invalid; |
| 14892 | } else if (child_type->id == TypeTableEntryIdErrorSet) { | 14892 | } else if (child_type->id == ZigTypeIdErrorSet) { |
| 14893 | ErrorTableEntry *err_entry; | 14893 | ErrorTableEntry *err_entry; |
| 14894 | ZigType *err_set_type; | 14894 | ZigType *err_set_type; |
| 14895 | if (type_is_global_error_set(child_type)) { | 14895 | if (type_is_global_error_set(child_type)) { |
| ... | @@ -14935,7 +14935,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14935,7 +14935,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14935 | bool ptr_is_volatile = false; | 14935 | bool ptr_is_volatile = false; |
| 14936 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, const_val, | 14936 | return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, const_val, |
| 14937 | err_set_type, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); | 14937 | err_set_type, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); |
| 14938 | } else if (child_type->id == TypeTableEntryIdInt) { | 14938 | } else if (child_type->id == ZigTypeIdInt) { |
| 14939 | if (buf_eql_str(field_name, "bit_count")) { | 14939 | if (buf_eql_str(field_name, "bit_count")) { |
| 14940 | bool ptr_is_const = true; | 14940 | bool ptr_is_const = true; |
| 14941 | bool ptr_is_volatile = false; | 14941 | bool ptr_is_volatile = false; |
| ... | @@ -14957,7 +14957,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14957,7 +14957,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14957 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 14957 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 14958 | return ira->codegen->builtin_types.entry_invalid; | 14958 | return ira->codegen->builtin_types.entry_invalid; |
| 14959 | } | 14959 | } |
| 14960 | } else if (child_type->id == TypeTableEntryIdFloat) { | 14960 | } else if (child_type->id == ZigTypeIdFloat) { |
| 14961 | if (buf_eql_str(field_name, "bit_count")) { | 14961 | if (buf_eql_str(field_name, "bit_count")) { |
| 14962 | bool ptr_is_const = true; | 14962 | bool ptr_is_const = true; |
| 14963 | bool ptr_is_volatile = false; | 14963 | bool ptr_is_volatile = false; |
| ... | @@ -14972,7 +14972,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14972,7 +14972,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14972 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 14972 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 14973 | return ira->codegen->builtin_types.entry_invalid; | 14973 | return ira->codegen->builtin_types.entry_invalid; |
| 14974 | } | 14974 | } |
| 14975 | } else if (child_type->id == TypeTableEntryIdPointer) { | 14975 | } else if (child_type->id == ZigTypeIdPointer) { |
| 14976 | if (buf_eql_str(field_name, "Child")) { | 14976 | if (buf_eql_str(field_name, "Child")) { |
| 14977 | bool ptr_is_const = true; | 14977 | bool ptr_is_const = true; |
| 14978 | bool ptr_is_volatile = false; | 14978 | bool ptr_is_volatile = false; |
| ... | @@ -14994,7 +14994,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -14994,7 +14994,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 14994 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 14994 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 14995 | return ira->codegen->builtin_types.entry_invalid; | 14995 | return ira->codegen->builtin_types.entry_invalid; |
| 14996 | } | 14996 | } |
| 14997 | } else if (child_type->id == TypeTableEntryIdArray) { | 14997 | } else if (child_type->id == ZigTypeIdArray) { |
| 14998 | if (buf_eql_str(field_name, "Child")) { | 14998 | if (buf_eql_str(field_name, "Child")) { |
| 14999 | bool ptr_is_const = true; | 14999 | bool ptr_is_const = true; |
| 15000 | bool ptr_is_volatile = false; | 15000 | bool ptr_is_volatile = false; |
| ... | @@ -15016,7 +15016,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -15016,7 +15016,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 15016 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 15016 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 15017 | return ira->codegen->builtin_types.entry_invalid; | 15017 | return ira->codegen->builtin_types.entry_invalid; |
| 15018 | } | 15018 | } |
| 15019 | } else if (child_type->id == TypeTableEntryIdErrorUnion) { | 15019 | } else if (child_type->id == ZigTypeIdErrorUnion) { |
| 15020 | if (buf_eql_str(field_name, "Payload")) { | 15020 | if (buf_eql_str(field_name, "Payload")) { |
| 15021 | bool ptr_is_const = true; | 15021 | bool ptr_is_const = true; |
| 15022 | bool ptr_is_volatile = false; | 15022 | bool ptr_is_volatile = false; |
| ... | @@ -15037,7 +15037,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -15037,7 +15037,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 15037 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 15037 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 15038 | return ira->codegen->builtin_types.entry_invalid; | 15038 | return ira->codegen->builtin_types.entry_invalid; |
| 15039 | } | 15039 | } |
| 15040 | } else if (child_type->id == TypeTableEntryIdOptional) { | 15040 | } else if (child_type->id == ZigTypeIdOptional) { |
| 15041 | if (buf_eql_str(field_name, "Child")) { | 15041 | if (buf_eql_str(field_name, "Child")) { |
| 15042 | bool ptr_is_const = true; | 15042 | bool ptr_is_const = true; |
| 15043 | bool ptr_is_volatile = false; | 15043 | bool ptr_is_volatile = false; |
| ... | @@ -15051,7 +15051,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -15051,7 +15051,7 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 15051 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 15051 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 15052 | return ira->codegen->builtin_types.entry_invalid; | 15052 | return ira->codegen->builtin_types.entry_invalid; |
| 15053 | } | 15053 | } |
| 15054 | } else if (child_type->id == TypeTableEntryIdFn) { | 15054 | } else if (child_type->id == ZigTypeIdFn) { |
| 15055 | if (buf_eql_str(field_name, "ReturnType")) { | 15055 | if (buf_eql_str(field_name, "ReturnType")) { |
| 15056 | if (child_type->data.fn.fn_type_id.return_type == nullptr) { | 15056 | if (child_type->data.fn.fn_type_id.return_type == nullptr) { |
| 15057 | // Return type can only ever be null, if the function is generic | 15057 | // Return type can only ever be null, if the function is generic |
| ... | @@ -15093,8 +15093,8 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi | ... | @@ -15093,8 +15093,8 @@ static ZigType *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFi |
| 15093 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); | 15093 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); |
| 15094 | return ira->codegen->builtin_types.entry_invalid; | 15094 | return ira->codegen->builtin_types.entry_invalid; |
| 15095 | } | 15095 | } |
| 15096 | } else if (container_type->id == TypeTableEntryIdNamespace) { | 15096 | } else if (container_type->id == ZigTypeIdNamespace) { |
| 15097 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | 15097 | assert(container_ptr->value.type->id == ZigTypeIdPointer); |
| 15098 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 15098 | ConstExprValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 15099 | if (!container_ptr_val) | 15099 | if (!container_ptr_val) |
| 15100 | return ira->codegen->builtin_types.entry_invalid; | 15100 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15151,7 +15151,7 @@ static ZigType *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionSt | ... | @@ -15151,7 +15151,7 @@ static ZigType *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionSt |
| 15151 | if (type_is_invalid(value->value.type)) | 15151 | if (type_is_invalid(value->value.type)) |
| 15152 | return value->value.type; | 15152 | return value->value.type; |
| 15153 | | 15153 | |
| 15154 | if (ptr->value.type->id != TypeTableEntryIdPointer) { | 15154 | if (ptr->value.type->id != ZigTypeIdPointer) { |
| 15155 | ir_add_error(ira, ptr, | 15155 | ir_add_error(ira, ptr, |
| 15156 | buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr->value.type->name))); | 15156 | buf_sprintf("attempt to dereference non pointer type '%s'", buf_ptr(&ptr->value.type->name))); |
| 15157 | return ira->codegen->builtin_types.entry_invalid; | 15157 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15208,33 +15208,33 @@ static ZigType *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeO | ... | @@ -15208,33 +15208,33 @@ static ZigType *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeO |
| 15208 | if (type_is_invalid(type_entry)) | 15208 | if (type_is_invalid(type_entry)) |
| 15209 | return ira->codegen->builtin_types.entry_invalid; | 15209 | return ira->codegen->builtin_types.entry_invalid; |
| 15210 | switch (type_entry->id) { | 15210 | switch (type_entry->id) { |
| 15211 | case TypeTableEntryIdInvalid: | 15211 | case ZigTypeIdInvalid: |
| 15212 | zig_unreachable(); // handled above | 15212 | zig_unreachable(); // handled above |
| 15213 | case TypeTableEntryIdComptimeFloat: | 15213 | case ZigTypeIdComptimeFloat: |
| 15214 | case TypeTableEntryIdComptimeInt: | 15214 | case ZigTypeIdComptimeInt: |
| 15215 | case TypeTableEntryIdUndefined: | 15215 | case ZigTypeIdUndefined: |
| 15216 | case TypeTableEntryIdNull: | 15216 | case ZigTypeIdNull: |
| 15217 | case TypeTableEntryIdNamespace: | 15217 | case ZigTypeIdNamespace: |
| 15218 | case TypeTableEntryIdBlock: | 15218 | case ZigTypeIdBlock: |
| 15219 | case TypeTableEntryIdBoundFn: | 15219 | case ZigTypeIdBoundFn: |
| 15220 | case TypeTableEntryIdMetaType: | 15220 | case ZigTypeIdMetaType: |
| 15221 | case TypeTableEntryIdVoid: | 15221 | case ZigTypeIdVoid: |
| 15222 | case TypeTableEntryIdBool: | 15222 | case ZigTypeIdBool: |
| 15223 | case TypeTableEntryIdUnreachable: | 15223 | case ZigTypeIdUnreachable: |
| 15224 | case TypeTableEntryIdInt: | 15224 | case ZigTypeIdInt: |
| 15225 | case TypeTableEntryIdFloat: | 15225 | case ZigTypeIdFloat: |
| 15226 | case TypeTableEntryIdPointer: | 15226 | case ZigTypeIdPointer: |
| 15227 | case TypeTableEntryIdArray: | 15227 | case ZigTypeIdArray: |
| 15228 | case TypeTableEntryIdStruct: | 15228 | case ZigTypeIdStruct: |
| 15229 | case TypeTableEntryIdOptional: | 15229 | case ZigTypeIdOptional: |
| 15230 | case TypeTableEntryIdErrorUnion: | 15230 | case ZigTypeIdErrorUnion: |
| 15231 | case TypeTableEntryIdErrorSet: | 15231 | case ZigTypeIdErrorSet: |
| 15232 | case TypeTableEntryIdEnum: | 15232 | case ZigTypeIdEnum: |
| 15233 | case TypeTableEntryIdUnion: | 15233 | case ZigTypeIdUnion: |
| 15234 | case TypeTableEntryIdFn: | 15234 | case ZigTypeIdFn: |
| 15235 | case TypeTableEntryIdArgTuple: | 15235 | case ZigTypeIdArgTuple: |
| 15236 | case TypeTableEntryIdOpaque: | 15236 | case ZigTypeIdOpaque: |
| 15237 | case TypeTableEntryIdPromise: | 15237 | case ZigTypeIdPromise: |
| 15238 | { | 15238 | { |
| 15239 | ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base); | 15239 | ConstExprValue *out_val = ir_build_const_from(ira, &typeof_instruction->base); |
| 15240 | out_val->data.x_type = type_entry; | 15240 | out_val->data.x_type = type_entry; |
| ... | @@ -15255,11 +15255,11 @@ static ZigType *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, | ... | @@ -15255,11 +15255,11 @@ static ZigType *ir_analyze_instruction_to_ptr_type(IrAnalyze *ira, |
| 15255 | return type_entry; | 15255 | return type_entry; |
| 15256 | | 15256 | |
| 15257 | ZigType *ptr_type; | 15257 | ZigType *ptr_type; |
| 15258 | if (type_entry->id == TypeTableEntryIdArray) { | 15258 | if (type_entry->id == ZigTypeIdArray) { |
| 15259 | ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, false); | 15259 | ptr_type = get_pointer_to_type(ira->codegen, type_entry->data.array.child_type, false); |
| 15260 | } else if (is_slice(type_entry)) { | 15260 | } else if (is_slice(type_entry)) { |
| 15261 | ptr_type = adjust_ptr_len(ira->codegen, type_entry->data.structure.fields[0].type_entry, PtrLenSingle); | 15261 | ptr_type = adjust_ptr_len(ira->codegen, type_entry->data.structure.fields[0].type_entry, PtrLenSingle); |
| 15262 | } else if (type_entry->id == TypeTableEntryIdArgTuple) { | 15262 | } else if (type_entry->id == ZigTypeIdArgTuple) { |
| 15263 | ConstExprValue *arg_tuple_val = ir_resolve_const(ira, value, UndefBad); | 15263 | ConstExprValue *arg_tuple_val = ir_resolve_const(ira, value, UndefBad); |
| 15264 | if (!arg_tuple_val) | 15264 | if (!arg_tuple_val) |
| 15265 | return ira->codegen->builtin_types.entry_invalid; | 15265 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15283,7 +15283,7 @@ static ZigType *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, | ... | @@ -15283,7 +15283,7 @@ static ZigType *ir_analyze_instruction_ptr_type_child(IrAnalyze *ira, |
| 15283 | if (type_is_invalid(type_entry)) | 15283 | if (type_is_invalid(type_entry)) |
| 15284 | return type_entry; | 15284 | return type_entry; |
| 15285 | | 15285 | |
| 15286 | if (type_entry->id != TypeTableEntryIdPointer) { | 15286 | if (type_entry->id != ZigTypeIdPointer) { |
| 15287 | ir_add_error_node(ira, ptr_type_child_instruction->base.source_node, | 15287 | ir_add_error_node(ira, ptr_type_child_instruction->base.source_node, |
| 15288 | buf_sprintf("expected pointer type, found '%s'", buf_ptr(&type_entry->name))); | 15288 | buf_sprintf("expected pointer type, found '%s'", buf_ptr(&type_entry->name))); |
| 15289 | return ira->codegen->builtin_types.entry_invalid; | 15289 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15400,24 +15400,24 @@ static ZigType *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | ... | @@ -15400,24 +15400,24 @@ static ZigType *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 15400 | | 15400 | |
| 15401 | bool *fast_math_on_ptr; | 15401 | bool *fast_math_on_ptr; |
| 15402 | AstNode **fast_math_set_node_ptr; | 15402 | AstNode **fast_math_set_node_ptr; |
| 15403 | if (target_type->id == TypeTableEntryIdBlock) { | 15403 | if (target_type->id == ZigTypeIdBlock) { |
| 15404 | ScopeBlock *block_scope = (ScopeBlock *)target_val->data.x_block; | 15404 | ScopeBlock *block_scope = (ScopeBlock *)target_val->data.x_block; |
| 15405 | fast_math_on_ptr = &block_scope->fast_math_on; | 15405 | fast_math_on_ptr = &block_scope->fast_math_on; |
| 15406 | fast_math_set_node_ptr = &block_scope->fast_math_set_node; | 15406 | fast_math_set_node_ptr = &block_scope->fast_math_set_node; |
| 15407 | } else if (target_type->id == TypeTableEntryIdFn) { | 15407 | } else if (target_type->id == ZigTypeIdFn) { |
| 15408 | assert(target_val->data.x_ptr.special == ConstPtrSpecialFunction); | 15408 | assert(target_val->data.x_ptr.special == ConstPtrSpecialFunction); |
| 15409 | ZigFn *target_fn = target_val->data.x_ptr.data.fn.fn_entry; | 15409 | ZigFn *target_fn = target_val->data.x_ptr.data.fn.fn_entry; |
| 15410 | assert(target_fn->def_scope); | 15410 | assert(target_fn->def_scope); |
| 15411 | fast_math_on_ptr = &target_fn->def_scope->fast_math_on; | 15411 | fast_math_on_ptr = &target_fn->def_scope->fast_math_on; |
| 15412 | fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node; | 15412 | fast_math_set_node_ptr = &target_fn->def_scope->fast_math_set_node; |
| 15413 | } else if (target_type->id == TypeTableEntryIdMetaType) { | 15413 | } else if (target_type->id == ZigTypeIdMetaType) { |
| 15414 | ScopeDecls *decls_scope; | 15414 | ScopeDecls *decls_scope; |
| 15415 | ZigType *type_arg = target_val->data.x_type; | 15415 | ZigType *type_arg = target_val->data.x_type; |
| 15416 | if (type_arg->id == TypeTableEntryIdStruct) { | 15416 | if (type_arg->id == ZigTypeIdStruct) { |
| 15417 | decls_scope = type_arg->data.structure.decls_scope; | 15417 | decls_scope = type_arg->data.structure.decls_scope; |
| 15418 | } else if (type_arg->id == TypeTableEntryIdEnum) { | 15418 | } else if (type_arg->id == ZigTypeIdEnum) { |
| 15419 | decls_scope = type_arg->data.enumeration.decls_scope; | 15419 | decls_scope = type_arg->data.enumeration.decls_scope; |
| 15420 | } else if (type_arg->id == TypeTableEntryIdUnion) { | 15420 | } else if (type_arg->id == ZigTypeIdUnion) { |
| 15421 | decls_scope = type_arg->data.unionation.decls_scope; | 15421 | decls_scope = type_arg->data.unionation.decls_scope; |
| 15422 | } else { | 15422 | } else { |
| 15423 | ir_add_error_node(ira, target_instruction->source_node, | 15423 | ir_add_error_node(ira, target_instruction->source_node, |
| ... | @@ -15476,36 +15476,36 @@ static ZigType *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -15476,36 +15476,36 @@ static ZigType *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 15476 | bool is_volatile = slice_type_instruction->is_volatile; | 15476 | bool is_volatile = slice_type_instruction->is_volatile; |
| 15477 | | 15477 | |
| 15478 | switch (child_type->id) { | 15478 | switch (child_type->id) { |
| 15479 | case TypeTableEntryIdInvalid: // handled above | 15479 | case ZigTypeIdInvalid: // handled above |
| 15480 | zig_unreachable(); | 15480 | zig_unreachable(); |
| 15481 | case TypeTableEntryIdUnreachable: | 15481 | case ZigTypeIdUnreachable: |
| 15482 | case TypeTableEntryIdUndefined: | 15482 | case ZigTypeIdUndefined: |
| 15483 | case TypeTableEntryIdNull: | 15483 | case ZigTypeIdNull: |
| 15484 | case TypeTableEntryIdBlock: | 15484 | case ZigTypeIdBlock: |
| 15485 | case TypeTableEntryIdArgTuple: | 15485 | case ZigTypeIdArgTuple: |
| 15486 | case TypeTableEntryIdOpaque: | 15486 | case ZigTypeIdOpaque: |
| 15487 | ir_add_error_node(ira, slice_type_instruction->base.source_node, | 15487 | ir_add_error_node(ira, slice_type_instruction->base.source_node, |
| 15488 | buf_sprintf("slice of type '%s' not allowed", buf_ptr(&child_type->name))); | 15488 | buf_sprintf("slice of type '%s' not allowed", buf_ptr(&child_type->name))); |
| 15489 | return ira->codegen->builtin_types.entry_invalid; | 15489 | return ira->codegen->builtin_types.entry_invalid; |
| 15490 | case TypeTableEntryIdMetaType: | 15490 | case ZigTypeIdMetaType: |
| 15491 | case TypeTableEntryIdVoid: | 15491 | case ZigTypeIdVoid: |
| 15492 | case TypeTableEntryIdBool: | 15492 | case ZigTypeIdBool: |
| 15493 | case TypeTableEntryIdInt: | 15493 | case ZigTypeIdInt: |
| 15494 | case TypeTableEntryIdFloat: | 15494 | case ZigTypeIdFloat: |
| 15495 | case TypeTableEntryIdPointer: | 15495 | case ZigTypeIdPointer: |
| 15496 | case TypeTableEntryIdArray: | 15496 | case ZigTypeIdArray: |
| 15497 | case TypeTableEntryIdStruct: | 15497 | case ZigTypeIdStruct: |
| 15498 | case TypeTableEntryIdComptimeFloat: | 15498 | case ZigTypeIdComptimeFloat: |
| 15499 | case TypeTableEntryIdComptimeInt: | 15499 | case ZigTypeIdComptimeInt: |
| 15500 | case TypeTableEntryIdOptional: | 15500 | case ZigTypeIdOptional: |
| 15501 | case TypeTableEntryIdErrorUnion: | 15501 | case ZigTypeIdErrorUnion: |
| 15502 | case TypeTableEntryIdErrorSet: | 15502 | case ZigTypeIdErrorSet: |
| 15503 | case TypeTableEntryIdEnum: | 15503 | case ZigTypeIdEnum: |
| 15504 | case TypeTableEntryIdUnion: | 15504 | case ZigTypeIdUnion: |
| 15505 | case TypeTableEntryIdFn: | 15505 | case ZigTypeIdFn: |
| 15506 | case TypeTableEntryIdNamespace: | 15506 | case ZigTypeIdNamespace: |
| 15507 | case TypeTableEntryIdBoundFn: | 15507 | case ZigTypeIdBoundFn: |
| 15508 | case TypeTableEntryIdPromise: | 15508 | case ZigTypeIdPromise: |
| 15509 | { | 15509 | { |
| 15510 | if ((err = type_ensure_zero_bits_known(ira->codegen, child_type))) | 15510 | if ((err = type_ensure_zero_bits_known(ira->codegen, child_type))) |
| 15511 | return ira->codegen->builtin_types.entry_invalid; | 15511 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15587,36 +15587,36 @@ static ZigType *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -15587,36 +15587,36 @@ static ZigType *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 15587 | if (type_is_invalid(child_type)) | 15587 | if (type_is_invalid(child_type)) |
| 15588 | return ira->codegen->builtin_types.entry_invalid; | 15588 | return ira->codegen->builtin_types.entry_invalid; |
| 15589 | switch (child_type->id) { | 15589 | switch (child_type->id) { |
| 15590 | case TypeTableEntryIdInvalid: // handled above | 15590 | case ZigTypeIdInvalid: // handled above |
| 15591 | zig_unreachable(); | 15591 | zig_unreachable(); |
| 15592 | case TypeTableEntryIdUnreachable: | 15592 | case ZigTypeIdUnreachable: |
| 15593 | case TypeTableEntryIdUndefined: | 15593 | case ZigTypeIdUndefined: |
| 15594 | case TypeTableEntryIdNull: | 15594 | case ZigTypeIdNull: |
| 15595 | case TypeTableEntryIdBlock: | 15595 | case ZigTypeIdBlock: |
| 15596 | case TypeTableEntryIdArgTuple: | 15596 | case ZigTypeIdArgTuple: |
| 15597 | case TypeTableEntryIdOpaque: | 15597 | case ZigTypeIdOpaque: |
| 15598 | ir_add_error_node(ira, array_type_instruction->base.source_node, | 15598 | ir_add_error_node(ira, array_type_instruction->base.source_node, |
| 15599 | buf_sprintf("array of type '%s' not allowed", buf_ptr(&child_type->name))); | 15599 | buf_sprintf("array of type '%s' not allowed", buf_ptr(&child_type->name))); |
| 15600 | return ira->codegen->builtin_types.entry_invalid; | 15600 | return ira->codegen->builtin_types.entry_invalid; |
| 15601 | case TypeTableEntryIdMetaType: | 15601 | case ZigTypeIdMetaType: |
| 15602 | case TypeTableEntryIdVoid: | 15602 | case ZigTypeIdVoid: |
| 15603 | case TypeTableEntryIdBool: | 15603 | case ZigTypeIdBool: |
| 15604 | case TypeTableEntryIdInt: | 15604 | case ZigTypeIdInt: |
| 15605 | case TypeTableEntryIdFloat: | 15605 | case ZigTypeIdFloat: |
| 15606 | case TypeTableEntryIdPointer: | 15606 | case ZigTypeIdPointer: |
| 15607 | case TypeTableEntryIdArray: | 15607 | case ZigTypeIdArray: |
| 15608 | case TypeTableEntryIdStruct: | 15608 | case ZigTypeIdStruct: |
| 15609 | case TypeTableEntryIdComptimeFloat: | 15609 | case ZigTypeIdComptimeFloat: |
| 15610 | case TypeTableEntryIdComptimeInt: | 15610 | case ZigTypeIdComptimeInt: |
| 15611 | case TypeTableEntryIdOptional: | 15611 | case ZigTypeIdOptional: |
| 15612 | case TypeTableEntryIdErrorUnion: | 15612 | case ZigTypeIdErrorUnion: |
| 15613 | case TypeTableEntryIdErrorSet: | 15613 | case ZigTypeIdErrorSet: |
| 15614 | case TypeTableEntryIdEnum: | 15614 | case ZigTypeIdEnum: |
| 15615 | case TypeTableEntryIdUnion: | 15615 | case ZigTypeIdUnion: |
| 15616 | case TypeTableEntryIdFn: | 15616 | case ZigTypeIdFn: |
| 15617 | case TypeTableEntryIdNamespace: | 15617 | case ZigTypeIdNamespace: |
| 15618 | case TypeTableEntryIdBoundFn: | 15618 | case ZigTypeIdBoundFn: |
| 15619 | case TypeTableEntryIdPromise: | 15619 | case ZigTypeIdPromise: |
| 15620 | { | 15620 | { |
| 15621 | if ((err = ensure_complete_type(ira->codegen, child_type))) | 15621 | if ((err = ensure_complete_type(ira->codegen, child_type))) |
| 15622 | return ira->codegen->builtin_types.entry_invalid; | 15622 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15658,36 +15658,36 @@ static ZigType *ir_analyze_instruction_size_of(IrAnalyze *ira, | ... | @@ -15658,36 +15658,36 @@ static ZigType *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 15658 | return ira->codegen->builtin_types.entry_invalid; | 15658 | return ira->codegen->builtin_types.entry_invalid; |
| 15659 | | 15659 | |
| 15660 | switch (type_entry->id) { | 15660 | switch (type_entry->id) { |
| 15661 | case TypeTableEntryIdInvalid: // handled above | 15661 | case ZigTypeIdInvalid: // handled above |
| 15662 | zig_unreachable(); | 15662 | zig_unreachable(); |
| 15663 | case TypeTableEntryIdUnreachable: | 15663 | case ZigTypeIdUnreachable: |
| 15664 | case TypeTableEntryIdUndefined: | 15664 | case ZigTypeIdUndefined: |
| 15665 | case TypeTableEntryIdNull: | 15665 | case ZigTypeIdNull: |
| 15666 | case TypeTableEntryIdBlock: | 15666 | case ZigTypeIdBlock: |
| 15667 | case TypeTableEntryIdComptimeFloat: | 15667 | case ZigTypeIdComptimeFloat: |
| 15668 | case TypeTableEntryIdComptimeInt: | 15668 | case ZigTypeIdComptimeInt: |
| 15669 | case TypeTableEntryIdBoundFn: | 15669 | case ZigTypeIdBoundFn: |
| 15670 | case TypeTableEntryIdMetaType: | 15670 | case ZigTypeIdMetaType: |
| 15671 | case TypeTableEntryIdNamespace: | 15671 | case ZigTypeIdNamespace: |
| 15672 | case TypeTableEntryIdArgTuple: | 15672 | case ZigTypeIdArgTuple: |
| 15673 | case TypeTableEntryIdOpaque: | 15673 | case ZigTypeIdOpaque: |
| 15674 | ir_add_error_node(ira, size_of_instruction->base.source_node, | 15674 | ir_add_error_node(ira, size_of_instruction->base.source_node, |
| 15675 | buf_sprintf("no size available for type '%s'", buf_ptr(&type_entry->name))); | 15675 | buf_sprintf("no size available for type '%s'", buf_ptr(&type_entry->name))); |
| 15676 | return ira->codegen->builtin_types.entry_invalid; | 15676 | return ira->codegen->builtin_types.entry_invalid; |
| 15677 | case TypeTableEntryIdVoid: | 15677 | case ZigTypeIdVoid: |
| 15678 | case TypeTableEntryIdBool: | 15678 | case ZigTypeIdBool: |
| 15679 | case TypeTableEntryIdInt: | 15679 | case ZigTypeIdInt: |
| 15680 | case TypeTableEntryIdFloat: | 15680 | case ZigTypeIdFloat: |
| 15681 | case TypeTableEntryIdPointer: | 15681 | case ZigTypeIdPointer: |
| 15682 | case TypeTableEntryIdArray: | 15682 | case ZigTypeIdArray: |
| 15683 | case TypeTableEntryIdStruct: | 15683 | case ZigTypeIdStruct: |
| 15684 | case TypeTableEntryIdOptional: | 15684 | case ZigTypeIdOptional: |
| 15685 | case TypeTableEntryIdErrorUnion: | 15685 | case ZigTypeIdErrorUnion: |
| 15686 | case TypeTableEntryIdErrorSet: | 15686 | case ZigTypeIdErrorSet: |
| 15687 | case TypeTableEntryIdEnum: | 15687 | case ZigTypeIdEnum: |
| 15688 | case TypeTableEntryIdUnion: | 15688 | case ZigTypeIdUnion: |
| 15689 | case TypeTableEntryIdFn: | 15689 | case ZigTypeIdFn: |
| 15690 | case TypeTableEntryIdPromise: | 15690 | case ZigTypeIdPromise: |
| 15691 | { | 15691 | { |
| 15692 | uint64_t size_in_bytes = type_size(ira->codegen, type_entry); | 15692 | uint64_t size_in_bytes = type_size(ira->codegen, type_entry); |
| 15693 | ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base); | 15693 | ConstExprValue *out_val = ir_build_const_from(ira, &size_of_instruction->base); |
| ... | @@ -15705,7 +15705,7 @@ static ZigType *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructi | ... | @@ -15705,7 +15705,7 @@ static ZigType *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructi |
| 15705 | | 15705 | |
| 15706 | ZigType *type_entry = value->value.type; | 15706 | ZigType *type_entry = value->value.type; |
| 15707 | | 15707 | |
| 15708 | if (type_entry->id == TypeTableEntryIdOptional) { | 15708 | if (type_entry->id == ZigTypeIdOptional) { |
| 15709 | if (instr_is_comptime(value)) { | 15709 | if (instr_is_comptime(value)) { |
| 15710 | ConstExprValue *maybe_val = ir_resolve_const(ira, value, UndefBad); | 15710 | ConstExprValue *maybe_val = ir_resolve_const(ira, value, UndefBad); |
| 15711 | if (!maybe_val) | 15711 | if (!maybe_val) |
| ... | @@ -15718,7 +15718,7 @@ static ZigType *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructi | ... | @@ -15718,7 +15718,7 @@ static ZigType *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructi |
| 15718 | | 15718 | |
| 15719 | ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value); | 15719 | ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value); |
| 15720 | return ira->codegen->builtin_types.entry_bool; | 15720 | return ira->codegen->builtin_types.entry_bool; |
| 15721 | } else if (type_entry->id == TypeTableEntryIdNull) { | 15721 | } else if (type_entry->id == ZigTypeIdNull) { |
| 15722 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 15722 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 15723 | out_val->data.x_bool = false; | 15723 | out_val->data.x_bool = false; |
| 15724 | return ira->codegen->builtin_types.entry_bool; | 15724 | return ira->codegen->builtin_types.entry_bool; |
| ... | @@ -15737,12 +15737,12 @@ static ZigType *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, | ... | @@ -15737,12 +15737,12 @@ static ZigType *ir_analyze_instruction_unwrap_maybe(IrAnalyze *ira, |
| 15737 | return ira->codegen->builtin_types.entry_invalid; | 15737 | return ira->codegen->builtin_types.entry_invalid; |
| 15738 | | 15738 | |
| 15739 | ZigType *ptr_type = value->value.type; | 15739 | ZigType *ptr_type = value->value.type; |
| 15740 | assert(ptr_type->id == TypeTableEntryIdPointer); | 15740 | assert(ptr_type->id == ZigTypeIdPointer); |
| 15741 | | 15741 | |
| 15742 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 15742 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 15743 | if (type_is_invalid(type_entry)) { | 15743 | if (type_is_invalid(type_entry)) { |
| 15744 | return ira->codegen->builtin_types.entry_invalid; | 15744 | return ira->codegen->builtin_types.entry_invalid; |
| 15745 | } else if (type_entry->id != TypeTableEntryIdOptional) { | 15745 | } else if (type_entry->id != ZigTypeIdOptional) { |
| 15746 | ir_add_error_node(ira, unwrap_maybe_instruction->value->source_node, | 15746 | ir_add_error_node(ira, unwrap_maybe_instruction->value->source_node, |
| 15747 | buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name))); | 15747 | buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name))); |
| 15748 | return ira->codegen->builtin_types.entry_invalid; | 15748 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15787,7 +15787,7 @@ static ZigType *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz | ... | @@ -15787,7 +15787,7 @@ static ZigType *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *ctz |
| 15787 | IrInstruction *value = ctz_instruction->value->other; | 15787 | IrInstruction *value = ctz_instruction->value->other; |
| 15788 | if (type_is_invalid(value->value.type)) { | 15788 | if (type_is_invalid(value->value.type)) { |
| 15789 | return ira->codegen->builtin_types.entry_invalid; | 15789 | return ira->codegen->builtin_types.entry_invalid; |
| 15790 | } else if (value->value.type->id == TypeTableEntryIdInt) { | 15790 | } else if (value->value.type->id == ZigTypeIdInt) { |
| 15791 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, | 15791 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, |
| 15792 | value->value.type->data.integral.bit_count); | 15792 | value->value.type->data.integral.bit_count); |
| 15793 | if (value->value.special != ConstValSpecialRuntime) { | 15793 | if (value->value.special != ConstValSpecialRuntime) { |
| ... | @@ -15811,7 +15811,7 @@ static ZigType *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz | ... | @@ -15811,7 +15811,7 @@ static ZigType *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *clz |
| 15811 | IrInstruction *value = clz_instruction->value->other; | 15811 | IrInstruction *value = clz_instruction->value->other; |
| 15812 | if (type_is_invalid(value->value.type)) { | 15812 | if (type_is_invalid(value->value.type)) { |
| 15813 | return ira->codegen->builtin_types.entry_invalid; | 15813 | return ira->codegen->builtin_types.entry_invalid; |
| 15814 | } else if (value->value.type->id == TypeTableEntryIdInt) { | 15814 | } else if (value->value.type->id == ZigTypeIdInt) { |
| 15815 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, | 15815 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, |
| 15816 | value->value.type->data.integral.bit_count); | 15816 | value->value.type->data.integral.bit_count); |
| 15817 | if (value->value.special != ConstValSpecialRuntime) { | 15817 | if (value->value.special != ConstValSpecialRuntime) { |
| ... | @@ -15836,7 +15836,7 @@ static ZigType *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPo | ... | @@ -15836,7 +15836,7 @@ static ZigType *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPo |
| 15836 | if (type_is_invalid(value->value.type)) | 15836 | if (type_is_invalid(value->value.type)) |
| 15837 | return ira->codegen->builtin_types.entry_invalid; | 15837 | return ira->codegen->builtin_types.entry_invalid; |
| 15838 | | 15838 | |
| 15839 | if (value->value.type->id != TypeTableEntryIdInt && value->value.type->id != TypeTableEntryIdComptimeInt) { | 15839 | if (value->value.type->id != ZigTypeIdInt && value->value.type->id != ZigTypeIdComptimeInt) { |
| 15840 | ir_add_error(ira, value, | 15840 | ir_add_error(ira, value, |
| 15841 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&value->value.type->name))); | 15841 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&value->value.type->name))); |
| 15842 | return ira->codegen->builtin_types.entry_invalid; | 15842 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -15852,7 +15852,7 @@ static ZigType *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPo | ... | @@ -15852,7 +15852,7 @@ static ZigType *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPo |
| 15852 | bigint_init_unsigned(&out_val->data.x_bigint, result); | 15852 | bigint_init_unsigned(&out_val->data.x_bigint, result); |
| 15853 | return ira->codegen->builtin_types.entry_num_lit_int; | 15853 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 15854 | } | 15854 | } |
| 15855 | if (value->value.type->id == TypeTableEntryIdComptimeInt) { | 15855 | if (value->value.type->id == ZigTypeIdComptimeInt) { |
| 15856 | Buf *val_buf = buf_alloc(); | 15856 | Buf *val_buf = buf_alloc(); |
| 15857 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); | 15857 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); |
| 15858 | ir_add_error(ira, &instruction->base, | 15858 | ir_add_error(ira, &instruction->base, |
| ... | @@ -15877,11 +15877,11 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -15877,11 +15877,11 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 15877 | if (type_is_invalid(value->value.type)) | 15877 | if (type_is_invalid(value->value.type)) |
| 15878 | return ira->codegen->invalid_instruction; | 15878 | return ira->codegen->invalid_instruction; |
| 15879 | | 15879 | |
| 15880 | if (value->value.type->id == TypeTableEntryIdEnum) { | 15880 | if (value->value.type->id == ZigTypeIdEnum) { |
| 15881 | return value; | 15881 | return value; |
| 15882 | } | 15882 | } |
| 15883 | | 15883 | |
| 15884 | if (value->value.type->id != TypeTableEntryIdUnion) { | 15884 | if (value->value.type->id != ZigTypeIdUnion) { |
| 15885 | ir_add_error(ira, value, | 15885 | ir_add_error(ira, value, |
| 15886 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name))); | 15886 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name))); |
| 15887 | return ira->codegen->invalid_instruction; | 15887 | return ira->codegen->invalid_instruction; |
| ... | @@ -15896,7 +15896,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -15896,7 +15896,7 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 15896 | } | 15896 | } |
| 15897 | | 15897 | |
| 15898 | ZigType *tag_type = value->value.type->data.unionation.tag_type; | 15898 | ZigType *tag_type = value->value.type->data.unionation.tag_type; |
| 15899 | assert(tag_type->id == TypeTableEntryIdEnum); | 15899 | assert(tag_type->id == ZigTypeIdEnum); |
| 15900 | | 15900 | |
| 15901 | if (instr_is_comptime(value)) { | 15901 | if (instr_is_comptime(value)) { |
| 15902 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); | 15902 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); |
| ... | @@ -15948,7 +15948,7 @@ static ZigType *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -15948,7 +15948,7 @@ static ZigType *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 15948 | if (type_is_invalid(case_value->value.type)) | 15948 | if (type_is_invalid(case_value->value.type)) |
| 15949 | return ir_unreach_error(ira); | 15949 | return ir_unreach_error(ira); |
| 15950 | | 15950 | |
| 15951 | if (case_value->value.type->id == TypeTableEntryIdEnum) { | 15951 | if (case_value->value.type->id == ZigTypeIdEnum) { |
| 15952 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); | 15952 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); |
| 15953 | if (type_is_invalid(case_value->value.type)) | 15953 | if (type_is_invalid(case_value->value.type)) |
| 15954 | return ir_unreach_error(ira); | 15954 | return ir_unreach_error(ira); |
| ... | @@ -15995,7 +15995,7 @@ static ZigType *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -15995,7 +15995,7 @@ static ZigType *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 15995 | if (type_is_invalid(new_value->value.type)) | 15995 | if (type_is_invalid(new_value->value.type)) |
| 15996 | continue; | 15996 | continue; |
| 15997 | | 15997 | |
| 15998 | if (new_value->value.type->id == TypeTableEntryIdEnum) { | 15998 | if (new_value->value.type->id == ZigTypeIdEnum) { |
| 15999 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); | 15999 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); |
| 16000 | if (type_is_invalid(new_value->value.type)) | 16000 | if (type_is_invalid(new_value->value.type)) |
| 16001 | continue; | 16001 | continue; |
| ... | @@ -16032,17 +16032,17 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -16032,17 +16032,17 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16032 | if (type_is_invalid(target_value_ptr->value.type)) | 16032 | if (type_is_invalid(target_value_ptr->value.type)) |
| 16033 | return ira->codegen->builtin_types.entry_invalid; | 16033 | return ira->codegen->builtin_types.entry_invalid; |
| 16034 | | 16034 | |
| 16035 | if (target_value_ptr->value.type->id == TypeTableEntryIdMetaType) { | 16035 | if (target_value_ptr->value.type->id == ZigTypeIdMetaType) { |
| 16036 | assert(instr_is_comptime(target_value_ptr)); | 16036 | assert(instr_is_comptime(target_value_ptr)); |
| 16037 | ZigType *ptr_type = target_value_ptr->value.data.x_type; | 16037 | ZigType *ptr_type = target_value_ptr->value.data.x_type; |
| 16038 | assert(ptr_type->id == TypeTableEntryIdPointer); | 16038 | assert(ptr_type->id == ZigTypeIdPointer); |
| 16039 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); | 16039 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 16040 | out_val->type = ira->codegen->builtin_types.entry_type; | 16040 | out_val->type = ira->codegen->builtin_types.entry_type; |
| 16041 | out_val->data.x_type = ptr_type->data.pointer.child_type; | 16041 | out_val->data.x_type = ptr_type->data.pointer.child_type; |
| 16042 | return out_val->type; | 16042 | return out_val->type; |
| 16043 | } | 16043 | } |
| 16044 | | 16044 | |
| 16045 | if (target_value_ptr->value.type->id != TypeTableEntryIdPointer) { | 16045 | if (target_value_ptr->value.type->id != ZigTypeIdPointer) { |
| 16046 | ir_add_error(ira, target_value_ptr, buf_sprintf("invalid deref on switch target")); | 16046 | ir_add_error(ira, target_value_ptr, buf_sprintf("invalid deref on switch target")); |
| 16047 | return ira->codegen->builtin_types.entry_invalid; | 16047 | return ira->codegen->builtin_types.entry_invalid; |
| 16048 | } | 16048 | } |
| ... | @@ -16061,20 +16061,20 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -16061,20 +16061,20 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16061 | return ira->codegen->builtin_types.entry_invalid; | 16061 | return ira->codegen->builtin_types.entry_invalid; |
| 16062 | | 16062 | |
| 16063 | switch (target_type->id) { | 16063 | switch (target_type->id) { |
| 16064 | case TypeTableEntryIdInvalid: | 16064 | case ZigTypeIdInvalid: |
| 16065 | zig_unreachable(); | 16065 | zig_unreachable(); |
| 16066 | case TypeTableEntryIdMetaType: | 16066 | case ZigTypeIdMetaType: |
| 16067 | case TypeTableEntryIdVoid: | 16067 | case ZigTypeIdVoid: |
| 16068 | case TypeTableEntryIdBool: | 16068 | case ZigTypeIdBool: |
| 16069 | case TypeTableEntryIdInt: | 16069 | case ZigTypeIdInt: |
| 16070 | case TypeTableEntryIdFloat: | 16070 | case ZigTypeIdFloat: |
| 16071 | case TypeTableEntryIdComptimeFloat: | 16071 | case ZigTypeIdComptimeFloat: |
| 16072 | case TypeTableEntryIdComptimeInt: | 16072 | case ZigTypeIdComptimeInt: |
| 16073 | case TypeTableEntryIdPointer: | 16073 | case ZigTypeIdPointer: |
| 16074 | case TypeTableEntryIdPromise: | 16074 | case ZigTypeIdPromise: |
| 16075 | case TypeTableEntryIdFn: | 16075 | case ZigTypeIdFn: |
| 16076 | case TypeTableEntryIdNamespace: | 16076 | case ZigTypeIdNamespace: |
| 16077 | case TypeTableEntryIdErrorSet: | 16077 | case ZigTypeIdErrorSet: |
| 16078 | if (pointee_val) { | 16078 | if (pointee_val) { |
| 16079 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); | 16079 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 16080 | copy_const_val(out_val, pointee_val, true); | 16080 | copy_const_val(out_val, pointee_val, true); |
| ... | @@ -16084,7 +16084,7 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -16084,7 +16084,7 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16084 | | 16084 | |
| 16085 | ir_build_load_ptr_from(&ira->new_irb, &switch_target_instruction->base, target_value_ptr); | 16085 | ir_build_load_ptr_from(&ira->new_irb, &switch_target_instruction->base, target_value_ptr); |
| 16086 | return target_type; | 16086 | return target_type; |
| 16087 | case TypeTableEntryIdUnion: { | 16087 | case ZigTypeIdUnion: { |
| 16088 | AstNode *decl_node = target_type->data.unionation.decl_node; | 16088 | AstNode *decl_node = target_type->data.unionation.decl_node; |
| 16089 | if (!decl_node->data.container_decl.auto_enum && | 16089 | if (!decl_node->data.container_decl.auto_enum && |
| 16090 | decl_node->data.container_decl.init_arg_expr == nullptr) | 16090 | decl_node->data.container_decl.init_arg_expr == nullptr) |
| ... | @@ -16097,7 +16097,7 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -16097,7 +16097,7 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16097 | } | 16097 | } |
| 16098 | ZigType *tag_type = target_type->data.unionation.tag_type; | 16098 | ZigType *tag_type = target_type->data.unionation.tag_type; |
| 16099 | assert(tag_type != nullptr); | 16099 | assert(tag_type != nullptr); |
| 16100 | assert(tag_type->id == TypeTableEntryIdEnum); | 16100 | assert(tag_type->id == ZigTypeIdEnum); |
| 16101 | if (pointee_val) { | 16101 | if (pointee_val) { |
| 16102 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); | 16102 | ConstExprValue *out_val = ir_build_const_from(ira, &switch_target_instruction->base); |
| 16103 | bigint_init_bigint(&out_val->data.x_enum_tag, &pointee_val->data.x_union.tag); | 16103 | bigint_init_bigint(&out_val->data.x_enum_tag, &pointee_val->data.x_union.tag); |
| ... | @@ -16120,7 +16120,7 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -16120,7 +16120,7 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16120 | ir_link_new_instruction(union_tag_inst, &switch_target_instruction->base); | 16120 | ir_link_new_instruction(union_tag_inst, &switch_target_instruction->base); |
| 16121 | return tag_type; | 16121 | return tag_type; |
| 16122 | } | 16122 | } |
| 16123 | case TypeTableEntryIdEnum: { | 16123 | case ZigTypeIdEnum: { |
| 16124 | if ((err = type_ensure_zero_bits_known(ira->codegen, target_type))) | 16124 | if ((err = type_ensure_zero_bits_known(ira->codegen, target_type))) |
| 16125 | return ira->codegen->builtin_types.entry_invalid; | 16125 | return ira->codegen->builtin_types.entry_invalid; |
| 16126 | if (target_type->data.enumeration.src_field_count < 2) { | 16126 | if (target_type->data.enumeration.src_field_count < 2) { |
| ... | @@ -16142,17 +16142,17 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -16142,17 +16142,17 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16142 | ir_link_new_instruction(enum_value, &switch_target_instruction->base); | 16142 | ir_link_new_instruction(enum_value, &switch_target_instruction->base); |
| 16143 | return target_type; | 16143 | return target_type; |
| 16144 | } | 16144 | } |
| 16145 | case TypeTableEntryIdErrorUnion: | 16145 | case ZigTypeIdErrorUnion: |
| 16146 | case TypeTableEntryIdUnreachable: | 16146 | case ZigTypeIdUnreachable: |
| 16147 | case TypeTableEntryIdArray: | 16147 | case ZigTypeIdArray: |
| 16148 | case TypeTableEntryIdStruct: | 16148 | case ZigTypeIdStruct: |
| 16149 | case TypeTableEntryIdUndefined: | 16149 | case ZigTypeIdUndefined: |
| 16150 | case TypeTableEntryIdNull: | 16150 | case ZigTypeIdNull: |
| 16151 | case TypeTableEntryIdOptional: | 16151 | case ZigTypeIdOptional: |
| 16152 | case TypeTableEntryIdBlock: | 16152 | case ZigTypeIdBlock: |
| 16153 | case TypeTableEntryIdBoundFn: | 16153 | case ZigTypeIdBoundFn: |
| 16154 | case TypeTableEntryIdArgTuple: | 16154 | case ZigTypeIdArgTuple: |
| 16155 | case TypeTableEntryIdOpaque: | 16155 | case ZigTypeIdOpaque: |
| 16156 | ir_add_error(ira, &switch_target_instruction->base, | 16156 | ir_add_error(ira, &switch_target_instruction->base, |
| 16157 | buf_sprintf("invalid switch target type '%s'", buf_ptr(&target_type->name))); | 16157 | buf_sprintf("invalid switch target type '%s'", buf_ptr(&target_type->name))); |
| 16158 | return ira->codegen->builtin_types.entry_invalid; | 16158 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -16169,14 +16169,14 @@ static ZigType *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionS | ... | @@ -16169,14 +16169,14 @@ static ZigType *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionS |
| 16169 | if (type_is_invalid(prong_value->value.type)) | 16169 | if (type_is_invalid(prong_value->value.type)) |
| 16170 | return ira->codegen->builtin_types.entry_invalid; | 16170 | return ira->codegen->builtin_types.entry_invalid; |
| 16171 | | 16171 | |
| 16172 | assert(target_value_ptr->value.type->id == TypeTableEntryIdPointer); | 16172 | assert(target_value_ptr->value.type->id == ZigTypeIdPointer); |
| 16173 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; | 16173 | ZigType *target_type = target_value_ptr->value.type->data.pointer.child_type; |
| 16174 | if (target_type->id == TypeTableEntryIdUnion) { | 16174 | if (target_type->id == ZigTypeIdUnion) { |
| 16175 | ConstExprValue *prong_val = ir_resolve_const(ira, prong_value, UndefBad); | 16175 | ConstExprValue *prong_val = ir_resolve_const(ira, prong_value, UndefBad); |
| 16176 | if (!prong_val) | 16176 | if (!prong_val) |
| 16177 | return ira->codegen->builtin_types.entry_invalid; | 16177 | return ira->codegen->builtin_types.entry_invalid; |
| 16178 | | 16178 | |
| 16179 | assert(prong_value->value.type->id == TypeTableEntryIdEnum); | 16179 | assert(prong_value->value.type->id == ZigTypeIdEnum); |
| 16180 | TypeUnionField *field = find_union_field_by_tag(target_type, &prong_val->data.x_enum_tag); | 16180 | TypeUnionField *field = find_union_field_by_tag(target_type, &prong_val->data.x_enum_tag); |
| 16181 | | 16181 | |
| 16182 | if (instr_is_comptime(target_value_ptr)) { | 16182 | if (instr_is_comptime(target_value_ptr)) { |
| ... | @@ -16285,7 +16285,7 @@ static ZigType *ir_analyze_instruction_array_len(IrAnalyze *ira, | ... | @@ -16285,7 +16285,7 @@ static ZigType *ir_analyze_instruction_array_len(IrAnalyze *ira, |
| 16285 | ZigType *type_entry = array_value->value.type; | 16285 | ZigType *type_entry = array_value->value.type; |
| 16286 | if (type_is_invalid(type_entry)) { | 16286 | if (type_is_invalid(type_entry)) { |
| 16287 | return ira->codegen->builtin_types.entry_invalid; | 16287 | return ira->codegen->builtin_types.entry_invalid; |
| 16288 | } else if (type_entry->id == TypeTableEntryIdArray) { | 16288 | } else if (type_entry->id == ZigTypeIdArray) { |
| 16289 | return ir_analyze_const_usize(ira, &array_len_instruction->base, | 16289 | return ir_analyze_const_usize(ira, &array_len_instruction->base, |
| 16290 | type_entry->data.array.len); | 16290 | type_entry->data.array.len); |
| 16291 | } else if (is_slice(type_entry)) { | 16291 | } else if (is_slice(type_entry)) { |
| ... | @@ -16318,7 +16318,7 @@ static ZigType *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruc | ... | @@ -16318,7 +16318,7 @@ static ZigType *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruc |
| 16318 | ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields) | 16318 | ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields) |
| 16319 | { | 16319 | { |
| 16320 | Error err; | 16320 | Error err; |
| 16321 | assert(container_type->id == TypeTableEntryIdUnion); | 16321 | assert(container_type->id == ZigTypeIdUnion); |
| 16322 | | 16322 | |
| 16323 | if ((err = ensure_complete_type(ira->codegen, container_type))) | 16323 | if ((err = ensure_complete_type(ira->codegen, container_type))) |
| 16324 | return ira->codegen->builtin_types.entry_invalid; | 16324 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -16384,10 +16384,10 @@ static ZigType *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction * | ... | @@ -16384,10 +16384,10 @@ static ZigType *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction * |
| 16384 | ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields) | 16384 | ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields) |
| 16385 | { | 16385 | { |
| 16386 | Error err; | 16386 | Error err; |
| 16387 | if (container_type->id == TypeTableEntryIdUnion) { | 16387 | if (container_type->id == ZigTypeIdUnion) { |
| 16388 | return ir_analyze_container_init_fields_union(ira, instruction, container_type, instr_field_count, fields); | 16388 | return ir_analyze_container_init_fields_union(ira, instruction, container_type, instr_field_count, fields); |
| 16389 | } | 16389 | } |
| 16390 | if (container_type->id != TypeTableEntryIdStruct || is_slice(container_type)) { | 16390 | if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) { |
| 16391 | ir_add_error(ira, instruction, | 16391 | ir_add_error(ira, instruction, |
| 16392 | buf_sprintf("type '%s' does not support struct initialization syntax", | 16392 | buf_sprintf("type '%s' does not support struct initialization syntax", |
| 16393 | buf_ptr(&container_type->name))); | 16393 | buf_ptr(&container_type->name))); |
| ... | @@ -16508,18 +16508,18 @@ static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16508,18 +16508,18 @@ static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16508 | return ira->codegen->builtin_types.entry_invalid; | 16508 | return ira->codegen->builtin_types.entry_invalid; |
| 16509 | | 16509 | |
| 16510 | size_t elem_count = instruction->item_count; | 16510 | size_t elem_count = instruction->item_count; |
| 16511 | if (container_type_value->value.type->id == TypeTableEntryIdMetaType) { | 16511 | if (container_type_value->value.type->id == ZigTypeIdMetaType) { |
| 16512 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 16512 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 16513 | if (type_is_invalid(container_type)) | 16513 | if (type_is_invalid(container_type)) |
| 16514 | return ira->codegen->builtin_types.entry_invalid; | 16514 | return ira->codegen->builtin_types.entry_invalid; |
| 16515 | | 16515 | |
| 16516 | if (container_type->id == TypeTableEntryIdStruct && !is_slice(container_type) && elem_count == 0) { | 16516 | if (container_type->id == ZigTypeIdStruct && !is_slice(container_type) && elem_count == 0) { |
| 16517 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 16517 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, |
| 16518 | 0, nullptr); | 16518 | 0, nullptr); |
| 16519 | } else if (is_slice(container_type) || container_type->id == TypeTableEntryIdArray) { | 16519 | } else if (is_slice(container_type) || container_type->id == ZigTypeIdArray) { |
| 16520 | // array is same as slice init but we make a compile error if the length is wrong | 16520 | // array is same as slice init but we make a compile error if the length is wrong |
| 16521 | ZigType *child_type; | 16521 | ZigType *child_type; |
| 16522 | if (container_type->id == TypeTableEntryIdArray) { | 16522 | if (container_type->id == ZigTypeIdArray) { |
| 16523 | child_type = container_type->data.array.child_type; | 16523 | child_type = container_type->data.array.child_type; |
| 16524 | if (container_type->data.array.len != elem_count) { | 16524 | if (container_type->data.array.len != elem_count) { |
| 16525 | ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count); | 16525 | ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count); |
| ... | @@ -16531,7 +16531,7 @@ static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16531,7 +16531,7 @@ static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16531 | } | 16531 | } |
| 16532 | } else { | 16532 | } else { |
| 16533 | ZigType *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry; | 16533 | ZigType *pointer_type = container_type->data.structure.fields[slice_ptr_index].type_entry; |
| 16534 | assert(pointer_type->id == TypeTableEntryIdPointer); | 16534 | assert(pointer_type->id == ZigTypeIdPointer); |
| 16535 | child_type = pointer_type->data.pointer.child_type; | 16535 | child_type = pointer_type->data.pointer.child_type; |
| 16536 | } | 16536 | } |
| 16537 | | 16537 | |
| ... | @@ -16598,7 +16598,7 @@ static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -16598,7 +16598,7 @@ static ZigType *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 16598 | container_type_value, elem_count, new_items); | 16598 | container_type_value, elem_count, new_items); |
| 16599 | ir_add_alloca(ira, new_instruction, fixed_size_array_type); | 16599 | ir_add_alloca(ira, new_instruction, fixed_size_array_type); |
| 16600 | return fixed_size_array_type; | 16600 | return fixed_size_array_type; |
| 16601 | } else if (container_type->id == TypeTableEntryIdVoid) { | 16601 | } else if (container_type->id == ZigTypeIdVoid) { |
| 16602 | if (elem_count != 0) { | 16602 | if (elem_count != 0) { |
| 16603 | ir_add_error_node(ira, instruction->base.source_node, | 16603 | ir_add_error_node(ira, instruction->base.source_node, |
| 16604 | buf_sprintf("void expression expects no arguments")); | 16604 | buf_sprintf("void expression expects no arguments")); |
| ... | @@ -16635,43 +16635,43 @@ static ZigType *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -16635,43 +16635,43 @@ static ZigType *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruc |
| 16635 | if (type_is_invalid(target_type)) | 16635 | if (type_is_invalid(target_type)) |
| 16636 | return ira->codegen->builtin_types.entry_invalid; | 16636 | return ira->codegen->builtin_types.entry_invalid; |
| 16637 | switch (target_type->id) { | 16637 | switch (target_type->id) { |
| 16638 | case TypeTableEntryIdInvalid: | 16638 | case ZigTypeIdInvalid: |
| 16639 | zig_unreachable(); | 16639 | zig_unreachable(); |
| 16640 | case TypeTableEntryIdInt: | 16640 | case ZigTypeIdInt: |
| 16641 | { | 16641 | { |
| 16642 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); | 16642 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); |
| 16643 | eval_min_max_value(ira->codegen, target_type, out_val, is_max); | 16643 | eval_min_max_value(ira->codegen, target_type, out_val, is_max); |
| 16644 | return ira->codegen->builtin_types.entry_num_lit_int; | 16644 | return ira->codegen->builtin_types.entry_num_lit_int; |
| 16645 | } | 16645 | } |
| 16646 | case TypeTableEntryIdBool: | 16646 | case ZigTypeIdBool: |
| 16647 | case TypeTableEntryIdVoid: | 16647 | case ZigTypeIdVoid: |
| 16648 | { | 16648 | { |
| 16649 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); | 16649 | ConstExprValue *out_val = ir_build_const_from(ira, source_instruction); |
| 16650 | eval_min_max_value(ira->codegen, target_type, out_val, is_max); | 16650 | eval_min_max_value(ira->codegen, target_type, out_val, is_max); |
| 16651 | return target_type; | 16651 | return target_type; |
| 16652 | } | 16652 | } |
| 16653 | case TypeTableEntryIdEnum: | 16653 | case ZigTypeIdEnum: |
| 16654 | case TypeTableEntryIdFloat: | 16654 | case ZigTypeIdFloat: |
| 16655 | case TypeTableEntryIdMetaType: | 16655 | case ZigTypeIdMetaType: |
| 16656 | case TypeTableEntryIdUnreachable: | 16656 | case ZigTypeIdUnreachable: |
| 16657 | case TypeTableEntryIdPointer: | 16657 | case ZigTypeIdPointer: |
| 16658 | case TypeTableEntryIdPromise: | 16658 | case ZigTypeIdPromise: |
| 16659 | case TypeTableEntryIdArray: | 16659 | case ZigTypeIdArray: |
| 16660 | case TypeTableEntryIdStruct: | 16660 | case ZigTypeIdStruct: |
| 16661 | case TypeTableEntryIdComptimeFloat: | 16661 | case ZigTypeIdComptimeFloat: |
| 16662 | case TypeTableEntryIdComptimeInt: | 16662 | case ZigTypeIdComptimeInt: |
| 16663 | case TypeTableEntryIdUndefined: | 16663 | case ZigTypeIdUndefined: |
| 16664 | case TypeTableEntryIdNull: | 16664 | case ZigTypeIdNull: |
| 16665 | case TypeTableEntryIdOptional: | 16665 | case ZigTypeIdOptional: |
| 16666 | case TypeTableEntryIdErrorUnion: | 16666 | case ZigTypeIdErrorUnion: |
| 16667 | case TypeTableEntryIdErrorSet: | 16667 | case ZigTypeIdErrorSet: |
| 16668 | case TypeTableEntryIdUnion: | 16668 | case ZigTypeIdUnion: |
| 16669 | case TypeTableEntryIdFn: | 16669 | case ZigTypeIdFn: |
| 16670 | case TypeTableEntryIdNamespace: | 16670 | case ZigTypeIdNamespace: |
| 16671 | case TypeTableEntryIdBlock: | 16671 | case ZigTypeIdBlock: |
| 16672 | case TypeTableEntryIdBoundFn: | 16672 | case ZigTypeIdBoundFn: |
| 16673 | case TypeTableEntryIdArgTuple: | 16673 | case ZigTypeIdArgTuple: |
| 16674 | case TypeTableEntryIdOpaque: | 16674 | case ZigTypeIdOpaque: |
| 16675 | { | 16675 | { |
| 16676 | const char *err_format = is_max ? | 16676 | const char *err_format = is_max ? |
| 16677 | "no max value available for type '%s'" : | 16677 | "no max value available for type '%s'" : |
| ... | @@ -16774,7 +16774,7 @@ static ZigType *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructi | ... | @@ -16774,7 +16774,7 @@ static ZigType *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructi |
| 16774 | if (type_is_invalid(target->value.type)) | 16774 | if (type_is_invalid(target->value.type)) |
| 16775 | return ira->codegen->builtin_types.entry_invalid; | 16775 | return ira->codegen->builtin_types.entry_invalid; |
| 16776 | | 16776 | |
| 16777 | assert(target->value.type->id == TypeTableEntryIdEnum); | 16777 | assert(target->value.type->id == ZigTypeIdEnum); |
| 16778 | | 16778 | |
| 16779 | if (instr_is_comptime(target)) { | 16779 | if (instr_is_comptime(target)) { |
| 16780 | if ((err = type_ensure_zero_bits_known(ira->codegen, target->value.type))) | 16780 | if ((err = type_ensure_zero_bits_known(ira->codegen, target->value.type))) |
| ... | @@ -16816,7 +16816,7 @@ static ZigType *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16816,7 +16816,7 @@ static ZigType *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16816 | if (type_is_invalid(field_ptr->value.type)) | 16816 | if (type_is_invalid(field_ptr->value.type)) |
| 16817 | return ira->codegen->builtin_types.entry_invalid; | 16817 | return ira->codegen->builtin_types.entry_invalid; |
| 16818 | | 16818 | |
| 16819 | if (container_type->id != TypeTableEntryIdStruct) { | 16819 | if (container_type->id != ZigTypeIdStruct) { |
| 16820 | ir_add_error(ira, type_value, | 16820 | ir_add_error(ira, type_value, |
| 16821 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | 16821 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| 16822 | return ira->codegen->builtin_types.entry_invalid; | 16822 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -16833,7 +16833,7 @@ static ZigType *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -16833,7 +16833,7 @@ static ZigType *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 16833 | return ira->codegen->builtin_types.entry_invalid; | 16833 | return ira->codegen->builtin_types.entry_invalid; |
| 16834 | } | 16834 | } |
| 16835 | | 16835 | |
| 16836 | if (field_ptr->value.type->id != TypeTableEntryIdPointer) { | 16836 | if (field_ptr->value.type->id != ZigTypeIdPointer) { |
| 16837 | ir_add_error(ira, field_ptr, | 16837 | ir_add_error(ira, field_ptr, |
| 16838 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name))); | 16838 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value.type->name))); |
| 16839 | return ira->codegen->builtin_types.entry_invalid; | 16839 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -16908,7 +16908,7 @@ static ZigType *ir_analyze_instruction_offset_of(IrAnalyze *ira, | ... | @@ -16908,7 +16908,7 @@ static ZigType *ir_analyze_instruction_offset_of(IrAnalyze *ira, |
| 16908 | if (!field_name) | 16908 | if (!field_name) |
| 16909 | return ira->codegen->builtin_types.entry_invalid; | 16909 | return ira->codegen->builtin_types.entry_invalid; |
| 16910 | | 16910 | |
| 16911 | if (container_type->id != TypeTableEntryIdStruct) { | 16911 | if (container_type->id != ZigTypeIdStruct) { |
| 16912 | ir_add_error(ira, type_value, | 16912 | ir_add_error(ira, type_value, |
| 16913 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | 16913 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| 16914 | return ira->codegen->builtin_types.entry_invalid; | 16914 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -16951,11 +16951,11 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig | ... | @@ -16951,11 +16951,11 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig |
| 16951 | static ZigType *type_info_type = nullptr; | 16951 | static ZigType *type_info_type = nullptr; |
| 16952 | if (type_info_var == nullptr) { | 16952 | if (type_info_var == nullptr) { |
| 16953 | type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); | 16953 | type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); |
| 16954 | assert(type_info_var->type->id == TypeTableEntryIdMetaType); | 16954 | assert(type_info_var->type->id == ZigTypeIdMetaType); |
| 16955 | | 16955 | |
| 16956 | assertNoError(ensure_complete_type(ira->codegen, type_info_var->data.x_type)); | 16956 | assertNoError(ensure_complete_type(ira->codegen, type_info_var->data.x_type)); |
| 16957 | type_info_type = type_info_var->data.x_type; | 16957 | type_info_type = type_info_var->data.x_type; |
| 16958 | assert(type_info_type->id == TypeTableEntryIdUnion); | 16958 | assert(type_info_type->id == ZigTypeIdUnion); |
| 16959 | } | 16959 | } |
| 16960 | | 16960 | |
| 16961 | if (type_name == nullptr && root == nullptr) | 16961 | if (type_name == nullptr && root == nullptr) |
| ... | @@ -16980,7 +16980,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig | ... | @@ -16980,7 +16980,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig |
| 16980 | | 16980 | |
| 16981 | if ((err = ensure_complete_type(ira->codegen, var->value->type))) | 16981 | if ((err = ensure_complete_type(ira->codegen, var->value->type))) |
| 16982 | return ira->codegen->builtin_types.entry_invalid; | 16982 | return ira->codegen->builtin_types.entry_invalid; |
| 16983 | assert(var->value->type->id == TypeTableEntryIdMetaType); | 16983 | assert(var->value->type->id == ZigTypeIdMetaType); |
| 16984 | return var->value->data.x_type; | 16984 | return var->value->data.x_type; |
| 16985 | } | 16985 | } |
| 16986 | | 16986 | |
| ... | @@ -17078,7 +17078,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco | ... | @@ -17078,7 +17078,7 @@ static Error ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Sco |
| 17078 | if ((err = ensure_complete_type(ira->codegen, var->value->type))) | 17078 | if ((err = ensure_complete_type(ira->codegen, var->value->type))) |
| 17079 | return ErrorSemanticAnalyzeFail; | 17079 | return ErrorSemanticAnalyzeFail; |
| 17080 | | 17080 | |
| 17081 | if (var->value->type->id == TypeTableEntryIdMetaType) | 17081 | if (var->value->type->id == ZigTypeIdMetaType) |
| 17082 | { | 17082 | { |
| 17083 | // We have a variable of type 'type', so it's actually a type definition. | 17083 | // We have a variable of type 'type', so it's actually a type definition. |
| 17084 | // 0: Data.Type: type | 17084 | // 0: Data.Type: type |
| ... | @@ -17238,7 +17238,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty | ... | @@ -17238,7 +17238,7 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty |
| 17238 | if (is_slice(ptr_type_entry)) { | 17238 | if (is_slice(ptr_type_entry)) { |
| 17239 | attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry; | 17239 | attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry; |
| 17240 | size_enum_index = 2; | 17240 | size_enum_index = 2; |
| 17241 | } else if (ptr_type_entry->id == TypeTableEntryIdPointer) { | 17241 | } else if (ptr_type_entry->id == ZigTypeIdPointer) { |
| 17242 | attrs_type = ptr_type_entry; | 17242 | attrs_type = ptr_type_entry; |
| 17243 | size_enum_index = (ptr_type_entry->data.pointer.ptr_len == PtrLenSingle) ? 0 : 1; | 17243 | size_enum_index = (ptr_type_entry->data.pointer.ptr_len == PtrLenSingle) ? 0 : 1; |
| 17244 | } else { | 17244 | } else { |
| ... | @@ -17320,20 +17320,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17320,20 +17320,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17320 | ConstExprValue *result = nullptr; | 17320 | ConstExprValue *result = nullptr; |
| 17321 | switch (type_entry->id) | 17321 | switch (type_entry->id) |
| 17322 | { | 17322 | { |
| 17323 | case TypeTableEntryIdInvalid: | 17323 | case ZigTypeIdInvalid: |
| 17324 | zig_unreachable(); | 17324 | zig_unreachable(); |
| 17325 | case TypeTableEntryIdMetaType: | 17325 | case ZigTypeIdMetaType: |
| 17326 | case TypeTableEntryIdVoid: | 17326 | case ZigTypeIdVoid: |
| 17327 | case TypeTableEntryIdBool: | 17327 | case ZigTypeIdBool: |
| 17328 | case TypeTableEntryIdUnreachable: | 17328 | case ZigTypeIdUnreachable: |
| 17329 | case TypeTableEntryIdComptimeFloat: | 17329 | case ZigTypeIdComptimeFloat: |
| 17330 | case TypeTableEntryIdComptimeInt: | 17330 | case ZigTypeIdComptimeInt: |
| 17331 | case TypeTableEntryIdUndefined: | 17331 | case ZigTypeIdUndefined: |
| 17332 | case TypeTableEntryIdNull: | 17332 | case ZigTypeIdNull: |
| 17333 | case TypeTableEntryIdNamespace: | 17333 | case ZigTypeIdNamespace: |
| 17334 | case TypeTableEntryIdBlock: | 17334 | case ZigTypeIdBlock: |
| 17335 | case TypeTableEntryIdArgTuple: | 17335 | case ZigTypeIdArgTuple: |
| 17336 | case TypeTableEntryIdOpaque: | 17336 | case ZigTypeIdOpaque: |
| 17337 | *out = nullptr; | 17337 | *out = nullptr; |
| 17338 | return ErrorNone; | 17338 | return ErrorNone; |
| 17339 | default: | 17339 | default: |
| ... | @@ -17347,7 +17347,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17347,7 +17347,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17347 | | 17347 | |
| 17348 | // Fallthrough if we don't find one. | 17348 | // Fallthrough if we don't find one. |
| 17349 | } | 17349 | } |
| 17350 | case TypeTableEntryIdInt: | 17350 | case ZigTypeIdInt: |
| 17351 | { | 17351 | { |
| 17352 | result = create_const_vals(1); | 17352 | result = create_const_vals(1); |
| 17353 | result->special = ConstValSpecialStatic; | 17353 | result->special = ConstValSpecialStatic; |
| ... | @@ -17369,7 +17369,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17369,7 +17369,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17369 | | 17369 | |
| 17370 | break; | 17370 | break; |
| 17371 | } | 17371 | } |
| 17372 | case TypeTableEntryIdFloat: | 17372 | case ZigTypeIdFloat: |
| 17373 | { | 17373 | { |
| 17374 | result = create_const_vals(1); | 17374 | result = create_const_vals(1); |
| 17375 | result->special = ConstValSpecialStatic; | 17375 | result->special = ConstValSpecialStatic; |
| ... | @@ -17386,12 +17386,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17386,12 +17386,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17386 | | 17386 | |
| 17387 | break; | 17387 | break; |
| 17388 | } | 17388 | } |
| 17389 | case TypeTableEntryIdPointer: | 17389 | case ZigTypeIdPointer: |
| 17390 | { | 17390 | { |
| 17391 | result = create_ptr_like_type_info(ira, type_entry); | 17391 | result = create_ptr_like_type_info(ira, type_entry); |
| 17392 | break; | 17392 | break; |
| 17393 | } | 17393 | } |
| 17394 | case TypeTableEntryIdArray: | 17394 | case ZigTypeIdArray: |
| 17395 | { | 17395 | { |
| 17396 | result = create_const_vals(1); | 17396 | result = create_const_vals(1); |
| 17397 | result->special = ConstValSpecialStatic; | 17397 | result->special = ConstValSpecialStatic; |
| ... | @@ -17413,7 +17413,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17413,7 +17413,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17413 | | 17413 | |
| 17414 | break; | 17414 | break; |
| 17415 | } | 17415 | } |
| 17416 | case TypeTableEntryIdOptional: | 17416 | case ZigTypeIdOptional: |
| 17417 | { | 17417 | { |
| 17418 | result = create_const_vals(1); | 17418 | result = create_const_vals(1); |
| 17419 | result->special = ConstValSpecialStatic; | 17419 | result->special = ConstValSpecialStatic; |
| ... | @@ -17430,7 +17430,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17430,7 +17430,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17430 | | 17430 | |
| 17431 | break; | 17431 | break; |
| 17432 | } | 17432 | } |
| 17433 | case TypeTableEntryIdPromise: | 17433 | case ZigTypeIdPromise: |
| 17434 | { | 17434 | { |
| 17435 | result = create_const_vals(1); | 17435 | result = create_const_vals(1); |
| 17436 | result->special = ConstValSpecialStatic; | 17436 | result->special = ConstValSpecialStatic; |
| ... | @@ -17456,7 +17456,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17456,7 +17456,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17456 | | 17456 | |
| 17457 | break; | 17457 | break; |
| 17458 | } | 17458 | } |
| 17459 | case TypeTableEntryIdEnum: | 17459 | case ZigTypeIdEnum: |
| 17460 | { | 17460 | { |
| 17461 | result = create_const_vals(1); | 17461 | result = create_const_vals(1); |
| 17462 | result->special = ConstValSpecialStatic; | 17462 | result->special = ConstValSpecialStatic; |
| ... | @@ -17506,7 +17506,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17506,7 +17506,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17506 | | 17506 | |
| 17507 | break; | 17507 | break; |
| 17508 | } | 17508 | } |
| 17509 | case TypeTableEntryIdErrorSet: | 17509 | case ZigTypeIdErrorSet: |
| 17510 | { | 17510 | { |
| 17511 | result = create_const_vals(1); | 17511 | result = create_const_vals(1); |
| 17512 | result->special = ConstValSpecialStatic; | 17512 | result->special = ConstValSpecialStatic; |
| ... | @@ -17555,7 +17555,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17555,7 +17555,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17555 | | 17555 | |
| 17556 | break; | 17556 | break; |
| 17557 | } | 17557 | } |
| 17558 | case TypeTableEntryIdErrorUnion: | 17558 | case ZigTypeIdErrorUnion: |
| 17559 | { | 17559 | { |
| 17560 | result = create_const_vals(1); | 17560 | result = create_const_vals(1); |
| 17561 | result->special = ConstValSpecialStatic; | 17561 | result->special = ConstValSpecialStatic; |
| ... | @@ -17578,7 +17578,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17578,7 +17578,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17578 | | 17578 | |
| 17579 | break; | 17579 | break; |
| 17580 | } | 17580 | } |
| 17581 | case TypeTableEntryIdUnion: | 17581 | case ZigTypeIdUnion: |
| 17582 | { | 17582 | { |
| 17583 | result = create_const_vals(1); | 17583 | result = create_const_vals(1); |
| 17584 | result->special = ConstValSpecialStatic; | 17584 | result->special = ConstValSpecialStatic; |
| ... | @@ -17663,7 +17663,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17663,7 +17663,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17663 | | 17663 | |
| 17664 | break; | 17664 | break; |
| 17665 | } | 17665 | } |
| 17666 | case TypeTableEntryIdStruct: | 17666 | case ZigTypeIdStruct: |
| 17667 | { | 17667 | { |
| 17668 | if (type_entry->data.structure.is_slice) { | 17668 | if (type_entry->data.structure.is_slice) { |
| 17669 | result = create_ptr_like_type_info(ira, type_entry); | 17669 | result = create_ptr_like_type_info(ira, type_entry); |
| ... | @@ -17737,7 +17737,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17737,7 +17737,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17737 | | 17737 | |
| 17738 | break; | 17738 | break; |
| 17739 | } | 17739 | } |
| 17740 | case TypeTableEntryIdFn: | 17740 | case ZigTypeIdFn: |
| 17741 | { | 17741 | { |
| 17742 | result = create_const_vals(1); | 17742 | result = create_const_vals(1); |
| 17743 | result->special = ConstValSpecialStatic; | 17743 | result->special = ConstValSpecialStatic; |
| ... | @@ -17842,10 +17842,10 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE | ... | @@ -17842,10 +17842,10 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17842 | | 17842 | |
| 17843 | break; | 17843 | break; |
| 17844 | } | 17844 | } |
| 17845 | case TypeTableEntryIdBoundFn: | 17845 | case ZigTypeIdBoundFn: |
| 17846 | { | 17846 | { |
| 17847 | ZigType *fn_type = type_entry->data.bound_fn.fn_type; | 17847 | ZigType *fn_type = type_entry->data.bound_fn.fn_type; |
| 17848 | assert(fn_type->id == TypeTableEntryIdFn); | 17848 | assert(fn_type->id == ZigTypeIdFn); |
| 17849 | if ((err = ir_make_type_info_value(ira, fn_type, &result))) | 17849 | if ((err = ir_make_type_info_value(ira, fn_type, &result))) |
| 17850 | return err; | 17850 | return err; |
| 17851 | | 17851 | |
| ... | @@ -17880,7 +17880,7 @@ static ZigType *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -17880,7 +17880,7 @@ static ZigType *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 17880 | out_val->data.x_union.payload = payload; | 17880 | out_val->data.x_union.payload = payload; |
| 17881 | | 17881 | |
| 17882 | if (payload != nullptr) { | 17882 | if (payload != nullptr) { |
| 17883 | assert(payload->type->id == TypeTableEntryIdStruct); | 17883 | assert(payload->type->id == ZigTypeIdStruct); |
| 17884 | payload->data.x_struct.parent.id = ConstParentIdUnion; | 17884 | payload->data.x_struct.parent.id = ConstParentIdUnion; |
| 17885 | payload->data.x_struct.parent.data.p_union.union_val = out_val; | 17885 | payload->data.x_struct.parent.data.p_union.union_val = out_val; |
| 17886 | } | 17886 | } |
| ... | @@ -17897,7 +17897,7 @@ static ZigType *ir_analyze_instruction_type_id(IrAnalyze *ira, | ... | @@ -17897,7 +17897,7 @@ static ZigType *ir_analyze_instruction_type_id(IrAnalyze *ira, |
| 17897 | return ira->codegen->builtin_types.entry_invalid; | 17897 | return ira->codegen->builtin_types.entry_invalid; |
| 17898 | | 17898 | |
| 17899 | ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId"); | 17899 | ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeId"); |
| 17900 | assert(var_value->type->id == TypeTableEntryIdMetaType); | 17900 | assert(var_value->type->id == ZigTypeIdMetaType); |
| 17901 | ZigType *result_type = var_value->data.x_type; | 17901 | ZigType *result_type = var_value->data.x_type; |
| 17902 | | 17902 | |
| 17903 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 17903 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| ... | @@ -18206,8 +18206,8 @@ static ZigType *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTru | ... | @@ -18206,8 +18206,8 @@ static ZigType *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTru |
| 18206 | if (type_is_invalid(dest_type)) | 18206 | if (type_is_invalid(dest_type)) |
| 18207 | return ira->codegen->builtin_types.entry_invalid; | 18207 | return ira->codegen->builtin_types.entry_invalid; |
| 18208 | | 18208 | |
| 18209 | if (dest_type->id != TypeTableEntryIdInt && | 18209 | if (dest_type->id != ZigTypeIdInt && |
| 18210 | dest_type->id != TypeTableEntryIdComptimeInt) | 18210 | dest_type->id != ZigTypeIdComptimeInt) |
| 18211 | { | 18211 | { |
| 18212 | ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 18212 | ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 18213 | return ira->codegen->builtin_types.entry_invalid; | 18213 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18218,8 +18218,8 @@ static ZigType *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTru | ... | @@ -18218,8 +18218,8 @@ static ZigType *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTru |
| 18218 | if (type_is_invalid(src_type)) | 18218 | if (type_is_invalid(src_type)) |
| 18219 | return ira->codegen->builtin_types.entry_invalid; | 18219 | return ira->codegen->builtin_types.entry_invalid; |
| 18220 | | 18220 | |
| 18221 | if (src_type->id != TypeTableEntryIdInt && | 18221 | if (src_type->id != ZigTypeIdInt && |
| 18222 | src_type->id != TypeTableEntryIdComptimeInt) | 18222 | src_type->id != ZigTypeIdComptimeInt) |
| 18223 | { | 18223 | { |
| 18224 | ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); | 18224 | ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); |
| 18225 | return ira->codegen->builtin_types.entry_invalid; | 18225 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18253,7 +18253,7 @@ static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionInt | ... | @@ -18253,7 +18253,7 @@ static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionInt |
| 18253 | if (type_is_invalid(dest_type)) | 18253 | if (type_is_invalid(dest_type)) |
| 18254 | return ira->codegen->builtin_types.entry_invalid; | 18254 | return ira->codegen->builtin_types.entry_invalid; |
| 18255 | | 18255 | |
| 18256 | if (dest_type->id != TypeTableEntryIdInt) { | 18256 | if (dest_type->id != ZigTypeIdInt) { |
| 18257 | ir_add_error(ira, instruction->dest_type, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 18257 | ir_add_error(ira, instruction->dest_type, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 18258 | return ira->codegen->builtin_types.entry_invalid; | 18258 | return ira->codegen->builtin_types.entry_invalid; |
| 18259 | } | 18259 | } |
| ... | @@ -18262,7 +18262,7 @@ static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionInt | ... | @@ -18262,7 +18262,7 @@ static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionInt |
| 18262 | if (type_is_invalid(target->value.type)) | 18262 | if (type_is_invalid(target->value.type)) |
| 18263 | return ira->codegen->builtin_types.entry_invalid; | 18263 | return ira->codegen->builtin_types.entry_invalid; |
| 18264 | | 18264 | |
| 18265 | if (target->value.type->id == TypeTableEntryIdComptimeInt) { | 18265 | if (target->value.type->id == ZigTypeIdComptimeInt) { |
| 18266 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { | 18266 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { |
| 18267 | IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_type, | 18267 | IrInstruction *result = ir_resolve_cast(ira, &instruction->base, target, dest_type, |
| 18268 | CastOpNumLitToConcrete, false); | 18268 | CastOpNumLitToConcrete, false); |
| ... | @@ -18275,7 +18275,7 @@ static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionInt | ... | @@ -18275,7 +18275,7 @@ static ZigType *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionInt |
| 18275 | } | 18275 | } |
| 18276 | } | 18276 | } |
| 18277 | | 18277 | |
| 18278 | if (target->value.type->id != TypeTableEntryIdInt) { | 18278 | if (target->value.type->id != ZigTypeIdInt) { |
| 18279 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", | 18279 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", |
| 18280 | buf_ptr(&target->value.type->name))); | 18280 | buf_ptr(&target->value.type->name))); |
| 18281 | return ira->codegen->builtin_types.entry_invalid; | 18281 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18294,7 +18294,7 @@ static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionF | ... | @@ -18294,7 +18294,7 @@ static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionF |
| 18294 | if (type_is_invalid(dest_type)) | 18294 | if (type_is_invalid(dest_type)) |
| 18295 | return ira->codegen->builtin_types.entry_invalid; | 18295 | return ira->codegen->builtin_types.entry_invalid; |
| 18296 | | 18296 | |
| 18297 | if (dest_type->id != TypeTableEntryIdFloat) { | 18297 | if (dest_type->id != ZigTypeIdFloat) { |
| 18298 | ir_add_error(ira, instruction->dest_type, | 18298 | ir_add_error(ira, instruction->dest_type, |
| 18299 | buf_sprintf("expected float type, found '%s'", buf_ptr(&dest_type->name))); | 18299 | buf_sprintf("expected float type, found '%s'", buf_ptr(&dest_type->name))); |
| 18300 | return ira->codegen->builtin_types.entry_invalid; | 18300 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18304,12 +18304,12 @@ static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionF | ... | @@ -18304,12 +18304,12 @@ static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionF |
| 18304 | if (type_is_invalid(target->value.type)) | 18304 | if (type_is_invalid(target->value.type)) |
| 18305 | return ira->codegen->builtin_types.entry_invalid; | 18305 | return ira->codegen->builtin_types.entry_invalid; |
| 18306 | | 18306 | |
| 18307 | if (target->value.type->id == TypeTableEntryIdComptimeInt || | 18307 | if (target->value.type->id == ZigTypeIdComptimeInt || |
| 18308 | target->value.type->id == TypeTableEntryIdComptimeFloat) | 18308 | target->value.type->id == ZigTypeIdComptimeFloat) |
| 18309 | { | 18309 | { |
| 18310 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { | 18310 | if (ir_num_lit_fits_in_other_type(ira, target, dest_type, true)) { |
| 18311 | CastOp op; | 18311 | CastOp op; |
| 18312 | if (target->value.type->id == TypeTableEntryIdComptimeInt) { | 18312 | if (target->value.type->id == ZigTypeIdComptimeInt) { |
| 18313 | op = CastOpIntToFloat; | 18313 | op = CastOpIntToFloat; |
| 18314 | } else { | 18314 | } else { |
| 18315 | op = CastOpNumLitToConcrete; | 18315 | op = CastOpNumLitToConcrete; |
| ... | @@ -18324,7 +18324,7 @@ static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionF | ... | @@ -18324,7 +18324,7 @@ static ZigType *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionF |
| 18324 | } | 18324 | } |
| 18325 | } | 18325 | } |
| 18326 | | 18326 | |
| 18327 | if (target->value.type->id != TypeTableEntryIdFloat) { | 18327 | if (target->value.type->id != ZigTypeIdFloat) { |
| 18328 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 18328 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", |
| 18329 | buf_ptr(&target->value.type->name))); | 18329 | buf_ptr(&target->value.type->name))); |
| 18330 | return ira->codegen->builtin_types.entry_invalid; | 18330 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18342,7 +18342,7 @@ static ZigType *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructio | ... | @@ -18342,7 +18342,7 @@ static ZigType *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructio |
| 18342 | if (type_is_invalid(dest_type)) | 18342 | if (type_is_invalid(dest_type)) |
| 18343 | return ira->codegen->builtin_types.entry_invalid; | 18343 | return ira->codegen->builtin_types.entry_invalid; |
| 18344 | | 18344 | |
| 18345 | if (dest_type->id != TypeTableEntryIdErrorSet) { | 18345 | if (dest_type->id != ZigTypeIdErrorSet) { |
| 18346 | ir_add_error(ira, instruction->dest_type, | 18346 | ir_add_error(ira, instruction->dest_type, |
| 18347 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); | 18347 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); |
| 18348 | return ira->codegen->builtin_types.entry_invalid; | 18348 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18352,7 +18352,7 @@ static ZigType *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructio | ... | @@ -18352,7 +18352,7 @@ static ZigType *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructio |
| 18352 | if (type_is_invalid(target->value.type)) | 18352 | if (type_is_invalid(target->value.type)) |
| 18353 | return ira->codegen->builtin_types.entry_invalid; | 18353 | return ira->codegen->builtin_types.entry_invalid; |
| 18354 | | 18354 | |
| 18355 | if (target->value.type->id != TypeTableEntryIdErrorSet) { | 18355 | if (target->value.type->id != ZigTypeIdErrorSet) { |
| 18356 | ir_add_error(ira, instruction->target, | 18356 | ir_add_error(ira, instruction->target, |
| 18357 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value.type->name))); | 18357 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value.type->name))); |
| 18358 | return ira->codegen->builtin_types.entry_invalid; | 18358 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18377,7 +18377,7 @@ static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionF | ... | @@ -18377,7 +18377,7 @@ static ZigType *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionF |
| 18377 | bool src_ptr_const; | 18377 | bool src_ptr_const; |
| 18378 | bool src_ptr_volatile; | 18378 | bool src_ptr_volatile; |
| 18379 | uint32_t src_ptr_align; | 18379 | uint32_t src_ptr_align; |
| 18380 | if (target->value.type->id == TypeTableEntryIdPointer) { | 18380 | if (target->value.type->id == ZigTypeIdPointer) { |
| 18381 | src_ptr_const = target->value.type->data.pointer.is_const; | 18381 | src_ptr_const = target->value.type->data.pointer.is_const; |
| 18382 | src_ptr_volatile = target->value.type->data.pointer.is_volatile; | 18382 | src_ptr_volatile = target->value.type->data.pointer.is_volatile; |
| 18383 | src_ptr_align = target->value.type->data.pointer.alignment; | 18383 | src_ptr_align = target->value.type->data.pointer.alignment; |
| ... | @@ -18477,7 +18477,7 @@ static ZigType *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructio | ... | @@ -18477,7 +18477,7 @@ static ZigType *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructio |
| 18477 | if (type_is_invalid(target->value.type)) | 18477 | if (type_is_invalid(target->value.type)) |
| 18478 | return ira->codegen->builtin_types.entry_invalid; | 18478 | return ira->codegen->builtin_types.entry_invalid; |
| 18479 | | 18479 | |
| 18480 | if (target->value.type->id != TypeTableEntryIdInt && target->value.type->id != TypeTableEntryIdComptimeInt) { | 18480 | if (target->value.type->id != ZigTypeIdInt && target->value.type->id != ZigTypeIdComptimeInt) { |
| 18481 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", | 18481 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", |
| 18482 | buf_ptr(&target->value.type->name))); | 18482 | buf_ptr(&target->value.type->name))); |
| 18483 | return ira->codegen->builtin_types.entry_invalid; | 18483 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18497,7 +18497,7 @@ static ZigType *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructio | ... | @@ -18497,7 +18497,7 @@ static ZigType *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructio |
| 18497 | if (type_is_invalid(target->value.type)) | 18497 | if (type_is_invalid(target->value.type)) |
| 18498 | return ira->codegen->builtin_types.entry_invalid; | 18498 | return ira->codegen->builtin_types.entry_invalid; |
| 18499 | | 18499 | |
| 18500 | if (target->value.type->id == TypeTableEntryIdComptimeInt) { | 18500 | if (target->value.type->id == ZigTypeIdComptimeInt) { |
| 18501 | IrInstruction *casted_value = ir_implicit_cast(ira, target, dest_type); | 18501 | IrInstruction *casted_value = ir_implicit_cast(ira, target, dest_type); |
| 18502 | if (type_is_invalid(casted_value->value.type)) | 18502 | if (type_is_invalid(casted_value->value.type)) |
| 18503 | return ira->codegen->builtin_types.entry_invalid; | 18503 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18505,7 +18505,7 @@ static ZigType *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructio | ... | @@ -18505,7 +18505,7 @@ static ZigType *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructio |
| 18505 | return casted_value->value.type; | 18505 | return casted_value->value.type; |
| 18506 | } | 18506 | } |
| 18507 | | 18507 | |
| 18508 | if (target->value.type->id != TypeTableEntryIdFloat && target->value.type->id != TypeTableEntryIdComptimeFloat) { | 18508 | if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) { |
| 18509 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 18509 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", |
| 18510 | buf_ptr(&target->value.type->name))); | 18510 | buf_ptr(&target->value.type->name))); |
| 18511 | return ira->codegen->builtin_types.entry_invalid; | 18511 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18522,7 +18522,7 @@ static ZigType *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionE | ... | @@ -18522,7 +18522,7 @@ static ZigType *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionE |
| 18522 | return ira->codegen->builtin_types.entry_invalid; | 18522 | return ira->codegen->builtin_types.entry_invalid; |
| 18523 | | 18523 | |
| 18524 | IrInstruction *casted_target; | 18524 | IrInstruction *casted_target; |
| 18525 | if (target->value.type->id == TypeTableEntryIdErrorSet) { | 18525 | if (target->value.type->id == ZigTypeIdErrorSet) { |
| 18526 | casted_target = target; | 18526 | casted_target = target; |
| 18527 | } else { | 18527 | } else { |
| 18528 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); | 18528 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); |
| ... | @@ -18554,7 +18554,7 @@ static ZigType *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstruction | ... | @@ -18554,7 +18554,7 @@ static ZigType *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstruction |
| 18554 | if (type_is_invalid(target->value.type)) | 18554 | if (type_is_invalid(target->value.type)) |
| 18555 | return ira->codegen->builtin_types.entry_invalid; | 18555 | return ira->codegen->builtin_types.entry_invalid; |
| 18556 | | 18556 | |
| 18557 | if (target->value.type->id != TypeTableEntryIdBool) { | 18557 | if (target->value.type->id != ZigTypeIdBool) { |
| 18558 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", | 18558 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", |
| 18559 | buf_ptr(&target->value.type->name))); | 18559 | buf_ptr(&target->value.type->name))); |
| 18560 | return ira->codegen->builtin_types.entry_invalid; | 18560 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18631,12 +18631,12 @@ static ZigType *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemse | ... | @@ -18631,12 +18631,12 @@ static ZigType *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemse |
| 18631 | return ira->codegen->builtin_types.entry_invalid; | 18631 | return ira->codegen->builtin_types.entry_invalid; |
| 18632 | | 18632 | |
| 18633 | ZigType *dest_uncasted_type = dest_ptr->value.type; | 18633 | ZigType *dest_uncasted_type = dest_ptr->value.type; |
| 18634 | bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) && | 18634 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| 18635 | dest_uncasted_type->data.pointer.is_volatile; | 18635 | dest_uncasted_type->data.pointer.is_volatile; |
| 18636 | | 18636 | |
| 18637 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 18637 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 18638 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; | 18638 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; |
| 18639 | uint32_t dest_align = (dest_uncasted_type->id == TypeTableEntryIdPointer) ? | 18639 | uint32_t dest_align = (dest_uncasted_type->id == ZigTypeIdPointer) ? |
| 18640 | dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8); | 18640 | dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8); |
| 18641 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, | 18641 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, |
| 18642 | PtrLenUnknown, dest_align, 0, 0); | 18642 | PtrLenUnknown, dest_align, 0, 0); |
| ... | @@ -18725,13 +18725,13 @@ static ZigType *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcp | ... | @@ -18725,13 +18725,13 @@ static ZigType *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcp |
| 18725 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; | 18725 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; |
| 18726 | ZigType *dest_uncasted_type = dest_ptr->value.type; | 18726 | ZigType *dest_uncasted_type = dest_ptr->value.type; |
| 18727 | ZigType *src_uncasted_type = src_ptr->value.type; | 18727 | ZigType *src_uncasted_type = src_ptr->value.type; |
| 18728 | bool dest_is_volatile = (dest_uncasted_type->id == TypeTableEntryIdPointer) && | 18728 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| 18729 | dest_uncasted_type->data.pointer.is_volatile; | 18729 | dest_uncasted_type->data.pointer.is_volatile; |
| 18730 | bool src_is_volatile = (src_uncasted_type->id == TypeTableEntryIdPointer) && | 18730 | bool src_is_volatile = (src_uncasted_type->id == ZigTypeIdPointer) && |
| 18731 | src_uncasted_type->data.pointer.is_volatile; | 18731 | src_uncasted_type->data.pointer.is_volatile; |
| 18732 | uint32_t dest_align = (dest_uncasted_type->id == TypeTableEntryIdPointer) ? | 18732 | uint32_t dest_align = (dest_uncasted_type->id == ZigTypeIdPointer) ? |
| 18733 | dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8); | 18733 | dest_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8); |
| 18734 | uint32_t src_align = (src_uncasted_type->id == TypeTableEntryIdPointer) ? | 18734 | uint32_t src_align = (src_uncasted_type->id == ZigTypeIdPointer) ? |
| 18735 | src_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8); | 18735 | src_uncasted_type->data.pointer.alignment : get_abi_alignment(ira->codegen, u8); |
| 18736 | | 18736 | |
| 18737 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 18737 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| ... | @@ -18850,7 +18850,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice | ... | @@ -18850,7 +18850,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice |
| 18850 | return ira->codegen->builtin_types.entry_invalid; | 18850 | return ira->codegen->builtin_types.entry_invalid; |
| 18851 | | 18851 | |
| 18852 | ZigType *ptr_type = ptr_ptr->value.type; | 18852 | ZigType *ptr_type = ptr_ptr->value.type; |
| 18853 | assert(ptr_type->id == TypeTableEntryIdPointer); | 18853 | assert(ptr_type->id == ZigTypeIdPointer); |
| 18854 | ZigType *array_type = ptr_type->data.pointer.child_type; | 18854 | ZigType *array_type = ptr_type->data.pointer.child_type; |
| 18855 | | 18855 | |
| 18856 | IrInstruction *start = instruction->start->other; | 18856 | IrInstruction *start = instruction->start->other; |
| ... | @@ -18876,7 +18876,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice | ... | @@ -18876,7 +18876,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice |
| 18876 | | 18876 | |
| 18877 | ZigType *return_type; | 18877 | ZigType *return_type; |
| 18878 | | 18878 | |
| 18879 | if (array_type->id == TypeTableEntryIdArray) { | 18879 | if (array_type->id == ZigTypeIdArray) { |
| 18880 | uint32_t byte_alignment = ptr_type->data.pointer.alignment; | 18880 | uint32_t byte_alignment = ptr_type->data.pointer.alignment; |
| 18881 | if (array_type->data.array.len == 0 && byte_alignment == 0) { | 18881 | if (array_type->data.array.len == 0 && byte_alignment == 0) { |
| 18882 | byte_alignment = get_abi_alignment(ira->codegen, array_type->data.array.child_type); | 18882 | byte_alignment = get_abi_alignment(ira->codegen, array_type->data.array.child_type); |
| ... | @@ -18889,10 +18889,10 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice | ... | @@ -18889,10 +18889,10 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice |
| 18889 | PtrLenUnknown, | 18889 | PtrLenUnknown, |
| 18890 | byte_alignment, 0, 0); | 18890 | byte_alignment, 0, 0); |
| 18891 | return_type = get_slice_type(ira->codegen, slice_ptr_type); | 18891 | return_type = get_slice_type(ira->codegen, slice_ptr_type); |
| 18892 | } else if (array_type->id == TypeTableEntryIdPointer) { | 18892 | } else if (array_type->id == ZigTypeIdPointer) { |
| 18893 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { | 18893 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { |
| 18894 | ZigType *main_type = array_type->data.pointer.child_type; | 18894 | ZigType *main_type = array_type->data.pointer.child_type; |
| 18895 | if (main_type->id == TypeTableEntryIdArray) { | 18895 | if (main_type->id == ZigTypeIdArray) { |
| 18896 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, | 18896 | ZigType *slice_ptr_type = get_pointer_to_type_extra(ira->codegen, |
| 18897 | main_type->data.pointer.child_type, | 18897 | main_type->data.pointer.child_type, |
| 18898 | array_type->data.pointer.is_const, array_type->data.pointer.is_volatile, | 18898 | array_type->data.pointer.is_const, array_type->data.pointer.is_volatile, |
| ... | @@ -18932,12 +18932,12 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice | ... | @@ -18932,12 +18932,12 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice |
| 18932 | size_t abs_offset; | 18932 | size_t abs_offset; |
| 18933 | size_t rel_end; | 18933 | size_t rel_end; |
| 18934 | bool ptr_is_undef = false; | 18934 | bool ptr_is_undef = false; |
| 18935 | if (array_type->id == TypeTableEntryIdArray || | 18935 | if (array_type->id == ZigTypeIdArray || |
| 18936 | (array_type->id == TypeTableEntryIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle)) | 18936 | (array_type->id == ZigTypeIdPointer && array_type->data.pointer.ptr_len == PtrLenSingle)) |
| 18937 | { | 18937 | { |
| 18938 | if (array_type->id == TypeTableEntryIdPointer) { | 18938 | if (array_type->id == ZigTypeIdPointer) { |
| 18939 | ZigType *child_array_type = array_type->data.pointer.child_type; | 18939 | ZigType *child_array_type = array_type->data.pointer.child_type; |
| 18940 | assert(child_array_type->id == TypeTableEntryIdArray); | 18940 | assert(child_array_type->id == ZigTypeIdArray); |
| 18941 | parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node); | 18941 | parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node); |
| 18942 | if (parent_ptr == nullptr) | 18942 | if (parent_ptr == nullptr) |
| 18943 | return ira->codegen->builtin_types.entry_invalid; | 18943 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -18956,7 +18956,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice | ... | @@ -18956,7 +18956,7 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice |
| 18956 | parent_ptr = nullptr; | 18956 | parent_ptr = nullptr; |
| 18957 | abs_offset = 0; | 18957 | abs_offset = 0; |
| 18958 | } | 18958 | } |
| 18959 | } else if (array_type->id == TypeTableEntryIdPointer) { | 18959 | } else if (array_type->id == ZigTypeIdPointer) { |
| 18960 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); | 18960 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); |
| 18961 | parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node); | 18961 | parent_ptr = ir_const_ptr_pointee(ira, &ptr_ptr->value, instruction->base.source_node); |
| 18962 | if (parent_ptr == nullptr) | 18962 | if (parent_ptr == nullptr) |
| ... | @@ -19063,11 +19063,11 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice | ... | @@ -19063,11 +19063,11 @@ static ZigType *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSlice |
| 19063 | size_t index = abs_offset + start_scalar; | 19063 | size_t index = abs_offset + start_scalar; |
| 19064 | bool is_const = slice_is_const(return_type); | 19064 | bool is_const = slice_is_const(return_type); |
| 19065 | init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown); | 19065 | init_const_ptr_array(ira->codegen, ptr_val, array_val, index, is_const, PtrLenUnknown); |
| 19066 | if (array_type->id == TypeTableEntryIdArray) { | 19066 | if (array_type->id == ZigTypeIdArray) { |
| 19067 | ptr_val->data.x_ptr.mut = ptr_ptr->value.data.x_ptr.mut; | 19067 | ptr_val->data.x_ptr.mut = ptr_ptr->value.data.x_ptr.mut; |
| 19068 | } else if (is_slice(array_type)) { | 19068 | } else if (is_slice(array_type)) { |
| 19069 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; | 19069 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; |
| 19070 | } else if (array_type->id == TypeTableEntryIdPointer) { | 19070 | } else if (array_type->id == ZigTypeIdPointer) { |
| 19071 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; | 19071 | ptr_val->data.x_ptr.mut = parent_ptr->data.x_ptr.mut; |
| 19072 | } | 19072 | } |
| 19073 | } else if (ptr_is_undef) { | 19073 | } else if (ptr_is_undef) { |
| ... | @@ -19122,13 +19122,13 @@ static ZigType *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructio | ... | @@ -19122,13 +19122,13 @@ static ZigType *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructio |
| 19122 | uint64_t result; | 19122 | uint64_t result; |
| 19123 | if (type_is_invalid(container_type)) { | 19123 | if (type_is_invalid(container_type)) { |
| 19124 | return ira->codegen->builtin_types.entry_invalid; | 19124 | return ira->codegen->builtin_types.entry_invalid; |
| 19125 | } else if (container_type->id == TypeTableEntryIdEnum) { | 19125 | } else if (container_type->id == ZigTypeIdEnum) { |
| 19126 | result = container_type->data.enumeration.src_field_count; | 19126 | result = container_type->data.enumeration.src_field_count; |
| 19127 | } else if (container_type->id == TypeTableEntryIdStruct) { | 19127 | } else if (container_type->id == ZigTypeIdStruct) { |
| 19128 | result = container_type->data.structure.src_field_count; | 19128 | result = container_type->data.structure.src_field_count; |
| 19129 | } else if (container_type->id == TypeTableEntryIdUnion) { | 19129 | } else if (container_type->id == ZigTypeIdUnion) { |
| 19130 | result = container_type->data.unionation.src_field_count; | 19130 | result = container_type->data.unionation.src_field_count; |
| 19131 | } else if (container_type->id == TypeTableEntryIdErrorSet) { | 19131 | } else if (container_type->id == ZigTypeIdErrorSet) { |
| 19132 | if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.source_node)) { | 19132 | if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.source_node)) { |
| 19133 | return ira->codegen->builtin_types.entry_invalid; | 19133 | return ira->codegen->builtin_types.entry_invalid; |
| 19134 | } | 19134 | } |
| ... | @@ -19163,7 +19163,7 @@ static ZigType *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstruction | ... | @@ -19163,7 +19163,7 @@ static ZigType *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstruction |
| 19163 | if (!ir_resolve_usize(ira, index_value, &member_index)) | 19163 | if (!ir_resolve_usize(ira, index_value, &member_index)) |
| 19164 | return ira->codegen->builtin_types.entry_invalid; | 19164 | return ira->codegen->builtin_types.entry_invalid; |
| 19165 | | 19165 | |
| 19166 | if (container_type->id == TypeTableEntryIdStruct) { | 19166 | if (container_type->id == ZigTypeIdStruct) { |
| 19167 | if (member_index >= container_type->data.structure.src_field_count) { | 19167 | if (member_index >= container_type->data.structure.src_field_count) { |
| 19168 | ir_add_error(ira, index_value, | 19168 | ir_add_error(ira, index_value, |
| 19169 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 19169 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| ... | @@ -19175,7 +19175,7 @@ static ZigType *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstruction | ... | @@ -19175,7 +19175,7 @@ static ZigType *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstruction |
| 19175 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 19175 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 19176 | out_val->data.x_type = field->type_entry; | 19176 | out_val->data.x_type = field->type_entry; |
| 19177 | return ira->codegen->builtin_types.entry_type; | 19177 | return ira->codegen->builtin_types.entry_type; |
| 19178 | } else if (container_type->id == TypeTableEntryIdUnion) { | 19178 | } else if (container_type->id == ZigTypeIdUnion) { |
| 19179 | if (member_index >= container_type->data.unionation.src_field_count) { | 19179 | if (member_index >= container_type->data.unionation.src_field_count) { |
| 19180 | ir_add_error(ira, index_value, | 19180 | ir_add_error(ira, index_value, |
| 19181 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 19181 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| ... | @@ -19209,7 +19209,7 @@ static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstruction | ... | @@ -19209,7 +19209,7 @@ static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstruction |
| 19209 | if (!ir_resolve_usize(ira, index_value, &member_index)) | 19209 | if (!ir_resolve_usize(ira, index_value, &member_index)) |
| 19210 | return ira->codegen->builtin_types.entry_invalid; | 19210 | return ira->codegen->builtin_types.entry_invalid; |
| 19211 | | 19211 | |
| 19212 | if (container_type->id == TypeTableEntryIdStruct) { | 19212 | if (container_type->id == ZigTypeIdStruct) { |
| 19213 | if (member_index >= container_type->data.structure.src_field_count) { | 19213 | if (member_index >= container_type->data.structure.src_field_count) { |
| 19214 | ir_add_error(ira, index_value, | 19214 | ir_add_error(ira, index_value, |
| 19215 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 19215 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| ... | @@ -19221,7 +19221,7 @@ static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstruction | ... | @@ -19221,7 +19221,7 @@ static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstruction |
| 19221 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 19221 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 19222 | init_const_str_lit(ira->codegen, out_val, field->name); | 19222 | init_const_str_lit(ira->codegen, out_val, field->name); |
| 19223 | return out_val->type; | 19223 | return out_val->type; |
| 19224 | } else if (container_type->id == TypeTableEntryIdEnum) { | 19224 | } else if (container_type->id == ZigTypeIdEnum) { |
| 19225 | if (member_index >= container_type->data.enumeration.src_field_count) { | 19225 | if (member_index >= container_type->data.enumeration.src_field_count) { |
| 19226 | ir_add_error(ira, index_value, | 19226 | ir_add_error(ira, index_value, |
| 19227 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 19227 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| ... | @@ -19233,7 +19233,7 @@ static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstruction | ... | @@ -19233,7 +19233,7 @@ static ZigType *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstruction |
| 19233 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 19233 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 19234 | init_const_str_lit(ira->codegen, out_val, field->name); | 19234 | init_const_str_lit(ira->codegen, out_val, field->name); |
| 19235 | return out_val->type; | 19235 | return out_val->type; |
| 19236 | } else if (container_type->id == TypeTableEntryIdUnion) { | 19236 | } else if (container_type->id == ZigTypeIdUnion) { |
| 19237 | if (member_index >= container_type->data.unionation.src_field_count) { | 19237 | if (member_index >= container_type->data.unionation.src_field_count) { |
| 19238 | ir_add_error(ira, index_value, | 19238 | ir_add_error(ira, index_value, |
| 19239 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 19239 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| ... | @@ -19292,36 +19292,36 @@ static ZigType *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAli | ... | @@ -19292,36 +19292,36 @@ static ZigType *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAli |
| 19292 | return ira->codegen->builtin_types.entry_invalid; | 19292 | return ira->codegen->builtin_types.entry_invalid; |
| 19293 | | 19293 | |
| 19294 | switch (type_entry->id) { | 19294 | switch (type_entry->id) { |
| 19295 | case TypeTableEntryIdInvalid: | 19295 | case ZigTypeIdInvalid: |
| 19296 | zig_unreachable(); | 19296 | zig_unreachable(); |
| 19297 | case TypeTableEntryIdMetaType: | 19297 | case ZigTypeIdMetaType: |
| 19298 | case TypeTableEntryIdUnreachable: | 19298 | case ZigTypeIdUnreachable: |
| 19299 | case TypeTableEntryIdComptimeFloat: | 19299 | case ZigTypeIdComptimeFloat: |
| 19300 | case TypeTableEntryIdComptimeInt: | 19300 | case ZigTypeIdComptimeInt: |
| 19301 | case TypeTableEntryIdUndefined: | 19301 | case ZigTypeIdUndefined: |
| 19302 | case TypeTableEntryIdNull: | 19302 | case ZigTypeIdNull: |
| 19303 | case TypeTableEntryIdNamespace: | 19303 | case ZigTypeIdNamespace: |
| 19304 | case TypeTableEntryIdBlock: | 19304 | case ZigTypeIdBlock: |
| 19305 | case TypeTableEntryIdBoundFn: | 19305 | case ZigTypeIdBoundFn: |
| 19306 | case TypeTableEntryIdArgTuple: | 19306 | case ZigTypeIdArgTuple: |
| 19307 | case TypeTableEntryIdVoid: | 19307 | case ZigTypeIdVoid: |
| 19308 | case TypeTableEntryIdOpaque: | 19308 | case ZigTypeIdOpaque: |
| 19309 | ir_add_error(ira, instruction->type_value, | 19309 | ir_add_error(ira, instruction->type_value, |
| 19310 | buf_sprintf("no align available for type '%s'", buf_ptr(&type_entry->name))); | 19310 | buf_sprintf("no align available for type '%s'", buf_ptr(&type_entry->name))); |
| 19311 | return ira->codegen->builtin_types.entry_invalid; | 19311 | return ira->codegen->builtin_types.entry_invalid; |
| 19312 | case TypeTableEntryIdBool: | 19312 | case ZigTypeIdBool: |
| 19313 | case TypeTableEntryIdInt: | 19313 | case ZigTypeIdInt: |
| 19314 | case TypeTableEntryIdFloat: | 19314 | case ZigTypeIdFloat: |
| 19315 | case TypeTableEntryIdPointer: | 19315 | case ZigTypeIdPointer: |
| 19316 | case TypeTableEntryIdPromise: | 19316 | case ZigTypeIdPromise: |
| 19317 | case TypeTableEntryIdArray: | 19317 | case ZigTypeIdArray: |
| 19318 | case TypeTableEntryIdStruct: | 19318 | case ZigTypeIdStruct: |
| 19319 | case TypeTableEntryIdOptional: | 19319 | case ZigTypeIdOptional: |
| 19320 | case TypeTableEntryIdErrorUnion: | 19320 | case ZigTypeIdErrorUnion: |
| 19321 | case TypeTableEntryIdErrorSet: | 19321 | case ZigTypeIdErrorSet: |
| 19322 | case TypeTableEntryIdEnum: | 19322 | case ZigTypeIdEnum: |
| 19323 | case TypeTableEntryIdUnion: | 19323 | case ZigTypeIdUnion: |
| 19324 | case TypeTableEntryIdFn: | 19324 | case ZigTypeIdFn: |
| 19325 | { | 19325 | { |
| 19326 | uint64_t align_in_bytes = get_abi_alignment(ira->codegen, type_entry); | 19326 | uint64_t align_in_bytes = get_abi_alignment(ira->codegen, type_entry); |
| 19327 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 19327 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| ... | @@ -19341,7 +19341,7 @@ static ZigType *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstruction | ... | @@ -19341,7 +19341,7 @@ static ZigType *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstruction |
| 19341 | if (type_is_invalid(dest_type)) | 19341 | if (type_is_invalid(dest_type)) |
| 19342 | return ira->codegen->builtin_types.entry_invalid; | 19342 | return ira->codegen->builtin_types.entry_invalid; |
| 19343 | | 19343 | |
| 19344 | if (dest_type->id != TypeTableEntryIdInt) { | 19344 | if (dest_type->id != ZigTypeIdInt) { |
| 19345 | ir_add_error(ira, type_value, | 19345 | ir_add_error(ira, type_value, |
| 19346 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 19346 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 19347 | return ira->codegen->builtin_types.entry_invalid; | 19347 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -19375,7 +19375,7 @@ static ZigType *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstruction | ... | @@ -19375,7 +19375,7 @@ static ZigType *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstruction |
| 19375 | return ira->codegen->builtin_types.entry_invalid; | 19375 | return ira->codegen->builtin_types.entry_invalid; |
| 19376 | | 19376 | |
| 19377 | ZigType *expected_ptr_type; | 19377 | ZigType *expected_ptr_type; |
| 19378 | if (result_ptr->value.type->id == TypeTableEntryIdPointer) { | 19378 | if (result_ptr->value.type->id == ZigTypeIdPointer) { |
| 19379 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, | 19379 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, |
| 19380 | false, result_ptr->value.type->data.pointer.is_volatile, | 19380 | false, result_ptr->value.type->data.pointer.is_volatile, |
| 19381 | PtrLenSingle, | 19381 | PtrLenSingle, |
| ... | @@ -19439,7 +19439,7 @@ static ZigType *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTes | ... | @@ -19439,7 +19439,7 @@ static ZigType *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTes |
| 19439 | ZigType *type_entry = value->value.type; | 19439 | ZigType *type_entry = value->value.type; |
| 19440 | if (type_is_invalid(type_entry)) { | 19440 | if (type_is_invalid(type_entry)) { |
| 19441 | return ira->codegen->builtin_types.entry_invalid; | 19441 | return ira->codegen->builtin_types.entry_invalid; |
| 19442 | } else if (type_entry->id == TypeTableEntryIdErrorUnion) { | 19442 | } else if (type_entry->id == ZigTypeIdErrorUnion) { |
| 19443 | if (instr_is_comptime(value)) { | 19443 | if (instr_is_comptime(value)) { |
| 19444 | ConstExprValue *err_union_val = ir_resolve_const(ira, value, UndefBad); | 19444 | ConstExprValue *err_union_val = ir_resolve_const(ira, value, UndefBad); |
| 19445 | if (!err_union_val) | 19445 | if (!err_union_val) |
| ... | @@ -19467,7 +19467,7 @@ static ZigType *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTes | ... | @@ -19467,7 +19467,7 @@ static ZigType *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTes |
| 19467 | | 19467 | |
| 19468 | ir_build_test_err_from(&ira->new_irb, &instruction->base, value); | 19468 | ir_build_test_err_from(&ira->new_irb, &instruction->base, value); |
| 19469 | return ira->codegen->builtin_types.entry_bool; | 19469 | return ira->codegen->builtin_types.entry_bool; |
| 19470 | } else if (type_entry->id == TypeTableEntryIdErrorSet) { | 19470 | } else if (type_entry->id == ZigTypeIdErrorSet) { |
| 19471 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 19471 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 19472 | out_val->data.x_bool = true; | 19472 | out_val->data.x_bool = true; |
| 19473 | return ira->codegen->builtin_types.entry_bool; | 19473 | return ira->codegen->builtin_types.entry_bool; |
| ... | @@ -19487,12 +19487,12 @@ static ZigType *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | ... | @@ -19487,12 +19487,12 @@ static ZigType *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, |
| 19487 | ZigType *ptr_type = value->value.type; | 19487 | ZigType *ptr_type = value->value.type; |
| 19488 | | 19488 | |
| 19489 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. | 19489 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. |
| 19490 | assert(ptr_type->id == TypeTableEntryIdPointer); | 19490 | assert(ptr_type->id == ZigTypeIdPointer); |
| 19491 | | 19491 | |
| 19492 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 19492 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 19493 | if (type_is_invalid(type_entry)) { | 19493 | if (type_is_invalid(type_entry)) { |
| 19494 | return ira->codegen->builtin_types.entry_invalid; | 19494 | return ira->codegen->builtin_types.entry_invalid; |
| 19495 | } else if (type_entry->id == TypeTableEntryIdErrorUnion) { | 19495 | } else if (type_entry->id == ZigTypeIdErrorUnion) { |
| 19496 | if (instr_is_comptime(value)) { | 19496 | if (instr_is_comptime(value)) { |
| 19497 | ConstExprValue *ptr_val = ir_resolve_const(ira, value, UndefBad); | 19497 | ConstExprValue *ptr_val = ir_resolve_const(ira, value, UndefBad); |
| 19498 | if (!ptr_val) | 19498 | if (!ptr_val) |
| ... | @@ -19529,12 +19529,12 @@ static ZigType *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | ... | @@ -19529,12 +19529,12 @@ static ZigType *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 19529 | ZigType *ptr_type = value->value.type; | 19529 | ZigType *ptr_type = value->value.type; |
| 19530 | | 19530 | |
| 19531 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. | 19531 | // This will be a pointer type because unwrap err payload IR instruction operates on a pointer to a thing. |
| 19532 | assert(ptr_type->id == TypeTableEntryIdPointer); | 19532 | assert(ptr_type->id == ZigTypeIdPointer); |
| 19533 | | 19533 | |
| 19534 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 19534 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 19535 | if (type_is_invalid(type_entry)) { | 19535 | if (type_is_invalid(type_entry)) { |
| 19536 | return ira->codegen->builtin_types.entry_invalid; | 19536 | return ira->codegen->builtin_types.entry_invalid; |
| 19537 | } else if (type_entry->id == TypeTableEntryIdErrorUnion) { | 19537 | } else if (type_entry->id == ZigTypeIdErrorUnion) { |
| 19538 | ZigType *payload_type = type_entry->data.error_union.payload_type; | 19538 | ZigType *payload_type = type_entry->data.error_union.payload_type; |
| 19539 | if (type_is_invalid(payload_type)) { | 19539 | if (type_is_invalid(payload_type)) { |
| 19540 | return ira->codegen->builtin_types.entry_invalid; | 19540 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -19633,7 +19633,7 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP | ... | @@ -19633,7 +19633,7 @@ static ZigType *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnP |
| 19633 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); | 19633 | fn_type_id.return_type = ir_resolve_type(ira, return_type_value); |
| 19634 | if (type_is_invalid(fn_type_id.return_type)) | 19634 | if (type_is_invalid(fn_type_id.return_type)) |
| 19635 | return ira->codegen->builtin_types.entry_invalid; | 19635 | return ira->codegen->builtin_types.entry_invalid; |
| 19636 | if (fn_type_id.return_type->id == TypeTableEntryIdOpaque) { | 19636 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { |
| 19637 | ir_add_error(ira, instruction->return_type, | 19637 | ir_add_error(ira, instruction->return_type, |
| 19638 | buf_sprintf("return type cannot be opaque")); | 19638 | buf_sprintf("return type cannot be opaque")); |
| 19639 | return ira->codegen->builtin_types.entry_invalid; | 19639 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -19674,7 +19674,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19674,7 +19674,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19674 | if (type_is_invalid(switch_type)) | 19674 | if (type_is_invalid(switch_type)) |
| 19675 | return ira->codegen->builtin_types.entry_invalid; | 19675 | return ira->codegen->builtin_types.entry_invalid; |
| 19676 | | 19676 | |
| 19677 | if (switch_type->id == TypeTableEntryIdEnum) { | 19677 | if (switch_type->id == ZigTypeIdEnum) { |
| 19678 | HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> field_prev_uses = {}; | 19678 | HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> field_prev_uses = {}; |
| 19679 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); | 19679 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); |
| 19680 | | 19680 | |
| ... | @@ -19689,7 +19689,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19689,7 +19689,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19689 | if (type_is_invalid(end_value->value.type)) | 19689 | if (type_is_invalid(end_value->value.type)) |
| 19690 | return ira->codegen->builtin_types.entry_invalid; | 19690 | return ira->codegen->builtin_types.entry_invalid; |
| 19691 | | 19691 | |
| 19692 | if (start_value->value.type->id != TypeTableEntryIdEnum) { | 19692 | if (start_value->value.type->id != ZigTypeIdEnum) { |
| 19693 | ir_add_error(ira, range->start, buf_sprintf("not an enum type")); | 19693 | ir_add_error(ira, range->start, buf_sprintf("not an enum type")); |
| 19694 | return ira->codegen->builtin_types.entry_invalid; | 19694 | return ira->codegen->builtin_types.entry_invalid; |
| 19695 | } | 19695 | } |
| ... | @@ -19697,7 +19697,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19697,7 +19697,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19697 | BigInt start_index; | 19697 | BigInt start_index; |
| 19698 | bigint_init_bigint(&start_index, &start_value->value.data.x_enum_tag); | 19698 | bigint_init_bigint(&start_index, &start_value->value.data.x_enum_tag); |
| 19699 | | 19699 | |
| 19700 | assert(end_value->value.type->id == TypeTableEntryIdEnum); | 19700 | assert(end_value->value.type->id == ZigTypeIdEnum); |
| 19701 | BigInt end_index; | 19701 | BigInt end_index; |
| 19702 | bigint_init_bigint(&end_index, &end_value->value.data.x_enum_tag); | 19702 | bigint_init_bigint(&end_index, &end_value->value.data.x_enum_tag); |
| 19703 | | 19703 | |
| ... | @@ -19733,7 +19733,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19733,7 +19733,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19733 | } | 19733 | } |
| 19734 | } | 19734 | } |
| 19735 | } | 19735 | } |
| 19736 | } else if (switch_type->id == TypeTableEntryIdErrorSet) { | 19736 | } else if (switch_type->id == ZigTypeIdErrorSet) { |
| 19737 | if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->source_node)) { | 19737 | if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->source_node)) { |
| 19738 | return ira->codegen->builtin_types.entry_invalid; | 19738 | return ira->codegen->builtin_types.entry_invalid; |
| 19739 | } | 19739 | } |
| ... | @@ -19751,10 +19751,10 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19751,10 +19751,10 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19751 | if (type_is_invalid(end_value->value.type)) | 19751 | if (type_is_invalid(end_value->value.type)) |
| 19752 | return ira->codegen->builtin_types.entry_invalid; | 19752 | return ira->codegen->builtin_types.entry_invalid; |
| 19753 | | 19753 | |
| 19754 | assert(start_value->value.type->id == TypeTableEntryIdErrorSet); | 19754 | assert(start_value->value.type->id == ZigTypeIdErrorSet); |
| 19755 | uint32_t start_index = start_value->value.data.x_err_set->value; | 19755 | uint32_t start_index = start_value->value.data.x_err_set->value; |
| 19756 | | 19756 | |
| 19757 | assert(end_value->value.type->id == TypeTableEntryIdErrorSet); | 19757 | assert(end_value->value.type->id == ZigTypeIdErrorSet); |
| 19758 | uint32_t end_index = end_value->value.data.x_err_set->value; | 19758 | uint32_t end_index = end_value->value.data.x_err_set->value; |
| 19759 | | 19759 | |
| 19760 | if (start_index != end_index) { | 19760 | if (start_index != end_index) { |
| ... | @@ -19790,7 +19790,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19790,7 +19790,7 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19790 | } | 19790 | } |
| 19791 | | 19791 | |
| 19792 | free(field_prev_uses); | 19792 | free(field_prev_uses); |
| 19793 | } else if (switch_type->id == TypeTableEntryIdInt) { | 19793 | } else if (switch_type->id == ZigTypeIdInt) { |
| 19794 | RangeSet rs = {0}; | 19794 | RangeSet rs = {0}; |
| 19795 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 19795 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 19796 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 19796 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| ... | @@ -19817,8 +19817,8 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -19817,8 +19817,8 @@ static ZigType *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 19817 | if (!end_val) | 19817 | if (!end_val) |
| 19818 | return ira->codegen->builtin_types.entry_invalid; | 19818 | return ira->codegen->builtin_types.entry_invalid; |
| 19819 | | 19819 | |
| 19820 | assert(start_val->type->id == TypeTableEntryIdInt || start_val->type->id == TypeTableEntryIdComptimeInt); | 19820 | assert(start_val->type->id == ZigTypeIdInt || start_val->type->id == ZigTypeIdComptimeInt); |
| 19821 | assert(end_val->type->id == TypeTableEntryIdInt || end_val->type->id == TypeTableEntryIdComptimeInt); | 19821 | assert(end_val->type->id == ZigTypeIdInt || end_val->type->id == ZigTypeIdComptimeInt); |
| 19822 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, | 19822 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, |
| 19823 | start_value->source_node); | 19823 | start_value->source_node); |
| 19824 | if (prev_node != nullptr) { | 19824 | if (prev_node != nullptr) { |
| ... | @@ -19854,7 +19854,7 @@ static ZigType *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, | ... | @@ -19854,7 +19854,7 @@ static ZigType *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, |
| 19854 | if (type_is_invalid(statement_type)) | 19854 | if (type_is_invalid(statement_type)) |
| 19855 | return ira->codegen->builtin_types.entry_invalid; | 19855 | return ira->codegen->builtin_types.entry_invalid; |
| 19856 | | 19856 | |
| 19857 | if (statement_type->id != TypeTableEntryIdVoid) { | 19857 | if (statement_type->id != ZigTypeIdVoid) { |
| 19858 | ir_add_error(ira, &instruction->base, buf_sprintf("expression value is ignored")); | 19858 | ir_add_error(ira, &instruction->base, buf_sprintf("expression value is ignored")); |
| 19859 | } | 19859 | } |
| 19860 | | 19860 | |
| ... | @@ -19892,24 +19892,24 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -19892,24 +19892,24 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 19892 | ZigType *result_type; | 19892 | ZigType *result_type; |
| 19893 | uint32_t old_align_bytes; | 19893 | uint32_t old_align_bytes; |
| 19894 | | 19894 | |
| 19895 | if (target_type->id == TypeTableEntryIdPointer) { | 19895 | if (target_type->id == ZigTypeIdPointer) { |
| 19896 | result_type = adjust_ptr_align(ira->codegen, target_type, align_bytes); | 19896 | result_type = adjust_ptr_align(ira->codegen, target_type, align_bytes); |
| 19897 | old_align_bytes = target_type->data.pointer.alignment; | 19897 | old_align_bytes = target_type->data.pointer.alignment; |
| 19898 | } else if (target_type->id == TypeTableEntryIdFn) { | 19898 | } else if (target_type->id == ZigTypeIdFn) { |
| 19899 | FnTypeId fn_type_id = target_type->data.fn.fn_type_id; | 19899 | FnTypeId fn_type_id = target_type->data.fn.fn_type_id; |
| 19900 | old_align_bytes = fn_type_id.alignment; | 19900 | old_align_bytes = fn_type_id.alignment; |
| 19901 | fn_type_id.alignment = align_bytes; | 19901 | fn_type_id.alignment = align_bytes; |
| 19902 | result_type = get_fn_type(ira->codegen, &fn_type_id); | 19902 | result_type = get_fn_type(ira->codegen, &fn_type_id); |
| 19903 | } else if (target_type->id == TypeTableEntryIdOptional && | 19903 | } else if (target_type->id == ZigTypeIdOptional && |
| 19904 | target_type->data.maybe.child_type->id == TypeTableEntryIdPointer) | 19904 | target_type->data.maybe.child_type->id == ZigTypeIdPointer) |
| 19905 | { | 19905 | { |
| 19906 | ZigType *ptr_type = target_type->data.maybe.child_type; | 19906 | ZigType *ptr_type = target_type->data.maybe.child_type; |
| 19907 | old_align_bytes = ptr_type->data.pointer.alignment; | 19907 | old_align_bytes = ptr_type->data.pointer.alignment; |
| 19908 | ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes); | 19908 | ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes); |
| 19909 | | 19909 | |
| 19910 | result_type = get_optional_type(ira->codegen, better_ptr_type); | 19910 | result_type = get_optional_type(ira->codegen, better_ptr_type); |
| 19911 | } else if (target_type->id == TypeTableEntryIdOptional && | 19911 | } else if (target_type->id == ZigTypeIdOptional && |
| 19912 | target_type->data.maybe.child_type->id == TypeTableEntryIdFn) | 19912 | target_type->data.maybe.child_type->id == ZigTypeIdFn) |
| 19913 | { | 19913 | { |
| 19914 | FnTypeId fn_type_id = target_type->data.maybe.child_type->data.fn.fn_type_id; | 19914 | FnTypeId fn_type_id = target_type->data.maybe.child_type->data.fn.fn_type_id; |
| 19915 | old_align_bytes = fn_type_id.alignment; | 19915 | old_align_bytes = fn_type_id.alignment; |
| ... | @@ -20033,33 +20033,33 @@ static ZigType *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtr | ... | @@ -20033,33 +20033,33 @@ static ZigType *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtr |
| 20033 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) { | 20033 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) { |
| 20034 | assert(val->special == ConstValSpecialStatic); | 20034 | assert(val->special == ConstValSpecialStatic); |
| 20035 | switch (val->type->id) { | 20035 | switch (val->type->id) { |
| 20036 | case TypeTableEntryIdInvalid: | 20036 | case ZigTypeIdInvalid: |
| 20037 | case TypeTableEntryIdMetaType: | 20037 | case ZigTypeIdMetaType: |
| 20038 | case TypeTableEntryIdOpaque: | 20038 | case ZigTypeIdOpaque: |
| 20039 | case TypeTableEntryIdBoundFn: | 20039 | case ZigTypeIdBoundFn: |
| 20040 | case TypeTableEntryIdArgTuple: | 20040 | case ZigTypeIdArgTuple: |
| 20041 | case TypeTableEntryIdNamespace: | 20041 | case ZigTypeIdNamespace: |
| 20042 | case TypeTableEntryIdBlock: | 20042 | case ZigTypeIdBlock: |
| 20043 | case TypeTableEntryIdUnreachable: | 20043 | case ZigTypeIdUnreachable: |
| 20044 | case TypeTableEntryIdComptimeFloat: | 20044 | case ZigTypeIdComptimeFloat: |
| 20045 | case TypeTableEntryIdComptimeInt: | 20045 | case ZigTypeIdComptimeInt: |
| 20046 | case TypeTableEntryIdUndefined: | 20046 | case ZigTypeIdUndefined: |
| 20047 | case TypeTableEntryIdNull: | 20047 | case ZigTypeIdNull: |
| 20048 | case TypeTableEntryIdPromise: | 20048 | case ZigTypeIdPromise: |
| 20049 | zig_unreachable(); | 20049 | zig_unreachable(); |
| 20050 | case TypeTableEntryIdVoid: | 20050 | case ZigTypeIdVoid: |
| 20051 | return; | 20051 | return; |
| 20052 | case TypeTableEntryIdBool: | 20052 | case ZigTypeIdBool: |
| 20053 | buf[0] = val->data.x_bool ? 1 : 0; | 20053 | buf[0] = val->data.x_bool ? 1 : 0; |
| 20054 | return; | 20054 | return; |
| 20055 | case TypeTableEntryIdInt: | 20055 | case ZigTypeIdInt: |
| 20056 | bigint_write_twos_complement(&val->data.x_bigint, buf, val->type->data.integral.bit_count, | 20056 | bigint_write_twos_complement(&val->data.x_bigint, buf, val->type->data.integral.bit_count, |
| 20057 | codegen->is_big_endian); | 20057 | codegen->is_big_endian); |
| 20058 | return; | 20058 | return; |
| 20059 | case TypeTableEntryIdFloat: | 20059 | case ZigTypeIdFloat: |
| 20060 | float_write_ieee597(val, buf, codegen->is_big_endian); | 20060 | float_write_ieee597(val, buf, codegen->is_big_endian); |
| 20061 | return; | 20061 | return; |
| 20062 | case TypeTableEntryIdPointer: | 20062 | case ZigTypeIdPointer: |
| 20063 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 20063 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 20064 | BigInt bn; | 20064 | BigInt bn; |
| 20065 | bigint_init_unsigned(&bn, val->data.x_ptr.data.hard_coded_addr.addr); | 20065 | bigint_init_unsigned(&bn, val->data.x_ptr.data.hard_coded_addr.addr); |
| ... | @@ -20068,7 +20068,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -20068,7 +20068,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 20068 | } else { | 20068 | } else { |
| 20069 | zig_unreachable(); | 20069 | zig_unreachable(); |
| 20070 | } | 20070 | } |
| 20071 | case TypeTableEntryIdArray: | 20071 | case ZigTypeIdArray: |
| 20072 | { | 20072 | { |
| 20073 | size_t buf_i = 0; | 20073 | size_t buf_i = 0; |
| 20074 | expand_undef_array(codegen, val); | 20074 | expand_undef_array(codegen, val); |
| ... | @@ -20079,19 +20079,19 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -20079,19 +20079,19 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 20079 | } | 20079 | } |
| 20080 | } | 20080 | } |
| 20081 | return; | 20081 | return; |
| 20082 | case TypeTableEntryIdStruct: | 20082 | case ZigTypeIdStruct: |
| 20083 | zig_panic("TODO buf_write_value_bytes struct type"); | 20083 | zig_panic("TODO buf_write_value_bytes struct type"); |
| 20084 | case TypeTableEntryIdOptional: | 20084 | case ZigTypeIdOptional: |
| 20085 | zig_panic("TODO buf_write_value_bytes maybe type"); | 20085 | zig_panic("TODO buf_write_value_bytes maybe type"); |
| 20086 | case TypeTableEntryIdErrorUnion: | 20086 | case ZigTypeIdErrorUnion: |
| 20087 | zig_panic("TODO buf_write_value_bytes error union"); | 20087 | zig_panic("TODO buf_write_value_bytes error union"); |
| 20088 | case TypeTableEntryIdErrorSet: | 20088 | case ZigTypeIdErrorSet: |
| 20089 | zig_panic("TODO buf_write_value_bytes pure error type"); | 20089 | zig_panic("TODO buf_write_value_bytes pure error type"); |
| 20090 | case TypeTableEntryIdEnum: | 20090 | case ZigTypeIdEnum: |
| 20091 | zig_panic("TODO buf_write_value_bytes enum type"); | 20091 | zig_panic("TODO buf_write_value_bytes enum type"); |
| 20092 | case TypeTableEntryIdFn: | 20092 | case ZigTypeIdFn: |
| 20093 | zig_panic("TODO buf_write_value_bytes fn type"); | 20093 | zig_panic("TODO buf_write_value_bytes fn type"); |
| 20094 | case TypeTableEntryIdUnion: | 20094 | case ZigTypeIdUnion: |
| 20095 | zig_panic("TODO buf_write_value_bytes union type"); | 20095 | zig_panic("TODO buf_write_value_bytes union type"); |
| 20096 | } | 20096 | } |
| 20097 | zig_unreachable(); | 20097 | zig_unreachable(); |
| ... | @@ -20100,33 +20100,33 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -20100,33 +20100,33 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 20100 | static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) { | 20100 | static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue *val) { |
| 20101 | assert(val->special == ConstValSpecialStatic); | 20101 | assert(val->special == ConstValSpecialStatic); |
| 20102 | switch (val->type->id) { | 20102 | switch (val->type->id) { |
| 20103 | case TypeTableEntryIdInvalid: | 20103 | case ZigTypeIdInvalid: |
| 20104 | case TypeTableEntryIdMetaType: | 20104 | case ZigTypeIdMetaType: |
| 20105 | case TypeTableEntryIdOpaque: | 20105 | case ZigTypeIdOpaque: |
| 20106 | case TypeTableEntryIdBoundFn: | 20106 | case ZigTypeIdBoundFn: |
| 20107 | case TypeTableEntryIdArgTuple: | 20107 | case ZigTypeIdArgTuple: |
| 20108 | case TypeTableEntryIdNamespace: | 20108 | case ZigTypeIdNamespace: |
| 20109 | case TypeTableEntryIdBlock: | 20109 | case ZigTypeIdBlock: |
| 20110 | case TypeTableEntryIdUnreachable: | 20110 | case ZigTypeIdUnreachable: |
| 20111 | case TypeTableEntryIdComptimeFloat: | 20111 | case ZigTypeIdComptimeFloat: |
| 20112 | case TypeTableEntryIdComptimeInt: | 20112 | case ZigTypeIdComptimeInt: |
| 20113 | case TypeTableEntryIdUndefined: | 20113 | case ZigTypeIdUndefined: |
| 20114 | case TypeTableEntryIdNull: | 20114 | case ZigTypeIdNull: |
| 20115 | case TypeTableEntryIdPromise: | 20115 | case ZigTypeIdPromise: |
| 20116 | zig_unreachable(); | 20116 | zig_unreachable(); |
| 20117 | case TypeTableEntryIdVoid: | 20117 | case ZigTypeIdVoid: |
| 20118 | return; | 20118 | return; |
| 20119 | case TypeTableEntryIdBool: | 20119 | case ZigTypeIdBool: |
| 20120 | val->data.x_bool = (buf[0] != 0); | 20120 | val->data.x_bool = (buf[0] != 0); |
| 20121 | return; | 20121 | return; |
| 20122 | case TypeTableEntryIdInt: | 20122 | case ZigTypeIdInt: |
| 20123 | bigint_read_twos_complement(&val->data.x_bigint, buf, val->type->data.integral.bit_count, | 20123 | bigint_read_twos_complement(&val->data.x_bigint, buf, val->type->data.integral.bit_count, |
| 20124 | codegen->is_big_endian, val->type->data.integral.is_signed); | 20124 | codegen->is_big_endian, val->type->data.integral.is_signed); |
| 20125 | return; | 20125 | return; |
| 20126 | case TypeTableEntryIdFloat: | 20126 | case ZigTypeIdFloat: |
| 20127 | float_read_ieee597(val, buf, codegen->is_big_endian); | 20127 | float_read_ieee597(val, buf, codegen->is_big_endian); |
| 20128 | return; | 20128 | return; |
| 20129 | case TypeTableEntryIdPointer: | 20129 | case ZigTypeIdPointer: |
| 20130 | { | 20130 | { |
| 20131 | val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 20131 | val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 20132 | BigInt bn; | 20132 | BigInt bn; |
| ... | @@ -20135,21 +20135,21 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -20135,21 +20135,21 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 20135 | val->data.x_ptr.data.hard_coded_addr.addr = bigint_as_unsigned(&bn); | 20135 | val->data.x_ptr.data.hard_coded_addr.addr = bigint_as_unsigned(&bn); |
| 20136 | return; | 20136 | return; |
| 20137 | } | 20137 | } |
| 20138 | case TypeTableEntryIdArray: | 20138 | case ZigTypeIdArray: |
| 20139 | zig_panic("TODO buf_read_value_bytes array type"); | 20139 | zig_panic("TODO buf_read_value_bytes array type"); |
| 20140 | case TypeTableEntryIdStruct: | 20140 | case ZigTypeIdStruct: |
| 20141 | zig_panic("TODO buf_read_value_bytes struct type"); | 20141 | zig_panic("TODO buf_read_value_bytes struct type"); |
| 20142 | case TypeTableEntryIdOptional: | 20142 | case ZigTypeIdOptional: |
| 20143 | zig_panic("TODO buf_read_value_bytes maybe type"); | 20143 | zig_panic("TODO buf_read_value_bytes maybe type"); |
| 20144 | case TypeTableEntryIdErrorUnion: | 20144 | case ZigTypeIdErrorUnion: |
| 20145 | zig_panic("TODO buf_read_value_bytes error union"); | 20145 | zig_panic("TODO buf_read_value_bytes error union"); |
| 20146 | case TypeTableEntryIdErrorSet: | 20146 | case ZigTypeIdErrorSet: |
| 20147 | zig_panic("TODO buf_read_value_bytes pure error type"); | 20147 | zig_panic("TODO buf_read_value_bytes pure error type"); |
| 20148 | case TypeTableEntryIdEnum: | 20148 | case ZigTypeIdEnum: |
| 20149 | zig_panic("TODO buf_read_value_bytes enum type"); | 20149 | zig_panic("TODO buf_read_value_bytes enum type"); |
| 20150 | case TypeTableEntryIdFn: | 20150 | case ZigTypeIdFn: |
| 20151 | zig_panic("TODO buf_read_value_bytes fn type"); | 20151 | zig_panic("TODO buf_read_value_bytes fn type"); |
| 20152 | case TypeTableEntryIdUnion: | 20152 | case ZigTypeIdUnion: |
| 20153 | zig_panic("TODO buf_read_value_bytes union type"); | 20153 | zig_panic("TODO buf_read_value_bytes union type"); |
| 20154 | } | 20154 | } |
| 20155 | zig_unreachable(); | 20155 | zig_unreachable(); |
| ... | @@ -20180,18 +20180,18 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit | ... | @@ -20180,18 +20180,18 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit |
| 20180 | } | 20180 | } |
| 20181 | | 20181 | |
| 20182 | switch (src_type->id) { | 20182 | switch (src_type->id) { |
| 20183 | case TypeTableEntryIdInvalid: | 20183 | case ZigTypeIdInvalid: |
| 20184 | case TypeTableEntryIdMetaType: | 20184 | case ZigTypeIdMetaType: |
| 20185 | case TypeTableEntryIdOpaque: | 20185 | case ZigTypeIdOpaque: |
| 20186 | case TypeTableEntryIdBoundFn: | 20186 | case ZigTypeIdBoundFn: |
| 20187 | case TypeTableEntryIdArgTuple: | 20187 | case ZigTypeIdArgTuple: |
| 20188 | case TypeTableEntryIdNamespace: | 20188 | case ZigTypeIdNamespace: |
| 20189 | case TypeTableEntryIdBlock: | 20189 | case ZigTypeIdBlock: |
| 20190 | case TypeTableEntryIdUnreachable: | 20190 | case ZigTypeIdUnreachable: |
| 20191 | case TypeTableEntryIdComptimeFloat: | 20191 | case ZigTypeIdComptimeFloat: |
| 20192 | case TypeTableEntryIdComptimeInt: | 20192 | case ZigTypeIdComptimeInt: |
| 20193 | case TypeTableEntryIdUndefined: | 20193 | case ZigTypeIdUndefined: |
| 20194 | case TypeTableEntryIdNull: | 20194 | case ZigTypeIdNull: |
| 20195 | ir_add_error(ira, dest_type_value, | 20195 | ir_add_error(ira, dest_type_value, |
| 20196 | buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&src_type->name))); | 20196 | buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&src_type->name))); |
| 20197 | return ira->codegen->builtin_types.entry_invalid; | 20197 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -20206,18 +20206,18 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit | ... | @@ -20206,18 +20206,18 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit |
| 20206 | } | 20206 | } |
| 20207 | | 20207 | |
| 20208 | switch (dest_type->id) { | 20208 | switch (dest_type->id) { |
| 20209 | case TypeTableEntryIdInvalid: | 20209 | case ZigTypeIdInvalid: |
| 20210 | case TypeTableEntryIdMetaType: | 20210 | case ZigTypeIdMetaType: |
| 20211 | case TypeTableEntryIdOpaque: | 20211 | case ZigTypeIdOpaque: |
| 20212 | case TypeTableEntryIdBoundFn: | 20212 | case ZigTypeIdBoundFn: |
| 20213 | case TypeTableEntryIdArgTuple: | 20213 | case ZigTypeIdArgTuple: |
| 20214 | case TypeTableEntryIdNamespace: | 20214 | case ZigTypeIdNamespace: |
| 20215 | case TypeTableEntryIdBlock: | 20215 | case ZigTypeIdBlock: |
| 20216 | case TypeTableEntryIdUnreachable: | 20216 | case ZigTypeIdUnreachable: |
| 20217 | case TypeTableEntryIdComptimeFloat: | 20217 | case ZigTypeIdComptimeFloat: |
| 20218 | case TypeTableEntryIdComptimeInt: | 20218 | case ZigTypeIdComptimeInt: |
| 20219 | case TypeTableEntryIdUndefined: | 20219 | case ZigTypeIdUndefined: |
| 20220 | case TypeTableEntryIdNull: | 20220 | case ZigTypeIdNull: |
| 20221 | ir_add_error(ira, dest_type_value, | 20221 | ir_add_error(ira, dest_type_value, |
| 20222 | buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name))); | 20222 | buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name))); |
| 20223 | return ira->codegen->builtin_types.entry_invalid; | 20223 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -20384,7 +20384,7 @@ static ZigType *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionP | ... | @@ -20384,7 +20384,7 @@ static ZigType *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionP |
| 20384 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); | 20384 | ConstExprValue *val = ir_resolve_const(ira, target, UndefBad); |
| 20385 | if (!val) | 20385 | if (!val) |
| 20386 | return ira->codegen->builtin_types.entry_invalid; | 20386 | return ira->codegen->builtin_types.entry_invalid; |
| 20387 | if (val->type->id == TypeTableEntryIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 20387 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 20388 | IrInstruction *result = ir_create_const(&ira->new_irb, instruction->base.scope, | 20388 | IrInstruction *result = ir_create_const(&ira->new_irb, instruction->base.scope, |
| 20389 | instruction->base.source_node, usize); | 20389 | instruction->base.source_node, usize); |
| 20390 | bigint_init_unsigned(&result->value.data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); | 20390 | bigint_init_unsigned(&result->value.data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); |
| ... | @@ -20406,10 +20406,10 @@ static ZigType *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtr | ... | @@ -20406,10 +20406,10 @@ static ZigType *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtr |
| 20406 | if (type_is_invalid(child_type)) | 20406 | if (type_is_invalid(child_type)) |
| 20407 | return ira->codegen->builtin_types.entry_invalid; | 20407 | return ira->codegen->builtin_types.entry_invalid; |
| 20408 | | 20408 | |
| 20409 | if (child_type->id == TypeTableEntryIdUnreachable) { | 20409 | if (child_type->id == ZigTypeIdUnreachable) { |
| 20410 | ir_add_error(ira, &instruction->base, buf_sprintf("pointer to noreturn not allowed")); | 20410 | ir_add_error(ira, &instruction->base, buf_sprintf("pointer to noreturn not allowed")); |
| 20411 | return ira->codegen->builtin_types.entry_invalid; | 20411 | return ira->codegen->builtin_types.entry_invalid; |
| 20412 | } else if (child_type->id == TypeTableEntryIdOpaque && instruction->ptr_len == PtrLenUnknown) { | 20412 | } else if (child_type->id == ZigTypeIdOpaque && instruction->ptr_len == PtrLenUnknown) { |
| 20413 | ir_add_error(ira, &instruction->base, buf_sprintf("unknown-length pointer to opaque")); | 20413 | ir_add_error(ira, &instruction->base, buf_sprintf("unknown-length pointer to opaque")); |
| 20414 | return ira->codegen->builtin_types.entry_invalid; | 20414 | return ira->codegen->builtin_types.entry_invalid; |
| 20415 | } | 20415 | } |
| ... | @@ -20510,7 +20510,7 @@ static ZigType *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArg | ... | @@ -20510,7 +20510,7 @@ static ZigType *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArg |
| 20510 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) | 20510 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) |
| 20511 | return ira->codegen->builtin_types.entry_invalid; | 20511 | return ira->codegen->builtin_types.entry_invalid; |
| 20512 | | 20512 | |
| 20513 | if (fn_type->id != TypeTableEntryIdFn) { | 20513 | if (fn_type->id != ZigTypeIdFn) { |
| 20514 | ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); | 20514 | ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); |
| 20515 | return ira->codegen->builtin_types.entry_invalid; | 20515 | return ira->codegen->builtin_types.entry_invalid; |
| 20516 | } | 20516 | } |
| ... | @@ -20545,14 +20545,14 @@ static ZigType *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTag | ... | @@ -20545,14 +20545,14 @@ static ZigType *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTag |
| 20545 | if (type_is_invalid(enum_type)) | 20545 | if (type_is_invalid(enum_type)) |
| 20546 | return ira->codegen->builtin_types.entry_invalid; | 20546 | return ira->codegen->builtin_types.entry_invalid; |
| 20547 | | 20547 | |
| 20548 | if (enum_type->id == TypeTableEntryIdEnum) { | 20548 | if (enum_type->id == ZigTypeIdEnum) { |
| 20549 | if ((err = ensure_complete_type(ira->codegen, enum_type))) | 20549 | if ((err = ensure_complete_type(ira->codegen, enum_type))) |
| 20550 | return ira->codegen->builtin_types.entry_invalid; | 20550 | return ira->codegen->builtin_types.entry_invalid; |
| 20551 | | 20551 | |
| 20552 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 20552 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 20553 | out_val->data.x_type = enum_type->data.enumeration.tag_int_type; | 20553 | out_val->data.x_type = enum_type->data.enumeration.tag_int_type; |
| 20554 | return ira->codegen->builtin_types.entry_type; | 20554 | return ira->codegen->builtin_types.entry_type; |
| 20555 | } else if (enum_type->id == TypeTableEntryIdUnion) { | 20555 | } else if (enum_type->id == ZigTypeIdUnion) { |
| 20556 | if ((err = ensure_complete_type(ira->codegen, enum_type))) | 20556 | if ((err = ensure_complete_type(ira->codegen, enum_type))) |
| 20557 | return ira->codegen->builtin_types.entry_invalid; | 20557 | return ira->codegen->builtin_types.entry_invalid; |
| 20558 | | 20558 | |
| ... | @@ -20734,7 +20734,7 @@ static ZigType *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInstructio | ... | @@ -20734,7 +20734,7 @@ static ZigType *ir_analyze_instruction_coro_promise(IrAnalyze *ira, IrInstructio |
| 20734 | if (type_is_invalid(coro_handle->value.type)) | 20734 | if (type_is_invalid(coro_handle->value.type)) |
| 20735 | return ira->codegen->builtin_types.entry_invalid; | 20735 | return ira->codegen->builtin_types.entry_invalid; |
| 20736 | | 20736 | |
| 20737 | if (coro_handle->value.type->id != TypeTableEntryIdPromise || | 20737 | if (coro_handle->value.type->id != ZigTypeIdPromise || |
| 20738 | coro_handle->value.type->data.promise.result_type == nullptr) | 20738 | coro_handle->value.type->data.promise.result_type == nullptr) |
| 20739 | { | 20739 | { |
| 20740 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", | 20740 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", |
| ... | @@ -20774,7 +20774,7 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op | ... | @@ -20774,7 +20774,7 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op |
| 20774 | if (type_is_invalid(operand_type)) | 20774 | if (type_is_invalid(operand_type)) |
| 20775 | return ira->codegen->builtin_types.entry_invalid; | 20775 | return ira->codegen->builtin_types.entry_invalid; |
| 20776 | | 20776 | |
| 20777 | if (operand_type->id == TypeTableEntryIdInt) { | 20777 | if (operand_type->id == ZigTypeIdInt) { |
| 20778 | if (operand_type->data.integral.bit_count < 8) { | 20778 | if (operand_type->data.integral.bit_count < 8) { |
| 20779 | ir_add_error(ira, op, | 20779 | ir_add_error(ira, op, |
| 20780 | buf_sprintf("expected integer type 8 bits or larger, found %" PRIu32 "-bit integer type", | 20780 | buf_sprintf("expected integer type 8 bits or larger, found %" PRIu32 "-bit integer type", |
| ... | @@ -20907,7 +20907,7 @@ static ZigType *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrIns | ... | @@ -20907,7 +20907,7 @@ static ZigType *ir_analyze_instruction_promise_result_type(IrAnalyze *ira, IrIns |
| 20907 | if (type_is_invalid(promise_type)) | 20907 | if (type_is_invalid(promise_type)) |
| 20908 | return ira->codegen->builtin_types.entry_invalid; | 20908 | return ira->codegen->builtin_types.entry_invalid; |
| 20909 | | 20909 | |
| 20910 | if (promise_type->id != TypeTableEntryIdPromise || promise_type->data.promise.result_type == nullptr) { | 20910 | if (promise_type->id != ZigTypeIdPromise || promise_type->data.promise.result_type == nullptr) { |
| 20911 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", | 20911 | ir_add_error(ira, &instruction->base, buf_sprintf("expected promise->T, found '%s'", |
| 20912 | buf_ptr(&promise_type->name))); | 20912 | buf_ptr(&promise_type->name))); |
| 20913 | return ira->codegen->builtin_types.entry_invalid; | 20913 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -20942,9 +20942,9 @@ static ZigType *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira, | ... | @@ -20942,9 +20942,9 @@ static ZigType *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira, |
| 20942 | if (type_is_invalid(coro_promise_ptr->value.type)) | 20942 | if (type_is_invalid(coro_promise_ptr->value.type)) |
| 20943 | return ira->codegen->builtin_types.entry_invalid; | 20943 | return ira->codegen->builtin_types.entry_invalid; |
| 20944 | | 20944 | |
| 20945 | assert(coro_promise_ptr->value.type->id == TypeTableEntryIdPointer); | 20945 | assert(coro_promise_ptr->value.type->id == ZigTypeIdPointer); |
| 20946 | ZigType *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type; | 20946 | ZigType *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type; |
| 20947 | assert(promise_frame_type->id == TypeTableEntryIdStruct); | 20947 | assert(promise_frame_type->id == ZigTypeIdStruct); |
| 20948 | ZigType *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry; | 20948 | ZigType *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry; |
| 20949 | | 20949 | |
| 20950 | if (!type_can_fail(promise_result_type)) { | 20950 | if (!type_can_fail(promise_result_type)) { |
| ... | @@ -20997,7 +20997,7 @@ static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *i | ... | @@ -20997,7 +20997,7 @@ static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *i |
| 20997 | if (type_is_invalid(op->value.type)) | 20997 | if (type_is_invalid(op->value.type)) |
| 20998 | return ira->codegen->builtin_types.entry_invalid; | 20998 | return ira->codegen->builtin_types.entry_invalid; |
| 20999 | | 20999 | |
| 21000 | bool ok_type = float_type->id == TypeTableEntryIdComptimeFloat || float_type->id == TypeTableEntryIdFloat; | 21000 | bool ok_type = float_type->id == ZigTypeIdComptimeFloat || float_type->id == ZigTypeIdFloat; |
| 21001 | if (!ok_type) { | 21001 | if (!ok_type) { |
| 21002 | ir_add_error(ira, instruction->type, buf_sprintf("@sqrt does not support type '%s'", buf_ptr(&float_type->name))); | 21002 | ir_add_error(ira, instruction->type, buf_sprintf("@sqrt does not support type '%s'", buf_ptr(&float_type->name))); |
| 21003 | return ira->codegen->builtin_types.entry_invalid; | 21003 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -21014,9 +21014,9 @@ static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *i | ... | @@ -21014,9 +21014,9 @@ static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *i |
| 21014 | | 21014 | |
| 21015 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 21015 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 21016 | | 21016 | |
| 21017 | if (float_type->id == TypeTableEntryIdComptimeFloat) { | 21017 | if (float_type->id == ZigTypeIdComptimeFloat) { |
| 21018 | bigfloat_sqrt(&out_val->data.x_bigfloat, &val->data.x_bigfloat); | 21018 | bigfloat_sqrt(&out_val->data.x_bigfloat, &val->data.x_bigfloat); |
| 21019 | } else if (float_type->id == TypeTableEntryIdFloat) { | 21019 | } else if (float_type->id == ZigTypeIdFloat) { |
| 21020 | switch (float_type->data.floating.bit_count) { | 21020 | switch (float_type->data.floating.bit_count) { |
| 21021 | case 16: | 21021 | case 16: |
| 21022 | out_val->data.x_f16 = f16_sqrt(val->data.x_f16); | 21022 | out_val->data.x_f16 = f16_sqrt(val->data.x_f16); |
| ... | @@ -21040,7 +21040,7 @@ static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *i | ... | @@ -21040,7 +21040,7 @@ static ZigType *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionSqrt *i |
| 21040 | return float_type; | 21040 | return float_type; |
| 21041 | } | 21041 | } |
| 21042 | | 21042 | |
| 21043 | assert(float_type->id == TypeTableEntryIdFloat); | 21043 | assert(float_type->id == ZigTypeIdFloat); |
| 21044 | if (float_type->data.floating.bit_count != 16 && | 21044 | if (float_type->data.floating.bit_count != 16 && |
| 21045 | float_type->data.floating.bit_count != 32 && | 21045 | float_type->data.floating.bit_count != 32 && |
| 21046 | float_type->data.floating.bit_count != 64) { | 21046 | float_type->data.floating.bit_count != 64) { |
| ... | @@ -21061,7 +21061,7 @@ static ZigType *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstruction | ... | @@ -21061,7 +21061,7 @@ static ZigType *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstruction |
| 21061 | if (type_is_invalid(target->value.type)) | 21061 | if (type_is_invalid(target->value.type)) |
| 21062 | return ira->codegen->builtin_types.entry_invalid; | 21062 | return ira->codegen->builtin_types.entry_invalid; |
| 21063 | | 21063 | |
| 21064 | if (target->value.type->id != TypeTableEntryIdEnum) { | 21064 | if (target->value.type->id != ZigTypeIdEnum) { |
| 21065 | ir_add_error(ira, instruction->target, | 21065 | ir_add_error(ira, instruction->target, |
| 21066 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name))); | 21066 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value.type->name))); |
| 21067 | return ira->codegen->builtin_types.entry_invalid; | 21067 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -21084,7 +21084,7 @@ static ZigType *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstruction | ... | @@ -21084,7 +21084,7 @@ static ZigType *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstruction |
| 21084 | if (type_is_invalid(dest_type)) | 21084 | if (type_is_invalid(dest_type)) |
| 21085 | return ira->codegen->builtin_types.entry_invalid; | 21085 | return ira->codegen->builtin_types.entry_invalid; |
| 21086 | | 21086 | |
| 21087 | if (dest_type->id != TypeTableEntryIdEnum) { | 21087 | if (dest_type->id != ZigTypeIdEnum) { |
| 21088 | ir_add_error(ira, instruction->dest_type, | 21088 | ir_add_error(ira, instruction->dest_type, |
| 21089 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); | 21089 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); |
| 21090 | return ira->codegen->builtin_types.entry_invalid; | 21090 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -21420,8 +21420,8 @@ static ZigType *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instructio | ... | @@ -21420,8 +21420,8 @@ static ZigType *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *instructio |
| 21420 | if (instruction->other) { | 21420 | if (instruction->other) { |
| 21421 | instruction->other->value.type = instruction_type; | 21421 | instruction->other->value.type = instruction_type; |
| 21422 | } else { | 21422 | } else { |
| 21423 | assert(instruction_type->id == TypeTableEntryIdInvalid || | 21423 | assert(instruction_type->id == ZigTypeIdInvalid || |
| 21424 | instruction_type->id == TypeTableEntryIdUnreachable); | 21424 | instruction_type->id == ZigTypeIdUnreachable); |
| 21425 | instruction->other = instruction; | 21425 | instruction->other = instruction; |
| 21426 | } | 21426 | } |
| 21427 | | 21427 | |
| ... | @@ -21478,7 +21478,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -21478,7 +21478,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 21478 | } | 21478 | } |
| 21479 | | 21479 | |
| 21480 | // unreachable instructions do their own control flow. | 21480 | // unreachable instructions do their own control flow. |
| 21481 | if (return_type->id == TypeTableEntryIdUnreachable) | 21481 | if (return_type->id == ZigTypeIdUnreachable) |
| 21482 | continue; | 21482 | continue; |
| 21483 | | 21483 | |
| 21484 | ira->instruction_index += 1; | 21484 | ira->instruction_index += 1; |