diff options
author | John Hodge <tpg@mutabah.net> | 2016-03-13 10:03:27 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-03-13 10:03:27 +0800 |
commit | 3e20e1a674114c36b200c698dfbd2242d3859e85 (patch) | |
tree | d2bf1e7b353747292015e9863ac0887398d42d09 /src/ast | |
parent | f6c69a1089e2246156e65c0173a14306935733f3 (diff) | |
download | mrust-3e20e1a674114c36b200c698dfbd2242d3859e85.tar.gz |
Parse+Expand - Remove a todo, fix bug in cfg handling
Diffstat (limited to 'src/ast')
-rw-r--r-- | src/ast/ast.cpp | 73 | ||||
-rw-r--r-- | src/ast/ast.hpp | 2 |
2 files changed, 3 insertions, 72 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 2a6b0b39..15b425c8 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -259,9 +259,8 @@ void Module::add_item(bool is_pub, ::std::string name, Item it, MetaItems attrs) m_items.back().data.attrs = mv$(attrs);
DEBUG("Item " << ::AST::Item::tag_to_str( m_items.back().data.tag() ) << " - attrs = " << m_items.back().data.attrs);
}
-void Module::add_ext_crate(::std::string ext_name, ::std::string imp_name, MetaItems attrs) {
- // TODO: Extern crates can be public
- this->add_item( false, imp_name, Item::make_Crate({mv$(ext_name)}), mv$(attrs) );
+void Module::add_ext_crate(bool is_public, ::std::string ext_name, ::std::string imp_name, MetaItems attrs) {
+ this->add_item( is_public, imp_name, Item::make_Crate({mv$(ext_name)}), mv$(attrs) );
}
void Module::add_alias(bool is_public, Path path, ::std::string name, MetaItems attrs) {
// TODO: Attributes on aliases / imports
@@ -299,74 +298,6 @@ void Module::prescan() //{
// sm_p.first.prescan();
//}
- //
- ///*
- //for( const auto& macro_imp : m_macro_imports )
- //{
- // resolve_macro_import( *(Crate*)0, macro_imp.first, macro_imp.second );
- //}
- //*/
-}
-
-void Module::resolve_macro_import(const Crate& crate, const ::std::string& modname, const ::std::string& macro_name)
-{
- /*
- DEBUG("Import macros from " << modname << " matching '" << macro_name << "'");
- for( const auto& sm_p : m_submods )
- {
- const AST::Module& sm = sm_p.first;
- if( sm.name() == modname )
- {
- DEBUG("Using module");
- if( macro_name == "" )
- {
- for( const auto& macro_p : sm.m_macro_import_res )
- m_macro_import_res.push_back( macro_p );
- for( const auto& macro_i : sm.m_macros )
- m_macro_import_res.push_back( ItemNS<const MacroRules*>( ::std::string(macro_i.name), ¯o_i.data, false ) );
- return ;
- }
- else
- {
- for( const auto& macro_p : sm.m_macro_import_res )
- {
- if( macro_p.name == macro_name ) {
- m_macro_import_res.push_back( macro_p );
- return ;
- }
- }
- throw ::std::runtime_error("Macro not in module");
- }
- }
- }
-
- for( const auto& cr : m_extern_crates )
- {
- if( cr.name == modname )
- {
- DEBUG("Using crate import " << cr.name << " == '" << cr.data << "'");
- if( macro_name == "" ) {
- for( const auto& macro_p : crate.extern_crates().at(cr.data).crate().m_exported_macros )
- m_macro_import_res.push_back( ItemNS<const MacroRules*>( ::std::string(macro_p.first), &*macro_p.second, false ) );
- return ;
- }
- else {
- for( const auto& macro_p : crate.extern_crates().at(cr.data).crate().m_exported_macros )
- {
- DEBUG("Macro " << macro_p.first);
- if( macro_p.first == macro_name ) {
- // TODO: Handle #[macro_export] on extern crate
- m_macro_import_res.push_back( ItemNS<const MacroRules*>( ::std::string(macro_p.first), &*macro_p.second, false ) );
- return ;
- }
- }
- throw ::std::runtime_error("Macro not in crate");
- }
- }
- }
-
- throw ::std::runtime_error( FMT("Could not find sub-module '" << modname << "' for macro import") );
- */
}
void Module::iterate_functions(fcn_visitor_t *visitor, const Crate& crate)
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index a84097d1..ed6ad07b 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -419,7 +419,7 @@ public: ::std::unique_ptr<AST::Module> add_anon();
void add_item(bool is_pub, ::std::string name, Item it, MetaItems attrs);
- void add_ext_crate(::std::string ext_name, ::std::string imp_name, MetaItems attrs);
+ void add_ext_crate(bool is_public, ::std::string ext_name, ::std::string imp_name, MetaItems attrs);
void add_alias(bool is_public, Path path, ::std::string name, MetaItems attrs);
void add_typealias(bool is_public, ::std::string name, TypeAlias alias, MetaItems attrs);
void add_static(bool is_public, ::std::string name, Static item, MetaItems attrs);
|