diff options
| author | Rafael Ávila de Espíndola <[email protected]> | 2011-01-18 15:23:11 -0500 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-01-18 15:43:13 -0800 |
| commit | 41b7d6d74da54b80419ab093303dd356fae957ec (patch) | |
| tree | c382e32f867eae4b42aae8a9dcb8882e198211bf /src/comp/middle/fold.rs | |
| parent | Add bzero glue and preliminary code for dynamic size/align calculations. (diff) | |
| download | rust-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/middle/fold.rs')
| -rw-r--r-- | src/comp/middle/fold.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index b96ca938..f81b7a52 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -210,7 +210,7 @@ type ast_fold[ENV] = def_id id) -> @view_item) fold_view_item_use, (fn(&ENV e, &span sp, vec[ident] idents, - def_id id) -> @view_item) fold_view_item_import, + def_id id, option.t[def]) -> @view_item) fold_view_item_import, // Additional nodes. (fn(&ENV e, &span sp, @@ -705,9 +705,10 @@ fn fold_view_item[ENV](&ENV env, ast_fold[ENV] fld, @view_item vi) ret fld.fold_view_item_use(env_, vi.span, ident, meta_items, def_id); } - case (ast.view_item_import(?idents, ?def_id)) { + case (ast.view_item_import(?idents, ?def_id, ?target_def)) { // FIXME: what other folding should be done in here? - ret fld.fold_view_item_import(env_, vi.span, idents, def_id); + ret fld.fold_view_item_import(env_, vi.span, idents, def_id, + target_def); } } @@ -1086,8 +1087,9 @@ fn identity_fold_view_item_use[ENV](&ENV e, &span sp, ident i, } fn identity_fold_view_item_import[ENV](&ENV e, &span sp, vec[ident] is, - def_id id) -> @view_item { - ret @respan(sp, ast.view_item_import(is, id)); + def_id id, option.t[def] target_def) + -> @view_item { + ret @respan(sp, ast.view_item_import(is, id, target_def)); } // Additional identities. @@ -1236,7 +1238,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] { fold_view_item_use = bind identity_fold_view_item_use[ENV](_,_,_,_,_), fold_view_item_import = - bind identity_fold_view_item_import[ENV](_,_,_,_), + bind identity_fold_view_item_import[ENV](_,_,_,_,_), fold_block = bind identity_fold_block[ENV](_,_,_), fold_fn = bind identity_fold_fn[ENV](_,_,_,_,_), |