diff options
author | John Hodge <tpg@mutabah.net> | 2018-05-20 22:01:59 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2018-05-20 22:01:59 +0800 |
commit | de9ecd7a2d70359b34e77ded57e5aa9284345ac5 (patch) | |
tree | 29ab42c6c06960720bd67f0b8ebaec807ad0284e /src/expand/proc_macro.cpp | |
parent | 134be5198993096ab5216b6d52a8937430c733b0 (diff) | |
download | mrust-de9ecd7a2d70359b34e77ded57e5aa9284345ac5.tar.gz |
AST - Refactor lifetime/HRB handling
Diffstat (limited to 'src/expand/proc_macro.cpp')
-rw-r--r-- | src/expand/proc_macro.cpp | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/expand/proc_macro.cpp b/src/expand/proc_macro.cpp index cdd13a42..28d9f613 100644 --- a/src/expand/proc_macro.cpp +++ b/src/expand/proc_macro.cpp @@ -345,45 +345,41 @@ namespace { ), (TraitObject, m_pmi.send_symbol("("); - if( te.hrls.size() > 0 ) - { - m_pmi.send_ident("for"); - m_pmi.send_symbol("<"); - for(const auto& v : te.hrls) - { - m_pmi.send_lifetime(v.c_str()); - m_pmi.send_symbol(","); - } - m_pmi.send_symbol(">"); - } for(const auto& t : te.traits) { - this->visit_path(t); + this->visit_hrbs(t.hrbs); + this->visit_path(t.path); m_pmi.send_symbol("+"); } + // TODO: Lifetimes m_pmi.send_symbol(")"); ), (ErasedType, m_pmi.send_ident("impl"); - if( te.hrls.size() > 0 ) - { - m_pmi.send_ident("for"); - m_pmi.send_symbol("<"); - for(const auto& v : te.hrls) - { - m_pmi.send_lifetime(v.c_str()); - m_pmi.send_symbol(","); - } - m_pmi.send_symbol(">"); - } for(const auto& t : te.traits) { - this->visit_path(t); + this->visit_hrbs(t.hrbs); + this->visit_path(t.path); m_pmi.send_symbol("+"); } + // TODO: Lifetimes ) ) } + void visit_hrbs(const AST::HigherRankedBounds& hrbs) + { + if( !hrbs.empty() ) + { + m_pmi.send_ident("for"); + m_pmi.send_symbol("<"); + for(const auto& v : hrbs.m_lifetimes) + { + m_pmi.send_lifetime(v.name().name.c_str()); + m_pmi.send_symbol(","); + } + m_pmi.send_symbol(">"); + } + } void visit_path(const AST::Path& path, bool is_expr=false) { @@ -445,7 +441,7 @@ namespace { m_pmi.send_symbol("<"); for(const auto& l : e.args().m_lifetimes) { - m_pmi.send_lifetime(l.c_str()); + m_pmi.send_lifetime(l.name().name.c_str()); m_pmi.send_symbol(","); } for(const auto& t : e.args().m_types) @@ -475,7 +471,7 @@ namespace { { if( !is_first ) m_pmi.send_symbol(","); - m_pmi.send_lifetime(p.c_str()); + m_pmi.send_lifetime(p.name().name.c_str()); is_first = false; } // Types |