| ... | @@ -16789,16 +16789,20 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -16789,16 +16789,20 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16789 | ConstExprValue *fields = create_const_vals(1); | 16789 | ConstExprValue *fields = create_const_vals(1); |
| 16790 | result->data.x_struct.fields = fields; | 16790 | result->data.x_struct.fields = fields; |
| 16791 | | 16791 | |
| 16792 | // @TODO ?type instead of using @typeOf(undefined) when we have no type. | 16792 | // child: ?type |
| 16793 | // child: type | | |
| 16794 | ensure_field_index(result->type, "child", 0); | 16793 | ensure_field_index(result->type, "child", 0); |
| 16795 | fields[0].special = ConstValSpecialStatic; | 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 | if (type_entry->data.promise.result_type == nullptr) | 16797 | if (type_entry->data.promise.result_type == nullptr) |
| 16799 | fields[0].data.x_type = ira->codegen->builtin_types.entry_undef; | 16798 | fields[0].data.x_optional = nullptr; |
| 16800 | else | 16799 | else { |
| 16801 | fields[0].data.x_type = type_entry->data.promise.result_type; | 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 | break; | 16807 | break; |
| 16804 | } | 16808 | } |
| ... | @@ -16939,19 +16943,23 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -16939,19 +16943,23 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16939 | fields[0].special = ConstValSpecialStatic; | 16943 | fields[0].special = ConstValSpecialStatic; |
| 16940 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout"); | 16944 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout"); |
| 16941 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout); | 16945 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout); |
| 16942 | // tag_type: type | 16946 | // tag_type: ?type |
| 16943 | ensure_field_index(result->type, "tag_type", 1); | 16947 | ensure_field_index(result->type, "tag_type", 1); |
| 16944 | fields[1].special = ConstValSpecialStatic; | 16948 | fields[1].special = ConstValSpecialStatic; |
| 16945 | fields[1].type = ira->codegen->builtin_types.entry_type; | 16949 | fields[1].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 16946 | // @TODO ?type instead of using @typeOf(undefined) when we have no type. | 16950 | |
| 16947 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; | 16951 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; |
| 16948 | if (union_decl_node->data.container_decl.auto_enum || | 16952 | if (union_decl_node->data.container_decl.auto_enum || |
| 16949 | union_decl_node->data.container_decl.init_arg_expr != nullptr) | 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 | else | 16961 | else |
| 16954 | fields[1].data.x_type = ira->codegen->builtin_types.entry_undef; | 16962 | fields[1].data.x_optional = nullptr; |
| 16955 | // fields: []TypeInfo.UnionField | 16963 | // fields: []TypeInfo.UnionField |
| 16956 | ensure_field_index(result->type, "fields", 2); | 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,7 +16988,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16980 | inner_fields[1].special = ConstValSpecialStatic; | 16988 | inner_fields[1].special = ConstValSpecialStatic; |
| 16981 | inner_fields[1].type = get_maybe_type(ira->codegen, type_info_enum_field_type); | 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 | inner_fields[1].data.x_optional = nullptr; | 16992 | inner_fields[1].data.x_optional = nullptr; |
| 16985 | } else { | 16993 | } else { |
| 16986 | inner_fields[1].data.x_optional = create_const_vals(1); | 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,8 +17097,6 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17089 | ConstExprValue *fields = create_const_vals(6); | 17097 | ConstExprValue *fields = create_const_vals(6); |
| 17090 | result->data.x_struct.fields = fields; | 17098 | result->data.x_struct.fields = fields; |
| 17091 | | 17099 | |
| 17092 | // @TODO Fix type = undefined with ?type | | |
| 17093 | | | |
| 17094 | // calling_convention: TypeInfo.CallingConvention | 17100 | // calling_convention: TypeInfo.CallingConvention |
| 17095 | ensure_field_index(result->type, "calling_convention", 0); | 17101 | ensure_field_index(result->type, "calling_convention", 0); |
| 17096 | fields[0].special = ConstValSpecialStatic; | 17102 | fields[0].special = ConstValSpecialStatic; |
| ... | @@ -17108,22 +17114,32 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -17108,22 +17114,32 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17108 | fields[2].special = ConstValSpecialStatic; | 17114 | fields[2].special = ConstValSpecialStatic; |
| 17109 | fields[2].type = ira->codegen->builtin_types.entry_bool; | 17115 | fields[2].type = ira->codegen->builtin_types.entry_bool; |
| 17110 | fields[2].data.x_bool = type_entry->data.fn.fn_type_id.is_var_args; | 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 | ensure_field_index(result->type, "return_type", 3); | 17118 | ensure_field_index(result->type, "return_type", 3); |
| 17113 | fields[3].special = ConstValSpecialStatic; | 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 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) | 17121 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 17116 | fields[3].data.x_type = ira->codegen->builtin_types.entry_undef; | 17122 | fields[3].data.x_optional = nullptr; |
| 17117 | else | 17123 | else { |
| 17118 | fields[3].data.x_type = type_entry->data.fn.fn_type_id.return_type; | 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 | // async_allocator_type: type | 17130 | // async_allocator_type: type |
| 17120 | ensure_field_index(result->type, "async_allocator_type", 4); | 17131 | ensure_field_index(result->type, "async_allocator_type", 4); |
| 17121 | fields[4].special = ConstValSpecialStatic; | 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 | if (type_entry->data.fn.fn_type_id.async_allocator_type == nullptr) | 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; | 17135 | fields[4].data.x_optional = nullptr; |
| 17125 | else | 17136 | else { |
| 17126 | fields[4].data.x_type = type_entry->data.fn.fn_type_id.async_allocator_type; | 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 | // args: []TypeInfo.FnArg | 17143 | // args: []TypeInfo.FnArg |
| 17128 | TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg"); | 17144 | TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg"); |
| 17129 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - | 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,12 +17173,17 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17157 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; | 17173 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; |
| 17158 | inner_fields[1].data.x_bool = fn_param_info->is_noalias; | 17174 | inner_fields[1].data.x_bool = fn_param_info->is_noalias; |
| 17159 | inner_fields[2].special = ConstValSpecialStatic; | 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 | if (arg_is_generic) | 17178 | if (arg_is_generic) |
| 17163 | inner_fields[2].data.x_type = ira->codegen->builtin_types.entry_undef; | 17179 | inner_fields[2].data.x_optional = nullptr; |
| 17164 | else | 17180 | else { |
| 17165 | inner_fields[2].data.x_type = fn_param_info->type; | 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 | fn_arg_val->data.x_struct.fields = inner_fields; | 17188 | fn_arg_val->data.x_struct.fields = inner_fields; |
| 17168 | fn_arg_val->data.x_struct.parent.id = ConstParentIdArray; | 17189 | fn_arg_val->data.x_struct.parent.id = ConstParentIdArray; |