From 13e938957698086e77b7a2c8bbcfea9bba76c17a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 19 Mar 2016 14:51:35 +0800 Subject: Expand - Handle std/core loading (partially) --- src/expand/mod.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/expand/mod.cpp') diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index f1a9891a..3b46736f 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -636,8 +636,9 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList mo for( auto& i : impl.items() ) { DEBUG(" - " << i.name << " :: " << i.data.attrs); + // TODO: Make a path from the impl definition? Requires having the impl def resolved to be correct - // - Does it? the namespace is essentially the same + // - Does it? the namespace is essentially the same. There may be issues with wherever the path is used though //::AST::Path path = modpath + i.name; auto attrs = mv$(i.data.attrs); @@ -680,7 +681,22 @@ void Expand(::AST::Crate& crate) // 1. Crate attributes Expand_Attrs(crate.m_attrs, AttrStage::EarlyPre, [&](const auto& d, const auto& a){ d.handle(a, crate); }); - // TODO: Load std/core + // Load libstd/libcore + switch( crate.m_load_std ) + { + case ::AST::Crate::LOAD_STD: + if( crate.m_prelude_path != AST::Path() ) + crate.m_prelude_path = AST::Path("std", {AST::PathNode("prelude"), AST::PathNode("v1")}); + TODO(Span(), "Load libstd"); + break; + case ::AST::Crate::LOAD_CORE: + if( crate.m_prelude_path != AST::Path() ) + crate.m_prelude_path = AST::Path("core", {AST::PathNode("prelude")}); + TODO(Span(), "Load libcore"); + break; + case ::AST::Crate::LOAD_NONE: + break; + } // 2. Module attributes for( auto& a : crate.m_attrs.m_items ) -- cgit v1.2.3