| ... | @@ -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; |
| 15273 | | 15273 | |
| 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 | } |
| 15277 | | 15279 | |
| ... | @@ -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 | } |
| 16753 | | 16755 | |
| 16754 | static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, TypeTableEntry *root = nullptr) | 16756 | static 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); |
| 16763 | | 16763 | |
| 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 |
| 16797 | static bool ir_make_type_info_defs(IrAnalyze *ira, ConstExprValue *out_val, ScopeDecls *decls_scope) | 16795 | static 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; |
| 16803 | | 16801 | |
| ... | @@ -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.CallingConvention | 16949 | // 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: bool | 16954 | // 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 | } |
| 17053 | | 17051 | |
| | 17052 | static 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 | |
| 17054 | static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry) { | 17107 | static 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 | }; |
| 17078 | | 17131 | |
| 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); |
| 17170 | | 17168 | |
| 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); |
| 17192 | | 17190 | |
| 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); |
| 17214 | | 17212 | |
| 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); |
| 17236 | | 17234 | |
| 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); |
| 17253 | | 17251 | |
| 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); |
| 17279 | | 17277 | |
| 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: ContainerLayout | 17281 | // 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: type | 17286 | // 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.EnumField | 17291 | // fields: []TypeInfo.EnumField |
| 17294 | ensure_field_index(result->type, "fields", 2); | 17292 | ensure_field_index(result->type, "fields", 2); |
| 17295 | | 17293 | |
| 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; |
| 17298 | | 17296 | |
| 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); |
| 17329 | | 17327 | |
| 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.Error | 17331 | // errors: []TypeInfo.Error |
| 17334 | ensure_field_index(result->type, "errors", 0); | 17332 | ensure_field_index(result->type, "errors", 0); |
| 17335 | | 17333 | |
| 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); |
| 17379 | | 17377 | |
| 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); |
| 17402 | | 17400 | |
| 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: ContainerLayout | 17404 | // 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: ?type | 17409 | // 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.UnionField | 17426 | // fields: []TypeInfo.UnionField |
| 17429 | ensure_field_index(result->type, "fields", 2); | 17427 | ensure_field_index(result->type, "fields", 2); |
| 17430 | | 17428 | |
| 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; |
| 17433 | | 17431 | |
| 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 |
| 17440 | | 17438 | |
| 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); |
| 17442 | | 17440 | |
| 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); |
| 17444 | | 17442 | |
| 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 | } |
| 17488 | | 17486 | |
| 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); |
| 17492 | | 17490 | |
| 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: ContainerLayout | 17494 | // 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.StructField | 17499 | // fields: []TypeInfo.StructField |
| 17502 | ensure_field_index(result->type, "fields", 1); | 17500 | ensure_field_index(result->type, "fields", 1); |
| 17503 | | 17501 | |
| 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; |
| 17506 | | 17504 | |
| 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); |
| 17561 | | 17559 | |
| 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.CallingConvention | 17563 | // 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: bool | 17568 | // 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.FnArg | 17606 | // 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); |
| 17612 | | 17610 | |
| ... | @@ -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; |
| 17683 | | 17681 | |
| 17684 | TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr); | 17682 | TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr, nullptr); |
| 17685 | | 17683 | |
| 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; |