| ... | @@ -15747,7 +15747,7 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz | ... | @@ -15747,7 +15747,7 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz |
| 15747 | (buf_deinit(field_name_buf), true)); | 15747 | (buf_deinit(field_name_buf), true)); |
| 15748 | } | 15748 | } |
| 15749 | | 15749 | |
| 15750 | static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExprValue *parent) { | 15750 | static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExprValue *parent, ssize_t parent_field_index) { |
| 15751 | assert(struct_val->type->id == TypeTableEntryIdStruct); | 15751 | assert(struct_val->type->id == TypeTableEntryIdStruct); |
| 15752 | assert(parent->type != nullptr && !type_is_invalid(parent->type)); | 15752 | assert(parent->type != nullptr && !type_is_invalid(parent->type)); |
| 15753 | | 15753 | |
| ... | @@ -15756,10 +15756,13 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr | ... | @@ -15756,10 +15756,13 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr |
| 15756 | case TypeTableEntryIdArray: | 15756 | case TypeTableEntryIdArray: |
| 15757 | zig_panic("TODO - Only expected struct or union parent."); | 15757 | zig_panic("TODO - Only expected struct or union parent."); |
| 15758 | case TypeTableEntryIdStruct: | 15758 | case TypeTableEntryIdStruct: |
| | 15759 | assert(parent_field_index >= 0); |
| 15759 | struct_val->data.x_struct.parent.id = ConstParentIdStruct; | 15760 | struct_val->data.x_struct.parent.id = ConstParentIdStruct; |
| 15760 | struct_val->data.x_struct.parent.data.p_union.union_val = parent; | 15761 | struct_val->data.x_struct.parent.data.p_struct.struct_val = parent; |
| | 15762 | struct_val->data.x_struct.parent.data.p_struct.field_index = parent_field_index; |
| 15761 | break; | 15763 | break; |
| 15762 | case TypeTableEntryIdUnion: | 15764 | case TypeTableEntryIdUnion: |
| | 15765 | assert(parent_field_index == -1); |
| 15763 | struct_val->data.x_struct.parent.id = ConstParentIdUnion; | 15766 | struct_val->data.x_struct.parent.id = ConstParentIdUnion; |
| 15764 | struct_val->data.x_struct.parent.data.p_union.union_val = parent; | 15767 | struct_val->data.x_struct.parent.data.p_union.union_val = parent; |
| 15765 | break; | 15768 | break; |
| ... | @@ -15768,7 +15771,8 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr | ... | @@ -15768,7 +15771,8 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr |
| 15768 | } | 15771 | } |
| 15769 | } | 15772 | } |
| 15770 | | 15773 | |
| 15771 | static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *parent, TypeTableEntry *type_entry) | 15774 | static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *parent, |
| | 15775 | ssize_t parent_field_index, TypeTableEntry *type_entry) |
| 15772 | { | 15776 | { |
| 15773 | assert(type_entry != nullptr); | 15777 | assert(type_entry != nullptr); |
| 15774 | assert(!type_is_invalid(type_entry)); | 15778 | assert(!type_is_invalid(type_entry)); |
| ... | @@ -15802,7 +15806,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15802,7 +15806,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15802 | ConstExprValue *fields = create_const_vals(2); | 15806 | ConstExprValue *fields = create_const_vals(2); |
| 15803 | payload->data.x_struct.fields = fields; | 15807 | payload->data.x_struct.fields = fields; |
| 15804 | | 15808 | |
| 15805 | ir_type_info_struct_set_parent(payload, parent); | 15809 | ir_type_info_struct_set_parent(payload, parent, parent_field_index); |
| 15806 | | 15810 | |
| 15807 | // is_signed: bool | 15811 | // is_signed: bool |
| 15808 | ensure_field_index(payload->type, "is_signed", 0); | 15812 | ensure_field_index(payload->type, "is_signed", 0); |
| ... | @@ -15829,7 +15833,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15829,7 +15833,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15829 | ConstExprValue *fields = create_const_vals(1); | 15833 | ConstExprValue *fields = create_const_vals(1); |
| 15830 | payload->data.x_struct.fields = fields; | 15834 | payload->data.x_struct.fields = fields; |
| 15831 | | 15835 | |
| 15832 | ir_type_info_struct_set_parent(payload, parent); | 15836 | ir_type_info_struct_set_parent(payload, parent, parent_field_index); |
| 15833 | | 15837 | |
| 15834 | // bits: u8 | 15838 | // bits: u8 |
| 15835 | ensure_field_index(payload->type, "bits", 0); | 15839 | ensure_field_index(payload->type, "bits", 0); |
| ... | @@ -15851,7 +15855,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15851,7 +15855,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15851 | ConstExprValue *fields = create_const_vals(4); | 15855 | ConstExprValue *fields = create_const_vals(4); |
| 15852 | payload->data.x_struct.fields = fields; | 15856 | payload->data.x_struct.fields = fields; |
| 15853 | | 15857 | |
| 15854 | ir_type_info_struct_set_parent(payload, parent); | 15858 | ir_type_info_struct_set_parent(payload, parent, parent_field_index); |
| 15855 | | 15859 | |
| 15856 | // is_const: bool | 15860 | // is_const: bool |
| 15857 | ensure_field_index(payload->type, "is_const", 0); | 15861 | ensure_field_index(payload->type, "is_const", 0); |
| ... | @@ -15880,7 +15884,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15880,7 +15884,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15880 | union_val->special = ConstValSpecialStatic; | 15884 | union_val->special = ConstValSpecialStatic; |
| 15881 | union_val->type = type_info_type->data.x_type; | 15885 | union_val->type = type_info_type->data.x_type; |
| 15882 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id)); | 15886 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id)); |
| 15883 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.pointer.child_type); | 15887 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.pointer.child_type); |
| 15884 | fields[3].data.x_ptr.data.ref.pointee = union_val; | 15888 | fields[3].data.x_ptr.data.ref.pointee = union_val; |
| 15885 | return payload; | 15889 | return payload; |
| 15886 | } | 15890 | } |
| ... | @@ -15896,7 +15900,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15896,7 +15900,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15896 | ConstExprValue *fields = create_const_vals(2); | 15900 | ConstExprValue *fields = create_const_vals(2); |
| 15897 | payload->data.x_struct.fields = fields; | 15901 | payload->data.x_struct.fields = fields; |
| 15898 | | 15902 | |
| 15899 | ir_type_info_struct_set_parent(payload, parent); | 15903 | ir_type_info_struct_set_parent(payload, parent, parent_field_index); |
| 15900 | | 15904 | |
| 15901 | // len: usize | 15905 | // len: usize |
| 15902 | ensure_field_index(payload->type, "len", 0); | 15906 | ensure_field_index(payload->type, "len", 0); |
| ... | @@ -15915,7 +15919,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15915,7 +15919,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15915 | union_val->special = ConstValSpecialStatic; | 15919 | union_val->special = ConstValSpecialStatic; |
| 15916 | union_val->type = type_info_type->data.x_type; | 15920 | union_val->type = type_info_type->data.x_type; |
| 15917 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id)); | 15921 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id)); |
| 15918 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.array.child_type); | 15922 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.array.child_type); |
| 15919 | fields[1].data.x_ptr.data.ref.pointee = union_val; | 15923 | fields[1].data.x_ptr.data.ref.pointee = union_val; |
| 15920 | return payload; | 15924 | return payload; |
| 15921 | } | 15925 | } |
| ... | @@ -15931,7 +15935,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15931,7 +15935,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15931 | ConstExprValue *fields = create_const_vals(1); | 15935 | ConstExprValue *fields = create_const_vals(1); |
| 15932 | payload->data.x_struct.fields = fields; | 15936 | payload->data.x_struct.fields = fields; |
| 15933 | | 15937 | |
| 15934 | ir_type_info_struct_set_parent(payload, parent); | 15938 | ir_type_info_struct_set_parent(payload, parent, parent_field_index); |
| 15935 | | 15939 | |
| 15936 | // child: &TypeInfo | 15940 | // child: &TypeInfo |
| 15937 | ensure_field_index(payload->type, "child", 0); | 15941 | ensure_field_index(payload->type, "child", 0); |
| ... | @@ -15945,7 +15949,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15945,7 +15949,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15945 | union_val->special = ConstValSpecialStatic; | 15949 | union_val->special = ConstValSpecialStatic; |
| 15946 | union_val->type = type_info_type->data.x_type; | 15950 | union_val->type = type_info_type->data.x_type; |
| 15947 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id)); | 15951 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id)); |
| 15948 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.maybe.child_type); | 15952 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.maybe.child_type); |
| 15949 | fields[0].data.x_ptr.data.ref.pointee = union_val; | 15953 | fields[0].data.x_ptr.data.ref.pointee = union_val; |
| 15950 | return payload; | 15954 | return payload; |
| 15951 | } | 15955 | } |
| ... | @@ -15961,7 +15965,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15961,7 +15965,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15961 | ConstExprValue *fields = create_const_vals(1); | 15965 | ConstExprValue *fields = create_const_vals(1); |
| 15962 | payload->data.x_struct.fields = fields; | 15966 | payload->data.x_struct.fields = fields; |
| 15963 | | 15967 | |
| 15964 | ir_type_info_struct_set_parent(payload, parent); | 15968 | ir_type_info_struct_set_parent(payload, parent, parent_field_index); |
| 15965 | | 15969 | |
| 15966 | // child: ?&TypeInfo | 15970 | // child: ?&TypeInfo |
| 15967 | ensure_field_index(payload->type, "child", 0); | 15971 | ensure_field_index(payload->type, "child", 0); |
| ... | @@ -15990,7 +15994,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p | ... | @@ -15990,7 +15994,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15990 | union_val->special = ConstValSpecialStatic; | 15994 | union_val->special = ConstValSpecialStatic; |
| 15991 | union_val->type = type_info_type->data.x_type; | 15995 | union_val->type = type_info_type->data.x_type; |
| 15992 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id)); | 15996 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id)); |
| 15993 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.promise.result_type); | 15997 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.promise.result_type); |
| 15994 | | 15998 | |
| 15995 | maybe_value->data.x_ptr.data.ref.pointee = union_val; | 15999 | maybe_value->data.x_ptr.data.ref.pointee = union_val; |
| 15996 | fields[0].data.x_maybe = maybe_value; | 16000 | fields[0].data.x_maybe = maybe_value; |
| ... | @@ -16017,7 +16021,7 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -16017,7 +16021,7 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 16017 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); | 16021 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 16018 | out_val->type = result_type; | 16022 | out_val->type = result_type; |
| 16019 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry->id)); | 16023 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry->id)); |
| 16020 | out_val->data.x_union.payload = ir_make_type_info_value(ira, out_val, type_entry); | 16024 | out_val->data.x_union.payload = ir_make_type_info_value(ira, out_val, -1, type_entry); |
| 16021 | | 16025 | |
| 16022 | return result_type; | 16026 | return result_type; |
| 16023 | } | 16027 | } |