diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-03 08:35:33 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-03 08:35:33 +0800 |
commit | 3d4b0c406c11a2f98ea258e0762736fca119b76a (patch) | |
tree | f2d9a6e2af70e7821ea1ec3809559be704cf43ec /src/hir | |
parent | 55bc4a9e019b1b5e51fec58030a30ea9146de45c (diff) | |
download | mrust-3d4b0c406c11a2f98ea258e0762736fca119b76a.tar.gz |
HIR/MIR - Vtable generation working well
Diffstat (limited to 'src/hir')
-rw-r--r-- | src/hir/deserialise.cpp | 10 | ||||
-rw-r--r-- | src/hir/hir.hpp | 11 | ||||
-rw-r--r-- | src/hir/serialise.cpp | 2 |
3 files changed, 8 insertions, 15 deletions
diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp index 3d84c9d6..2d16b230 100644 --- a/src/hir/deserialise.cpp +++ b/src/hir/deserialise.cpp @@ -539,12 +539,9 @@ namespace { ::HIR::TraitValueItem deserialise_traitvalueitem() { - auto tag = m_in.read_tag(); - auto idx = m_in.read_count(); - ::HIR::TraitValueItem rv; - switch( tag ) + switch( m_in.read_tag() ) { - #define _(x, ...) case ::HIR::TraitValueItem::TAG_##x: DEBUG("- " #x); rv = ::HIR::TraitValueItem::make_##x( __VA_ARGS__ ); break; + #define _(x, ...) case ::HIR::TraitValueItem::TAG_##x: DEBUG("- " #x); return ::HIR::TraitValueItem::make_##x( __VA_ARGS__ ); break; _(Constant, deserialise_constant() ) _(Static, deserialise_static() ) _(Function, deserialise_function() ) @@ -553,8 +550,6 @@ namespace { DEBUG("Invalid TraitValueItem tag"); throw ""; } - rv.vtable_ofs = idx; - return rv; } ::HIR::AssociatedType deserialise_associatedtype() { @@ -866,6 +861,7 @@ namespace { rv.m_is_marker = m_in.read_bool(); rv.m_types = deserialise_strumap< ::HIR::AssociatedType>(); rv.m_values = deserialise_strumap< ::HIR::TraitValueItem>(); + rv.m_value_indexes = deserialise_strumap< unsigned int>(); rv.m_type_indexes = deserialise_strumap< unsigned int>(); return rv; } diff --git a/src/hir/hir.hpp b/src/hir/hir.hpp index 1a933993..0fc12a55 100644 --- a/src/hir/hir.hpp +++ b/src/hir/hir.hpp @@ -231,15 +231,10 @@ struct AssociatedType ::std::vector< ::HIR::TraitPath> m_trait_bounds; ::HIR::TypeRef m_default; }; -TAGGED_UNION_EX(TraitValueItem, (), Constant, ( +TAGGED_UNION(TraitValueItem, Constant, (Constant, Constant), (Static, Static), (Function, Function) - ), - (),(), - ( - unsigned int vtable_ofs = ~0u; - ) ); struct Trait { @@ -252,7 +247,9 @@ struct Trait ::std::unordered_map< ::std::string, AssociatedType > m_types; ::std::unordered_map< ::std::string, TraitValueItem > m_values; - // Indexes in the parameter list for each associated type + // Indexes into the vtable for each present method and value + ::std::unordered_map< ::std::string, unsigned int > m_value_indexes; + // Indexes in the vtable parameter list for each associated type ::std::unordered_map< ::std::string, unsigned int > m_type_indexes; Trait( GenericParams gps, ::std::string lifetime, ::std::vector< ::HIR::TraitPath> parents): diff --git a/src/hir/serialise.cpp b/src/hir/serialise.cpp index c58780a0..d890aed6 100644 --- a/src/hir/serialise.cpp +++ b/src/hir/serialise.cpp @@ -817,12 +817,12 @@ namespace { m_out.write_bool( item.m_is_marker ); serialise_strmap( item.m_types ); serialise_strmap( item.m_values ); + serialise_strmap( item.m_value_indexes ); serialise_strmap( item.m_type_indexes ); } void serialise(const ::HIR::TraitValueItem& tvi) { m_out.write_tag( tvi.tag() ); - m_out.write_count( tvi.vtable_ofs ); TU_MATCHA( (tvi), (e), (Constant, DEBUG("Constant"); |