summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-27 21:32:09 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-27 21:32:09 +0800
commit28697d7ef5f7cac8664cc248e6e219177c822eb8 (patch)
treeb2adc5a41382e6114daa86c736c1f6928d2f0c3b /src
parent924efe07fca8620a8ed9726e473e31b86cff9b2e (diff)
downloadmrust-28697d7ef5f7cac8664cc248e6e219177c822eb8.tar.gz
Resolve - Working on extern crate support
Diffstat (limited to 'src')
-rw-r--r--src/ast/path.cpp2
-rw-r--r--src/ast/path.hpp4
-rw-r--r--src/resolve/index.cpp4
-rw-r--r--src/resolve/use.cpp8
4 files changed, 15 insertions, 3 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp
index 92fdc4fe..58eadf24 100644
--- a/src/ast/path.cpp
+++ b/src/ast/path.cpp
@@ -15,6 +15,7 @@ namespace AST {
::std::ostream& operator<<(::std::ostream& os, const PathBinding& x) {
TU_MATCH(PathBinding, (x), (i),
(Unbound, os << "UNBOUND"; ),
+ (Crate , os << "Crate"; ),
(Module, os << "Module"; ),
(Trait, os << "Trait"; ),
(Struct, os << "Struct"; ),
@@ -36,6 +37,7 @@ PathBinding PathBinding::clone() const
TU_MATCH(::AST::PathBinding, (*this), (e),
(Unbound , return PathBinding::make_Unbound({}); ),
(Module , return PathBinding::make_Module(e); ),
+ (Crate , return PathBinding(e); ),
(Trait , return PathBinding::make_Trait(e); ),
(Struct , return PathBinding::make_Struct(e); ),
(Enum , return PathBinding::make_Enum(e); ),
diff --git a/src/ast/path.hpp b/src/ast/path.hpp
index 809486b0..dbb92cde 100644
--- a/src/ast/path.hpp
+++ b/src/ast/path.hpp
@@ -27,10 +27,14 @@ class Struct;
class Trait;
class Static;
class Function;
+class ExternCrate;
TAGGED_UNION_EX(PathBinding, (), Unbound, (
(Unbound, struct {
}),
+ (Crate, struct {
+ const ExternCrate* crate_;
+ }),
(Module, struct {
const Module* module_;
}),
diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp
index 57f33cc6..c63b424d 100644
--- a/src/resolve/index.cpp
+++ b/src/resolve/index.cpp
@@ -149,6 +149,7 @@ void Resolve_Index_Module_Base(AST::Module& mod)
BUG(sp, "Import was bound to struct method");
),
+ (Crate , _add_item(sp, mod, IndexName::Namespace, i.name, i.is_pub, i.data.path); ),
(Module, _add_item(sp, mod, IndexName::Namespace, i.name, i.is_pub, i.data.path); ),
//(Crate, _add_item_type(sp, mod, IndexName::Namespace, i.name, i.is_pub, i.data.path); ),
(Enum, _add_item_type(sp, mod, i.name, i.is_pub, i.data.path); ),
@@ -225,6 +226,9 @@ void Resolve_Index_Module_Wildcard(AST::Module& mod, bool handle_pub)
BUG(sp, "Import was bound to struct method");
),
+ (Crate,
+ TODO(sp, "Glob import of crate");
+ ),
(Module,
DEBUG("Glob mod " << i.data.path);
if( e.module_ == &mod ) {
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp
index 3ddee7c2..12c4b458 100644
--- a/src/resolve/use.cpp
+++ b/src/resolve/use.cpp
@@ -220,11 +220,10 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
// IMPOSSIBLE - Handled above
),
(MacroInv,
- BUG(span, "HIt MacroInv in use resolution");
+ BUG(span, "Hit MacroInv in use resolution");
),
(Crate,
- //return ::AST::PathBinding::make_Crate({&e});
- TODO(span, "Handle importing from a crate");
+ return ::AST::PathBinding::make_Crate({ &crate.m_extern_crates.at(e.name) });
),
(Type,
return ::AST::PathBinding::make_TypeAlias({&e});
@@ -313,6 +312,9 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path
(
ERROR(span, E0000, "Unexpected item type in import");
),
+ (Crate,
+ TODO(span, "Get binding within an extern crate");
+ ),
(Enum,
const auto& enum_ = *e.enum_;
i += 1;