diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-29 12:57:24 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-29 12:57:24 +0800 |
commit | 1689ddf48bf7ce56df11c19d73eef84aea918e0d (patch) | |
tree | 3f955a9eaf815e11f50a025925f03c0e1365fbc7 /src | |
parent | 9c5fd80efca12e1be08e0c4efad920eab794daa4 (diff) | |
download | mrust-1689ddf48bf7ce56df11c19d73eef84aea918e0d.tar.gz |
AST Crate - Planning post-load index pass
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/crate.cpp | 9 | ||||
-rw-r--r-- | src/ast/crate.hpp | 7 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index d7cce519..f1f363d9 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -59,12 +59,17 @@ void Crate::load_externs() } void Crate::load_extern_crate(const ::std::string& name) { - m_extern_crates.insert(::std::make_pair( name, ExternCrate { "output/lib"+name+".hir" } )); + m_extern_crates.insert(::std::make_pair( name, ExternCrate { name, "output/lib"+name+".hir" } )); } -ExternCrate::ExternCrate(const ::std::string& path) +ExternCrate::ExternCrate(const ::std::string& name, const ::std::string& path) { m_hir = HIR_Deserialise(path); + + // TODO: Do a pass across m_hir that + // 1. Loads referenced crates + // 2. Updates all absolute paths with the crate name + // 3. Updates macros with the crate name } void ExternCrate::with_all_macros(::std::function<void(const ::std::string& , const MacroRules&)> cb) const diff --git a/src/ast/crate.hpp b/src/ast/crate.hpp index fecd01b0..3b01d221 100644 --- a/src/ast/crate.hpp +++ b/src/ast/crate.hpp @@ -59,9 +59,12 @@ class ExternCrate public: ::HIR::CratePtr m_hir; - ExternCrate(const ::std::string& path); - ExternCrate(const ExternCrate&) = delete; + ExternCrate(const ::std::string& name, const ::std::string& path); + ExternCrate(ExternCrate&&) = default; + ExternCrate& operator=(ExternCrate&&) = default; + ExternCrate(const ExternCrate&) = delete; + ExternCrate& operator=(const ExternCrate& ) = delete; void with_all_macros(::std::function<void(const ::std::string& , const MacroRules&)> cb) const; const MacroRules* find_macro_rules(const ::std::string& name) const; |