diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs index 0e4f957b5ba..1b12c318163 100644 --- a/src/comp/back/link.rs +++ b/src/comp/back/link.rs @@ -490,8 +490,7 @@ fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &istr) 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))])); + ret mangle(path + [ccx.names.next(flav)]); } fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[istr]) -> istr { @@ -499,7 +498,7 @@ fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[istr]) -> istr { } fn mangle_internal_name_by_seq(ccx: &@crate_ctxt, flav: &istr) -> istr { - ret istr::from_estr(ccx.names.next(istr::to_estr(flav))); + ret ccx.names.next(flav); } // // Local Variables: diff --git a/src/comp/middle/shape.rs b/src/comp/middle/shape.rs index 8a1201b4d83..d84105656d2 100644 --- a/src/comp/middle/shape.rs +++ b/src/comp/middle/shape.rs @@ -248,7 +248,7 @@ fn s_float(_tcx: &ty_ctxt) -> u8 { } fn mk_ctxt(llmod: ModuleRef) -> ctxt { - let llshapetablesty = trans_common::T_named_struct("shapes"); + let llshapetablesty = trans_common::T_named_struct(~"shapes"); let llshapetables = istr::as_buf(~"shapes", { |buf| lib::llvm::llvm::LLVMAddGlobal(llmod, llshapetablesty, buf) }); diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 200fd042416..a5fb80433bd 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -2492,7 +2492,7 @@ fn trans_lit_istr(cx: &@block_ctxt, s: str) -> result { let llvecptr = alloc_res.llptr; let llfirsteltptr = alloc_res.llfirsteltptr; - let llcstr = C_cstr(bcx_ccx(cx), s); + let llcstr = C_cstr(bcx_ccx(cx), istr::from_estr(s)); // FIXME: We need to avoid this memmove bcx = call_memmove(bcx, llfirsteltptr, llcstr, C_uint(veclen)).bcx; @@ -2523,16 +2523,16 @@ fn trans_crate_lit(cx: &@crate_ctxt, lit: &ast::lit) -> ValueRef { } ret C_integral(t, i as uint, s); } - ast::lit_float(fs) { ret C_float(fs); } + ast::lit_float(fs) { ret C_float(istr::from_estr(fs)); } ast::lit_mach_float(tm, s) { let t = T_float(); alt tm { ast::ty_f32. { t = T_f32(); } ast::ty_f64. { t = T_f64(); } } - ret C_floating(s, t); + ret C_floating(istr::from_estr(s), t); } ast::lit_char(c) { ret C_integral(T_char(), c as uint, False); } ast::lit_bool(b) { ret C_bool(b); } ast::lit_nil. { ret C_nil(); } - ast::lit_str(s, ast::sk_rc.) { ret C_str(cx, s); } + ast::lit_str(s, ast::sk_rc.) { ret C_str(cx, istr::from_estr(s)); } ast::lit_str(s, ast::sk_unique.) { cx.sess.span_unimpl(lit.span, "unique string in this context"); } @@ -4317,7 +4317,8 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) -> let ccx = bcx_ccx(cx); 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 sub_cx = extend_path(cx.fcx.lcx, + istr::to_estr(ccx.names.next(~"anon"))); let s = mangle_internal_name_by_path(ccx, istr::from_estrs(sub_cx.path)); let llfn = decl_internal_fastcall_fn(ccx.llmod, @@ -4632,7 +4633,7 @@ fn trans_fail_expr(cx: &@block_ctxt, sp_opt: &option::t, fn trans_fail(cx: &@block_ctxt, sp_opt: &option::t, fail_str: &str) -> result { - let V_fail_str = C_cstr(bcx_ccx(cx), fail_str); + let V_fail_str = C_cstr(bcx_ccx(cx), istr::from_estr(fail_str)); ret trans_fail_value(cx, sp_opt, V_fail_str); } @@ -4643,10 +4644,10 @@ fn trans_fail_value(cx: &@block_ctxt, sp_opt: &option::t, alt sp_opt { some(sp) { let loc = bcx_ccx(cx).sess.lookup_pos(sp.lo); - V_filename = C_cstr(bcx_ccx(cx), loc.filename); + V_filename = C_cstr(bcx_ccx(cx), istr::from_estr(loc.filename)); V_line = loc.line as int; } - none. { V_filename = C_cstr(bcx_ccx(cx), ""); V_line = 0; } + none. { V_filename = C_cstr(bcx_ccx(cx), ~""); V_line = 0; } } let V_str = bld::PointerCast(cx, V_fail_str, T_ptr(T_i8())); V_filename = bld::PointerCast(cx, V_filename, T_ptr(T_i8())); @@ -4924,12 +4925,12 @@ fn trans_stmt(cx: &@block_ctxt, s: &ast::stmt) -> result { // next three functions instead. fn new_block_ctxt(cx: &@fn_ctxt, parent: &block_parent, kind: block_kind, name: &str) -> @block_ctxt { - let s = ""; + let s = ~""; if cx.lcx.ccx.sess.get_opts().save_temps || cx.lcx.ccx.sess.get_opts().debuginfo { - s = cx.lcx.ccx.names.next(name); + s = cx.lcx.ccx.names.next(istr::from_estr(name)); } - let llbb: BasicBlockRef = istr::as_buf(istr::from_estr(s), { |buf| + let llbb: BasicBlockRef = istr::as_buf(s, { |buf| llvm::LLVMAppendBasicBlock(cx.llfn, buf) }); ret @{llbb: llbb, @@ -6325,7 +6326,7 @@ fn create_module_map(ccx: &@crate_ctxt) -> ValueRef { lib::llvm::LLVMInternalLinkage as llvm::Linkage); let elts: [ValueRef] = []; for each item: @{key: istr, val: ValueRef} in ccx.module_data.items() { - let elt = C_struct([p2i(C_cstr(ccx, istr::to_estr(item.key))), + let elt = C_struct([p2i(C_cstr(ccx, item.key)), p2i(item.val)]); elts += [elt]; } @@ -6370,7 +6371,8 @@ fn create_crate_map(ccx: &@crate_ctxt) -> ValueRef { fn write_metadata(cx: &@crate_ctxt, crate: &@ast::crate) { if !cx.sess.get_opts().library { ret; } - let llmeta = C_postr(metadata::encoder::encode_metadata(cx, crate)); + let llmeta = C_postr( + istr::from_estr(metadata::encoder::encode_metadata(cx, crate))); let llconst = trans_common::C_struct([llmeta]); let llglobal = istr::as_buf(~"rust_metadata", { |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(llconst), buf) diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index f193f1e5623..e4c842bdf4f 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -63,8 +63,8 @@ import trans::type_of_fn_full; import trans::drop_ty; obj namegen(mutable i: int) { - fn next(prefix: str) -> str { - i += 1; ret prefix + istr::to_estr(int::str(i)); + fn next(prefix: &istr) -> istr { + i += 1; ret prefix + int::str(i); } } @@ -438,13 +438,15 @@ fn rslt(bcx: @block_ctxt, val: ValueRef) -> result { ret {bcx: bcx, val: val}; } -fn ty_str(tn: type_names, t: TypeRef) -> str { - ret istr::to_estr(lib::llvm::type_to_str(tn, t)); +fn ty_str(tn: type_names, t: TypeRef) -> istr { + ret lib::llvm::type_to_str(tn, t); } fn val_ty(v: ValueRef) -> TypeRef { ret llvm::LLVMTypeOf(v); } -fn val_str(tn: type_names, v: ValueRef) -> str { ret ty_str(tn, val_ty(v)); } +fn val_str(tn: type_names, v: ValueRef) -> istr { + ret ty_str(tn, val_ty(v)); +} // Returns the nth element of the given LLVM structure type. fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef { @@ -551,9 +553,9 @@ fn T_struct(elts: &[TypeRef]) -> TypeRef { False); } -fn T_named_struct(name: &str) -> TypeRef { +fn T_named_struct(name: &istr) -> TypeRef { let c = llvm::LLVMGetGlobalContext(); - ret istr::as_buf(istr::from_estr(name), { |buf| + ret istr::as_buf(name, { |buf| llvm::LLVMStructCreateNamed(c, buf) }); } @@ -570,14 +572,14 @@ fn T_empty_struct() -> TypeRef { ret T_struct([]); } // existing objects, use ccx.rust_object_type. Calling // T_rust_object() again will return a different one. fn T_rust_object() -> TypeRef { - let t = T_named_struct("rust_object"); + let t = T_named_struct(~"rust_object"); let e = T_ptr(T_empty_struct()); set_struct_body(t, [e, e]); ret t; } fn T_task() -> TypeRef { - let t = T_named_struct("task"); + let t = T_named_struct(~"task"); // Refcount // Delegate pointer @@ -633,7 +635,7 @@ fn T_copy_glue_fn(cx: &crate_ctxt) -> TypeRef { } fn T_tydesc(taskptr_type: TypeRef) -> TypeRef { - let tydesc = T_named_struct("tydesc"); + let tydesc = T_named_struct(~"tydesc"); let tydescpp = T_ptr(T_ptr(tydesc)); let pvoid = T_ptr(T_i8()); let glue_fn_ty = @@ -817,14 +819,14 @@ fn C_integral(t: TypeRef, u: uint, sign_extend: Bool) -> ValueRef { ret llvm::LLVMRustConstSmallInt(t, u, sign_extend); } -fn C_float(s: &str) -> ValueRef { - ret istr::as_buf(istr::from_estr(s), { |buf| +fn C_float(s: &istr) -> ValueRef { + ret istr::as_buf(s, { |buf| llvm::LLVMConstRealOfString(T_float(), buf) }); } -fn C_floating(s: &str, t: TypeRef) -> ValueRef { - ret istr::as_buf(istr::from_estr(s), { |buf| +fn C_floating(s: &istr, t: TypeRef) -> ValueRef { + ret istr::as_buf(s, { |buf| llvm::LLVMConstRealOfString(t, buf) }); } @@ -850,11 +852,11 @@ fn C_u8(i: uint) -> ValueRef { ret C_integral(T_i8(), i, False); } // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. -fn C_cstr(cx: &@crate_ctxt, s: &str) -> ValueRef { - let sc = istr::as_buf(istr::from_estr(s), { |buf| - llvm::LLVMConstString(buf, str::byte_len(s), False) +fn C_cstr(cx: &@crate_ctxt, s: &istr) -> ValueRef { + let sc = istr::as_buf(s, { |buf| + llvm::LLVMConstString(buf, istr::byte_len(s), False) }); - let g = istr::as_buf(istr::from_estr(cx.names.next("str")), { |buf| + let g = istr::as_buf(cx.names.next(~"str"), { |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(sc), buf) }); llvm::LLVMSetInitializer(g, sc); @@ -865,19 +867,19 @@ fn C_cstr(cx: &@crate_ctxt, s: &str) -> ValueRef { // A rust boxed-and-length-annotated string. -fn C_str(cx: &@crate_ctxt, s: &str) -> ValueRef { +fn C_str(cx: &@crate_ctxt, s: &istr) -> ValueRef { let len = - str::byte_len(s); // 'alloc' + istr::byte_len(s); // 'alloc' // 'fill' // 'pad' - let cstr = istr::as_buf(istr::from_estr(s), { |buf| + let cstr = istr::as_buf(s, { |buf| llvm::LLVMConstString(buf, len, False) }); let box = C_struct([C_int(abi::const_refcount as int), C_int(len + 1u as int), C_int(len + 1u as int), C_int(0), cstr]); - let g = istr::as_buf(istr::from_estr(cx.names.next("str")), { |buf| + let g = istr::as_buf(cx.names.next(~"str"), { |buf| llvm::LLVMAddGlobal(cx.llmod, val_ty(box), buf) }); llvm::LLVMSetInitializer(g, box); @@ -887,9 +889,9 @@ fn C_str(cx: &@crate_ctxt, s: &str) -> ValueRef { } // Returns a Plain Old LLVM String: -fn C_postr(s: &str) -> ValueRef { - ret istr::as_buf(istr::from_estr(s), { |buf| - llvm::LLVMConstString(buf, str::byte_len(s), False) +fn C_postr(s: &istr) -> ValueRef { + ret istr::as_buf(s, { |buf| + llvm::LLVMConstString(buf, istr::byte_len(s), False) }); } @@ -922,8 +924,7 @@ fn C_bytes(bytes: &[u8]) -> ValueRef { fn C_shape(ccx: &@crate_ctxt, bytes: &[u8]) -> ValueRef { let llshape = C_bytes(bytes); - let llglobal = istr::as_buf( - istr::from_estr(ccx.names.next("shape")), { |buf| + let llglobal = istr::as_buf(ccx.names.next(~"shape"), { |buf| llvm::LLVMAddGlobal(ccx.llmod, val_ty(llshape), buf) }); llvm::LLVMSetInitializer(llglobal, llshape);