diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-03 09:53:37 +0100 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2012-02-03 11:34:12 +0100 |
| commit | 43ce38375d95fcc33c550037bfb96ef2a75ce253 (patch) | |
| tree | a5a97ce956600bdabf764773cd1b94b1134238bc /src/comp/back | |
| parent | c1b075d042cabb90f804f3d73e6a4f4b512aa697 (diff) | |
| download | rust-43ce38375d95fcc33c550037bfb96ef2a75ce253.tar.gz rust-43ce38375d95fcc33c550037bfb96ef2a75ce253.zip | |
Store item paths in ast_map, get rid of trans::local_ctxt
The direct motivation for this was that the monomorphizer needs to be able to generate sane symbols for random items. The typechecker can probably also use this in the future to provide more useful error messages.
Diffstat (limited to 'src/comp/back')
| -rw-r--r-- | src/comp/back/link.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 0052cdd352a..eee0c60599f 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -18,6 +18,7 @@ import syntax::ast; import syntax::print::pprust; import lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False}; import util::filesearch; +import middle::ast_map::{path, path_mod, path_name}; enum output_type { output_type_none, @@ -514,25 +515,27 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> str { ret hash; } -fn mangle(ss: [str]) -> str { +fn mangle(ss: path) -> str { // Follow C++ namespace-mangling style let n = "_ZN"; // Begin name-sequence. - for s: str in ss { n += #fmt["%u%s", str::byte_len(s), s]; } + for s in ss { + alt s { path_name(s) | path_mod(s) { + n += #fmt["%u%s", str::byte_len(s), s]; + } } + } n += "E"; // End name-sequence. - - ret n; + n } -fn exported_name(path: [str], hash: str, _vers: str) -> str { +fn exported_name(path: path, hash: str, _vers: str) -> str { // FIXME: versioning isn't working yet - - ret mangle(path + [hash]); // + "@" + vers; + ret mangle(path + [path_name(hash)]); // + "@" + vers; } -fn mangle_exported_name(ccx: @crate_ctxt, path: [str], t: ty::t) -> str { +fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str { let hash = get_symbol_hash(ccx, t); ret exported_name(path, hash, ccx.link_meta.vers); } @@ -541,15 +544,15 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: str) -> str { let s = util::ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); - ret mangle([name, s, hash]); + ret mangle([path_name(name), path_name(s), path_name(hash)]); } -fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: [str], +fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path, flav: str) -> str { - ret mangle(path + [ccx.names(flav)]); + ret mangle(path + [path_name(ccx.names(flav))]); } -fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: [str]) -> str { +fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str { ret mangle(path); } |
