From 1689ddf48bf7ce56df11c19d73eef84aea918e0d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 29 Aug 2016 12:57:24 +0800 Subject: AST Crate - Planning post-load index pass --- src/ast/crate.cpp | 9 +++++++-- src/ast/crate.hpp | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') 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 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 cb) const; const MacroRules* find_macro_rules(const ::std::string& name) const; -- cgit v1.2.3