aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <[email protected]>2011-01-18 15:23:11 -0500
committerGraydon Hoare <[email protected]>2011-01-18 15:43:13 -0800
commit41b7d6d74da54b80419ab093303dd356fae957ec (patch)
treec382e32f867eae4b42aae8a9dcb8882e198211bf /src/comp/front
parentAdd bzero glue and preliminary code for dynamic size/align calculations. (diff)
downloadrust-41b7d6d74da54b80419ab093303dd356fae957ec.tar.xz
rust-41b7d6d74da54b80419ab093303dd356fae957ec.zip
One last refactoring of the import handling:
* Create an import resolving stage. Currently this involves a copy of the ast, we can probably revisit this once we revisit doing full copies of the ast in general. * Don't repeat work. Once we resolve a import, put it on a hash table and use it next time we are asked for it. This solves a O(n^2) behaviour in degenerated cases. * Once import resolution is done, the target of an import is stored on the import itself.
Diffstat (limited to 'src/comp/front')
-rw-r--r--src/comp/front/ast.rs4
-rw-r--r--src/comp/front/parser.rs3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 1ee50c2a..1fad1c1a 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -229,7 +229,7 @@ type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann);
type view_item = spanned[view_item_];
tag view_item_ {
view_item_use(ident, vec[@meta_item], def_id);
- view_item_import(vec[ident], def_id);
+ view_item_import(vec[ident], def_id, option.t[def]);
}
type item = spanned[item_];
@@ -247,7 +247,7 @@ fn index_view_item(mod_index index, @view_item it) {
case(ast.view_item_use(?id, _, _)) {
index.insert(id, ast.mie_view_item(it));
}
- case(ast.view_item_import(?ids,_)) {
+ case(ast.view_item_import(?ids,_,_)) {
auto len = _vec.len[ast.ident](ids);
auto last_id = ids.(len - 1u);
index.insert(last_id, ast.mie_view_item(it));
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index c44da8f1..0e8d1dc7 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -1704,7 +1704,8 @@ impure fn parse_rest_import_name(parser p, ast.ident id) -> @ast.view_item {
identifiers += i;
}
p.bump();
- auto import_decl = ast.view_item_import(identifiers, p.next_def_id());
+ auto import_decl = ast.view_item_import(identifiers, p.next_def_id(),
+ none[ast.def]);
ret @spanned(lo, hi, import_decl);
}