authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-25 03:33:25-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-08-25 03:40:47-04:00
logb95ff12f2fb4aa5c20aecb789a91396557662287
tree4592adf93c28cc06897f69991e6d3ca619f316f6
parentac36f98e72f7ef33346bc772e4f257b79d04fcff

fix regressions


2 files changed, 102 insertions(+), 90 deletions(-)

src/analyze.cpp+16-2
...@@ -1739,6 +1739,9 @@ bool type_is_invalid(TypeTableEntry *type_entry) {...@@ -1739,6 +1739,9 @@ bool type_is_invalid(TypeTableEntry *type_entry) {
1739static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {1739static Error resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1740 assert(enum_type->id == TypeTableEntryIdEnum);1740 assert(enum_type->id == TypeTableEntryIdEnum);
17411741
1742 if (enum_type->data.enumeration.is_invalid)
1743 return ErrorSemanticAnalyzeFail;
1744
1742 if (enum_type->data.enumeration.complete)1745 if (enum_type->data.enumeration.complete)
1743 return ErrorNone;1746 return ErrorNone;
17441747
...@@ -2536,7 +2539,9 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {...@@ -2536,7 +2539,9 @@ static Error resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
2536 enum_type->data.enumeration.zero_bits_loop_flag = false;2539 enum_type->data.enumeration.zero_bits_loop_flag = false;
2537 enum_type->zero_bits = !type_has_bits(tag_int_type);2540 enum_type->zero_bits = !type_has_bits(tag_int_type);
2538 enum_type->data.enumeration.zero_bits_known = true;2541 enum_type->data.enumeration.zero_bits_known = true;
2539 assert(!enum_type->data.enumeration.is_invalid);2542
2543 if (enum_type->data.enumeration.is_invalid)
2544 return ErrorSemanticAnalyzeFail;
25402545
2541 return ErrorNone;2546 return ErrorNone;
2542}2547}
...@@ -2546,6 +2551,9 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {...@@ -2546,6 +2551,9 @@ static Error resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
25462551
2547 Error err;2552 Error err;
25482553
2554 if (struct_type->data.structure.is_invalid)
2555 return ErrorSemanticAnalyzeFail;
2556
2549 if (struct_type->data.structure.zero_bits_known)2557 if (struct_type->data.structure.zero_bits_known)
2550 return ErrorNone;2558 return ErrorNone;
25512559
...@@ -2662,6 +2670,9 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2662,6 +2670,9 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
26622670
2663 Error err;2671 Error err;
26642672
2673 if (union_type->data.unionation.is_invalid)
2674 return ErrorSemanticAnalyzeFail;
2675
2665 if (union_type->data.unionation.zero_bits_known)2676 if (union_type->data.unionation.zero_bits_known)
2666 return ErrorNone;2677 return ErrorNone;
26672678
...@@ -2992,7 +3003,10 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {...@@ -2992,7 +3003,10 @@ static Error resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type) {
2992 union_type->data.unionation.gen_field_count = gen_field_index;3003 union_type->data.unionation.gen_field_count = gen_field_index;
2993 union_type->zero_bits = (gen_field_index == 0 && (field_count < 2 || !src_have_tag));3004 union_type->zero_bits = (gen_field_index == 0 && (field_count < 2 || !src_have_tag));
2994 union_type->data.unionation.zero_bits_known = true;3005 union_type->data.unionation.zero_bits_known = true;
2995 assert(!union_type->data.unionation.is_invalid);3006
3007 if (union_type->data.unionation.is_invalid)
3008 return ErrorSemanticAnalyzeFail;
3009
2996 return ErrorNone;3010 return ErrorNone;
2997}3011}
29983012
src/ir.cpp+86-88
...@@ -15272,6 +15272,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -15272,6 +15272,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
15272 return ira->codegen->builtin_types.entry_invalid;15272 return ira->codegen->builtin_types.entry_invalid;
1527315273
15274 if (slice_type_instruction->align_value == nullptr) {15274 if (slice_type_instruction->align_value == nullptr) {
15275 if ((err = type_ensure_zero_bits_known(ira->codegen, child_type)))
15276 return ira->codegen->builtin_types.entry_invalid;
15275 align_bytes = get_abi_alignment(ira->codegen, child_type);15277 align_bytes = get_abi_alignment(ira->codegen, child_type);
15276 }15278 }
1527715279
...@@ -16751,19 +16753,15 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz...@@ -16751,19 +16753,15 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz
16751 (buf_deinit(field_name_buf), true));16753 (buf_deinit(field_name_buf), true));
16752}16754}
1675316755
16754static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, TypeTableEntry *root = nullptr)16756static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, TypeTableEntry *root) {
16755{
16756 Error err;16757 Error err;
16757 static ConstExprValue *type_info_var = nullptr;16758 static ConstExprValue *type_info_var = nullptr;
16758 static TypeTableEntry *type_info_type = nullptr;16759 static TypeTableEntry *type_info_type = nullptr;
16759 if (type_info_var == nullptr)16760 if (type_info_var == nullptr) {
16760 {
16761 type_info_var = get_builtin_value(ira->codegen, "TypeInfo");16761 type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
16762 assert(type_info_var->type->id == TypeTableEntryIdMetaType);16762 assert(type_info_var->type->id == TypeTableEntryIdMetaType);
1676316763
16764 if ((err = ensure_complete_type(ira->codegen, type_info_var->data.x_type)))16764 assertNoError(ensure_complete_type(ira->codegen, type_info_var->data.x_type));
16765 return ira->codegen->builtin_types.entry_invalid;
16766
16767 type_info_type = type_info_var->data.x_type;16765 type_info_type = type_info_var->data.x_type;
16768 assert(type_info_type->id == TypeTableEntryIdUnion);16766 assert(type_info_type->id == TypeTableEntryIdUnion);
16769 }16767 }
...@@ -16797,7 +16795,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na...@@ -16797,7 +16795,7 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na
16797static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope)16795static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope)
16798{16796{
16799 Error err;16797 Error err;
16800 TypeTableEntry *type_info_definition_type = ir_type_info_get_type(ira, "Definition");16798 TypeTableEntry *type_info_definition_type = ir_type_info_get_type(ira, "Definition", nullptr);
16801 if ((err = ensure_complete_type(ira->codegen, type_info_definition_type)))16799 if ((err = ensure_complete_type(ira->codegen, type_info_definition_type)))
16802 return false;16800 return false;
1680316801
...@@ -16951,7 +16949,7 @@ static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop...@@ -16951,7 +16949,7 @@ static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
16951 // calling_convention: TypeInfo.CallingConvention16949 // calling_convention: TypeInfo.CallingConvention
16952 ensure_field_index(fn_def_val->type, "calling_convention", 2);16950 ensure_field_index(fn_def_val->type, "calling_convention", 2);
16953 fn_def_fields[2].special = ConstValSpecialStatic;16951 fn_def_fields[2].special = ConstValSpecialStatic;
16954 fn_def_fields[2].type = ir_type_info_get_type(ira, "CallingConvention");16952 fn_def_fields[2].type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
16955 bigint_init_unsigned(&fn_def_fields[2].data.x_enum_tag, fn_node->cc);16953 bigint_init_unsigned(&fn_def_fields[2].data.x_enum_tag, fn_node->cc);
16956 // is_var_args: bool16954 // is_var_args: bool
16957 ensure_field_index(fn_def_val->type, "is_var_args", 3);16955 ensure_field_index(fn_def_val->type, "is_var_args", 3);
...@@ -17051,6 +17049,61 @@ static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop...@@ -17051,6 +17049,61 @@ static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, Scop
17051 return true;17049 return true;
17052}17050}
1705317051
17052static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, TypeTableEntry *ptr_type_entry) {
17053 TypeTableEntry *attrs_type;
17054 uint32_t size_enum_index;
17055 if (is_slice(ptr_type_entry)) {
17056 attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;
17057 size_enum_index = 2;
17058 } else if (ptr_type_entry->id == TypeTableEntryIdPointer) {
17059 attrs_type = ptr_type_entry;
17060 size_enum_index = (ptr_type_entry->data.pointer.ptr_len == PtrLenSingle) ? 0 : 1;
17061 } else {
17062 zig_unreachable();
17063 }
17064
17065 TypeTableEntry *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr);
17066 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_type));
17067
17068 ConstExprValue *result = create_const_vals(1);
17069 result->special = ConstValSpecialStatic;
17070 result->type = type_info_pointer_type;
17071
17072 ConstExprValue *fields = create_const_vals(5);
17073 result->data.x_struct.fields = fields;
17074
17075 // size: Size
17076 ensure_field_index(result->type, "size", 0);
17077 TypeTableEntry *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);
17078 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_size_type));
17079 fields[0].special = ConstValSpecialStatic;
17080 fields[0].type = type_info_pointer_size_type;
17081 bigint_init_unsigned(&fields[0].data.x_enum_tag, size_enum_index);
17082
17083 // is_const: bool
17084 ensure_field_index(result->type, "is_const", 1);
17085 fields[1].special = ConstValSpecialStatic;
17086 fields[1].type = ira->codegen->builtin_types.entry_bool;
17087 fields[1].data.x_bool = attrs_type->data.pointer.is_const;
17088 // is_volatile: bool
17089 ensure_field_index(result->type, "is_volatile", 2);
17090 fields[2].special = ConstValSpecialStatic;
17091 fields[2].type = ira->codegen->builtin_types.entry_bool;
17092 fields[2].data.x_bool = attrs_type->data.pointer.is_volatile;
17093 // alignment: u32
17094 ensure_field_index(result->type, "alignment", 3);
17095 fields[3].special = ConstValSpecialStatic;
17096 fields[3].type = ira->codegen->builtin_types.entry_u32;
17097 bigint_init_unsigned(&fields[3].data.x_bigint, attrs_type->data.pointer.alignment);
17098 // child: type
17099 ensure_field_index(result->type, "child", 4);
17100 fields[4].special = ConstValSpecialStatic;
17101 fields[4].type = ira->codegen->builtin_types.entry_type;
17102 fields[4].data.x_type = attrs_type->data.pointer.child_type;
17103
17104 return result;
17105};
17106
17054static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry) {17107static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry) {
17055 Error err;17108 Error err;
17056 assert(type_entry != nullptr);17109 assert(type_entry != nullptr);
...@@ -17076,61 +17129,6 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17076,61 +17129,6 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17076 enum_field_val->data.x_struct.fields = inner_fields;17129 enum_field_val->data.x_struct.fields = inner_fields;
17077 };17130 };
1707817131
17079 const auto create_ptr_like_type_info = [ira](TypeTableEntry *ptr_type_entry) {
17080 TypeTableEntry *attrs_type;
17081 uint32_t size_enum_index;
17082 if (is_slice(ptr_type_entry)) {
17083 attrs_type = ptr_type_entry->data.structure.fields[slice_ptr_index].type_entry;
17084 size_enum_index = 2;
17085 } else if (ptr_type_entry->id == TypeTableEntryIdPointer) {
17086 attrs_type = ptr_type_entry;
17087 size_enum_index = (ptr_type_entry->data.pointer.ptr_len == PtrLenSingle) ? 0 : 1;
17088 } else {
17089 zig_unreachable();
17090 }
17091
17092 TypeTableEntry *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer");
17093 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_type));
17094
17095 ConstExprValue *result = create_const_vals(1);
17096 result->special = ConstValSpecialStatic;
17097 result->type = type_info_pointer_type;
17098
17099 ConstExprValue *fields = create_const_vals(5);
17100 result->data.x_struct.fields = fields;
17101
17102 // size: Size
17103 ensure_field_index(result->type, "size", 0);
17104 TypeTableEntry *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type);
17105 assertNoError(ensure_complete_type(ira->codegen, type_info_pointer_size_type));
17106 fields[0].special = ConstValSpecialStatic;
17107 fields[0].type = type_info_pointer_size_type;
17108 bigint_init_unsigned(&fields[0].data.x_enum_tag, size_enum_index);
17109
17110 // is_const: bool
17111 ensure_field_index(result->type, "is_const", 1);
17112 fields[1].special = ConstValSpecialStatic;
17113 fields[1].type = ira->codegen->builtin_types.entry_bool;
17114 fields[1].data.x_bool = attrs_type->data.pointer.is_const;
17115 // is_volatile: bool
17116 ensure_field_index(result->type, "is_volatile", 2);
17117 fields[2].special = ConstValSpecialStatic;
17118 fields[2].type = ira->codegen->builtin_types.entry_bool;
17119 fields[2].data.x_bool = attrs_type->data.pointer.is_volatile;
17120 // alignment: u32
17121 ensure_field_index(result->type, "alignment", 3);
17122 fields[3].special = ConstValSpecialStatic;
17123 fields[3].type = ira->codegen->builtin_types.entry_u32;
17124 bigint_init_unsigned(&fields[3].data.x_bigint, attrs_type->data.pointer.alignment);
17125 // child: type
17126 ensure_field_index(result->type, "child", 4);
17127 fields[4].special = ConstValSpecialStatic;
17128 fields[4].type = ira->codegen->builtin_types.entry_type;
17129 fields[4].data.x_type = attrs_type->data.pointer.child_type;
17130
17131 return result;
17132 };
17133
17134 if (type_entry == ira->codegen->builtin_types.entry_global_error_set) {17132 if (type_entry == ira->codegen->builtin_types.entry_global_error_set) {
17135 zig_panic("TODO implement @typeInfo for global error set");17133 zig_panic("TODO implement @typeInfo for global error set");
17136 }17134 }
...@@ -17166,7 +17164,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17166,7 +17164,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17166 {17164 {
17167 result = create_const_vals(1);17165 result = create_const_vals(1);
17168 result->special = ConstValSpecialStatic;17166 result->special = ConstValSpecialStatic;
17169 result->type = ir_type_info_get_type(ira, "Int");17167 result->type = ir_type_info_get_type(ira, "Int", nullptr);
1717017168
17171 ConstExprValue *fields = create_const_vals(2);17169 ConstExprValue *fields = create_const_vals(2);
17172 result->data.x_struct.fields = fields;17170 result->data.x_struct.fields = fields;
...@@ -17188,7 +17186,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17188,7 +17186,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17188 {17186 {
17189 result = create_const_vals(1);17187 result = create_const_vals(1);
17190 result->special = ConstValSpecialStatic;17188 result->special = ConstValSpecialStatic;
17191 result->type = ir_type_info_get_type(ira, "Float");17189 result->type = ir_type_info_get_type(ira, "Float", nullptr);
1719217190
17193 ConstExprValue *fields = create_const_vals(1);17191 ConstExprValue *fields = create_const_vals(1);
17194 result->data.x_struct.fields = fields;17192 result->data.x_struct.fields = fields;
...@@ -17203,14 +17201,14 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17203,14 +17201,14 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17203 }17201 }
17204 case TypeTableEntryIdPointer:17202 case TypeTableEntryIdPointer:
17205 {17203 {
17206 result = create_ptr_like_type_info(type_entry);17204 result = create_ptr_like_type_info(ira, type_entry);
17207 break;17205 break;
17208 }17206 }
17209 case TypeTableEntryIdArray:17207 case TypeTableEntryIdArray:
17210 {17208 {
17211 result = create_const_vals(1);17209 result = create_const_vals(1);
17212 result->special = ConstValSpecialStatic;17210 result->special = ConstValSpecialStatic;
17213 result->type = ir_type_info_get_type(ira, "Array");17211 result->type = ir_type_info_get_type(ira, "Array", nullptr);
1721417212
17215 ConstExprValue *fields = create_const_vals(2);17213 ConstExprValue *fields = create_const_vals(2);
17216 result->data.x_struct.fields = fields;17214 result->data.x_struct.fields = fields;
...@@ -17232,7 +17230,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17232,7 +17230,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17232 {17230 {
17233 result = create_const_vals(1);17231 result = create_const_vals(1);
17234 result->special = ConstValSpecialStatic;17232 result->special = ConstValSpecialStatic;
17235 result->type = ir_type_info_get_type(ira, "Optional");17233 result->type = ir_type_info_get_type(ira, "Optional", nullptr);
1723617234
17237 ConstExprValue *fields = create_const_vals(1);17235 ConstExprValue *fields = create_const_vals(1);
17238 result->data.x_struct.fields = fields;17236 result->data.x_struct.fields = fields;
...@@ -17249,7 +17247,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17249,7 +17247,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17249 {17247 {
17250 result = create_const_vals(1);17248 result = create_const_vals(1);
17251 result->special = ConstValSpecialStatic;17249 result->special = ConstValSpecialStatic;
17252 result->type = ir_type_info_get_type(ira, "Promise");17250 result->type = ir_type_info_get_type(ira, "Promise", nullptr);
1725317251
17254 ConstExprValue *fields = create_const_vals(1);17252 ConstExprValue *fields = create_const_vals(1);
17255 result->data.x_struct.fields = fields;17253 result->data.x_struct.fields = fields;
...@@ -17275,7 +17273,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17275,7 +17273,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17275 {17273 {
17276 result = create_const_vals(1);17274 result = create_const_vals(1);
17277 result->special = ConstValSpecialStatic;17275 result->special = ConstValSpecialStatic;
17278 result->type = ir_type_info_get_type(ira, "Enum");17276 result->type = ir_type_info_get_type(ira, "Enum", nullptr);
1727917277
17280 ConstExprValue *fields = create_const_vals(4);17278 ConstExprValue *fields = create_const_vals(4);
17281 result->data.x_struct.fields = fields;17279 result->data.x_struct.fields = fields;
...@@ -17283,7 +17281,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17283,7 +17281,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17283 // layout: ContainerLayout17281 // layout: ContainerLayout
17284 ensure_field_index(result->type, "layout", 0);17282 ensure_field_index(result->type, "layout", 0);
17285 fields[0].special = ConstValSpecialStatic;17283 fields[0].special = ConstValSpecialStatic;
17286 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout");17284 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
17287 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.enumeration.layout);17285 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.enumeration.layout);
17288 // tag_type: type17286 // tag_type: type
17289 ensure_field_index(result->type, "tag_type", 1);17287 ensure_field_index(result->type, "tag_type", 1);
...@@ -17293,7 +17291,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17293,7 +17291,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17293 // fields: []TypeInfo.EnumField17291 // fields: []TypeInfo.EnumField
17294 ensure_field_index(result->type, "fields", 2);17292 ensure_field_index(result->type, "fields", 2);
1729517293
17296 TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField");17294 TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
17297 uint32_t enum_field_count = type_entry->data.enumeration.src_field_count;17295 uint32_t enum_field_count = type_entry->data.enumeration.src_field_count;
1729817296
17299 ConstExprValue *enum_field_array = create_const_vals(1);17297 ConstExprValue *enum_field_array = create_const_vals(1);
...@@ -17325,7 +17323,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17325,7 +17323,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17325 {17323 {
17326 result = create_const_vals(1);17324 result = create_const_vals(1);
17327 result->special = ConstValSpecialStatic;17325 result->special = ConstValSpecialStatic;
17328 result->type = ir_type_info_get_type(ira, "ErrorSet");17326 result->type = ir_type_info_get_type(ira, "ErrorSet", nullptr);
1732917327
17330 ConstExprValue *fields = create_const_vals(1);17328 ConstExprValue *fields = create_const_vals(1);
17331 result->data.x_struct.fields = fields;17329 result->data.x_struct.fields = fields;
...@@ -17333,7 +17331,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17333,7 +17331,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17333 // errors: []TypeInfo.Error17331 // errors: []TypeInfo.Error
17334 ensure_field_index(result->type, "errors", 0);17332 ensure_field_index(result->type, "errors", 0);
1733517333
17336 TypeTableEntry *type_info_error_type = ir_type_info_get_type(ira, "Error");17334 TypeTableEntry *type_info_error_type = ir_type_info_get_type(ira, "Error", nullptr);
17337 uint32_t error_count = type_entry->data.error_set.err_count;17335 uint32_t error_count = type_entry->data.error_set.err_count;
17338 ConstExprValue *error_array = create_const_vals(1);17336 ConstExprValue *error_array = create_const_vals(1);
17339 error_array->special = ConstValSpecialStatic;17337 error_array->special = ConstValSpecialStatic;
...@@ -17375,7 +17373,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17375,7 +17373,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17375 {17373 {
17376 result = create_const_vals(1);17374 result = create_const_vals(1);
17377 result->special = ConstValSpecialStatic;17375 result->special = ConstValSpecialStatic;
17378 result->type = ir_type_info_get_type(ira, "ErrorUnion");17376 result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr);
1737917377
17380 ConstExprValue *fields = create_const_vals(2);17378 ConstExprValue *fields = create_const_vals(2);
17381 result->data.x_struct.fields = fields;17379 result->data.x_struct.fields = fields;
...@@ -17398,7 +17396,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17398,7 +17396,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17398 {17396 {
17399 result = create_const_vals(1);17397 result = create_const_vals(1);
17400 result->special = ConstValSpecialStatic;17398 result->special = ConstValSpecialStatic;
17401 result->type = ir_type_info_get_type(ira, "Union");17399 result->type = ir_type_info_get_type(ira, "Union", nullptr);
1740217400
17403 ConstExprValue *fields = create_const_vals(4);17401 ConstExprValue *fields = create_const_vals(4);
17404 result->data.x_struct.fields = fields;17402 result->data.x_struct.fields = fields;
...@@ -17406,7 +17404,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17406,7 +17404,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17406 // layout: ContainerLayout17404 // layout: ContainerLayout
17407 ensure_field_index(result->type, "layout", 0);17405 ensure_field_index(result->type, "layout", 0);
17408 fields[0].special = ConstValSpecialStatic;17406 fields[0].special = ConstValSpecialStatic;
17409 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout");17407 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
17410 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout);17408 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout);
17411 // tag_type: ?type17409 // tag_type: ?type
17412 ensure_field_index(result->type, "tag_type", 1);17410 ensure_field_index(result->type, "tag_type", 1);
...@@ -17428,7 +17426,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17428,7 +17426,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17428 // fields: []TypeInfo.UnionField17426 // fields: []TypeInfo.UnionField
17429 ensure_field_index(result->type, "fields", 2);17427 ensure_field_index(result->type, "fields", 2);
1743017428
17431 TypeTableEntry *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField");17429 TypeTableEntry *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField", nullptr);
17432 uint32_t union_field_count = type_entry->data.unionation.src_field_count;17430 uint32_t union_field_count = type_entry->data.unionation.src_field_count;
1743317431
17434 ConstExprValue *union_field_array = create_const_vals(1);17432 ConstExprValue *union_field_array = create_const_vals(1);
...@@ -17440,7 +17438,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17440,7 +17438,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1744017438
17441 init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false);17439 init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false);
1744217440
17443 TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField");17441 TypeTableEntry *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
1744417442
17445 for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) {17443 for (uint32_t union_field_index = 0; union_field_index < union_field_count; union_field_index++) {
17446 TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index];17444 TypeUnionField *union_field = &type_entry->data.unionation.fields[union_field_index];
...@@ -17482,13 +17480,13 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17482,13 +17480,13 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17482 case TypeTableEntryIdStruct:17480 case TypeTableEntryIdStruct:
17483 {17481 {
17484 if (type_entry->data.structure.is_slice) {17482 if (type_entry->data.structure.is_slice) {
17485 result = create_ptr_like_type_info(type_entry);17483 result = create_ptr_like_type_info(ira, type_entry);
17486 break;17484 break;
17487 }17485 }
1748817486
17489 result = create_const_vals(1);17487 result = create_const_vals(1);
17490 result->special = ConstValSpecialStatic;17488 result->special = ConstValSpecialStatic;
17491 result->type = ir_type_info_get_type(ira, "Struct");17489 result->type = ir_type_info_get_type(ira, "Struct", nullptr);
1749217490
17493 ConstExprValue *fields = create_const_vals(3);17491 ConstExprValue *fields = create_const_vals(3);
17494 result->data.x_struct.fields = fields;17492 result->data.x_struct.fields = fields;
...@@ -17496,12 +17494,12 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17496,12 +17494,12 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17496 // layout: ContainerLayout17494 // layout: ContainerLayout
17497 ensure_field_index(result->type, "layout", 0);17495 ensure_field_index(result->type, "layout", 0);
17498 fields[0].special = ConstValSpecialStatic;17496 fields[0].special = ConstValSpecialStatic;
17499 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout");17497 fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
17500 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.structure.layout);17498 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.structure.layout);
17501 // fields: []TypeInfo.StructField17499 // fields: []TypeInfo.StructField
17502 ensure_field_index(result->type, "fields", 1);17500 ensure_field_index(result->type, "fields", 1);
1750317501
17504 TypeTableEntry *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField");17502 TypeTableEntry *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField", nullptr);
17505 uint32_t struct_field_count = type_entry->data.structure.src_field_count;17503 uint32_t struct_field_count = type_entry->data.structure.src_field_count;
1750617504
17507 ConstExprValue *struct_field_array = create_const_vals(1);17505 ConstExprValue *struct_field_array = create_const_vals(1);
...@@ -17557,7 +17555,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17557,7 +17555,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17557 {17555 {
17558 result = create_const_vals(1);17556 result = create_const_vals(1);
17559 result->special = ConstValSpecialStatic;17557 result->special = ConstValSpecialStatic;
17560 result->type = ir_type_info_get_type(ira, "Fn");17558 result->type = ir_type_info_get_type(ira, "Fn", nullptr);
1756117559
17562 ConstExprValue *fields = create_const_vals(6);17560 ConstExprValue *fields = create_const_vals(6);
17563 result->data.x_struct.fields = fields;17561 result->data.x_struct.fields = fields;
...@@ -17565,7 +17563,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17565,7 +17563,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17565 // calling_convention: TypeInfo.CallingConvention17563 // calling_convention: TypeInfo.CallingConvention
17566 ensure_field_index(result->type, "calling_convention", 0);17564 ensure_field_index(result->type, "calling_convention", 0);
17567 fields[0].special = ConstValSpecialStatic;17565 fields[0].special = ConstValSpecialStatic;
17568 fields[0].type = ir_type_info_get_type(ira, "CallingConvention");17566 fields[0].type = ir_type_info_get_type(ira, "CallingConvention", nullptr);
17569 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.fn.fn_type_id.cc);17567 bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.fn.fn_type_id.cc);
17570 // is_generic: bool17568 // is_generic: bool
17571 ensure_field_index(result->type, "is_generic", 1);17569 ensure_field_index(result->type, "is_generic", 1);
...@@ -17606,7 +17604,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -17606,7 +17604,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
17606 fields[4].data.x_optional = async_alloc_type;17604 fields[4].data.x_optional = async_alloc_type;
17607 }17605 }
17608 // args: []TypeInfo.FnArg17606 // args: []TypeInfo.FnArg
17609 TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg");17607 TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr);
17610 size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count -17608 size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count -
17611 (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC);17609 (is_varargs && type_entry->data.fn.fn_type_id.cc != CallingConventionC);
1761217610
...@@ -17681,7 +17679,7 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,...@@ -17681,7 +17679,7 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,
17681 if (type_is_invalid(type_entry))17679 if (type_is_invalid(type_entry))
17682 return ira->codegen->builtin_types.entry_invalid;17680 return ira->codegen->builtin_types.entry_invalid;
1768317681
17684 TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr);17682 TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr, nullptr);
1768517683
17686 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);17684 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
17687 out_val->type = result_type;17685 out_val->type = result_type;