| ... | ... | @@ -15775,17 +15775,20 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr |
| 15775 | 15775 | |
| 15776 | 15776 | static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name) |
| 15777 | 15777 | { |
| 15778 | | ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15779 | | assert(type_info_var->type->id == TypeTableEntryIdMetaType); |
| 15778 | static ConstExprValue *type_info_var = nullptr; |
| 15779 | static TypeTableEntry *type_info_type = nullptr; |
| 15780 | if (type_info_var == nullptr) |
| 15781 | { |
| 15782 | type_info_var = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15783 | assert(type_info_var->type->id == TypeTableEntryIdMetaType); |
| 15780 | 15784 | |
| 15781 | | TypeTableEntry *type_info_type = type_info_var->data.x_type; |
| 15782 | | assert(type_info_type->id == TypeTableEntryIdUnion); |
| 15785 | type_info_type = type_info_var->data.x_type; |
| 15786 | assert(type_info_type->id == TypeTableEntryIdUnion); |
| 15787 | } |
| 15783 | 15788 | |
| 15784 | 15789 | if (type_name == nullptr) |
| 15785 | 15790 | return type_info_type; |
| 15786 | 15791 | |
| 15787 | | // @TODO |
| 15788 | | |
| 15789 | 15792 | ScopeDecls *type_info_scope = get_container_scope(type_info_type); |
| 15790 | 15793 | assert(type_info_scope != nullptr); |
| 15791 | 15794 | |
| ... | ... | @@ -15898,15 +15901,16 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15898 | 15901 | bigint_init_unsigned(&fields[2].data.x_bigint, type_entry->data.pointer.alignment); |
| 15899 | 15902 | // child: &TypeInfo |
| 15900 | 15903 | ensure_field_index(payload->type, "child", 3); |
| 15901 | | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15902 | | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15904 | |
| 15905 | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 15906 | |
| 15903 | 15907 | fields[3].special = ConstValSpecialStatic; |
| 15904 | | fields[3].type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 15908 | fields[3].type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 15905 | 15909 | fields[3].data.x_ptr.special = ConstPtrSpecialRef; |
| 15906 | 15910 | fields[3].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15907 | 15911 | ConstExprValue *union_val = create_const_vals(1); |
| 15908 | 15912 | union_val->special = ConstValSpecialStatic; |
| 15909 | | union_val->type = type_info_type->data.x_type; |
| 15913 | union_val->type = type_info_type; |
| 15910 | 15914 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id)); |
| 15911 | 15915 | |
| 15912 | 15916 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| ... | ... | @@ -15933,15 +15937,16 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15933 | 15937 | bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len); |
| 15934 | 15938 | // child: &TypeInfo |
| 15935 | 15939 | ensure_field_index(payload->type, "child", 1); |
| 15936 | | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15937 | | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15940 | |
| 15941 | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 15942 | |
| 15938 | 15943 | fields[1].special = ConstValSpecialStatic; |
| 15939 | | fields[1].type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 15944 | fields[1].type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 15940 | 15945 | fields[1].data.x_ptr.special = ConstPtrSpecialRef; |
| 15941 | 15946 | fields[1].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15942 | 15947 | ConstExprValue *union_val = create_const_vals(1); |
| 15943 | 15948 | union_val->special = ConstValSpecialStatic; |
| 15944 | | union_val->type = type_info_type->data.x_type; |
| 15949 | union_val->type = type_info_type; |
| 15945 | 15950 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id)); |
| 15946 | 15951 | |
| 15947 | 15952 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| ... | ... | @@ -15963,15 +15968,16 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15963 | 15968 | |
| 15964 | 15969 | // child: &TypeInfo |
| 15965 | 15970 | ensure_field_index(payload->type, "child", 0); |
| 15966 | | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15967 | | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15971 | |
| 15972 | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 15973 | |
| 15968 | 15974 | fields[0].special = ConstValSpecialStatic; |
| 15969 | | fields[0].type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 15975 | fields[0].type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 15970 | 15976 | fields[0].data.x_ptr.special = ConstPtrSpecialRef; |
| 15971 | 15977 | fields[0].data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 15972 | 15978 | ConstExprValue *union_val = create_const_vals(1); |
| 15973 | 15979 | union_val->special = ConstValSpecialStatic; |
| 15974 | | union_val->type = type_info_type->data.x_type; |
| 15980 | union_val->type = type_info_type; |
| 15975 | 15981 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id)); |
| 15976 | 15982 | |
| 15977 | 15983 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| ... | ... | @@ -15993,10 +15999,9 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 15993 | 15999 | |
| 15994 | 16000 | // child: ?&TypeInfo |
| 15995 | 16001 | ensure_field_index(payload->type, "child", 0); |
| 15996 | | ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo"); |
| 15997 | | assert(type_info_type->type->id == TypeTableEntryIdMetaType); |
| 15998 | 16002 | |
| 15999 | | TypeTableEntry *type_info_ptr_type = get_pointer_to_type(ira->codegen, type_info_type->data.x_type, false); |
| 16003 | TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr); |
| 16004 | TypeTableEntry *type_info_ptr_type = get_pointer_to_type(ira->codegen, type_info_type, false); |
| 16000 | 16005 | |
| 16001 | 16006 | fields[0].special = ConstValSpecialStatic; |
| 16002 | 16007 | fields[0].type = get_maybe_type(ira->codegen, type_info_ptr_type); |
| ... | ... | @@ -16016,7 +16021,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p |
| 16016 | 16021 | |
| 16017 | 16022 | ConstExprValue *union_val = create_const_vals(1); |
| 16018 | 16023 | union_val->special = ConstValSpecialStatic; |
| 16019 | | union_val->type = type_info_type->data.x_type; |
| 16024 | union_val->type = type_info_type; |
| 16020 | 16025 | bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id)); |
| 16021 | 16026 | union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, |
| 16022 | 16027 | type_entry->data.promise.result_type); |