Skip to content

Commit 6bd25f7

Browse files
committed
---
yaml --- r: 4991 b: refs/heads/master c: a58bfce h: refs/heads/master i: 4989: da5cd85 4987: df929e1 4983: 00c1437 4975: 87c24bd 4959: 75af126 4927: 706fd60 4863: 9cf28fa v: v3
1 parent 3ea437d commit 6bd25f7

File tree

7 files changed

+163
-116
lines changed

7 files changed

+163
-116
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 9c9c5c9054c2680a68c47f0bd9d80625b0906507
2+
refs/heads/master: a58bfced3cdb8e4eccbee9c5f9494ab1929d3720

trunk/src/comp/back/link.rs

+71-55
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ tag output_type {
3232
output_type_exe;
3333
}
3434

35-
fn llvm_err(sess: session::session, msg: str) {
35+
fn llvm_err(sess: session::session, msg: &istr) {
3636
let buf = llvm::LLVMRustGetLastError();
3737
if buf as uint == 0u {
38-
sess.fatal(msg);
39-
} else { sess.fatal(msg + ": " + str::str_from_cstr(buf)); }
38+
sess.fatal(istr::to_estr(msg));
39+
} else {
40+
sess.fatal(
41+
istr::to_estr(msg) + ": " + str::str_from_cstr(buf));
42+
}
4043
}
4144

