| ... | ... | @@ -15748,31 +15748,6 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz |
| 15748 | 15748 | (buf_deinit(field_name_buf), true)); |
| 15749 | 15749 | } |
| 15750 | 15750 | |
| 15751 | | static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExprValue *parent, ssize_t parent_field_index) |
| 15752 | | { |
| 15753 | | assert(struct_val->type->id == TypeTableEntryIdStruct); |
| 15754 | | assert(parent->type != nullptr && !type_is_invalid(parent->type)); |
| 15755 | | |
| 15756 | | switch (parent->type->id) |
| 15757 | | { |
| 15758 | | case TypeTableEntryIdArray: |
| 15759 | | zig_panic("TODO - Only expected struct or union parent."); |
| 15760 | | case TypeTableEntryIdStruct: |
| 15761 | | assert(parent_field_index >= 0); |
| 15762 | | struct_val->data.x_struct.parent.id = ConstParentIdStruct; |
| 15763 | | struct_val->data.x_struct.parent.data.p_struct.struct_val = parent; |
| 15764 | | struct_val->data.x_struct.parent.data.p_struct.field_index = parent_field_index; |
| 15765 | | break; |
| 15766 | | case TypeTableEntryIdUnion: |
| 15767 | | assert(parent_field_index == -1); |
| 15768 | | struct_val->data.x_struct.parent.id = ConstParentIdUnion; |
| 15769 | | struct_val->data.x_struct.parent.data.p_union.union_val = parent; |
| 15770 | | break; |
| 15771 | | default: |
| 15772 | | struct_val->data.x_struct.parent.id = ConstParentIdNone; |
| 15773 | | } |
| 15774 | | } |
| 15775 | | |
| 15776 | 15751 | static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name) |
| 15777 | 15752 | { |
| 15778 | 15753 | static ConstExprValue *type_info_var = nullptr; |
| ... | ... | @@ -15807,69 +15782,12 @@ static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_na |
| 15807 | 15782 | return var->value->data.x_type; |
| 15808 | 15783 | } |
| 15809 | 15784 | |
| 15810 | | static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *parent, |
| 15811 | | ssize_t parent_field_index, TypeTableEntry *type_entry) |
| 15785 | static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *type_entry) |
| 15812 | 15786 | { |
| 15813 | 15787 | assert(type_entry != nullptr); |
| 15814 | 15788 | assert(!type_is_invalid(type_entry)); |
| 15815 | 15789 | |
| 15816 | | // Lookup an available value in our cache. |
| 15817 | | auto entry = ira->codegen->type_info_cache.maybe_get(type_entry); |
| 15818 | | if (entry != nullptr) |
| 15819 | | { |
| 15820 | | // Override the parent if we need to. |
| 15821 | | ConstExprValue *result = entry->value; |
| 15822 | | |
| 15823 | | assert(result->type->id == TypeTableEntryIdStruct); |
| 15824 | | |
| 15825 | | ConstParent *curr_parent = &result->data.x_struct.parent; |
| 15826 | | if (curr_parent->id == ConstParentIdStruct) |
| 15827 | | { |
| 15828 | | if (curr_parent->data.p_struct.struct_val == parent && |
| 15829 | | parent_field_index != -1 && |
| 15830 | | curr_parent->data.p_struct.field_index == (size_t)parent_field_index) |
| 15831 | | { |
| 15832 | | return result; |
| 15833 | | } |
| 15834 | | ConstExprValue *new_result = create_const_vals(1); |
| 15835 | | copy_const_val(new_result, result, true); |
| 15836 | | ir_type_info_struct_set_parent(new_result, parent, parent_field_index); |
| 15837 | | return new_result; |
| 15838 | | } |
| 15839 | | else if (curr_parent->id == ConstParentIdUnion) |
| 15840 | | { |
| 15841 | | if (curr_parent->data.p_union.union_val == parent) |
| 15842 | | { |
| 15843 | | return result; |
| 15844 | | } |
| 15845 | | ConstExprValue *new_result = create_const_vals(1); |
| 15846 | | copy_const_val(new_result, result, true); |
| 15847 | | ir_type_info_struct_set_parent(new_result, parent, parent_field_index); |
| 15848 | | return new_result; |
| 15849 | | } |
| 15850 | | else if (curr_parent->id == ConstParentIdNone) |
| 15851 | | { |
| 15852 | | if (parent->type->id != TypeTableEntryIdStruct && |
| 15853 | | parent->type->id != TypeTableEntryIdArray && |
| 15854 | | parent->type->id != TypeTableEntryIdUnion) |
| 15855 | | { |
| 15856 | | return result; |
| 15857 | | } |
| 15858 | | ConstExprValue *new_result = create_const_vals(1); |
| 15859 | | copy_const_val(new_result, result, true); |
| 15860 | | ir_type_info_struct_set_parent(new_result, parent, parent_field_index); |
| 15861 | | return new_result; |
| 15862 | | } |
| 15863 | | |
| 15864 | | return result; |
| 15865 | | } |
| 15866 | | |
| 15867 | | // If the value is not present in the cache, we will build it, add it and return it. |
| 15868 | | // We add values to the cache eagerly, as soon as we have filled out the root object's fields. |
| 15869 | | // That way, if we need to fetch the value in a recursive call down the line, even if we need to |
| 15870 | | // copy the value and reajust the parent, the value we get back still points to child values that |
| 15871 | | // will be filled later. |
| 15872 | | |
| 15790 | ConstExprValue *result = nullptr; |
| 15873 | 15791 | switch (type_entry->id) |
| 15874 | 15792 | { |
| 15875 | 15793 | case TypeTableEntryIdInvalid: |
| ... | ... | @@ -15887,18 +15805,24 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15887 | 15805 | case TypeTableEntryIdArgTuple: |
| 15888 | 15806 | case TypeTableEntryIdOpaque: |
| 15889 | 15807 | return nullptr; |
| 15808 | default: |
| 15809 | { |
| 15810 | // Lookup an available value in our cache. |
| 15811 | auto entry = ira->codegen->type_info_cache.maybe_get(type_entry); |
| 15812 | if (entry != nullptr) |
| 15813 | return entry->value; |
| 15814 | |
| 15815 | // Fallthrough if we don't find one. |
| 15816 | } |
| 15890 | 15817 | case TypeTableEntryIdInt: |
| 15891 | 15818 | { |
| 15892 | | ConstExprValue *result = create_const_vals(1); |
| 15819 | result = create_const_vals(1); |
| 15893 | 15820 | result->special = ConstValSpecialStatic; |
| 15894 | 15821 | result->type = ir_type_info_get_type(ira, "Int"); |
| 15895 | 15822 | |
| 15896 | 15823 | ConstExprValue *fields = create_const_vals(2); |
| 15897 | 15824 | result->data.x_struct.fields = fields; |
| 15898 | 15825 | |
| 15899 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 15900 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 15901 | | |
| 15902 | 15826 | // is_signed: bool |
| 15903 | 15827 | ensure_field_index(result->type, "is_signed", 0); |
| 15904 | 15828 | fields[0].special = ConstValSpecialStatic; |
| ... | ... | @@ -15910,40 +15834,34 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15910 | 15834 | fields[1].type = ira->codegen->builtin_types.entry_u8; |
| 15911 | 15835 | bigint_init_unsigned(&fields[1].data.x_bigint, type_entry->data.integral.bit_count); |
| 15912 | 15836 | |
| 15913 | | return result; |
| 15837 | break; |
| 15914 | 15838 | } |
| 15915 | 15839 | case TypeTableEntryIdFloat: |
| 15916 | 15840 | { |
| 15917 | | ConstExprValue *result = create_const_vals(1); |
| 15841 | result = create_const_vals(1); |
| 15918 | 15842 | result->special = ConstValSpecialStatic; |
| 15919 | 15843 | result->type = ir_type_info_get_type(ira, "Float"); |
| 15920 | 15844 | |
| 15921 | 15845 | ConstExprValue *fields = create_const_vals(1); |
| 15922 | 15846 | result->data.x_struct.fields = fields; |
| 15923 | 15847 | |
| 15924 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 15925 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 15926 | | |
| 15927 | 15848 | // bits: u8 |
| 15928 | 15849 | ensure_field_index(result->type, "bits", 0); |
| 15929 | 15850 | fields[0].special = ConstValSpecialStatic; |
| 15930 | 15851 | fields[0].type = ira->codegen->builtin_types.entry_u8; |
| 15931 | 15852 | bigint_init_unsigned(&fields->data.x_bigint, type_entry->data.floating.bit_count); |
| 15932 | 15853 | |
| 15933 | | return result; |
| 15854 | break; |
| 15934 | 15855 | } |
| 15935 | 15856 | case TypeTableEntryIdPointer: |
| 15936 | 15857 | { |
| 15937 | | ConstExprValue *result = create_const_vals(1); |
| 15858 | result = create_const_vals(1); |
| 15938 | 15859 | result->special = ConstValSpecialStatic; |
| 15939 | 15860 | result->type = ir_type_info_get_type(ira, "Pointer"); |
| 15940 | 15861 | |
| 15941 | 15862 | ConstExprValue *fields = create_const_vals(4); |
| 15942 | 15863 | result->data.x_struct.fields = fields; |
| 15943 | 15864 | |
| 15944 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 15945 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 15946 | | |
| 15947 | 15865 | // is_const: bool |
| 15948 | 15866 | ensure_field_index(result->type, "is_const", 0); |
| 15949 | 15867 | fields[0].special = ConstValSpecialStatic; |
| ... | ... | @@ -15959,175 +15877,94 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15959 | 15877 | fields[2].special = ConstValSpecialStatic; |
| 15960 | 15878 | fields[2].type = ira->codegen->builtin_types.entry_u32; |
| 15961 | 15879 | bigint_init_unsigned(&fields[2].data.x_bigint, type_entry->data.pointer.alignment); |
| 15962 | | // child: &TypeInfo |
| 15880 | // child: type |
| 15963 | 15881 | ensure_field_index(result->type, "child", 3); |
| 15964 | | |
| 15965 | | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 15966 | | |
| 15967 | 15882 | fields[3].special = ConstValSpecialStatic; |
| 15968 | | fields[3].type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 15969 | | fields[3].data.x_ptr.special = ConstPtrSpecialRef; |
| 15970 | | fields[3].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15971 | | ConstExprValue *union_val = create_const_vals(1); |
| 15972 | | union_val->special = ConstValSpecialStatic; |
| 15973 | | union_val->type = type_info_type; |
| 15974 | | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id)); |
| 15883 | fields[3].type = ira->codegen->builtin_types.entry_type; |
| 15884 | fields[3].data.x_type = type_entry->data.pointer.child_type; |
| 15975 | 15885 | |
| 15976 | | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| 15977 | | type_entry->data.pointer.child_type); |
| 15978 | | |
| 15979 | | fields[3].data.x_ptr.data.ref.pointee = union_val; |
| 15980 | | |
| 15981 | | return result; |
| 15886 | break; |
| 15982 | 15887 | } |
| 15983 | 15888 | case TypeTableEntryIdArray: |
| 15984 | 15889 | { |
| 15985 | | ConstExprValue *result = create_const_vals(1); |
| 15890 | result = create_const_vals(1); |
| 15986 | 15891 | result->special = ConstValSpecialStatic; |
| 15987 | 15892 | result->type = ir_type_info_get_type(ira, "Array"); |
| 15988 | 15893 | |
| 15989 | 15894 | ConstExprValue *fields = create_const_vals(2); |
| 15990 | 15895 | result->data.x_struct.fields = fields; |
| 15991 | 15896 | |
| 15992 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 15993 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 15994 | | |
| 15995 | 15897 | // len: usize |
| 15996 | 15898 | ensure_field_index(result->type, "len", 0); |
| 15997 | 15899 | fields[0].special = ConstValSpecialStatic; |
| 15998 | 15900 | fields[0].type = ira->codegen->builtin_types.entry_usize; |
| 15999 | 15901 | bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len); |
| 16000 | | // child: &TypeInfo |
| 15902 | // child: type |
| 16001 | 15903 | ensure_field_index(result->type, "child", 1); |
| 16002 | | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 16003 | | |
| 16004 | 15904 | fields[1].special = ConstValSpecialStatic; |
| 16005 | | fields[1].type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 16006 | | fields[1].data.x_ptr.special = ConstPtrSpecialRef; |
| 16007 | | fields[1].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16008 | | ConstExprValue *union_val = create_const_vals(1); |
| 16009 | | union_val->special = ConstValSpecialStatic; |
| 16010 | | union_val->type = type_info_type; |
| 16011 | | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id)); |
| 15905 | fields[1].type = ira->codegen->builtin_types.entry_type; |
| 15906 | fields[1].data.x_type = type_entry->data.array.child_type; |
| 16012 | 15907 | |
| 16013 | | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| 16014 | | type_entry->data.array.child_type); |
| 16015 | | |
| 16016 | | fields[1].data.x_ptr.data.ref.pointee = union_val; |
| 16017 | | |
| 16018 | | return result; |
| 15908 | break; |
| 16019 | 15909 | } |
| 16020 | 15910 | case TypeTableEntryIdMaybe: |
| 16021 | 15911 | { |
| 16022 | | ConstExprValue *result = create_const_vals(1); |
| 15912 | result = create_const_vals(1); |
| 16023 | 15913 | result->special = ConstValSpecialStatic; |
| 16024 | 15914 | result->type = ir_type_info_get_type(ira, "Nullable"); |
| 16025 | 15915 | |
| 16026 | 15916 | ConstExprValue *fields = create_const_vals(1); |
| 16027 | 15917 | result->data.x_struct.fields = fields; |
| 16028 | 15918 | |
| 16029 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 16030 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 16031 | | |
| 16032 | | // child: &TypeInfo |
| 15919 | // child: type |
| 16033 | 15920 | ensure_field_index(result->type, "child", 0); |
| 16034 | | |
| 16035 | | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 16036 | | |
| 16037 | 15921 | fields[0].special = ConstValSpecialStatic; |
| 16038 | | fields[0].type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 16039 | | fields[0].data.x_ptr.special = ConstPtrSpecialRef; |
| 16040 | | fields[0].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16041 | | ConstExprValue *union_val = create_const_vals(1); |
| 16042 | | union_val->special = ConstValSpecialStatic; |
| 16043 | | union_val->type = type_info_type; |
| 16044 | | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id)); |
| 16045 | | |
| 16046 | | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| 16047 | | type_entry->data.maybe.child_type); |
| 16048 | | |
| 16049 | | fields[0].data.x_ptr.data.ref.pointee = union_val; |
| 15922 | fields[0].type = ira->codegen->builtin_types.entry_type; |
| 15923 | fields[0].data.x_type = type_entry->data.maybe.child_type; |
| 16050 | 15924 | |
| 16051 | | return result; |
| 15925 | break; |
| 16052 | 15926 | } |
| 16053 | 15927 | case TypeTableEntryIdPromise: |
| 16054 | 15928 | { |
| 16055 | | ConstExprValue *result = create_const_vals(1); |
| 15929 | result = create_const_vals(1); |
| 16056 | 15930 | result->special = ConstValSpecialStatic; |
| 16057 | 15931 | result->type = ir_type_info_get_type(ira, "Promise"); |
| 16058 | 15932 | |
| 16059 | 15933 | ConstExprValue *fields = create_const_vals(1); |
| 16060 | 15934 | result->data.x_struct.fields = fields; |
| 16061 | 15935 | |
| 16062 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 16063 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 16064 | | |
| 16065 | | // child: ?&TypeInfo |
| 15936 | // @TODO ?type instead of using @typeOf(undefined) when we have no type. |
| 15937 | // child: type |
| 16066 | 15938 | ensure_field_index(result->type, "child", 0); |
| 16067 | | |
| 16068 | | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 16069 | | TypeTableEntry *type_info_ptr_type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 16070 | | |
| 16071 | 15939 | fields[0].special = ConstValSpecialStatic; |
| 16072 | | fields[0].type = get_maybe_type(ira->codegen, type_info_ptr_type); |
| 15940 | fields[0].type = ira->codegen->builtin_types.entry_type; |
| 16073 | 15941 | |
| 16074 | 15942 | if (type_entry->data.promise.result_type == nullptr) |
| 16075 | | { |
| 16076 | | fields[0].data.x_maybe = nullptr; |
| 16077 | | } |
| 15943 | fields[0].data.x_type = ira->codegen->builtin_types.entry_undef; |
| 16078 | 15944 | else |
| 16079 | | { |
| 16080 | | ConstExprValue *maybe_value = create_const_vals(1); |
| 16081 | | maybe_value->special = ConstValSpecialStatic; |
| 16082 | | maybe_value->type = type_info_ptr_type; |
| 16083 | | |
| 16084 | | maybe_value->data.x_ptr.special = ConstPtrSpecialRef; |
| 16085 | | maybe_value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16086 | | |
| 16087 | | ConstExprValue *union_val = create_const_vals(1); |
| 16088 | | union_val->special = ConstValSpecialStatic; |
| 16089 | | union_val->type = type_info_type; |
| 16090 | | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id)); |
| 16091 | | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| 16092 | | type_entry->data.promise.result_type); |
| 16093 | | |
| 16094 | | maybe_value->data.x_ptr.data.ref.pointee = union_val; |
| 16095 | | fields[0].data.x_maybe = maybe_value; |
| 16096 | | } |
| 15945 | fields[0].data.x_type = type_entry->data.promise.result_type; |
| 16097 | 15946 | |
| 16098 | | return result; |
| 15947 | break; |
| 16099 | 15948 | } |
| 16100 | 15949 | case TypeTableEntryIdEnum: |
| 16101 | 15950 | { |
| 16102 | | ConstExprValue *result = create_const_vals(1); |
| 15951 | result = create_const_vals(1); |
| 16103 | 15952 | result->special = ConstValSpecialStatic; |
| 16104 | 15953 | result->type = ir_type_info_get_type(ira, "Enum"); |
| 16105 | 15954 | |
| 16106 | 15955 | ConstExprValue *fields = create_const_vals(4); |
| 16107 | 15956 | result->data.x_struct.fields = fields; |
| 16108 | 15957 | |
| 16109 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 16110 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 16111 | | |
| 16112 | 15958 | // layout: ContainerLayout |
| 16113 | 15959 | ensure_field_index(result->type, "layout", 0); |
| 16114 | 15960 | fields[0].special = ConstValSpecialStatic; |
| 16115 | 15961 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout"); |
| 16116 | 15962 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.enumeration.layout); |
| 16117 | | // tag_type: &TypeInfo.Int |
| 15963 | // tag_type: type |
| 16118 | 15964 | ensure_field_index(result->type, "tag_type", 1); |
| 16119 | | |
| 16120 | | TypeTableEntry *type_info_int_type = ir_type_info_get_type(ira, "Int"); |
| 16121 | | |
| 16122 | 15965 | fields[1].special = ConstValSpecialStatic; |
| 16123 | | fields[1].type = get_pointer_to_type(ira->codegen, type_info_int_type, false); |
| 16124 | | fields[1].data.x_ptr.special = ConstPtrSpecialRef; |
| 16125 | | fields[1].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16126 | | |
| 16127 | | ConstExprValue *tag_type_info_struct = ir_make_type_info_value(ira, &fields[1], -1, |
| 16128 | | type_entry->data.enumeration.tag_int_type); |
| 16129 | | assert(tag_type_info_struct->type == type_info_int_type); |
| 16130 | | fields[1].data.x_ptr.data.ref.pointee = tag_type_info_struct; |
| 15966 | fields[1].type = ira->codegen->builtin_types.entry_type; |
| 15967 | fields[1].data.x_type = type_entry->data.enumeration.tag_int_type; |
| 16131 | 15968 | // fields: []TypeInfo.EnumField |
| 16132 | 15969 | ensure_field_index(result->type, "fields", 2); |
| 16133 | 15970 | |
| ... | ... | @@ -16172,20 +16009,17 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 16172 | 16009 | |
| 16173 | 16010 | // @TODO |
| 16174 | 16011 | // methods: []TypeInfo.Method |
| 16175 | | return result; |
| 16012 | break; |
| 16176 | 16013 | } |
| 16177 | 16014 | case TypeTableEntryIdErrorSet: |
| 16178 | 16015 | { |
| 16179 | | ConstExprValue *result = create_const_vals(1); |
| 16016 | result = create_const_vals(1); |
| 16180 | 16017 | result->special = ConstValSpecialStatic; |
| 16181 | 16018 | result->type = ir_type_info_get_type(ira, "ErrorSet"); |
| 16182 | 16019 | |
| 16183 | 16020 | ConstExprValue *fields = create_const_vals(1); |
| 16184 | 16021 | result->data.x_struct.fields = fields; |
| 16185 | 16022 | |
| 16186 | | ir_type_info_struct_set_parent(result, parent, parent_field_index); |
| 16187 | | ira->codegen->type_info_cache.put(type_entry, result); |
| 16188 | | |
| 16189 | 16023 | // errors: []TypeInfo.Error |
| 16190 | 16024 | ensure_field_index(result->type, "errors", 0); |
| 16191 | 16025 | |
| ... | ... | @@ -16229,13 +16063,13 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 16229 | 16063 | error_val->data.x_struct.parent.data.p_array.elem_index = error_index; |
| 16230 | 16064 | } |
| 16231 | 16065 | |
| 16232 | | return result; |
| 16066 | break; |
| 16233 | 16067 | } |
| 16234 | | default: |
| 16235 | | zig_unreachable(); |
| 16236 | 16068 | } |
| 16237 | 16069 | |
| 16238 | | zig_unreachable(); |
| 16070 | assert(result != nullptr); |
| 16071 | ira->codegen->type_info_cache.put(type_entry, result); |
| 16072 | return result; |
| 16239 | 16073 | } |
| 16240 | 16074 | |
| 16241 | 16075 | static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| ... | ... | @@ -16251,7 +16085,16 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 16251 | 16085 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 16252 | 16086 | out_val->type = result_type; |
| 16253 | 16087 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry->id)); |
| 16254 | | out_val->data.x_union.payload = ir_make_type_info_value(ira, out_val, -1, type_entry); |
| 16088 | |
| 16089 | ConstExprValue *payload = ir_make_type_info_value(ira, type_entry); |
| 16090 | out_val->data.x_union.payload = payload; |
| 16091 | |
| 16092 | if (payload != nullptr) |
| 16093 | { |
| 16094 | assert(payload->type->id == TypeTableEntryIdStruct); |
| 16095 | payload->data.x_struct.parent.id = ConstParentIdUnion; |
| 16096 | payload->data.x_struct.parent.data.p_union.union_val = out_val; |
| 16097 | } |
| 16255 | 16098 | |
| 16256 | 16099 | return result_type; |
| 16257 | 16100 | } |