authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-25 17:50:11+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-25 17:50:11+03:00
logbc160821d33a9284cf8bb85cca6cbf161af71d3b
treef1f4423e2f85f651e77b3c1933f66ddbf44bd045
parent2606993cb48e69015a9152b860e48fca29d330e1

Changed TypeInfo layout.


2 files changed, 174 insertions(+), 151 deletions(-)

src/codegen.cpp+118-118
...@@ -6349,143 +6349,143 @@ static void define_builtin_compile_vars(CodeGen *g) {...@@ -6349,143 +6349,143 @@ static void define_builtin_compile_vars(CodeGen *g) {
6349 {6349 {
6350 // TODO: Add method info where methods are supported.6350 // TODO: Add method info where methods are supported.
6351 buf_appendf(contents,6351 buf_appendf(contents,
6352 "pub const IntInfo = struct {\n"6352 "pub const TypeInfo = union(TypeId) {\n"
6353 " is_signed: bool,\n"6353 " Type: void,\n"
6354 " bits: u8,\n"6354 " Void: void,\n"
6355 "};\n"6355 " Bool: void,\n"
6356 "\n"6356 " NoReturn: void,\n"
6357 "pub const FloatInfo = struct {\n"6357 " Int: Int,\n"
6358 " bits: u8,\n"6358 " Float: Float,\n"
6359 "};\n"6359 " Pointer: Pointer,\n"
6360 " Array: Array,\n"
6361 " Struct: Struct,\n"
6362 " FloatLiteral: void,\n"
6363 " IntLiteral: void,\n"
6364 " UndefinedLiteral: void,\n"
6365 " NullLiteral: void,\n"
6366 " Nullable: Nullable,\n"
6367 " ErrorUnion: ErrorUnion,\n"
6368 " ErrorSet: ErrorSet,\n"
6369 " Enum: Enum,\n"
6370 " Union: Union,\n"
6371 " Fn: Fn,\n"
6372 " Namespace: void,\n"
6373 " Block: void,\n"
6374 " BoundFn: BoundFn,\n"
6375 " ArgTuple: void,\n"
6376 " Opaque: void,\n"
6377 " Promise: Promise,\n"
6378 "\n\n"
6379 " pub const Int = struct {\n"
6380 " is_signed: bool,\n"
6381 " bits: u8,\n"
6382 " };\n"
6360 "\n"6383 "\n"
6361 "pub const PointerInfo = struct {\n"6384 " pub const Float = struct {\n"
6362 " is_const: bool,\n"6385 " bits: u8,\n"
6363 " is_volatile: bool,\n"6386 " };\n"
6364 " alignment: u32,\n"
6365 " child: &TypeInfo,\n"
6366 "};\n"
6367 "\n"6387 "\n"
6368 "pub const ArrayInfo = struct {\n"6388 " pub const Pointer = struct {\n"
6369 " len: usize,\n"6389 " is_const: bool,\n"
6370 " child: &TypeInfo,\n"6390 " is_volatile: bool,\n"
6371 "};\n"6391 " alignment: u32,\n"
6392 " child: &TypeInfo,\n"
6393 " };\n"
6372 "\n"6394 "\n"
6373 "pub const ContainerLayout = enum {\n"6395 " pub const Array = struct {\n"
6374 " Auto,\n"6396 " len: usize,\n"
6375 " Extern,\n"6397 " child: &TypeInfo,\n"
6376 " Packed,\n"6398 " };\n"
6377 "};\n"
6378 "\n"6399 "\n"
6379 "pub const StructFieldInfo = struct {\n"6400 " pub const ContainerLayout = enum {\n"
6380 " name: []const u8,\n"6401 " Auto,\n"
6381 " offset: usize,\n"6402 " Extern,\n"
6382 " type_info: TypeInfo,\n"6403 " Packed,\n"
6383 "};\n"6404 " };\n"
6384 "\n"6405 "\n"
6385 "pub const StructInfo = struct {\n"6406 " pub const StructField = struct {\n"
6386 " layout: ContainerLayout,\n"6407 " name: []const u8,\n"
6387 " fields: []StructFieldInfo,\n"6408 " offset: usize,\n"
6388 "};\n"6409 " type_info: TypeInfo,\n"
6410 " };\n"
6389 "\n"6411 "\n"
6390 "pub const NullableInfo = struct {\n"6412 " pub const Struct = struct {\n"
6391 " child: &TypeInfo,\n"6413 " layout: ContainerLayout,\n"
6392 "};\n"6414 " fields: []StructField,\n"
6415 " };\n"
6393 "\n"6416 "\n"
6394 "pub const ErrorUnionInfo = struct {\n"6417 " pub const Nullable = struct {\n"
6395 " error_set: ErrorSetInfo,\n"6418 " child: &TypeInfo,\n"
6396 " payload: &TypeInfo,\n"6419 " };\n"
6397 "};\n"
6398 "\n"6420 "\n"
6399 "pub const ErrorInfo = struct {\n"6421 " pub const ErrorUnion = struct {\n"
6400 " name: []const u8,\n"6422 " error_set: ErrorSet,\n"
6401 " value: usize,\n"6423 " payload: &TypeInfo,\n"
6402 "};\n"6424 " };\n"
6403 "\n"6425 "\n"
6404 "pub const ErrorSetInfo = struct {\n"6426 " pub const Error = struct {\n"
6405 " errors: []ErrorInfo,\n"6427 " name: []const u8,\n"
6406 "};\n"6428 " value: usize,\n"
6429 " };\n"
6407 "\n"6430 "\n"
6408 "pub const EnumFieldInfo = struct {\n"6431 " pub const ErrorSet = struct {\n"
6409 " name: []const u8,\n"6432 " errors: []Error,\n"
6410 " value: usize,\n"6433 " };\n"
6411 "};\n"
6412 "\n"6434 "\n"
6413 "pub const EnumInfo = struct {\n"6435 " pub const EnumField = struct {\n"
6414 " layout: ContainerLayout,\n"6436 " name: []const u8,\n"
6415 " tag_type: IntInfo,\n"6437 " value: usize,\n"
6416 " fields: []EnumFieldInfo,\n"6438 " };\n"
6417 "};\n"
6418 "\n"6439 "\n"
6419 "pub const UnionFieldInfo = struct {\n"6440 " pub const Enum = struct {\n"
6420 " name: []const u8,\n"6441 " layout: ContainerLayout,\n"
6421 " enum_field: EnumFieldInfo,\n"6442 " tag_type: Int,\n"
6422 " type_info: TypeInfo,\n"6443 " fields: []EnumField,\n"
6423 "};\n"6444 " };\n"
6424 "\n"6445 "\n"
6425 "pub const UnionInfo = struct {\n"6446 " pub const UnionField = struct {\n"
6426 " layout: ContainerLayout,\n"6447 " name: []const u8,\n"
6427 " tag_type: ?EnumInfo,\n"6448 " enum_field: EnumField,\n"
6428 " fields: []UnionFieldInfo,\n"6449 " type_info: TypeInfo,\n"
6429 "};\n"6450 " };\n"
6430 "\n"6451 "\n"
6431 "pub const CallingConvention = enum {\n"6452 " pub const Union = struct {\n"
6432 " Unspecified,\n"6453 " layout: ContainerLayout,\n"
6433 " C,\n"6454 " tag_type: ?Enum,\n"
6434 " Cold,\n"6455 " fields: []UnionField,\n"
6435 " Naked,\n"6456 " };\n"
6436 " Stdcall,\n"
6437 " Async,\n"
6438 "};\n"
6439 "\n"6457 "\n"
6440 "pub const FnArgInfo = struct {\n"6458 " pub const CallingConvention = enum {\n"
6441 " is_comptime: bool,\n"6459 " Unspecified,\n"
6442 " name: []const u8,\n"6460 " C,\n"
6443 " type_info: TypeInfo,\n"6461 " Cold,\n"
6444 "};\n"6462 " Naked,\n"
6463 " Stdcall,\n"
6464 " Async,\n"
6465 " };\n"
6445 "\n"6466 "\n"
6446 "pub const FnInfo = struct {\n"6467 " pub const FnArg = struct {\n"
6447 " calling_convention: CallingConvention,\n"6468 " is_comptime: bool,\n"
6448 " is_generic: bool,\n"6469 " name: []const u8,\n"
6449 " is_varargs: bool,\n"6470 " type_info: TypeInfo,\n"
6450 " return_type: &TypeInfo,\n"6471 " };\n"
6451 " args: []FnArgInfo,\n"
6452 "};\n"
6453 "\n"6472 "\n"
6454 "pub const BoundFnInfo = struct {\n"6473 " pub const Fn = struct {\n"
6455 " bound_type: &TypeInfo,\n"6474 " calling_convention: CallingConvention,\n"
6456 " fn_info: FnInfo,\n"6475 " is_generic: bool,\n"
6457 "};\n"6476 " is_varargs: bool,\n"
6477 " return_type: &TypeInfo,\n"
6478 " args: []FnArg,\n"
6479 " };\n"
6458 "\n"6480 "\n"
6459 "pub const PromiseInfo = struct {\n"6481 " pub const BoundFn = struct {\n"
6460 " child: ?&TypeInfo,\n"6482 " bound_type: &TypeInfo,\n"
6461 "};\n"6483 " fn_info: Fn,\n"
6484 " };\n"
6462 "\n"6485 "\n"
6463 "pub const TypeInfo = union(TypeId) {\n"6486 " pub const Promise = struct {\n"
6464 " Type: void,\n"6487 " child: ?&TypeInfo,\n"
6465 " Void: void,\n"6488 " };\n"
6466 " Bool: void,\n"
6467 " NoReturn: void,\n"
6468 " Int: IntInfo,\n"
6469 " Float: FloatInfo,\n"
6470 " Pointer: PointerInfo,\n"
6471 " Array: ArrayInfo,\n"
6472 " Struct: StructInfo,\n"
6473 " FloatLiteral: void,\n"
6474 " IntLiteral: void,\n"
6475 " UndefinedLiteral: void,\n"
6476 " NullLiteral: void,\n"
6477 " Nullable: NullableInfo,\n"
6478 " ErrorUnion: ErrorUnionInfo,\n"
6479 " ErrorSet: ErrorSetInfo,\n"
6480 " Enum: EnumInfo,\n"
6481 " Union: UnionInfo,\n"
6482 " Fn: FnInfo,\n"
6483 " Namespace: void,\n"
6484 " Block: void,\n"
6485 " BoundFn: BoundFnInfo,\n"
6486 " ArgTuple: void,\n"
6487 " Opaque: void,\n"
6488 " Promise: PromiseInfo,\n"
6489 "};\n\n");6489 "};\n\n");
6490 assert(ContainerLayoutAuto == 0);6490 assert(ContainerLayoutAuto == 0);
6491 assert(ContainerLayoutExtern == 1);6491 assert(ContainerLayoutExtern == 1);
src/ir.cpp+56-33
...@@ -15737,7 +15737,8 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,...@@ -15737,7 +15737,8 @@ static TypeTableEntry *ir_analyze_instruction_offset_of(IrAnalyze *ira,
15737 return ira->codegen->builtin_types.entry_num_lit_int;15737 return ira->codegen->builtin_types.entry_num_lit_int;
15738}15738}
1573915739
15740static void ensure_field_index(TypeTableEntry *type, const char *field_name, size_t index) {15740static void ensure_field_index(TypeTableEntry *type, const char *field_name, size_t index)
15741{
15741 Buf *field_name_buf;15742 Buf *field_name_buf;
1574215743
15743 assert(type != nullptr && !type_is_invalid(type));15744 assert(type != nullptr && !type_is_invalid(type));
...@@ -15747,7 +15748,8 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz...@@ -15747,7 +15748,8 @@ static void ensure_field_index(TypeTableEntry *type, const char *field_name, siz
15747 (buf_deinit(field_name_buf), true));15748 (buf_deinit(field_name_buf), true));
15748}15749}
1574915750
15750static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExprValue *parent, ssize_t parent_field_index) {15751static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExprValue *parent, ssize_t parent_field_index)
15752{
15751 assert(struct_val->type->id == TypeTableEntryIdStruct);15753 assert(struct_val->type->id == TypeTableEntryIdStruct);
15752 assert(parent->type != nullptr && !type_is_invalid(parent->type));15754 assert(parent->type != nullptr && !type_is_invalid(parent->type));
1575315755
...@@ -15771,6 +15773,37 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr...@@ -15771,6 +15773,37 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr
15771 }15773 }
15772}15774}
1577315775
15776static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name)
15777{
15778 ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
15779 assert(type_info_var->type->id == TypeTableEntryIdMetaType);
15780
15781 TypeTableEntry *type_info_type = type_info_var->data.x_type;
15782 assert(type_info_type->id == TypeTableEntryIdUnion);
15783
15784 if (type_name == nullptr)
15785 return type_info_type;
15786
15787 // @TODO
15788
15789 ScopeDecls *type_info_scope = get_container_scope(type_info_type);
15790 assert(type_info_scope != nullptr);
15791
15792 Buf field_name = BUF_INIT;
15793 buf_init_from_str(&field_name, type_name);
15794 auto entry = type_info_scope->decl_table.maybe_get(&field_name);
15795 buf_deinit(&field_name);
15796 assert(entry != nullptr);
15797
15798 TldVar *tld = (TldVar *)entry->value;
15799 assert(tld->base.id == TldIdVar);
15800
15801 VariableTableEntry *var = tld->var;
15802
15803 assert(var->value->type->id == TypeTableEntryIdMetaType);
15804 return var->value->data.x_type;
15805}
15806
15774static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *parent,15807static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *parent,
15775 ssize_t parent_field_index, TypeTableEntry *type_entry)15808 ssize_t parent_field_index, TypeTableEntry *type_entry)
15776{15809{
...@@ -15798,10 +15831,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15798,10 +15831,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15798 {15831 {
15799 ConstExprValue *payload = create_const_vals(1);15832 ConstExprValue *payload = create_const_vals(1);
15800 payload->special = ConstValSpecialStatic;15833 payload->special = ConstValSpecialStatic;
1580115834 payload->type = ir_type_info_get_type(ira, "Int");
15802 ConstExprValue *int_info_type = get_builtin_value(ira->codegen, "IntInfo");
15803 assert(int_info_type->type->id == TypeTableEntryIdMetaType);
15804 payload->type = int_info_type->data.x_type;
1580515835
15806 ConstExprValue *fields = create_const_vals(2);15836 ConstExprValue *fields = create_const_vals(2);
15807 payload->data.x_struct.fields = fields;15837 payload->data.x_struct.fields = fields;
...@@ -15825,10 +15855,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15825,10 +15855,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15825 {15855 {
15826 ConstExprValue *payload = create_const_vals(1);15856 ConstExprValue *payload = create_const_vals(1);
15827 payload->special = ConstValSpecialStatic;15857 payload->special = ConstValSpecialStatic;
1582815858 payload->type = ir_type_info_get_type(ira, "Float");
15829 ConstExprValue *float_info_type = get_builtin_value(ira->codegen, "FloatInfo");
15830 assert(float_info_type->type->id == TypeTableEntryIdMetaType);
15831 payload->type = float_info_type->data.x_type;
1583215859
15833 ConstExprValue *fields = create_const_vals(1);15860 ConstExprValue *fields = create_const_vals(1);
15834 payload->data.x_struct.fields = fields;15861 payload->data.x_struct.fields = fields;
...@@ -15847,10 +15874,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15847,10 +15874,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15847 {15874 {
15848 ConstExprValue *payload = create_const_vals(1);15875 ConstExprValue *payload = create_const_vals(1);
15849 payload->special = ConstValSpecialStatic;15876 payload->special = ConstValSpecialStatic;
1585015877 payload->type = ir_type_info_get_type(ira, "Pointer");
15851 ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "PointerInfo");
15852 assert(pointer_info_type->type->id == TypeTableEntryIdMetaType);
15853 payload->type = pointer_info_type->data.x_type;
1585415878
15855 ConstExprValue *fields = create_const_vals(4);15879 ConstExprValue *fields = create_const_vals(4);
15856 payload->data.x_struct.fields = fields;15880 payload->data.x_struct.fields = fields;
...@@ -15884,7 +15908,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15884,7 +15908,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15884 union_val->special = ConstValSpecialStatic;15908 union_val->special = ConstValSpecialStatic;
15885 union_val->type = type_info_type->data.x_type;15909 union_val->type = type_info_type->data.x_type;
15886 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id));15910 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id));
15887 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.pointer.child_type);15911
15912 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1,
15913 type_entry->data.pointer.child_type);
15914
15888 fields[3].data.x_ptr.data.ref.pointee = union_val;15915 fields[3].data.x_ptr.data.ref.pointee = union_val;
15889 return payload;15916 return payload;
15890 }15917 }
...@@ -15892,10 +15919,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15892,10 +15919,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15892 {15919 {
15893 ConstExprValue *payload = create_const_vals(1);15920 ConstExprValue *payload = create_const_vals(1);
15894 payload->special = ConstValSpecialStatic;15921 payload->special = ConstValSpecialStatic;
1589515922 payload->type = ir_type_info_get_type(ira, "Array");
15896 ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "ArrayInfo");
15897 assert(pointer_info_type->type->id == TypeTableEntryIdMetaType);
15898 payload->type = pointer_info_type->data.x_type;
1589915923
15900 ConstExprValue *fields = create_const_vals(2);15924 ConstExprValue *fields = create_const_vals(2);
15901 payload->data.x_struct.fields = fields;15925 payload->data.x_struct.fields = fields;
...@@ -15919,7 +15943,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15919,7 +15943,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15919 union_val->special = ConstValSpecialStatic;15943 union_val->special = ConstValSpecialStatic;
15920 union_val->type = type_info_type->data.x_type;15944 union_val->type = type_info_type->data.x_type;
15921 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id));15945 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id));
15922 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.array.child_type);15946
15947 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1,
15948 type_entry->data.array.child_type);
15949
15923 fields[1].data.x_ptr.data.ref.pointee = union_val;15950 fields[1].data.x_ptr.data.ref.pointee = union_val;
15924 return payload;15951 return payload;
15925 }15952 }
...@@ -15927,10 +15954,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15927,10 +15954,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15927 {15954 {
15928 ConstExprValue *payload = create_const_vals(1);15955 ConstExprValue *payload = create_const_vals(1);
15929 payload->special = ConstValSpecialStatic;15956 payload->special = ConstValSpecialStatic;
1593015957 payload->type = ir_type_info_get_type(ira, "Nullable");
15931 ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "NullableInfo");
15932 assert(pointer_info_type->type->id == TypeTableEntryIdMetaType);
15933 payload->type = pointer_info_type->data.x_type;
1593415958
15935 ConstExprValue *fields = create_const_vals(1);15959 ConstExprValue *fields = create_const_vals(1);
15936 payload->data.x_struct.fields = fields;15960 payload->data.x_struct.fields = fields;
...@@ -15949,7 +15973,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15949,7 +15973,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15949 union_val->special = ConstValSpecialStatic;15973 union_val->special = ConstValSpecialStatic;
15950 union_val->type = type_info_type->data.x_type;15974 union_val->type = type_info_type->data.x_type;
15951 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id));15975 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id));
15952 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.maybe.child_type);15976
15977 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1,
15978 type_entry->data.maybe.child_type);
15979
15953 fields[0].data.x_ptr.data.ref.pointee = union_val;15980 fields[0].data.x_ptr.data.ref.pointee = union_val;
15954 return payload;15981 return payload;
15955 }15982 }
...@@ -15957,10 +15984,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15957,10 +15984,7 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15957 {15984 {
15958 ConstExprValue *payload = create_const_vals(1);15985 ConstExprValue *payload = create_const_vals(1);
15959 payload->special = ConstValSpecialStatic;15986 payload->special = ConstValSpecialStatic;
1596015987 payload->type = ir_type_info_get_type(ira, "Promise");
15961 ConstExprValue *pointer_info_type = get_builtin_value(ira->codegen, "PromiseInfo");
15962 assert(pointer_info_type->type->id == TypeTableEntryIdMetaType);
15963 payload->type = pointer_info_type->data.x_type;
1596415988
15965 ConstExprValue *fields = create_const_vals(1);15989 ConstExprValue *fields = create_const_vals(1);
15966 payload->data.x_struct.fields = fields;15990 payload->data.x_struct.fields = fields;
...@@ -15994,7 +16018,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p...@@ -15994,7 +16018,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
15994 union_val->special = ConstValSpecialStatic;16018 union_val->special = ConstValSpecialStatic;
15995 union_val->type = type_info_type->data.x_type;16019 union_val->type = type_info_type->data.x_type;
15996 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id));16020 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id));
15997 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1, type_entry->data.promise.result_type);16021 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1,
16022 type_entry->data.promise.result_type);
1599816023
15999 maybe_value->data.x_ptr.data.ref.pointee = union_val;16024 maybe_value->data.x_ptr.data.ref.pointee = union_val;
16000 fields[0].data.x_maybe = maybe_value;16025 fields[0].data.x_maybe = maybe_value;
...@@ -16014,9 +16039,7 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,...@@ -16014,9 +16039,7 @@ static TypeTableEntry *ir_analyze_instruction_type_info(IrAnalyze *ira,
16014 if (type_is_invalid(type_entry))16039 if (type_is_invalid(type_entry))
16015 return ira->codegen->builtin_types.entry_invalid;16040 return ira->codegen->builtin_types.entry_invalid;
1601616041
16017 ConstExprValue *var_value = get_builtin_value(ira->codegen, "TypeInfo");16042 TypeTableEntry *result_type = ir_type_info_get_type(ira, nullptr);
16018 assert(var_value->type->id == TypeTableEntryIdMetaType);
16019 TypeTableEntry *result_type = var_value->data.x_type;
1602016043
16021 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);16044 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
16022 out_val->type = result_type;16045 out_val->type = result_type;