4245
fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
@@ -46,19 +49,20 @@ fn link_intrinsics(sess: session::session, llmod: ModuleRef) {
4649
let membuf =
4750
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(str::buf(path));
4851
if membuf as uint == 0u {
49-
llvm_err(sess, "installation problem: couldn't open " + path);
52+
llvm_err(sess, ~"installation problem: couldn't open "
53+
+ istr::from_estr(path));
5054
fail;
5155
}
5256
let llintrinsicsmod = llvm::LLVMRustParseBitcode(membuf);
5357
llvm::LLVMDisposeMemoryBuffer(membuf);
5458
if llintrinsicsmod as uint == 0u {
55-
llvm_err(sess, "installation problem: couldn't parse intrinsics.bc");
59+
llvm_err(sess, ~"installation problem: couldn't parse intrinsics.bc");
5660
fail;
5761
}
5862
let linkres = llvm::LLVMLinkModules(llmod, llintrinsicsmod);
5963
llvm::LLVMDisposeModule(llintrinsicsmod);
6064
if linkres == False {
61-
llvm_err(sess, "couldn't link the module with the intrinsics");
65+
llvm_err(sess, ~"couldn't link the module with the intrinsics");
6266
fail;
6367
}
6468
}
@@ -74,15 +78,15 @@ mod write {
7478

7579
// Decides what to call an intermediate file, given the name of the output
7680
// and the extension to use.
77-
fn mk_intermediate_name(output_path: str, extension: str) -> str {
78-
let dot_pos = str::index(output_path, '.' as u8);
81+
fn mk_intermediate_name(output_path: &istr, extension: &istr) -> istr {
82+
let dot_pos = istr::index(output_path, '.' as u8);
7983
let stem;
8084
if dot_pos < 0 {
8185
stem = output_path;
82-
} else { stem = str::substr(output_path, 0u, dot_pos as uint); }
83-
ret stem + "." + extension;
86+
} else { stem = istr::substr(output_path, 0u, dot_pos as uint); }
87+
ret stem + ~"." + extension;
8488
}
85-
fn run_passes(sess: session::session, llmod: ModuleRef, output: str) {
89+
fn run_passes(sess: session::session, llmod: ModuleRef, output: &istr) {
8690
let opts = sess.get_opts();
8791
if opts.time_llvm_passes { llvm::LLVMRustEnableTimePasses(); }
8892
link_intrinsics(sess, llmod);
@@ -99,12 +103,14 @@ mod write {
99103
alt opts.output_type {
100104
output_type_bitcode. {
101105
if opts.optimize != 0u {
102-
let filename = mk_intermediate_name(output, "no-opt.bc");
106+
let filename = mk_intermediate_name(output, ~"no-opt.bc");
107+
let filename = istr::to_estr(filename);
103108
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
104109
}
105110
}
106111
_ {
107-
let filename = mk_intermediate_name(output, "bc");
112+
let filename = mk_intermediate_name(output, ~"bc");
113+
let filename = istr::to_estr(filename);
108114
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
109115
}
110116
}
@@ -176,14 +182,16 @@ mod write {
176182
if opts.save_temps {
177183
// Always output the bitcode file with --save-temps
178184

179-
let filename = mk_intermediate_name(output, "opt.bc");
185+
let filename = mk_intermediate_name(output, ~"opt.bc");
186+
let filename = istr::to_estr(filename);
180187
llvm::LLVMRunPassManager(pm.llpm, llmod);
181188
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(filename));
182189
pm = mk_pass_manager();
183190
// Save the assembly file if -S is used
184191

185192
if opts.output_type == output_type_assembly {
186193
let triple = x86::get_target_triple();
194+
let output = istr::to_estr(output);
187195
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
188196
str::buf(triple),
189197
str::buf(output),
@@ -197,6 +205,7 @@ mod write {
197205
if opts.output_type == output_type_object ||
198206
opts.output_type == output_type_exe {
199207
let triple = x86::get_target_triple();
208+
let output = istr::to_estr(output);
200209
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
201210
str::buf(triple),
202211
str::buf(output),
@@ -208,6 +217,7 @@ mod write {
208217
// type corresponding to the '-c' or '-S' flag used
209218

210219
let triple = x86::get_target_triple();
220+
let output = istr::to_estr(output);
211221
llvm::LLVMRustWriteOutputFile(pm.llpm, llmod,
212222
str::buf(triple),
213223
str::buf(output), FileType,
@@ -223,6 +233,7 @@ mod write {
223233
// flag, then output it here
224234

225235
llvm::LLVMRunPassManager(pm.llpm, llmod);
236+
let output = istr::to_estr(output);
226237
llvm::LLVMWriteBitcodeToFile(llmod, str::buf(output));
227238
llvm::LLVMDisposeModule(llmod);
228239
if opts.time_llvm_passes { llvm::LLVMRustPrintPassTimings(); }
@@ -281,32 +292,32 @@ mod write {
281292
*
282293
*/
283294

284-
type link_meta = {name: str, vers: str, extras_hash: str};
295+
type link_meta = {name: istr, vers: istr, extras_hash: istr};
285296

286-
fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
297+
fn build_link_meta(sess: &session::session, c: &ast::crate, output: &istr,
287298
sha: sha1) -> link_meta {
288299

289300
type provided_metas =
290-
{name: option::t<str>,
291-
vers: option::t<str>,
301+
{name: option::t<istr>,
302+
vers: option::t<istr>,
292303
cmh_items: [@ast::meta_item]};
293304

294305
fn provided_link_metas(sess: &session::session, c: &ast::crate) ->
295306
provided_metas {
296-
let name: option::t<str> = none;
297-
let vers: option::t<str> = none;
307+
let name: option::t<istr> = none;
308+
let vers: option::t<istr> = none;
298309
let cmh_items: [@ast::meta_item] = [];
299310
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
300311
attr::require_unique_names(sess, linkage_metas);
301312
for meta: @ast::meta_item in linkage_metas {
302313
if attr::get_meta_item_name(meta) == ~"name" {
303314
alt attr::get_meta_item_value_str(meta) {
304-
some(v) { name = some(v); }
315+
some(v) { name = some(istr::from_estr(v)); }
305316
none. { cmh_items += [meta]; }
306317
}
307318
} else if attr::get_meta_item_name(meta) == ~"vers" {
308319
alt attr::get_meta_item_value_str(meta) {
309-
some(v) { vers = some(v); }
320+
some(v) { vers = some(istr::from_estr(v)); }
310321
none. { cmh_items += [meta]; }
311322
}
312323
} else { cmh_items += [meta]; }
@@ -316,7 +327,7 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
316327

317328
// This calculates CMH as defined above
318329
fn crate_meta_extras_hash(sha: sha1, _crate: &ast::crate,
319-
metas: &provided_metas) -> str {
330+
metas: &provided_metas) -> istr {
320331
fn len_and_str(s: &istr) -> istr {
321332
ret istr::from_estr(#fmt["%u_%s",
322333
istr::byte_len(s),
@@ -349,39 +360,39 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
349360
ret truncated_sha1_result(sha);
350361
}
351362

352-
fn warn_missing(sess: &session::session, name: str, default: str) {
363+
fn warn_missing(sess: &session::session, name: &istr, default: &istr) {
353364
if !sess.get_opts().library { ret; }
354365
sess.warn(#fmt["missing crate link meta '%s', using '%s' as default",
355-
name, default]);
366+
istr::to_estr(name), istr::to_estr(default)]);
356367
}
357368

358369
fn crate_meta_name(sess: &session::session, _crate: &ast::crate,
359-
output: &str, metas: &provided_metas) -> str {
370+
output: &istr, metas: &provided_metas) -> istr {
360371
ret alt metas.name {
361372
some(v) { v }
362373
none. {
363374
let name =
364375
{
365376
let os = istr::split(
366-
fs::basename(istr::from_estr(output)),
377+
fs::basename(output),
367378
'.' as u8);
368379
assert (vec::len(os) >= 2u);
369380
vec::pop(os);
370-
istr::to_estr(istr::connect(os, ~"."))
381+
istr::connect(os, ~".")
371382
};
372-
warn_missing(sess, "name", name);
383+
warn_missing(sess, ~"name", name);
373384
name
374385
}
375386
};
376387
}
377388

378389
fn crate_meta_vers(sess: &session::session, _crate: &ast::crate,
379-
metas: &provided_metas) -> str {
390+
metas: &provided_metas) -> istr {
380391
ret alt metas.vers {
381392
some(v) { v }
382393
none. {
383-
let vers = "0.0";
384-
warn_missing(sess, "vers", vers);
394+
let vers = ~"0.0";
395+
warn_missing(sess, ~"vers", vers);
385396
vers
386397
}
387398
};
@@ -395,32 +406,32 @@ fn build_link_meta(sess: &session::session, c: &ast::crate, output: &str,
395406
ret {name: name, vers: vers, extras_hash: extras_hash};
396407
}
397408

398-
fn truncated_sha1_result(sha: sha1) -> str {
399-
ret istr::to_estr(istr::substr(sha.result_str(), 0u, 16u));
409+
fn truncated_sha1_result(sha: sha1) -> istr {
410+
ret istr::substr(sha.result_str(), 0u, 16u);
400411
}
401412

402413

403414
// This calculates STH for a symbol, as defined above
404415
fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t, link_meta: &link_meta) ->
405-
str {
416+
istr {
406417
// NB: do *not* use abbrevs here as we want the symbol names
407418
// to be independent of one another in the crate.
408419

409420
sha.reset();
410-
sha.input_str(istr::from_estr(link_meta.name));
421+
sha.input_str(link_meta.name);
411422
sha.input_str(~"-");
412423
// FIXME: This wants to be link_meta.meta_hash
413-
sha.input_str(istr::from_estr(link_meta.name));
424+
sha.input_str(link_meta.name);
414425
sha.input_str(~"-");
415426
sha.input_str(encoder::encoded_ty(tcx, t));
416427
let hash = truncated_sha1_result(sha);
417428
// Prefix with _ so that it never blends into adjacent digits
418429
419-
ret "_" + hash;
430+
ret ~"_" + hash;
420431
}
421432

422-
fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> str {
423-
let hash = "";
433+
fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> istr {
434+
let hash = ~"";
424435
alt ccx.type_sha1s.find(t) {
425436
some(h) { hash = h; }
426437
none. {
@@ -431,47 +442,52 @@ fn get_symbol_hash(ccx: &@crate_ctxt, t: ty::t) -> str {
431442
ret hash;
432443
}
433444

434-
fn mangle(ss: &[str]) -> str {
445+
fn mangle(ss: &[istr]) -> istr {
435446
// Follow C++ namespace-mangling style
436447

437-
let n = "_ZN"; // Begin name-sequence.
448+
let n = ~"_ZN"; // Begin name-sequence.
438449

439-
for s: str in ss { n += #fmt["%u%s", str::byte_len(s), s]; }
440-
n += "E"; // End name-sequence.
450+
for s: istr in ss {
451+
n += istr::from_estr(#fmt["%u%s",
452+
istr::byte_len(s),
453+
istr::to_estr(s)]);
454+
}
455+
n += ~"E"; // End name-sequence.
441456

442457
ret n;
443458
}
444459

445-
fn exported_name(path: &[str], hash: &str, _vers: &str) -> str {
460+
fn exported_name(path: &[istr], hash: &istr, _vers: &istr) -> istr {
446461
// FIXME: versioning isn't working yet
447462

448463
ret mangle(path + [hash]); // + "@" + vers;
449464

450465
}
451466

452-
fn mangle_exported_name(ccx: &@crate_ctxt, path: &[str], t: ty::t) -> str {
467+
fn mangle_exported_name(ccx: &@crate_ctxt, path: &[istr], t: ty::t) -> istr {
453468
let hash = get_symbol_hash(ccx, t);
454469
ret exported_name(path, hash, ccx.link_meta.vers);
455470
}
456471

457-
fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &str)
458-
-> str {
472+
fn mangle_internal_name_by_type_only(ccx: &@crate_ctxt, t: ty::t, name: &istr)
473+
-> istr {
459474
let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
460475
let hash = get_symbol_hash(ccx, t);
461-
ret mangle([name, istr::to_estr(s), hash]);
476+
ret mangle([name, s, hash]);
462477
}
463478

464-
fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[str],
465-
flav: &str) -> str {
466-
ret mangle(path + [ccx.names.next(flav)]);
479+
fn mangle_internal_name_by_path_and_seq(ccx: &@crate_ctxt, path: &[istr],
480+
flav: &istr) -> istr {
481+
ret mangle(path +
482+
istr::from_estrs([ccx.names.next(istr::to_estr(flav))]));
467483
}
468484

469-
fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[str]) -> str {
485+
fn mangle_internal_name_by_path(_ccx: &@crate_ctxt, path: &[istr]) -> istr {
470486
ret mangle(path);
471487
}
472488

473-
fn mangle_internal_name_by_seq(ccx: &@crate_ctxt, flav: &str) -> str {
474-
ret ccx.names.next(flav);
489+
fn mangle_internal_name_by_seq(ccx: &@crate_ctxt, flav: &istr) -> istr {
490+
ret istr::from_estr(ccx.names.next(istr::to_estr(flav)));
475491
}
476492
//
477493
// Local Variables:

trunk/src/comp/driver/rustc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
169169
bind trans::trans_crate(sess, crate, ty_cx, output,
170170
ast_map, mut_map));
171171
time(time_passes, "LLVM passes",
172-
bind link::write::run_passes(sess, llmod, output));
172+
bind link::write::run_passes(sess, llmod, istr::from_estr(output)));
173173
}
174174

175175
fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,

trunk/src/comp/metadata/encoder.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,15 @@ fn synthesize_crate_attrs(ecx: &@encode_ctxt, crate: &@crate) -> [attribute] {
504504
fn synthesize_link_attr(ecx: &@encode_ctxt, items: &[@meta_item]) ->
505505
attribute {
506506

507-
assert (ecx.ccx.link_meta.name != "");
508-
assert (ecx.ccx.link_meta.vers != "");
507+
assert (ecx.ccx.link_meta.name != ~"");
508+
assert (ecx.ccx.link_meta.vers != ~"");
509509

510510
let name_item =
511-
attr::mk_name_value_item_str(~"name", ecx.ccx.link_meta.name);
511+
attr::mk_name_value_item_str(
512+
~"name", istr::to_estr(ecx.ccx.link_meta.name));
512513
let vers_item =
513-
attr::mk_name_value_item_str(~"vers", ecx.ccx.link_meta.vers);
514+
attr::mk_name_value_item_str(
515+
~"vers", istr::to_estr(ecx.ccx.link_meta.vers));
514516

515517
let other_items =
516518
{

0 commit comments

Comments
 (0)