diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-14 17:01:36 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-14 17:01:36 +0800 |
commit | 63fb307fb112dcf3abb73c1da0dfb5a27935f4eb (patch) | |
tree | 5473ed81b50a4571ab7eca0da9dbcbaf53092ee0 /src/hir_expand/vtable.cpp | |
parent | 53983bf333143560ef4b161eaa2f46c55bcd517b (diff) | |
download | mrust-63fb307fb112dcf3abb73c1da0dfb5a27935f4eb.tar.gz |
HIR - Build up a flattened list of parent traits early to save time later
Diffstat (limited to 'src/hir_expand/vtable.cpp')
-rw-r--r-- | src/hir_expand/vtable.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/hir_expand/vtable.cpp b/src/hir_expand/vtable.cpp index f366a7d4..12a5f416 100644 --- a/src/hir_expand/vtable.cpp +++ b/src/hir_expand/vtable.cpp @@ -75,10 +75,6 @@ namespace { } i ++; } - for(const auto& st : tr.m_parent_traits) { - add_types_from_trait(*st.m_trait_ptr); - } - // TODO: Iterate supertraits from bounds too } }; Foo visitor { &tr, {}, static_cast<unsigned int>(tr.m_params.m_types.size()) }; @@ -86,6 +82,8 @@ namespace { visitor.params.m_types.push_back( ::HIR::TypeParamDef { tp.m_name, {}, tp.m_is_sized } ); } visitor.add_types_from_trait(tr); + for(const auto& st : tr.m_all_parent_traits) + visitor.add_types_from_trait(*st.m_trait_ptr); auto args = mv$(visitor.params); struct VtableConstruct { @@ -149,9 +147,10 @@ namespace { ::HIR::TypeRef fcn_type( mv$(ft) ); // Detect use of `Self` and don't create the vtable if there is. + // NOTE: Associated types where replaced by clone_ty_with if( visit_ty_with(fcn_type, [&](const auto& t){ return (t == ::HIR::TypeRef("Self", 0xFFFF)); }) ) { - DEBUG("- '" << vi.first << "' NOT object safe (Self), not creating vtable - " << fcn_type); + DEBUG("- '" << vi.first << "' NOT object safe (uses Self), not creating vtable - " << fcn_type); return false; } @@ -176,13 +175,12 @@ namespace { ) ) } - for(const auto& st : tr.m_parent_traits) { + for(const auto& st : tr.m_all_parent_traits) { ::HIR::TypeRef self("Self", 0xFFFF); auto st_gp = monomorphise_genericpath_with(sp, st.m_path, monomorphise_type_get_cb(sp, &self, &trait_path.m_params, nullptr), false); // NOTE: Doesn't trigger non-object-safe add_ents_from_trait(*st.m_trait_ptr, st_gp); } - // TODO: Iterate supertraits from bounds too return true; } }; |