diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-02-17 14:15:09 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-17 16:00:39 -0800 |
| commit | a5ede9d34533be86bab0fd5a255d527b2fd3cdc6 (patch) | |
| tree | a3cd32118644e16698c988d4e093a673dd9eda93 /src/comp | |
| parent | f7f73c79ec0cca88fc6e3657f955307049cb5801 (diff) | |
| download | rust-a5ede9d34533be86bab0fd5a255d527b2fd3cdc6.tar.gz rust-a5ede9d34533be86bab0fd5a255d527b2fd3cdc6.zip | |
rustdoc: Resolve imports and reexports
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/driver/driver.rs | 20 | ||||
| -rw-r--r-- | src/comp/middle/resolve.rs | 51 |
2 files changed, 47 insertions, 24 deletions
diff --git a/src/comp/driver/driver.rs b/src/comp/driver/driver.rs index 53ba8c65bdf..40cf4e50472 100644 --- a/src/comp/driver/driver.rs +++ b/src/comp/driver/driver.rs @@ -440,17 +440,27 @@ fn build_session_options(match: getopts::match, fn build_session(sopts: @session::options, input: str, demitter: diagnostic::emitter) -> session { + let codemap = codemap::new_codemap(); + let diagnostic_handler = + diagnostic::mk_handler(some(demitter)); + let span_diagnostic_handler = + diagnostic::mk_span_handler(diagnostic_handler, codemap); + build_session_(sopts, input, codemap, demitter, + span_diagnostic_handler) +} + +fn build_session_( + sopts: @session::options, input: str, + codemap: codemap::codemap, + demitter: diagnostic::emitter, + span_diagnostic_handler: diagnostic::span_handler +) -> session { let target_cfg = build_target_config(sopts, demitter); let cstore = cstore::mk_cstore(); let filesearch = filesearch::mk_filesearch( sopts.maybe_sysroot, sopts.target_triple, sopts.addl_lib_search_paths); - let codemap = codemap::new_codemap(); - let diagnostic_handler = - diagnostic::mk_handler(some(demitter)); - let span_diagnostic_handler = - diagnostic::mk_span_handler(diagnostic_handler, codemap); @{targ_cfg: target_cfg, opts: sopts, cstore: cstore, diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 1f68bb4a25e..c4e1923fc29 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -19,7 +19,7 @@ import std::list::{list, nil, cons}; import option::{is_none, is_some}; import syntax::print::pprust::*; -export resolve_crate; +export resolve_crate, resolve_crate_reexports; export def_map, ext_map, exp_map, impl_map; export _impl, iscopes, method_info; @@ -155,24 +155,7 @@ enum ns_value_type { ns_a_enum, ns_any_value, } fn resolve_crate(sess: session, amap: ast_map::map, crate: @ast::crate) -> {def_map: def_map, exp_map: exp_map, impl_map: impl_map} { - let e = - @{cstore: sess.cstore, - def_map: new_int_hash(), - ast_map: amap, - imports: new_int_hash(), - exp_map: new_str_hash(), - mod_map: new_int_hash(), - block_map: new_int_hash(), - ext_map: new_def_hash(), - impl_map: new_int_hash(), - impl_cache: new_def_hash(), - ext_cache: new_ext_hash(), - used_imports: {mutable track: false, mutable data: []}, - mutable reported: [], - mutable ignored_imports: [], - mutable current_tp: none, - mutable resolve_unexported: false, - sess: sess}; + let e = create_env(sess, amap); map_crate(e, crate); resolve_imports(*e); check_exports(e); @@ -187,6 +170,36 @@ fn resolve_crate(sess: session, amap: ast_map::map, crate: @ast::crate) -> ret {def_map: e.def_map, exp_map: e.exp_map, impl_map: e.impl_map}; } +// Used by rustdoc +fn resolve_crate_reexports(sess: session, amap: ast_map::map, + crate: @ast::crate) -> exp_map { + let e = create_env(sess, amap); + map_crate(e, crate); + resolve_imports(*e); + check_exports(e); + ret e.exp_map; +} + +fn create_env(sess: session, amap: ast_map::map) -> @env { + @{cstore: sess.cstore, + def_map: new_int_hash(), + ast_map: amap, + imports: new_int_hash(), + exp_map: new_str_hash(), + mod_map: new_int_hash(), + block_map: new_int_hash(), + ext_map: new_def_hash(), + impl_map: new_int_hash(), + impl_cache: new_def_hash(), + ext_cache: new_ext_hash(), + used_imports: {mutable track: false, mutable data: []}, + mutable reported: [], + mutable ignored_imports: [], + mutable current_tp: none, + mutable resolve_unexported: false, + sess: sess} +} + // Locate all modules and imports and index them, so that the next passes can // resolve through them. fn map_crate(e: @env, c: @ast::crate) { |
