diff options
author | John Hodge <tpg@mutabah.net> | 2018-12-22 15:53:25 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-12-22 15:53:25 +0800 |
commit | d0e127f48e35ec7ad95b1c595c259f91c20628b8 (patch) | |
tree | d2a7a33d023557b2e6dc8aa6d4078a9cbdbfb49c | |
parent | b141095b38ac0ea5a7ed58aa405afd1c318aa442 (diff) | |
download | mrust-d0e127f48e35ec7ad95b1c595c259f91c20628b8.tar.gz |
MIR Cleanup - Misc commenting on handling of Defer literals
-rw-r--r-- | src/hir_typeck/static.cpp | 24 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/mir/cleanup.cpp | 15 | ||||
-rw-r--r-- | src/trans/trans_list.hpp | 7 |
4 files changed, 28 insertions, 19 deletions
diff --git a/src/hir_typeck/static.cpp b/src/hir_typeck/static.cpp index 84c73bfb..64b04611 100644 --- a/src/hir_typeck/static.cpp +++ b/src/hir_typeck/static.cpp @@ -2006,8 +2006,8 @@ StaticTraitResolve::ValuePtr StaticTraitResolve::get_value(const Span& sp, const { TRACE_FUNCTION_F(p << ", signature_only=" << signature_only); out_params = MonomorphState {}; - TU_MATCHA( (p.m_data), (pe), - (Generic, + TU_MATCH_HDR( (p.m_data), {) + TU_ARM(p.m_data, Generic, pe) { if( pe.m_path.m_components.size() > 1 ) { const auto& ti = m_crate.get_typeitem_by_path(sp, pe.m_path, /*ignore_crate_name=*/false, /*ignore_last_node=*/true); @@ -2051,8 +2051,8 @@ StaticTraitResolve::ValuePtr StaticTraitResolve::get_value(const Span& sp, const ) ) throw ""; - ), - (UfcsKnown, + } + TU_ARM(p.m_data, UfcsKnown, pe) { out_params.self_ty = &*pe.type; out_params.pp_impl = &pe.trait.m_params; out_params.pp_method = &pe.params; @@ -2074,8 +2074,10 @@ StaticTraitResolve::ValuePtr StaticTraitResolve::get_value(const Span& sp, const return false; const auto& ti = *impl.m_data.as_TraitImpl().impl; auto it = ti.m_constants.find(pe.item); - if(it == ti.m_constants.end()) + if(it == ti.m_constants.end()) { + // An impl was found, but it did't have the value return false; + } if( impl.more_specific_than(best_impl) ) { @@ -2108,8 +2110,8 @@ StaticTraitResolve::ValuePtr StaticTraitResolve::get_value(const Span& sp, const return &c.data; } throw ""; - ), - (UfcsInherent, + } + TU_ARM(p.m_data, UfcsInherent, pe) { out_params.self_ty = &*pe.type; //out_params.pp_impl = &out_params.pp_impl_data; out_params.pp_impl = &pe.impl_params; @@ -2140,10 +2142,10 @@ StaticTraitResolve::ValuePtr StaticTraitResolve::get_value(const Span& sp, const return false; }); return rv; - ), - (UfcsUnknown, + } + TU_ARM(p.m_data, UfcsUnknown, pe) { BUG(sp, "UfcsUnknown - " << p); - ) - ) + } + } throw ""; } diff --git a/src/main.cpp b/src/main.cpp index 6eb726ac..a34cb76d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -80,6 +80,7 @@ void init_debug_list() g_debug_disable_map.insert( "HIR Serialise" ); g_debug_disable_map.insert( "Trans Enumerate" ); + g_debug_disable_map.insert( "Trans Auto Impls" ); g_debug_disable_map.insert( "Trans Monomorph" ); g_debug_disable_map.insert( "MIR Optimise Inline" ); g_debug_disable_map.insert( "Trans Codegen" ); diff --git a/src/mir/cleanup.cpp b/src/mir/cleanup.cpp index 03e8f99e..1a15ea22 100644 --- a/src/mir/cleanup.cpp +++ b/src/mir/cleanup.cpp @@ -170,9 +170,10 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const MIR::TypeResolve& state, con // No impl found at all, use the default in the trait if( trait_cdef.m_value_res.is_Defer() ) { - // - Monomorphise and insert the item's MIR? - // OR: Should a previous stage have already done this? (E.g. after typecheck) - MIR_TODO(state, "Evaluate deferred trait constant - " << path); + DEBUG(state << "Found deferred trait constant - " << path); + // Return null to force the replacement to not happen (yet) + // - Expansion and resolution of this constant happens after/in "Trans Monomorph" + return nullptr; } else { @@ -184,7 +185,7 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const MIR::TypeResolve& state, con ), (UfcsInherent, const ::HIR::TypeImpl* best_impl = nullptr; - // TODO: Associated constants (inherent) + // Associated constants (inherent) resolve.m_crate.find_type_impls(*pe.type, [&](const auto& ty)->const auto& { return ty; }, [&](const auto& impl) { auto it = impl.m_constants.find(pe.item); @@ -366,7 +367,6 @@ const ::HIR::Literal* MIR_Cleanup_GetConstant(const MIR::TypeResolve& state, con ), (Pointer, if( lit.is_BorrowPath() || lit.is_BorrowData() ) { - // TODO: MIR_TODO(state, "BorrowOf into pointer - " << lit << " into " << ty); } else { @@ -715,7 +715,7 @@ bool MIR_Cleanup_Unsize_GetMetadata(const ::MIR::TypeResolve& state, MirMutator& bool source_is_dst = false; if( MIR_Cleanup_Unsize_GetMetadata(state, mutator, dst_ty_inner, src_ty_inner, ptr_value, meta_value, meta_type, source_is_dst) ) { - // TODO: There is a case where the source is already a fat pointer. In that case the pointer of the new DST must be the source DST pointer + // There is a case where the source is already a fat pointer. In that case the pointer of the new DST must be the source DST pointer if( source_is_dst ) { auto ty_unit_ptr = ::HIR::TypeRef::new_pointer(::HIR::BorrowType::Shared, ::HIR::TypeRef::new_unit()); @@ -845,7 +845,6 @@ bool MIR_Cleanup_Unsize_GetMetadata(const ::MIR::TypeResolve& state, MirMutator& if( dte.type == ste.type ) { - // TODO: Use unsize code above return MIR_Cleanup_Unsize(state, mutator, dst_ty, *ste.inner, mv$(value)); } else @@ -1084,7 +1083,7 @@ void MIR_Cleanup(const StaticTraitResolve& resolve, const ::HIR::ItemPath& path, auto& se = stmt.as_Assign(); TU_IFLET( ::MIR::RValue, se.src, Constant, e, - // TODO: Replace `Const` with actual values + // Replace `Const` with actual values TU_IFLET( ::MIR::Constant, e, Const, ce, // 1. Find the constant ::HIR::TypeRef ty; diff --git a/src/trans/trans_list.hpp b/src/trans/trans_list.hpp index 51e8af4b..703180fd 100644 --- a/src/trans/trans_list.hpp +++ b/src/trans/trans_list.hpp @@ -62,6 +62,11 @@ struct TransList_Static const ::HIR::Static* ptr; Trans_Params pp; }; +struct TransList_Const +{ + const ::HIR::Constant* ptr; + Trans_Params pp; +}; class TransList { @@ -74,6 +79,8 @@ public: ::std::map< ::HIR::Path, ::std::unique_ptr<TransList_Function> > m_functions; ::std::map< ::HIR::Path, ::std::unique_ptr<TransList_Static> > m_statics; + /// Constants that are still Defer + ::std::map< ::HIR::Path, ::std::unique_ptr<TransList_Const> > m_constants; ::std::map< ::HIR::Path, Trans_Params> m_vtables; /// Required type_id values ::std::set< ::HIR::TypeRef> m_typeids; |