| ... | ... | @@ -15875,6 +15875,151 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15875 | 15875 | fields[3].data.x_ptr.data.ref.pointee = union_val; |
| 15876 | 15876 | return payload; |
| 15877 | 15877 | } |
| 15878 | case TypeTableEntryIdArray: |
| 15879 | { |
| 15880 | ConstExprValue *payload = create_const_vals(1); |
| 15881 | payload->special = ConstValSpecialStatic; |
| 15882 | |
| 15883 | ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "ArrayInfo"); |
| 15884 | assert(pointer_info_type->type->id == TypeTableEntryIdMetaType); |
| 15885 | payload->type = pointer_info_type->data.x_type; |
| 15886 | |
| 15887 | ConstExprValue *fields = create_const_vals(2); |
| 15888 | payload->data.x_struct.fields = fields; |
| 15889 | |
| 15890 | if (parent->type->id == TypeTableEntryIdStruct) |
| 15891 | { |
| 15892 | payload->data.x_struct.parent.id = ConstParentIdStruct; |
| 15893 | payload->data.x_struct.parent.data.p_union.union_val = parent; |
| 15894 | } |
| 15895 | else if (parent->type->id == TypeTableEntryIdUnion) |
| 15896 | { |
| 15897 | payload->data.x_struct.parent.id = ConstParentIdUnion; |
| 15898 | payload->data.x_struct.parent.data.p_union.union_val = parent; |
| 15899 | } |
| 15900 | else |
| 15901 | { |
| 15902 | payload->data.x_struct.parent.id = ConstParentIdNone; |
| 15903 | } |
| 15904 | // len: usize |
| 15905 | fields[0].special = ConstValSpecialStatic; |
| 15906 | fields[0].type = ira->codegen->builtin_types.entry_usize; |
| 15907 | bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len); |
| 15908 | // child: &TypeInfo |
| 15909 | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15910 | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15911 | fields[1].special = ConstValSpecialStatic; |
| 15912 | fields[1].type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 15913 | fields[1].data.x_ptr.special = ConstPtrSpecialRef; |
| 15914 | fields[1].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15915 | ConstExprValue *union_val = create_const_vals(1); |
| 15916 | union_val->special = ConstValSpecialStatic; |
| 15917 | union_val->type = type_info_type->data.x_type; |
| 15918 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id)); |
| 15919 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.array.child_type); |
| 15920 | fields[1].data.x_ptr.data.ref.pointee = union_val; |
| 15921 | return payload; |
| 15922 | } |
| 15923 | case TypeTableEntryIdMaybe: |
| 15924 | { |
| 15925 | ConstExprValue *payload = create_const_vals(1); |
| 15926 | payload->special = ConstValSpecialStatic; |
| 15927 | |
| 15928 | ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "NullableInfo"); |
| 15929 | assert(pointer_info_type->type->id == TypeTableEntryIdMetaType); |
| 15930 | payload->type = pointer_info_type->data.x_type; |
| 15931 | |
| 15932 | ConstExprValue *fields = create_const_vals(1); |
| 15933 | payload->data.x_struct.fields = fields; |
| 15934 | |
| 15935 | if (parent->type->id == TypeTableEntryIdStruct) |
| 15936 | { |
| 15937 | payload->data.x_struct.parent.id = ConstParentIdStruct; |
| 15938 | payload->data.x_struct.parent.data.p_union.union_val = parent; |
| 15939 | } |
| 15940 | else if (parent->type->id == TypeTableEntryIdUnion) |
| 15941 | { |
| 15942 | payload->data.x_struct.parent.id = ConstParentIdUnion; |
| 15943 | payload->data.x_struct.parent.data.p_union.union_val = parent; |
| 15944 | } |
| 15945 | else |
| 15946 | { |
| 15947 | payload->data.x_struct.parent.id = ConstParentIdNone; |
| 15948 | } |
| 15949 | // child: &TypeInfo |
| 15950 | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15951 | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15952 | fields[0].special = ConstValSpecialStatic; |
| 15953 | fields[0].type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 15954 | fields[0].data.x_ptr.special = ConstPtrSpecialRef; |
| 15955 | fields[0].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15956 | ConstExprValue *union_val = create_const_vals(1); |
| 15957 | union_val->special = ConstValSpecialStatic; |
| 15958 | union_val->type = type_info_type->data.x_type; |
| 15959 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id)); |
| 15960 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.maybe.child_type); |
| 15961 | fields[0].data.x_ptr.data.ref.pointee = union_val; |
| 15962 | return payload; |
| 15963 | } |
| 15964 | case TypeTableEntryIdPromise: |
| 15965 | { |
| 15966 | ConstExprValue *payload = create_const_vals(1); |
| 15967 | payload->special = ConstValSpecialStatic; |
| 15968 | |
| 15969 | ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "PromiseInfo"); |
| 15970 | assert(pointer_info_type->type->id == TypeTableEntryIdMetaType); |
| 15971 | payload->type = pointer_info_type->data.x_type; |
| 15972 | |
| 15973 | ConstExprValue *fields = create_const_vals(1); |
| 15974 | payload->data.x_struct.fields = fields; |
| 15975 | |
| 15976 | if (parent->type->id == TypeTableEntryIdStruct) |
| 15977 | { |
| 15978 | payload->data.x_struct.parent.id = ConstParentIdStruct; |
| 15979 | payload->data.x_struct.parent.data.p_union.union_val = parent; |
| 15980 | } |
| 15981 | else if (parent->type->id == TypeTableEntryIdUnion) |
| 15982 | { |
| 15983 | payload->data.x_struct.parent.id = ConstParentIdUnion; |
| 15984 | payload->data.x_struct.parent.data.p_union.union_val = parent; |
| 15985 | } |
| 15986 | else |
| 15987 | { |
| 15988 | payload->data.x_struct.parent.id = ConstParentIdNone; |
| 15989 | } |
| 15990 | // child: ?&TypeInfo |
| 15991 | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15992 | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15993 | |
| 15994 | TypeTableEntry *type_info_ptr_type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 15995 | |
| 15996 | fields[0].special = ConstValSpecialStatic; |
| 15997 | fields[0].type = get_maybe_type(ira->codegen, type_info_ptr_type); |
| 15998 | |
| 15999 | if (type_entry->data.promise.result_type == nullptr) |
| 16000 | { |
| 16001 | fields[0].data.x_maybe = nullptr; |
| 16002 | } |
| 16003 | else |
| 16004 | { |
| 16005 | ConstExprValue *maybe_value = create_const_vals(1); |
| 16006 | maybe_value->special = ConstValSpecialStatic; |
| 16007 | maybe_value->type = type_info_ptr_type; |
| 16008 | |
| 16009 | maybe_value->data.x_ptr.special = ConstPtrSpecialRef; |
| 16010 | maybe_value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 16011 | |
| 16012 | ConstExprValue *union_val = create_const_vals(1); |
| 16013 | union_val->special = ConstValSpecialStatic; |
| 16014 | union_val->type = type_info_type->data.x_type; |
| 16015 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id)); |
| 16016 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, type_entry->data.promise.result_type); |
| 16017 | |
| 16018 | maybe_value->data.x_ptr.data.ref.pointee = union_val; |
| 16019 | fields[0].data.x_maybe = maybe_value; |
| 16020 | } |
| 16021 | return payload; |
| 16022 | } |
| 15878 | 16023 | default: |
| 15879 | 16024 | zig_unreachable(); |
| 15880 | 16025 | } |