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