| ... | @@ -16722,16 +16722,20 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -16722,16 +16722,20 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16722 | ConstExprValue *fields = create_const_vals(1); | 16722 | ConstExprValue *fields = create_const_vals(1); |
| 16723 | result->data.x_struct.fields = fields; | 16723 | result->data.x_struct.fields = fields; |
| 16724 | | 16724 | |
| 16725 | // @TODO ?type instead of using @typeOf(undefined) when we have no type. | 16725 | // child: ?type |
| 16726 | // child: type | | |
| 16727 | ensure_field_index(result->type, "child", 0); | 16726 | ensure_field_index(result->type, "child", 0); |
| 16728 | fields[0].special = ConstValSpecialStatic; | 16727 | fields[0].special = ConstValSpecialStatic; |
| 16729 | fields[0].type = ira->codegen->builtin_types.entry_type; | 16728 | fields[0].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 16730 | | 16729 | |
| 16731 | if (type_entry->data.promise.result_type == nullptr) | 16730 | if (type_entry->data.promise.result_type == nullptr) |
| 16732 | fields[0].data.x_type = ira->codegen->builtin_types.entry_undef; | 16731 | fields[0].data.x_optional = nullptr; |
| 16733 | else | 16732 | else { |
| 16734 | fields[0].data.x_type = type_entry->data.promise.result_type; | 16733 | ConstExprValue *child_type = create_const_vals(1); |
| | 16734 | child_type->special = ConstValSpecialStatic; |
| | 16735 | child_type->type = ira->codegen->builtin_types.entry_type; |
| | 16736 | child_type->data.x_type = type_entry->data.promise.result_type; |
| | 16737 | fields[0].data.x_optional = child_type; |
| | 16738 | } |
| 16735 | | 16739 | |
| 16736 | break; | 16740 | break; |
| 16737 | } | 16741 | } |
| ... | @@ -16872,19 +16876,23 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -16872,19 +16876,23 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16872 | fields[0].special = ConstValSpecialStatic; | 16876 | fields[0].special = ConstValSpecialStatic; |
| 16873 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout"); | 16877 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout"); |
| 16874 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout); | 16878 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout); |
| 16875 | // tag_type: type | 16879 | // tag_type: ?type |
| 16876 | ensure_field_index(result->type, "tag_type", 1); | 16880 | ensure_field_index(result->type, "tag_type", 1); |
| 16877 | fields[1].special = ConstValSpecialStatic; | 16881 | fields[1].special = ConstValSpecialStatic; |
| 16878 | fields[1].type = ira->codegen->builtin_types.entry_type; | 16882 | fields[1].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 16879 | // @TODO ?type instead of using @typeOf(undefined) when we have no type. | 16883 | |
| 16880 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; | 16884 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; |
| 16881 | if (union_decl_node->data.container_decl.auto_enum || | 16885 | if (union_decl_node->data.container_decl.auto_enum || |
| 16882 | union_decl_node->data.container_decl.init_arg_expr != nullptr) | 16886 | union_decl_node->data.container_decl.init_arg_expr != nullptr) |
| 16883 | { | 16887 | { |
| 16884 | fields[1].data.x_type = type_entry->data.unionation.tag_type; | 16888 | ConstExprValue *tag_type = create_const_vals(1); |
| | 16889 | tag_type->special = ConstValSpecialStatic; |
| | 16890 | tag_type->type = ira->codegen->builtin_types.entry_type; |
| | 16891 | tag_type->data.x_type = type_entry->data.unionation.tag_type; |
| | 16892 | fields[1].data.x_optional = tag_type; |
| 16885 | } | 16893 | } |
| 16886 | else | 16894 | else |
| 16887 | fields[1].data.x_type = ira->codegen->builtin_types.entry_undef; | 16895 | fields[1].data.x_optional = nullptr; |
| 16888 | // fields: []TypeInfo.UnionField | 16896 | // fields: []TypeInfo.UnionField |
| 16889 | ensure_field_index(result->type, "fields", 2); | 16897 | ensure_field_index(result->type, "fields", 2); |
| 16890 | | 16898 | |
| ... | @@ -16913,7 +16921,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -16913,7 +16921,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16913 | inner_fields[1].special = ConstValSpecialStatic; | 16921 | inner_fields[1].special = ConstValSpecialStatic; |
| 16914 | inner_fields[1].type = get_maybe_type(ira->codegen, type_info_enum_field_type); | 16922 | inner_fields[1].type = get_maybe_type(ira->codegen, type_info_enum_field_type); |
| 16915 | | 16923 | |
| 16916 | if (fields[1].data.x_type == ira->codegen->builtin_types.entry_undef) { | 16924 | if (fields[1].data.x_optional == nullptr) { |
| 16917 | inner_fields[1].data.x_optional = nullptr; | 16925 | inner_fields[1].data.x_optional = nullptr; |
| 16918 | } else { | 16926 | } else { |
| 16919 | inner_fields[1].data.x_optional = create_const_vals(1); | 16927 | inner_fields[1].data.x_optional = create_const_vals(1); |
| ... | @@ -17022,8 +17030,6 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -17022,8 +17030,6 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17022 | ConstExprValue *fields = create_const_vals(6); | 17030 | ConstExprValue *fields = create_const_vals(6); |
| 17023 | result->data.x_struct.fields = fields; | 17031 | result->data.x_struct.fields = fields; |
| 17024 | | 17032 | |
| 17025 | // @TODO Fix type = undefined with ?type | | |
| 17026 | | | |
| 17027 | // calling_convention: TypeInfo.CallingConvention | 17033 | // calling_convention: TypeInfo.CallingConvention |
| 17028 | ensure_field_index(result->type, "calling_convention", 0); | 17034 | ensure_field_index(result->type, "calling_convention", 0); |
| 17029 | fields[0].special = ConstValSpecialStatic; | 17035 | fields[0].special = ConstValSpecialStatic; |
| ... | @@ -17041,22 +17047,32 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -17041,22 +17047,32 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17041 | fields[2].special = ConstValSpecialStatic; | 17047 | fields[2].special = ConstValSpecialStatic; |
| 17042 | fields[2].type = ira->codegen->builtin_types.entry_bool; | 17048 | fields[2].type = ira->codegen->builtin_types.entry_bool; |
| 17043 | fields[2].data.x_bool = type_entry->data.fn.fn_type_id.is_var_args; | 17049 | fields[2].data.x_bool = type_entry->data.fn.fn_type_id.is_var_args; |
| 17044 | // return_type: type | 17050 | // return_type: ?type |
| 17045 | ensure_field_index(result->type, "return_type", 3); | 17051 | ensure_field_index(result->type, "return_type", 3); |
| 17046 | fields[3].special = ConstValSpecialStatic; | 17052 | fields[3].special = ConstValSpecialStatic; |
| 17047 | fields[3].type = ira->codegen->builtin_types.entry_type; | 17053 | fields[3].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 17048 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) | 17054 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 17049 | fields[3].data.x_type = ira->codegen->builtin_types.entry_undef; | 17055 | fields[3].data.x_optional = nullptr; |
| 17050 | else | 17056 | else { |
| 17051 | fields[3].data.x_type = type_entry->data.fn.fn_type_id.return_type; | 17057 | ConstExprValue *return_type = create_const_vals(1); |
| | 17058 | return_type->special = ConstValSpecialStatic; |
| | 17059 | return_type->type = ira->codegen->builtin_types.entry_type; |
| | 17060 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| | 17061 | fields[3].data.x_optional = return_type; |
| | 17062 | } |
| 17052 | // async_allocator_type: type | 17063 | // async_allocator_type: type |
| 17053 | ensure_field_index(result->type, "async_allocator_type", 4); | 17064 | ensure_field_index(result->type, "async_allocator_type", 4); |
| 17054 | fields[4].special = ConstValSpecialStatic; | 17065 | fields[4].special = ConstValSpecialStatic; |
| 17055 | fields[4].type = ira->codegen->builtin_types.entry_type; | 17066 | fields[4].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 17056 | if (type_entry->data.fn.fn_type_id.async_allocator_type == nullptr) | 17067 | if (type_entry->data.fn.fn_type_id.async_allocator_type == nullptr) |
| 17057 | fields[4].data.x_type = ira->codegen->builtin_types.entry_undef; | 17068 | fields[4].data.x_optional = nullptr; |
| 17058 | else | 17069 | else { |
| 17059 | fields[4].data.x_type = type_entry->data.fn.fn_type_id.async_allocator_type; | 17070 | ConstExprValue *async_alloc_type = create_const_vals(1); |
| | 17071 | async_alloc_type->special = ConstValSpecialStatic; |
| | 17072 | async_alloc_type->type = ira->codegen->builtin_types.entry_type; |
| | 17073 | async_alloc_type->data.x_type = type_entry->data.fn.fn_type_id.async_allocator_type; |
| | 17074 | fields[4].data.x_optional = async_alloc_type; |
| | 17075 | } |
| 17060 | // args: []TypeInfo.FnArg | 17076 | // args: []TypeInfo.FnArg |
| 17061 | TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg"); | 17077 | TypeTableEntry *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg"); |
| 17062 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - | 17078 | size_t fn_arg_count = type_entry->data.fn.fn_type_id.param_count - |
| ... | @@ -17090,12 +17106,17 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t | ... | @@ -17090,12 +17106,17 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 17090 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; | 17106 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; |
| 17091 | inner_fields[1].data.x_bool = fn_param_info->is_noalias; | 17107 | inner_fields[1].data.x_bool = fn_param_info->is_noalias; |
| 17092 | inner_fields[2].special = ConstValSpecialStatic; | 17108 | inner_fields[2].special = ConstValSpecialStatic; |
| 17093 | inner_fields[2].type = ira->codegen->builtin_types.entry_type; | 17109 | inner_fields[2].type = get_maybe_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 17094 | | 17110 | |
| 17095 | if (arg_is_generic) | 17111 | if (arg_is_generic) |
| 17096 | inner_fields[2].data.x_type = ira->codegen->builtin_types.entry_undef; | 17112 | inner_fields[2].data.x_optional = nullptr; |
| 17097 | else | 17113 | else { |
| 17098 | inner_fields[2].data.x_type = fn_param_info->type; | 17114 | ConstExprValue *arg_type = create_const_vals(1); |
| | 17115 | arg_type->special = ConstValSpecialStatic; |
| | 17116 | arg_type->type = ira->codegen->builtin_types.entry_type; |
| | 17117 | arg_type->data.x_type = fn_param_info->type; |
| | 17118 | inner_fields[2].data.x_optional = arg_type; |
| | 17119 | } |
| 17099 | | 17120 | |
| 17100 | fn_arg_val->data.x_struct.fields = inner_fields; | 17121 | fn_arg_val->data.x_struct.fields = inner_fields; |
| 17101 | fn_arg_val->data.x_struct.parent.id = ConstParentIdArray; | 17122 | fn_arg_val->data.x_struct.parent.id = ConstParentIdArray; |