| ... | ... | @@ -16789,16 +16789,20 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16789 | 16789 | ConstExprValue *fields = create_const_vals(1); |
| 16790 | 16790 | result->data.x_struct.fields = fields; |
| 16791 | 16791 | |
| 16792 | | // @TODO ?type instead of using @typeOf(undefined) when we have no type. |
| 16793 | | // child: type |
| 16792 | // child: ?type |
| 16794 | 16793 | ensure_field_index(result->type, "child", 0); |
| 16795 | 16794 | fields[0].special = ConstValSpecialStatic; |
| 16796 | | fields[0].type = ira->codegen->builtin_types.entry_type; |
| 16795 | fields[0].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 16797 | 16796 | |
| 16798 | 16797 | if (type_entry->data.promise.result_type == nullptr) |
| 16799 | | fields[0].data.x_type = ira->codegen->builtin_types.entry_undef; |
| 16800 | | else |
| 16801 | | fields[0].data.x_type = type_entry->data.promise.result_type; |
| 16798 | fields[0].data.x_optional = nullptr; |
| 16799 | else { |
| 16800 | ConstExprValue *child_type = create_const_vals(1); |
| 16801 | child_type->special = ConstValSpecialStatic; |
| 16802 | child_type->type = ira->codegen->builtin_types.entry_type; |
| 16803 | child_type->data.x_type = type_entry->data.promise.result_type; |
| 16804 | fields[0].data.x_optional = child_type; |
| 16805 | } |
| 16802 | 16806 | |
| 16803 | 16807 | break; |
| 16804 | 16808 | } |
| ... | ... | @@ -16939,19 +16943,23 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16939 | 16943 | fields[0].special = ConstValSpecialStatic; |
| 16940 | 16944 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout"); |
| 16941 | 16945 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout); |
| 16942 | | // tag_type: type |
| 16946 | // tag_type: ?type |
| 16943 | 16947 | ensure_field_index(result->type, "tag_type", 1); |
| 16944 | 16948 | fields[1].special = ConstValSpecialStatic; |
| 16945 | | fields[1].type = ira->codegen->builtin_types.entry_type; |
| 16946 | | // @TODO ?type instead of using @typeOf(undefined) when we have no type. |
| 16949 | fields[1].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 16950 | |
| 16947 | 16951 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; |
| 16948 | 16952 | if (union_decl_node->data.container_decl.auto_enum || |
| 16949 | 16953 | union_decl_node->data.container_decl.init_arg_expr != nullptr) |
| 16950 | 16954 | { |
| 16951 | | fields[1].data.x_type = type_entry->data.unionation.tag_type; |
| 16955 | ConstExprValue *tag_type = create_const_vals(1); |
| 16956 | tag_type->special = ConstValSpecialStatic; |
| 16957 | tag_type->type = ira->codegen->builtin_types.entry_type; |
| 16958 | tag_type->data.x_type = type_entry->data.unionation.tag_type; |
| 16959 | fields[1].data.x_optional = tag_type; |
| 16952 | 16960 | } |
| 16953 | 16961 | else |
| 16954 | | fields[1].data.x_type = ira->codegen->builtin_types.entry_undef; |
| 16962 | fields[1].data.x_optional = nullptr; |
| 16955 | 16963 | // fields: []TypeInfo.UnionField |
| 16956 | 16964 | ensure_field_index(result->type, "fields", 2); |
| 16957 | 16965 | |
| ... | ... | @@ -16980,7 +16988,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16980 | 16988 | inner_fields[1].special = ConstValSpecialStatic; |
| 16981 | 16989 | inner_fields[1].type = get_maybe_type(ira->codegen, type_info_enum_field_type); |
| 16982 | 16990 | |
| 16983 | | if (fields[1].data.x_type == ira->codegen->builtin_types.entry_undef) { |
| 16991 | if (fields[1].data.x_optional == nullptr) { |
| 16984 | 16992 | inner_fields[1].data.x_optional = nullptr; |
| 16985 | 16993 | } else { |
| 16986 | 16994 | inner_fields[1].data.x_optional = create_const_vals(1); |
| ... | ... | @@ -17089,8 +17097,6 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17089 | 17097 | ConstExprValue *fields = create_const_vals(6); |
| 17090 | 17098 | result->data.x_struct.fields = fields; |
| 17091 | 17099 | |
| 17092 | | // @TODO Fix type = undefined with ?type |
| 17093 | | |
| 17094 | 17100 | // calling_convention: TypeInfo.CallingConvention |
| 17095 | 17101 | ensure_field_index(result->type, "calling_convention", 0); |
| 17096 | 17102 | fields[0].special = ConstValSpecialStatic; |
| ... | ... | @@ -17108,22 +17114,32 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17108 | 17114 | fields[2].special = ConstValSpecialStatic; |
| 17109 | 17115 | fields[2].type = ira->codegen->builtin_types.entry_bool; |
| 17110 | 17116 | fields[2].data.x_bool = type_entry->data.fn.fn_type_id.is_var_args; |
| 17111 | | // return_type: type |
| 17117 | // return_type: ?type |
| 17112 | 17118 | ensure_field_index(result->type, "return_type", 3); |
| 17113 | 17119 | fields[3].special = ConstValSpecialStatic; |
| 17114 | | fields[3].type = ira->codegen->builtin_types.entry_type; |
| 17120 | fields[3].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 17115 | 17121 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 17116 | | fields[3].data.x_type = ira->codegen->builtin_types.entry_undef; |
| 17117 | | else |
| 17118 | | fields[3].data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| 17122 | fields[3].data.x_optional = nullptr; |
| 17123 | else { |
| 17124 | ConstExprValue *return_type = create_const_vals(1); |
| 17125 | return_type->special = ConstValSpecialStatic; |
| 17126 | return_type->type = ira->codegen->builtin_types.entry_type; |
| 17127 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| 17128 | fields[3].data.x_optional = return_type; |
| 17129 | } |
| 17119 | 17130 | // async_allocator_type: type |
| 17120 | 17131 | ensure_field_index(result->type, "async_allocator_type", 4); |
| 17121 | 17132 | fields[4].special = ConstValSpecialStatic; |
| 17122 | | fields[4].type = ira->codegen->builtin_types.entry_type; |
| 17133 | fields[4].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 17123 | 17134 | if (type_entry->data.fn.fn_type_id.async_allocator_type == nullptr) |
| 17124 | | fields[4].data.x_type = ira->codegen->builtin_types.entry_undef; |
| 17125 | | else |
| 17126 | | fields[4].data.x_type = type_entry->data.fn.fn_type_id.async_allocator_type; |
| 17135 | fields[4].data.x_optional = nullptr; |
| 17136 | else { |
| 17137 | ConstExprValue *async_alloc_type = create_const_vals(1); |
| 17138 | async_alloc_type->special = ConstValSpecialStatic; |
| 17139 | async_alloc_type->type = ira->codegen->builtin_types.entry_type; |
| 17140 | async_alloc_type->data.x_type = type_entry->data.fn.fn_type_id.async_allocator_type; |
| 17141 | fields[4].data.x_optional = async_alloc_type; |
| 17142 | } |
| 17127 | 17143 | // args: []TypeInfo.FnArg |
| 17128 | 17144 | TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg"); |
| 17129 | 17145 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - |
| ... | ... | @@ -17157,12 +17173,17 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17157 | 17173 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; |
| 17158 | 17174 | inner_fields[1].data.x_bool = fn_param_info->is_noalias; |
| 17159 | 17175 | inner_fields[2].special = ConstValSpecialStatic; |
| 17160 | | inner_fields[2].type = ira->codegen->builtin_types.entry_type; |
| 17176 | inner_fields[2].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 17161 | 17177 | |
| 17162 | 17178 | if (arg_is_generic) |
| 17163 | | inner_fields[2].data.x_type = ira->codegen->builtin_types.entry_undef; |
| 17164 | | else |
| 17165 | | inner_fields[2].data.x_type = fn_param_info->type; |
| 17179 | inner_fields[2].data.x_optional = nullptr; |
| 17180 | else { |
| 17181 | ConstExprValue *arg_type = create_const_vals(1); |
| 17182 | arg_type->special = ConstValSpecialStatic; |
| 17183 | arg_type->type = ira->codegen->builtin_types.entry_type; |
| 17184 | arg_type->data.x_type = fn_param_info->type; |
| 17185 | inner_fields[2].data.x_optional = arg_type; |
| 17186 | } |
| 17166 | 17187 | |
| 17167 | 17188 | fn_arg_val->data.x_struct.fields = inner_fields; |
| 17168 | 17189 | fn_arg_val->data.x_struct.parent.id = ConstParentIdArray; |