diff options
author | John Hodge <tpg@ucc.asn.au> | 2018-06-03 14:57:05 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2018-06-03 14:57:05 +0800 |
commit | bf8f8b4b4a9fe273451be59f68acafbe61968b83 (patch) | |
tree | 82993550cb3c88de0edbd55d79e4ea8e8cefffac /src/expand/mod.cpp | |
parent | 39b3cf53798683e496804f8322da2254b10850f4 (diff) | |
parent | a7fb27789a2b34543851d207120e2c0001ee9c27 (diff) | |
download | mrust-bf8f8b4b4a9fe273451be59f68acafbe61968b83.tar.gz |
Merge branch 'master' of https://github.com/thepowersgang/mrustc
Diffstat (limited to 'src/expand/mod.cpp')
-rw-r--r-- | src/expand/mod.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 571d21e2..8e052dfe 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -21,7 +21,7 @@ MacroDef* g_macros_list = nullptr; ::std::map< ::std::string, ::std::unique_ptr<ExpandDecorator> > g_decorators; ::std::map< ::std::string, ::std::unique_ptr<ExpandProcMacro> > g_macros; -void Expand_Attrs(const ::AST::MetaItems& attrs, AttrStage stage, ::std::function<void(const ExpandDecorator& d,const ::AST::MetaItem& a)> f); +void Expand_Attrs(const ::AST::AttributeList& attrs, AttrStage stage, ::std::function<void(const ExpandDecorator& d,const ::AST::Attribute& a)> f); void Expand_Mod(::AST::Crate& crate, LList<const AST::Module*> modstack, ::AST::Path modpath, ::AST::Module& mod, unsigned int first_item = 0); void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, AST::Expr& node); void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::shared_ptr<AST::ExprNode>& node); @@ -43,12 +43,12 @@ void Register_Synext_Macro_Static(MacroDef* def) { } -void ExpandDecorator::unexpected(const Span& sp, const AST::MetaItem& mi, const char* loc_str) const +void ExpandDecorator::unexpected(const Span& sp, const AST::Attribute& mi, const char* loc_str) const { WARNING(sp, W0000, "Unexpected attribute " << mi.name() << " on " << loc_str); } -void Expand_Attr(const Span& sp, const ::AST::MetaItem& a, AttrStage stage, ::std::function<void(const Span& sp, const ExpandDecorator& d,const ::AST::MetaItem& a)> f) +void Expand_Attr(const Span& sp, const ::AST::Attribute& a, AttrStage stage, ::std::function<void(const Span& sp, const ExpandDecorator& d,const ::AST::Attribute& a)> f) { for( auto& d : g_decorators ) { if( d.first == a.name() ) { @@ -59,29 +59,30 @@ void Expand_Attr(const Span& sp, const ::AST::MetaItem& a, AttrStage stage, ::s } } } -void Expand_Attrs(/*const */::AST::MetaItems& attrs, AttrStage stage, ::std::function<void(const Span& sp, const ExpandDecorator& d,const ::AST::MetaItem& a)> f) +void Expand_Attrs(/*const */::AST::AttributeList& attrs, AttrStage stage, ::std::function<void(const Span& sp, const ExpandDecorator& d,const ::AST::Attribute& a)> f) { for( auto& a : attrs.m_items ) { if( a.name() == "cfg_attr" ) { - if( check_cfg(attrs.m_span, a.items().at(0)) ) { + if( check_cfg(a.span(), a.items().at(0)) ) { + // Wait? Why move? auto inner_attr = mv$(a.items().at(1)); - Expand_Attr(attrs.m_span, inner_attr, stage, f); + Expand_Attr(inner_attr.span(), inner_attr, stage, f); a = mv$(inner_attr); } else { } } else { - Expand_Attr(attrs.m_span, a, stage, f); + Expand_Attr(a.span(), a, stage, f); } } } -void Expand_Attrs(::AST::MetaItems& attrs, AttrStage stage, ::AST::Crate& crate, const ::AST::Path& path, ::AST::Module& mod, ::AST::Item& item) +void Expand_Attrs(::AST::AttributeList& attrs, AttrStage stage, ::AST::Crate& crate, const ::AST::Path& path, ::AST::Module& mod, ::AST::Item& item) { Expand_Attrs(attrs, stage, [&](const auto& sp, const auto& d, const auto& a){ if(!item.is_None()) d.handle(sp, a, crate, path, mod, item); }); } -void Expand_Attrs(::AST::MetaItems& attrs, AttrStage stage, ::AST::Crate& crate, ::AST::Module& mod, ::AST::ImplDef& impl) +void Expand_Attrs(::AST::AttributeList& attrs, AttrStage stage, ::AST::Crate& crate, ::AST::Module& mod, ::AST::ImplDef& impl) { Expand_Attrs(attrs, stage, [&](const auto& sp, const auto& d, const auto& a){ d.handle(sp, a, crate, mod, impl); }); } @@ -271,13 +272,15 @@ void Expand_Type(::AST::Crate& crate, LList<const AST::Module*> modstack, ::AST: (TraitObject, for(auto& p : e.traits) { - Expand_Path(crate, modstack, mod, p); + // TODO: p.hrbs? Not needed until types are in those + Expand_Path(crate, modstack, mod, p.path); } ), (ErasedType, for(auto& p : e.traits) { - Expand_Path(crate, modstack, mod, p); + // TODO: p.hrbs? + Expand_Path(crate, modstack, mod, p.path); } ) ) @@ -585,13 +588,13 @@ struct CExpandExpr: ::std::vector< ::AST::ExprNode_Match_Arm> arms; // - `Some(pattern ) => code` arms.push_back( ::AST::ExprNode_Match_Arm( - ::make_vec1( ::AST::Pattern(::AST::Pattern::TagNamedTuple(), path_Some, ::make_vec1( mv$(node.m_pattern) ) ) ), + ::make_vec1( ::AST::Pattern(::AST::Pattern::TagNamedTuple(), node.span(), path_Some, ::make_vec1( mv$(node.m_pattern) ) ) ), nullptr, mv$(node.m_code) ) ); // - `None => break label` arms.push_back( ::AST::ExprNode_Match_Arm( - ::make_vec1( ::AST::Pattern(::AST::Pattern::TagValue(), ::AST::Pattern::Value::make_Named(path_None)) ), + ::make_vec1( ::AST::Pattern(::AST::Pattern::TagValue(), node.span(), ::AST::Pattern::Value::make_Named(path_None)) ), nullptr, ::AST::ExprNodeP(new ::AST::ExprNode_Flow(::AST::ExprNode_Flow::BREAK, node.m_label, nullptr)) ) ); @@ -602,7 +605,7 @@ struct CExpandExpr: ::make_vec1( mv$(node.m_cond) ) )), ::make_vec1(::AST::ExprNode_Match_Arm( - ::make_vec1( ::AST::Pattern(::AST::Pattern::TagBind(), "it") ), + ::make_vec1( ::AST::Pattern(::AST::Pattern::TagBind(), node.span(), "it") ), nullptr, ::AST::ExprNodeP(new ::AST::ExprNode_Loop( node.m_label, @@ -796,13 +799,13 @@ struct CExpandExpr: ::std::vector< ::AST::ExprNode_Match_Arm> arms; // `Ok(v) => v,` arms.push_back(::AST::ExprNode_Match_Arm( - ::make_vec1( ::AST::Pattern(::AST::Pattern::TagNamedTuple(), path_Ok, ::make_vec1( ::AST::Pattern(::AST::Pattern::TagBind(), "v") )) ), + ::make_vec1( ::AST::Pattern(::AST::Pattern::TagNamedTuple(), node.span(), path_Ok, ::make_vec1( ::AST::Pattern(::AST::Pattern::TagBind(), node.span(), "v") )) ), nullptr, ::AST::ExprNodeP( new ::AST::ExprNode_NamedValue( ::AST::Path(::AST::Path::TagLocal(), "v") ) ) )); // `Err(e) => return Err(From::from(e)),` arms.push_back(::AST::ExprNode_Match_Arm( - ::make_vec1( ::AST::Pattern(::AST::Pattern::TagNamedTuple(), path_Err, ::make_vec1( ::AST::Pattern(::AST::Pattern::TagBind(), "e") )) ), + ::make_vec1( ::AST::Pattern(::AST::Pattern::TagNamedTuple(), node.span(), path_Err, ::make_vec1( ::AST::Pattern(::AST::Pattern::TagBind(), node.span(), "e") )) ), nullptr, ::AST::ExprNodeP(new ::AST::ExprNode_Flow( ::AST::ExprNode_Flow::RETURN, @@ -858,6 +861,8 @@ void Expand_GenericParams(::AST::Crate& crate, LList<const AST::Module*> modstac for(auto& bound : params.bounds()) { TU_MATCHA( (bound), (be), + (None, + ), (Lifetime, ), (TypeLifetime, @@ -1293,7 +1298,7 @@ void Expand(::AST::Crate& crate) crate.m_extern_crates.at("std").with_all_macros([&](const auto& name, const auto& mac) { crate.m_root_module.add_macro_import( name, mac ); }); - crate.m_root_module.add_ext_crate(false, "std", "std", ::AST::MetaItems {}); + crate.m_root_module.add_ext_crate(false, "std", "std", ::AST::AttributeList {}); break; case ::AST::Crate::LOAD_CORE: if( crate.m_prelude_path == AST::Path() ) @@ -1301,7 +1306,7 @@ void Expand(::AST::Crate& crate) crate.m_extern_crates.at("core").with_all_macros([&](const auto& name, const auto& mac) { crate.m_root_module.add_macro_import( name, mac ); }); - crate.m_root_module.add_ext_crate(false, "core", "core", ::AST::MetaItems {}); + crate.m_root_module.add_ext_crate(false, "core", "core", ::AST::AttributeList {}); break; case ::AST::Crate::LOAD_NONE: break; |