authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-26 13:27:16+03:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2018-04-26 13:27:16+03:00
logdd88d7deda66a4e4e1527831e7b24a3cf358d1b7
treecddf61283dd218b0a05d23f22ddac215116e242a
parentbc160821d33a9284cf8bb85cca6cbf161af71d3b

Cleanup


1 files changed, 27 insertions(+), 22 deletions(-)

src/ir.cpp+27-22
......@@ -15775,17 +15775,20 @@ static void ir_type_info_struct_set_parent(ConstExprValue *struct_val, ConstExpr
1577515775
1577615776static TypeTableEntry *ir_type_info_get_type(IrAnalyze *ira, const char *type_name)
1577715777{
15778 ConstExprValue *type_info_var = get_builtin_value(ira->codegen, "TypeInfo");
15779 assert(type_info_var->type->id == TypeTableEntryIdMetaType);
15778 static ConstExprValue *type_info_var = nullptr;
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);
1578015784
15781 TypeTableEntry *type_info_type = type_info_var->data.x_type;
15782 assert(type_info_type->id == TypeTableEntryIdUnion);
15785 type_info_type = type_info_var->data.x_type;
15786 assert(type_info_type->id == TypeTableEntryIdUnion);
15787 }
1578315788
1578415789 if (type_name == nullptr)
1578515790 return type_info_type;
1578615791
15787 // @TODO
15788
1578915792 ScopeDecls *type_info_scope = get_container_scope(type_info_type);
1579015793 assert(type_info_scope != nullptr);
1579115794
......@@ -15898,15 +15901,16 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, ConstExprValue *p
1589815901 bigint_init_unsigned(&fields[2].data.x_bigint, type_entry->data.pointer.alignment);
1589915902 // child: &TypeInfo
1590015903 ensure_field_index(payload->type, "child", 3);
15901 ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo");
15902 assert(type_info_type->type->id == TypeTableEntryIdMetaType);
15904
15905 TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr);
15906
1590315907 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);
1590515909 fields[3].data.x_ptr.special = ConstPtrSpecialRef;
1590615910 fields[3].data.x_ptr.mut = ConstPtrMutComptimeVar;
1590715911 ConstExprValue *union_val = create_const_vals(1);
1590815912 union_val->special = ConstValSpecialStatic;
15909 union_val->type = type_info_type->data.x_type;
15913 union_val->type = type_info_type;
1591015914 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.pointer.child_type->id));
1591115915
1591215916 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
1593315937 bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len);
1593415938 // child: &TypeInfo
1593515939 ensure_field_index(payload->type, "child", 1);
15936 ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo");
15937 assert(type_info_type->type->id == TypeTableEntryIdMetaType);
15940
15941 TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr);
15942
1593815943 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);
1594015945 fields[1].data.x_ptr.special = ConstPtrSpecialRef;
1594115946 fields[1].data.x_ptr.mut = ConstPtrMutComptimeVar;
1594215947 ConstExprValue *union_val = create_const_vals(1);
1594315948 union_val->special = ConstValSpecialStatic;
15944 union_val->type = type_info_type->data.x_type;
15949 union_val->type = type_info_type;
1594515950 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.array.child_type->id));
1594615951
1594715952 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
1596315968
1596415969 // child: &TypeInfo
1596515970 ensure_field_index(payload->type, "child", 0);
15966 ConstExprValue *type_info_type = get_builtin_value(ira->codegen, "TypeInfo");
15967 assert(type_info_type->type->id == TypeTableEntryIdMetaType);
15971
15972 TypeTableEntry *type_info_type = ir_type_info_get_type(ira, nullptr);
15973
1596815974 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);
1597015976 fields[0].data.x_ptr.special = ConstPtrSpecialRef;
1597115977 fields[0].data.x_ptr.mut = ConstPtrMutComptimeVar;
1597215978 ConstExprValue *union_val = create_const_vals(1);
1597315979 union_val->special = ConstValSpecialStatic;
15974 union_val->type = type_info_type->data.x_type;
15980 union_val->type = type_info_type;
1597515981 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.maybe.child_type->id));
1597615982
1597715983 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
1599315999
1599416000 // child: ?&TypeInfo
1599516001 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);
1599816002
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);
1600016005
1600116006 fields[0].special = ConstValSpecialStatic;
1600216007 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
1601616021
1601716022 ConstExprValue *union_val = create_const_vals(1);
1601816023 union_val->special = ConstValSpecialStatic;
16019 union_val->type = type_info_type->data.x_type;
16024 union_val->type = type_info_type;
1602016025 bigint_init_unsigned(&union_val->data.x_union.tag, type_id_index(type_entry->data.promise.result_type->id));
1602116026 union_val->data.x_union.payload = ir_make_type_info_value(ira, union_val, -1,
1602216027 type_entry->data.promise.result_type);