From 7c8f99fdc1be0ed80095af160fffae2995cda83f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Tue, 4 Jan 2011 17:58:10 -0500 Subject: [PATCH] Add names from imports to the namespace. --- src/comp/front/ast.rs | 3 ++- src/comp/front/parser.rs | 7 +++++-- src/comp/middle/resolve.rs | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 15c0e4994a5..fff7b24ca93 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -36,6 +36,7 @@ def_ty_arg(def_id); def_binding(def_id); def_use(def_id); + def_import(def_id); } type crate = spanned[crate_]; @@ -213,7 +214,7 @@ tag mod_index_entry { - mie_use(uint); + mie_view_item(uint); mie_item(uint); mie_tag_variant(uint /* tag item index */, uint /* variant index */); } diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 8c3db0e10ba..f71fae61386 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1,4 +1,5 @@ import std._io; +import std._vec; import std.option; import std.option.some; import std.option.none; @@ -1751,10 +1752,12 @@ fn is_use_or_import(token.token t) -> bool { items += vec(item); alt (item.node) { case(ast.view_item_use(?id, _, _)) { - index.insert(id, ast.mie_use(u)); + index.insert(id, ast.mie_view_item(u)); } case(ast.view_item_import(?ids,_)) { - // FIXME + auto len = _vec.len[ast.ident](ids); + auto last_id = ids.(len - 1u); + index.insert(last_id, ast.mie_view_item(u)); } } u = u + 1u; diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 551993dda8b..e1f58b5d731 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -73,7 +73,7 @@ fn found_def_view(@ast.view_item i) -> option.t[def] { ret some[def](ast.def_use(id)); } case (ast.view_item_import(_,?id)) { - fail; + ret some[def](ast.def_import(id)); } } } @@ -82,7 +82,7 @@ fn check_mod(ast.ident i, ast._mod m) -> option.t[def] { alt (m.index.find(i)) { case (some[ast.mod_index_entry](?ent)) { alt (ent) { - case (ast.mie_use(?ix)) { + case (ast.mie_view_item(?ix)) { ret found_def_view(m.view_items.(ix)); } case (ast.mie_item(?ix)) { -- GitLab