diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 3f09374309cb..6a56ca94f94d 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -32,11 +32,14 @@ tag output_type { output_type_exe; } -fn llvm_err(sess: session::session, msg: str) { +fn llvm_err(sess: session::session, msg: &istr) { let buf = llvm::LLVMRustGetLastError(); if buf as uint == 0u { - sess.fatal(msg); - } else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); } + sess.fatal(istr::to_estr(msg)); + } else { + sess.fatal( + istr::to_estr(msg) + ": " + str::str_from_cstr(buf)); + } } fn link_intrinsics(sess: session::session, llmod: ModuleRef) { @@ -46,19 +49,20 @@ fn link_intrinsics(sess: session::session, llmod: ModuleRef) { let membuf = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(str::buf(path)); if membuf as uint == 0u { - llvm_err(sess, "installation problem: couldn't open " + path); + llvm_err(sess, ~"installation problem: couldn't open " + + istr::from_estr(path)); fail; } let llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf); llvm::LLVMDisposeMemoryBuffer(membuf); if llintrinsicsmod as uint == 0u { - llvm_err(sess, "installation problem: couldn't parse intrinsics.bc"); + llvm_err(sess, ~"installation problem: couldn't parse intrinsics.bc"); fail; } let linkres = llvm::LLVMLinkModules(llmod, llintrinsicsmod); llvm::LLVMDisposeModule(llintrinsicsmod); if linkres == False { - llvm_err(sess, "couldn't link the module with the intrinsics"); + llvm_err(sess, ~"couldn't link the module with the intrinsics"); fail; } } @@ -74,15 +78,15 @@ mod write { // Decides what to call an intermediate file, given the name of the output // and the extension to use. - fn mk_intermediate_name(output_path: str, extension: str) -> str { - let dot_pos = str::index(output_path, '.' as u8); + fn mk_intermediate_name(output_path: &istr, extension: &istr) -> istr { + let dot_pos = istr::index(output_path, '.' as u8); let stem; if dot_pos < 0 { stem = output_path; - } else { stem = str::substr(output_path, 0u, dot_pos as uint); } - ret stem + "." + extension; + } else { stem = istr::substr(output_path, 0u, dot_pos as uint); } + ret stem + ~"." + extension; } - fn run_passes(sess: session::session, llmod: ModuleRef, output: str) { + fn run_passes(sess: session::session, llmod: ModuleRef, output: &istr) { let opts = sess.get_opts(); if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); } link_intrinsics(sess, llmod); @@ -99,12 +103,14 @@ mod write { alt opts.output_type { output_type_bitcode. { if opts.optimize != 0u { - let filename = mk_intermediate_name(output, "no-opt.bc"); + let filename = mk_intermediate_name(output, ~"no-opt.bc"); + let filename = istr::to_estr(filename); llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename)); } } _ { - let filename = mk_intermediate_name(output, "bc"); + let filename = mk_intermediate_name(output, ~"bc"); + let filename = istr::to_estr(filename); llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename)); } } @@ -176,7 +182,8 @@ mod write { if opts.save_temps { // Always output the bitcode file with --save-temps - let filename = mk_intermediate_name(output, "opt.bc"); + let filename = mk_intermediate_name(output, ~"opt.bc"); + let filename = istr::to_estr(filename); llvm::LLVMRunPassManager(pm.llpm, llmod); llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename)); pm = mk_pass_manager(); @@ -184,6 +191,7 @@ mod write { if opts.output_type == output_type_assembly { let triple = x86::get_target_triple(); + let output = istr::to_estr(output); llvm::LLVMRustWriteOutputFile(pm.llpm, llmod, str::buf(triple), str::buf(output), @@ -197,6 +205,7 @@ mod write { if opts.output_type == output_type_object || opts.output_type == output_type_exe { let triple = x86::get_target_triple(); + let output = istr::to_estr(output); llvm::LLVMRustWriteOutputFile(pm.llpm, llmod, str::buf(triple), str::buf(output), @@ -208,6 +217,7 @@ mod write { // type corresponding to the '-c' or '-S' flag used let triple = x86::get_target_triple(); + let output = istr::to_estr(output); llvm::LLVMRustWriteOutputFile(pm.llpm, llmod, str::buf(triple), str::buf(output), FileType, @@ -223,6 +233,7 @@ mod write { // flag, then output it here llvm::LLVMRunPassManager(pm.llpm, llmod); + let output = istr::to_estr(output); llvm::LLVMWriteBitcodeToFile(llmod, str::buf(output)); llvm::LLVMDisposeModule(llmod); if opts.time_llvm_passes { llvm::LLVMRustPrintPassTimings(); } @@ -281,32 +292,32 @@ mod write { * */ -type link_meta = {name: str, vers: str, extras_hash: str}; +type link_meta = {name: istr, vers: istr, extras_hash: istr}; -fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, +fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr, sha: sha1) -> link_meta { type provided_metas = - {name: option::t, - vers: option::t, + {name: option::t, + vers: option::t, cmh_items: [@ast::meta_item]}; fn provided_link_metas(sess: &session::session, c: &ast::crate) -> provided_metas { - let name: option::t = none; - let vers: option::t = none; + let name: option::t = none; + let vers: option::t = none; let cmh_items: [@ast::meta_item] = []; let linkage_metas = attr::find_linkage_metas(c.node.attrs); attr::require_unique_names(sess, linkage_metas); for meta: @ast::meta_item in linkage_metas { if attr::get_meta_item_name(meta) == ~"name" { alt attr::get_meta_item_value_str(meta) { - some(v) { name = some(v); } + some(v) { name = some(istr::from_estr(v)); } none. { cmh_items += [meta]; } } } else if attr::get_meta_item_name(meta) == ~"vers" { alt attr::get_meta_item_value_str(meta) { - some(v) { vers = some(v); } + some(v) { vers = some(istr::from_estr(v)); } none. { cmh_items += [meta]; } } } else { cmh_items += [meta]; } @@ -316,7 +327,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, // This calculates CMH as defined above fn crate_meta_extras_hash(sha: sha1, _crate: &ast::crate, - metas: &provided_metas) -> str { + metas: &provided_metas) -> istr { fn len_and_str(s: &istr) -> istr { ret istr::from_estr(#fmt["%u_%s", istr::byte_len(s), @@ -349,39 +360,39 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, ret truncated_sha1_result(sha); } - fn warn_missing(sess: &session::session, name: str, default: str) { + fn warn_missing(sess: &session::session, name: &istr, default: &istr) { if !sess.get_opts().library { ret; } sess.warn(#fmt["missing crate link meta '%s', using '%s' as default", - name, default]); + istr::to_estr(name), istr::to_estr(default)]); } fn crate_meta_name(sess: &session::session, _crate: &ast::crate, - output: &str, metas: &provided_metas) -> str { + output: &istr, metas: &provided_metas) -> istr { ret alt metas.name { some(v) { v } none. { let name = { let os = istr::split( - fs::basename(istr::from_estr(output)), + fs::basename(output), '.' as u8); assert (vec::len(os) >= 2u); vec::pop(os); - istr::to_estr(istr::connect(os, ~".")) + istr::connect(os, ~".") }; - warn_missing(sess, "name", name); + warn_missing(sess, ~"name", name); name } }; } fn crate_meta_vers(sess: &session::session, _crate: &ast::crate, - metas: &provided_metas) -> str { + metas: &provided_metas) -> istr { ret alt metas.vers { some(v) { v } none. { - let vers = "0.0"; - warn_missing(sess, "vers", vers); + let vers = ~"0.0"; + warn_missing(sess, ~"vers", vers); vers } }; @@ -395,32 +406,32 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str, ret {name: name, vers: vers, extras_hash: extras_hash}; } -fn truncated_sha1_result(sha: sha1) -> str { - ret istr::to_estr(istr::substr(sha.result_str(), 0u, 16u)); +fn truncated_sha1_result(sha: sha1) -> istr { + ret istr::substr(sha.result_str(), 0u, 16u); } // This calculates STH for a symbol, as defined above fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, link_meta: &link_meta) -> - str { + istr { // NB: do *not* use abbrevs here as we want the symbol names // to be independent of one another in the crate. sha.reset(); - sha.input_str(istr::from_estr(link_meta.name)); + sha.input_str(link_meta.name); sha.input_str(~"-"); // FIXME: This wants to be link_meta.meta_hash - sha.input_str(istr::from_estr(link_meta.name)); + sha.input_str(link_meta.name); sha.input_str(~"-"); sha.input_str(encoder::encoded_ty(tcx, t)); let hash = truncated_sha1_result(sha); // Prefix with _ so that it never blends into adjacent digits - ret "_" + hash; + ret ~"_" + hash; } -fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> str { - let hash = ""; +fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> istr { + let hash = ~""; alt ccx.type_sha1s.find(t) { some(h) { hash = h; } none. { @@ -431,47 +442,52 @@ fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> str { ret hash; } -fn mangle(ss: &[str]) -> str { +fn mangle(ss: &[istr]) -> istr { // Follow C++ namespace-mangling style - let n = "_ZN"; // Begin name-sequence. + let n = ~"_ZN"; // Begin name-sequence. - for s: str in ss { n += #fmt["%u%s", str::byte_len(s), s]; } - n += "E"; // End name-sequence. + for s: istr in ss { + n += istr::from_estr(#fmt["%u%s", + istr::byte_len(s), + istr::to_estr(s)]); + } + n += ~"E"; // End name-sequence. ret n; } -fn exported_name(path: &[str], hash: &str, _vers: &str) -> str { +fn exported_name(path: &[istr], hash: &istr, _vers: &istr) -> istr { // FIXME: versioning isn't working yet ret mangle(path + [hash]); // + "@" + vers; } -fn mangle_exported_name(ccx: &@crate_ctxt, path: &[str], t: ty::t) -> str { +fn mangle_exported_name(ccx: &@crate_ctxt, path: &[istr], t: ty::t) -> istr { let hash = get_symbol_hash(ccx, t); ret exported_name(path, hash, ccx.link_meta.vers); } -fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &str) - -> str { +fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &istr) + -> istr { let s = util::ppaux::ty_to_short_str(ccx.tcx, t); let hash = get_symbol_hash(ccx, t); - ret mangle([name, istr::to_estr(s), hash]); + ret mangle([name, s, hash]); } -fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[str], - flav: &str) -> str { - ret mangle(path + [ccx.names.next(flav)]); +fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[istr], + flav: &istr) -> istr { + ret mangle(path + + istr::from_estrs([ccx.names.next(istr::to_estr(flav))])); } -fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[str]) -> str { +fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[istr]) -> istr { ret mangle(path); } -fn mangle_internal_name_by_seq(ccx: &@crate_ctxt, flav: &str) -> str { - ret ccx.names.next(flav); +fn mangle_internal_name_by_seq(ccx: &@crate_ctxt, flav: &istr) -> istr { + ret istr::from_estr(ccx.names.next(istr::to_estr(flav))); } // // Local Variables: diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 18ff05596240..be7e06d0460b 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -169,7 +169,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str, bind trans::trans_crate(sess, crate, ty_cx, output, ast_map, mut_map)); time(time_passes, "LLVM passes", - bind link::write::run_passes(sess, llmod, output)); + bind link::write::run_passes(sess, llmod, istr::from_estr(output))); } fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str, diff --git a/src/comp/metadata/encoder.rs b/src/comp/metadata/encoder.rs index f803292d9ad4..537e40761af1 100644 --- a/src/comp/metadata/encoder.rs +++ b/src/comp/metadata/encoder.rs @@ -504,13 +504,15 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] { fn synthesize_link_attr(ecx: &@encode_ctxt, items: &[@meta_item]) -> attribute { - assert (ecx.ccx.link_meta.name != ""); - assert (ecx.ccx.link_meta.vers != ""); + assert (ecx.ccx.link_meta.name != ~""); + assert (ecx.ccx.link_meta.vers != ~""); let name_item = - attr::mk_name_value_item_str(~"name", ecx.ccx.link_meta.name); + attr::mk_name_value_item_str( + ~"name", istr::to_estr(ecx.ccx.link_meta.name)); let vers_item = - attr::mk_name_value_item_str(~"vers", ecx.ccx.link_meta.vers); + attr::mk_name_value_item_str( + ~"vers", istr::to_estr(ecx.ccx.link_meta.vers)); let other_items = { diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index c2391563b787..65c829d2bd7d 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -287,23 +287,23 @@ fn type_of_or_i8(bcx: &@block_ctxt, typ: ty::t) -> TypeRef { // Name sanitation. LLVM will happily accept identifiers with weird names, but // gas doesn't! -fn sanitize(s: &str) -> str { - let result = ""; +fn sanitize(s: &istr) -> istr { + let result = ~""; for c: u8 in s { if c == '@' as u8 { - result += "boxed_"; + result += ~"boxed_"; } else { if c == ',' as u8 { - result += "_"; + result += ~"_"; } else { if c == '{' as u8 || c == '(' as u8 { - result += "_of_"; + result += ~"_of_"; } else { if c != 10u8 && c != '}' as u8 && c != ')' as u8 && c != ' ' as u8 && c != '\t' as u8 && c != ';' as u8 { let v = [c]; - result += str::unsafe_from_bytes(v); + result += istr::unsafe_from_bytes(v); } } } @@ -1137,9 +1137,10 @@ fn declare_tydesc(cx: &@local_ctxt, sp: &span, t: ty::t, ty_params: &[uint]) } let name; if cx.ccx.sess.get_opts().debuginfo { - name = mangle_internal_name_by_type_only(cx.ccx, t, "tydesc"); + name = mangle_internal_name_by_type_only(cx.ccx, t, ~"tydesc"); name = sanitize(name); - } else { name = mangle_internal_name_by_seq(cx.ccx, "tydesc"); } + } else { name = mangle_internal_name_by_seq(cx.ccx, ~"tydesc"); } + let name = istr::to_estr(name); let gvar = llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, str::buf(name)); let info = @@ -1164,12 +1165,13 @@ tag glue_helper { fn declare_generic_glue(cx: &@local_ctxt, t: ty::t, llfnty: TypeRef, name: &str) -> ValueRef { + let name = istr::from_estr(name); let fn_nm; if cx.ccx.sess.get_opts().debuginfo { - fn_nm = mangle_internal_name_by_type_only(cx.ccx, t, "glue_" + name); + fn_nm = mangle_internal_name_by_type_only(cx.ccx, t, ~"glue_" + name); fn_nm = sanitize(fn_nm); - } else { fn_nm = mangle_internal_name_by_seq(cx.ccx, "glue_" + name); } - let llfn = decl_cdecl_fn(cx.ccx.llmod, fn_nm, llfnty); + } else { fn_nm = mangle_internal_name_by_seq(cx.ccx, ~"glue_" + name); } + let llfn = decl_cdecl_fn(cx.ccx.llmod, istr::to_estr(fn_nm), llfnty); set_glue_inlining(cx, llfn, t); ret llfn; } @@ -3155,8 +3157,10 @@ fn trans_for_each(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr, let llenv = build_closure(cx, upvars, false); // Step 2: Declare foreach body function. - let s: str = - mangle_internal_name_by_path_and_seq(lcx.ccx, lcx.path, "foreach"); + let s: istr = + mangle_internal_name_by_path_and_seq(lcx.ccx, + istr::from_estrs(lcx.path), + ~"foreach"); // The 'env' arg entering the body function is a fake env member (as in // the env-part of the normal rust calling convention) that actually @@ -3167,7 +3171,8 @@ fn trans_for_each(cx: &@block_ctxt, local: &@ast::local, seq: &@ast::expr, type_of_fn_from_ty(lcx.ccx, cx.sp, ty::mk_iter_body_fn(lcx.ccx.tcx, decl_ty), 0u); let lliterbody: ValueRef = - decl_internal_fastcall_fn(lcx.ccx.llmod, s, iter_body_llty); + decl_internal_fastcall_fn(lcx.ccx.llmod, + istr::to_estr(s), iter_body_llty); let fcx = new_fn_ctxt_w_id(lcx, cx.sp, lliterbody, body.node.id); fcx.iterbodyty = cx.fcx.iterbodyty; @@ -3699,12 +3704,15 @@ fn trans_bind_thunk(cx: &@local_ctxt, sp: &span, incoming_fty: ty::t, // construct and return that thunk. // Give the thunk a name, type, and value. - let s: str = - mangle_internal_name_by_path_and_seq(cx.ccx, cx.path, "thunk"); + let s: istr = + mangle_internal_name_by_path_and_seq(cx.ccx, + istr::from_estrs(cx.path), + ~"thunk"); let llthunk_ty: TypeRef = get_pair_fn_ty(type_of(cx.ccx, sp, incoming_fty)); let llthunk: ValueRef = - decl_internal_fastcall_fn(cx.ccx.llmod, s, llthunk_ty); + decl_internal_fastcall_fn(cx.ccx.llmod, + istr::to_estr(s), llthunk_ty); // Create a new function context and block context for the thunk, and hold // onto a pointer to the first block in the function for later use. @@ -4298,8 +4306,10 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) -> let llfnty: TypeRef = type_of_fn_from_ty(ccx, e.span, node_id_type(ccx, e.id), 0u); let sub_cx = extend_path(cx.fcx.lcx, ccx.names.next("anon")); - let s = mangle_internal_name_by_path(ccx, sub_cx.path); - let llfn = decl_internal_fastcall_fn(ccx.llmod, s, llfnty); + let s = mangle_internal_name_by_path(ccx, + istr::from_estrs(sub_cx.path)); + let llfn = decl_internal_fastcall_fn(ccx.llmod, + istr::to_estr(s), llfnty); let fn_res = trans_closure(some(cx), some(llfnty), sub_cx, e.span, f, llfn, @@ -4308,7 +4318,8 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) -> alt fn_res { some(fn_pair) { fn_pair } none. { - {fn_pair: create_fn_pair(ccx, s, llfnty, llfn, false), + {fn_pair: create_fn_pair(ccx, istr::to_estr(s), + llfnty, llfn, false), bcx: cx} } }; @@ -4532,9 +4543,11 @@ fn trans_log(lvl: int, cx: &@block_ctxt, e: &@ast::expr) -> result { global = lcx.ccx.module_data.get(istr::from_estr(modname)); } else { let s = - link::mangle_internal_name_by_path_and_seq(lcx.ccx, - lcx.module_path, - "loglevel"); + link::mangle_internal_name_by_path_and_seq( + lcx.ccx, + istr::from_estrs(lcx.module_path), + ~"loglevel"); + let s = istr::to_estr(s); global = llvm::LLVMAddGlobal(lcx.ccx.llmod, T_int(), str::buf(s)); llvm::LLVMSetGlobalConstant(global, False); llvm::LLVMSetInitializer(global, C_null(T_int())); @@ -5130,7 +5143,7 @@ fn trans_block(cx: &@block_ctxt, b: &ast::blk, output: &out_method) -> fn new_local_ctxt(ccx: &@crate_ctxt) -> @local_ctxt { let pth: [str] = []; ret @{path: pth, - module_path: [ccx.link_meta.name], + module_path: [istr::to_estr(ccx.link_meta.name)], obj_typarams: [], obj_fields: [], ccx: ccx}; @@ -5702,6 +5715,7 @@ fn decl_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str], flav: str, fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &[str], _flav: str, ty_params: &[ast::ty_param], node_id: ast::node_id, node_type: ty::t) { + let path = istr::from_estrs(path); let llfty = type_of_fn_from_ty(ccx, sp, node_type, std::vec::len(ty_params)); alt ty::struct(ccx.tcx, node_type) { @@ -5712,14 +5726,14 @@ fn decl_fn_and_pair_full(ccx: &@crate_ctxt, sp: &span, path: &[str], } _ { ccx.sess.bug("decl_fn_and_pair(): fn item doesn't have fn type!"); } } - let s: str = mangle_internal_name_by_path(ccx, path); - let llfn: ValueRef = decl_internal_fastcall_fn(ccx.llmod, s, llfty); + let s: istr = mangle_internal_name_by_path(ccx, path); + let llfn: ValueRef = decl_internal_fastcall_fn(ccx.llmod, + istr::to_estr(s), llfty); // Declare the global constant pair that points to it. - let ps: str = mangle_exported_name(ccx, path, node_type); - register_fn_pair(ccx, ps, llfty, llfn, node_id); + let ps: istr = mangle_exported_name(ccx, path, node_type); + register_fn_pair(ccx, istr::to_estr(ps), llfty, llfn, node_id); - let path = istr::from_estrs(path); let is_main: bool = is_main_name(path) && !ccx.sess.get_opts().library; if is_main { create_main_wrapper(ccx, sp, llfn, node_type); } } @@ -5851,18 +5865,20 @@ fn native_fn_wrapper_type(cx: &@crate_ctxt, sp: &span, ty_param_count: uint, fn decl_native_fn_and_pair(ccx: &@crate_ctxt, sp: &span, path: &[str], name: str, id: ast::node_id) { + let path = istr::from_estrs(path); let num_ty_param = native_fn_ty_param_count(ccx, id); // Declare the wrapper. let t = node_id_type(ccx, id); let wrapper_type = native_fn_wrapper_type(ccx, sp, num_ty_param, t); - let s: str = mangle_internal_name_by_path(ccx, path); + let s: istr = mangle_internal_name_by_path(ccx, path); let wrapper_fn: ValueRef = - decl_internal_fastcall_fn(ccx.llmod, s, wrapper_type); + decl_internal_fastcall_fn(ccx.llmod, + istr::to_estr(s), wrapper_type); // Declare the global constant pair that points to it. - let ps: str = mangle_exported_name(ccx, path, node_id_type(ccx, id)); - register_fn_pair(ccx, ps, wrapper_type, wrapper_fn, id); + let ps: istr = mangle_exported_name(ccx, path, node_id_type(ccx, id)); + register_fn_pair(ccx, istr::to_estr(ps), wrapper_type, wrapper_fn, id); // Build the wrapper. let fcx = new_fn_ctxt(new_local_ctxt(ccx), sp, wrapper_fn); @@ -6054,8 +6070,9 @@ fn collect_item_1(ccx: @crate_ctxt, i: &@ast::item, pt: &[str], ast::item_const(_, _) { let typ = node_id_type(ccx, i.id); let s = - mangle_exported_name(ccx, pt + [istr::to_estr(i.ident)], + mangle_exported_name(ccx, istr::from_estrs(pt) + [i.ident], node_id_type(ccx, i.id)); + let s = istr::to_estr(s); let g = llvm::LLVMAddGlobal(ccx.llmod, type_of(ccx, i.span, typ), str::buf(s)); @@ -6143,9 +6160,12 @@ fn trans_constant(ccx: @crate_ctxt, it: &@ast::item, pt: &[str], let n_variants = std::vec::len::(variants); while i < n_variants { let variant = variants[i]; - let p = new_pt + istr::to_estrs([it.ident, - variant.node.name, ~"discrim"]); - let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx)); + let p = istr::from_estrs(new_pt) + [it.ident, + variant.node.name, + ~"discrim"]; + let s = mangle_exported_name(ccx, p, + ty::mk_int(ccx.tcx)); + let s = istr::to_estr(s); let discrim_gvar = llvm::LLVMAddGlobal(ccx.llmod, T_int(), str::buf(s)); if n_variants != 1u { @@ -6263,7 +6283,7 @@ fn make_common_glue(sess: &session::session, output: &str) { let modl_asm = x86::get_module_asm(); //HACK (buf lifetime issue) llvm::LLVMSetModuleInlineAsm(llmod, str::buf(modl_asm)); make_glues(llmod, taskptr_type); - link::write::run_passes(sess, llmod, output); + link::write::run_passes(sess, llmod, istr::from_estr(output)); } fn create_module_map(ccx: &@crate_ctxt) -> ValueRef { @@ -6301,8 +6321,8 @@ fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef { let mapname; if ccx.sess.get_opts().library { mapname = ccx.link_meta.name; - } else { mapname = "toplevel"; } - let sym_name = "_rust_crate_map_" + mapname; + } else { mapname = ~"toplevel"; } + let sym_name = istr::to_estr(~"_rust_crate_map_" + mapname); let arrtype = T_array(T_int(), std::vec::len::(subcrates)); let maptype = T_struct([T_int(), arrtype]); let map = llvm::LLVMAddGlobal(ccx.llmod, maptype, str::buf(sym_name)); @@ -6367,7 +6387,7 @@ fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt, let tag_sizes = map::mk_hashmap::(hasher, eqer); let tydescs = map::mk_hashmap::(hasher, eqer); let lltypes = map::mk_hashmap::(hasher, eqer); - let sha1s = map::mk_hashmap::(hasher, eqer); + let sha1s = map::mk_hashmap::(hasher, eqer); let short_names = map::mk_hashmap::(hasher, eqer); let sha = std::sha1::mk_sha1(); let ccx = @@ -6381,7 +6401,8 @@ fn trans_crate(sess: &session::session, crate: &@ast::crate, tcx: &ty::ctxt, ast_map: amap, item_symbols: new_int_hash::(), mutable main_fn: none::, - link_meta: link::build_link_meta(sess, *crate, output, sha), + link_meta: link::build_link_meta(sess, *crate, + istr::from_estr(output), sha), tag_sizes: tag_sizes, discrims: new_int_hash::(), discrim_symbols: new_int_hash::(), diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index 77a101d9f681..b4c243d9842c 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -146,7 +146,7 @@ type crate_ctxt = glues: @glue_fns, names: namegen, sha: std::sha1::sha1, - type_sha1s: hashmap, + type_sha1s: hashmap, type_short_names: hashmap, tcx: ty::ctxt, mut_map: alias::mut_map, diff --git a/src/comp/middle/trans_objects.rs b/src/comp/middle/trans_objects.rs index c55d32593d8d..085c955c2c39 100644 --- a/src/comp/middle/trans_objects.rs +++ b/src/comp/middle/trans_objects.rs @@ -569,7 +569,9 @@ fn create_backwarding_vtbl(cx: @local_ctxt, sp: &span, inner_obj_ty: ty::t, fn finish_vtbl(cx: @local_ctxt, llmethods: [ValueRef], name: str) -> ValueRef { let vtbl = C_struct(llmethods); - let vtbl_name = mangle_internal_name_by_path(cx.ccx, cx.path + [name]); + let vtbl_name = mangle_internal_name_by_path( + cx.ccx, istr::from_estrs(cx.path + [name])); + let vtbl_name = istr::to_estr(vtbl_name); let gvar = llvm::LLVMAddGlobal(cx.ccx.llmod, val_ty(vtbl), str::buf(vtbl_name)); llvm::LLVMSetInitializer(gvar, vtbl); @@ -603,16 +605,18 @@ fn process_bkwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, + ["method", istr::to_estr(m.ident)] with *cx}; // Make up a name for the backwarding function. - let fn_name: str = "backwarding_fn"; - let s: str = - mangle_internal_name_by_path_and_seq(mcx.ccx, mcx.path, fn_name); + let fn_name: istr = ~"backwarding_fn"; + let s: istr = + mangle_internal_name_by_path_and_seq( + mcx.ccx, istr::from_estrs(mcx.path), fn_name); // Get the backwarding function's type and declare it. let llbackwarding_fn_ty: TypeRef = type_of_fn_full(cx.ccx, sp, m.proto, true, m.inputs, m.output, std::vec::len::(ty_params)); let llbackwarding_fn: ValueRef = - decl_internal_fastcall_fn(cx.ccx.llmod, s, llbackwarding_fn_ty); + decl_internal_fastcall_fn( + cx.ccx.llmod, istr::to_estr(s), llbackwarding_fn_ty); // Create a new function context and block context for the backwarding // function, holding onto a pointer to the first block. @@ -732,16 +736,18 @@ fn process_fwding_mthd(cx: @local_ctxt, sp: &span, m: @ty::method, + ["method", istr::to_estr(m.ident)] with *cx}; // Make up a name for the forwarding function. - let fn_name: str = "forwarding_fn"; - let s: str = - mangle_internal_name_by_path_and_seq(mcx.ccx, mcx.path, fn_name); + let fn_name: istr = ~"forwarding_fn"; + let s: istr = + mangle_internal_name_by_path_and_seq( + mcx.ccx, istr::from_estrs(mcx.path), fn_name); // Get the forwarding function's type and declare it. let llforwarding_fn_ty: TypeRef = type_of_fn_full(cx.ccx, sp, m.proto, true, m.inputs, m.output, std::vec::len::(ty_params)); let llforwarding_fn: ValueRef = - decl_internal_fastcall_fn(cx.ccx.llmod, s, llforwarding_fn_ty); + decl_internal_fastcall_fn( + cx.ccx.llmod, istr::to_estr(s), llforwarding_fn_ty); // Create a new function context and block context for the forwarding // function, holding onto a pointer to the first block. @@ -921,14 +927,16 @@ fn process_normal_mthd(cx: @local_ctxt, m: @ast::method, self_ty: ty::t, } let mcx: @local_ctxt = @{path: cx.path + ["method", istr::to_estr(m.node.ident)] with *cx}; - let s: str = mangle_internal_name_by_path(mcx.ccx, mcx.path); - let llfn: ValueRef = decl_internal_fastcall_fn(cx.ccx.llmod, s, llfnty); + let s: istr = mangle_internal_name_by_path(mcx.ccx, + istr::from_estrs(mcx.path)); + let llfn: ValueRef = decl_internal_fastcall_fn( + cx.ccx.llmod, istr::to_estr(s), llfnty); // Every method on an object gets its node_id inserted into the crate-wide // item_ids map, together with the ValueRef that points to where that // method's definition will be in the executable. cx.ccx.item_ids.insert(m.node.id, llfn); - cx.ccx.item_symbols.insert(m.node.id, s); + cx.ccx.item_symbols.insert(m.node.id, istr::to_estr(s)); trans_fn(mcx, m.span, m.node.meth, llfn, some(self_ty), ty_params, m.node.id);