Skip to content

Commit 54b072c

Browse files
committed
---
yaml --- r: 5004 b: refs/heads/master c: 54691f9 h: refs/heads/master v: v3
1 parent 6f01220 commit 54b072c

File tree

11 files changed

+134
-120
lines changed

11 files changed

+134
-120
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 7d70685eefc98668804c05428bb94f43933cca61
2+
refs/heads/master: 54691f9a6cb6a92152fe57e4ca4b9fb6298dac0e

trunk/src/comp/driver/rustc.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -491,17 +491,18 @@ fn main(args: [str]) {
491491
} else if n_inputs > 1u {
492492
sess.fatal("Multiple input filenames provided.");
493493
}
494-
let ifile = istr::to_estr(match.free[0]);
494+
let ifile = match.free[0];
495495
let saved_out_filename: str = "";
496-
let cfg = build_configuration(sess, binary, ifile);
496+
let cfg = build_configuration(sess, binary,
497+
istr::to_estr(ifile));
497498
let pretty =
498499
option::map::<istr,
499500
pp_mode>(bind parse_pretty(sess, _),
500501
getopts::opt_default(match, ~"pretty",
501502
~"normal"));
502503
alt pretty {
503504
some::<pp_mode>(ppm) {
504-
pretty_print_input(sess, cfg, ifile, ppm);
505+
pretty_print_input(sess, cfg, istr::to_estr(ifile), ppm);
505506
ret;
506507
}
507508
none::<pp_mode>. {/* continue */ }
@@ -519,8 +520,8 @@ fn main(args: [str]) {
519520
// have to make up a name
520521
// We want to toss everything after the final '.'
521522
let parts =
522-
if !input_is_stdin(ifile) {
523-
str::split(ifile, '.' as u8)
523+
if !input_is_stdin(istr::to_estr(ifile)) {
524+
istr::to_estrs(istr::split(ifile, '.' as u8))
524525
} else { ["default", "rs"] };
525526
vec::pop(parts);
526527
saved_out_filename = str::connect(parts, ".");
@@ -536,15 +537,15 @@ fn main(args: [str]) {
536537
}
537538
};
538539
let ofile = saved_out_filename + "." + suffix;
539-
compile_input(sess, cfg, ifile, ofile);
540+
compile_input(sess, cfg, istr::to_estr(ifile), ofile);
540541
}
541542
some(ofile) {
542543
let ofile = istr::to_estr(ofile);
543544
// FIXME: what about windows? This will create a foo.exe.o.
544545
saved_out_filename = ofile;
545546
let temp_filename =
546547
if !stop_after_codegen { ofile + ".o" } else { ofile };
547-
compile_input(sess, cfg, ifile, temp_filename);
548+
compile_input(sess, cfg, istr::to_estr(ifile), temp_filename);
548549
}
549550
}
550551

@@ -596,23 +597,23 @@ fn main(args: [str]) {
596597
}
597598

598599
let cstore = sess.get_cstore();
599-
for cratepath: str in cstore::get_used_crate_files(cstore) {
600-
if str::ends_with(cratepath, ".rlib") {
601-
gcc_args += [istr::from_estr(cratepath)];
600+
for cratepath: istr in cstore::get_used_crate_files(cstore) {
601+
if istr::ends_with(cratepath, ~".rlib") {
602+
gcc_args += [cratepath];
602603
cont;
603604
}
604-
let cratepath = istr::from_estr(cratepath);
605+
let cratepath = cratepath;
605606
let dir = fs::dirname(cratepath);
606607
if dir != ~"" { gcc_args += [~"-L" + dir]; }
607608
let libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
608609
gcc_args += [~"-l" + libarg];
609610
}
610611

611612
let ula = cstore::get_used_link_args(cstore);
612-
for arg: str in ula { gcc_args += [istr::from_estr(arg)]; }
613+
for arg: istr in ula { gcc_args += [arg]; }
613614

614615
let used_libs = cstore::get_used_libraries(cstore);
615-
for l: str in used_libs { gcc_args += [~"-l" + istr::from_estr(l)]; }
616+
for l: istr in used_libs { gcc_args += [~"-l" + l]; }
616617

617618
if sopts.library {
618619
gcc_args += [istr::from_estr(lib_cmd)];

trunk/src/comp/metadata/creader.rs

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ fn read_crates(sess: session::session, crate: &ast::crate) {
3535
let e =
3636
@{sess: sess,
3737
crate_cache: @std::map::new_str_hash::<int>(),
38-
library_search_paths: sess.get_opts().library_search_paths,
38+
library_search_paths:
39+
istr::from_estrs(sess.get_opts().library_search_paths),
3940
mutable next_crate_num: 1};
4041
let v =
4142
visit::mk_simple_visitor(@{visit_view_item:
@@ -48,7 +49,7 @@ fn read_crates(sess: session::session, crate: &ast::crate) {
4849
type env =
4950
@{sess: session::session,
5051
crate_cache: @hashmap<istr, int>,
51-
library_search_paths: [str],
52+
library_search_paths: [istr],
5253
mutable next_crate_num: ast::crate_num};
5354

5455
fn visit_view_item(e: env, i: &@ast::view_item) {
@@ -69,12 +70,12 @@ fn visit_item(e: env, i: &@ast::item) {
6970
}
7071
let cstore = e.sess.get_cstore();
7172
if !cstore::add_used_library(cstore,
72-
istr::to_estr(m.native_name)) { ret; }
73+
m.native_name) { ret; }
7374
for a: ast::attribute in
7475
attr::find_attrs_by_name(i.attrs, ~"link_args") {
7576
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
7677
some(linkarg) {
77-
cstore::add_used_link_args(cstore, istr::to_estr(linkarg));
78+
cstore::add_used_link_args(cstore, linkarg);
7879
}
7980
none. {/* fallthrough */ }
8081
}
@@ -85,12 +86,12 @@ fn visit_item(e: env, i: &@ast::item) {
8586
}
8687

8788
// A diagnostic function for dumping crate metadata to an output stream
88-
fn list_file_metadata(path: str, out: io::writer) {
89+
fn list_file_metadata(path: &istr, out: io::writer) {
8990
alt get_metadata_section(path) {
9091
option::some(bytes) { decoder::list_crate_metadata(bytes, out); }
9192
option::none. {
9293
out.write_str(
93-
istr::from_estr("Could not find metadata in " + path + ".\n"));
94+
~"Could not find metadata in " + path + ~".\n");
9495
}
9596
}
9697
}
@@ -112,18 +113,18 @@ fn metadata_matches(crate_data: &@[u8], metas: &[@ast::meta_item]) -> bool {
112113
}
113114

114115
fn default_native_lib_naming(sess: session::session, static: bool) ->
115-
{prefix: str, suffix: str} {
116-
if static { ret {prefix: "lib", suffix: ".rlib"}; }
116+
{prefix: istr, suffix: istr} {
117+
if static { ret {prefix: ~"lib", suffix: ~".rlib"}; }
117118
alt sess.get_targ_cfg().os {
118-
session::os_win32. { ret {prefix: "", suffix: ".dll"}; }
119-
session::os_macos. { ret {prefix: "lib", suffix: ".dylib"}; }
120-
session::os_linux. { ret {prefix: "lib", suffix: ".so"}; }
119+
session::os_win32. { ret {prefix: ~"", suffix: ~".dll"}; }
120+
session::os_macos. { ret {prefix: ~"lib", suffix: ~".dylib"}; }
121+
session::os_linux. { ret {prefix: ~"lib", suffix: ~".so"}; }
121122
}
122123
}
123124

124125
fn find_library_crate(sess: &session::session, ident: &ast::ident,
125-
metas: &[@ast::meta_item], library_search_paths: &[str])
126-
-> option::t<{ident: str, data: @[u8]}> {
126+
metas: &[@ast::meta_item], library_search_paths: &[istr])
127+
-> option::t<{ident: istr, data: @[u8]}> {
127128

128129
attr::require_unique_names(sess, metas);
129130

@@ -145,48 +146,49 @@ fn find_library_crate(sess: &session::session, ident: &ast::ident,
145146

146147
let nn = default_native_lib_naming(sess, sess.get_opts().static);
147148
let x =
148-
find_library_crate_aux(nn, istr::to_estr(crate_name),
149+
find_library_crate_aux(nn, crate_name,
149150
metas, library_search_paths);
150151
if x != none || sess.get_opts().static { ret x; }
151152
let nn2 = default_native_lib_naming(sess, true);
152-
ret find_library_crate_aux(nn2, istr::to_estr(crate_name),
153+
ret find_library_crate_aux(nn2, crate_name,
153154
metas, library_search_paths);
154155
}
155156

156-
fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
157+
fn find_library_crate_aux(nn: &{prefix: istr, suffix: istr},
158+
crate_name: &istr,
157159
metas: &[@ast::meta_item],
158-
library_search_paths: &[str]) ->
159-
option::t<{ident: str, data: @[u8]}> {
160-
let prefix: istr = istr::from_estr(nn.prefix + crate_name);
161-
let suffix: istr = istr::from_estr(nn.suffix);
160+
library_search_paths: &[istr]) ->
161+
option::t<{ident: istr, data: @[u8]}> {
162+
let prefix: istr = nn.prefix + crate_name;
163+
let suffix: istr = nn.suffix;
162164
// FIXME: we could probably use a 'glob' function in std::fs but it will
163165
// be much easier to write once the unsafe module knows more about FFI
164166
// tricks. Currently the glob(3) interface is a bit more than we can
165167
// stomach from here, and writing a C++ wrapper is more work than just
166168
// manually filtering fs::list_dir here.
167169

168-
for library_search_path: str in library_search_paths {
169-
log #fmt["searching %s", library_search_path];
170-
let library_search_path = istr::from_estr(library_search_path);
170+
for library_search_path: istr in library_search_paths {
171+
log #fmt["searching %s", istr::to_estr(library_search_path)];
171172
for path: istr in fs::list_dir(library_search_path) {
172173
log #fmt["searching %s", istr::to_estr(path)];
173174
let f: istr = fs::basename(path);
174-
let path = istr::to_estr(path);
175175
if !(istr::starts_with(f, prefix) && istr::ends_with(f, suffix))
176176
{
177177
log #fmt["skipping %s, doesn't look like %s*%s",
178-
path,
178+
istr::to_estr(path),
179179
istr::to_estr(prefix),
180180
istr::to_estr(suffix)];
181181
cont;
182182
}
183183
alt get_metadata_section(path) {
184184
option::some(cvec) {
185185
if !metadata_matches(cvec, metas) {
186-
log #fmt["skipping %s, metadata doesn't match", path];
186+
log #fmt["skipping %s, metadata doesn't match",
187+
istr::to_estr(path)];
187188
cont;
188189
}
189-
log #fmt["found %s with matching metadata", path];
190+
log #fmt["found %s with matching metadata",
191+
istr::to_estr(path)];
190192
ret some({ident: path, data: cvec});
191193
}
192194
_ { }
@@ -196,8 +198,8 @@ fn find_library_crate_aux(nn: &{prefix: str, suffix: str}, crate_name: str,
196198
ret none;
197199
}
198200

199-
fn get_metadata_section(filename: str) -> option::t<@[u8]> {
200-
let mb = istr::as_buf(istr::from_estr(filename), { |buf|
201+
fn get_metadata_section(filename: &istr) -> option::t<@[u8]> {
202+
let mb = istr::as_buf(filename, { |buf|
201203
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
202204
});
203205
if mb as int == 0 { ret option::none::<@[u8]>; }
@@ -218,8 +220,9 @@ fn get_metadata_section(filename: str) -> option::t<@[u8]> {
218220
}
219221

220222
fn load_library_crate(sess: &session::session, span: span, ident: &ast::ident,
221-
metas: &[@ast::meta_item], library_search_paths: &[str])
222-
-> {ident: str, data: @[u8]} {
223+
metas: &[@ast::meta_item],
224+
library_search_paths: &[istr])
225+
-> {ident: istr, data: @[u8]} {
223226

224227

225228
alt find_library_crate(sess, ident, metas, library_search_paths) {
@@ -249,12 +252,13 @@ fn resolve_crate(e: env, ident: &ast::ident, metas: [@ast::meta_item],
249252
// Now resolve the crates referenced by this crate
250253
let cnum_map = resolve_crate_deps(e, cdata);
251254

252-
let cmeta = {name: istr::to_estr(ident),
255+
let cmeta = {name: ident,
253256
data: cdata, cnum_map: cnum_map};
254257

255258
let cstore = e.sess.get_cstore();
256259
cstore::set_crate_data(cstore, cnum, cmeta);
257-
cstore::add_used_crate_file(cstore, cfilename);
260+
cstore::add_used_crate_file(cstore,
261+
cfilename);
258262
ret cnum;
259263
} else { ret e.crate_cache.get(ident); }
260264
}
@@ -268,19 +272,19 @@ fn resolve_crate_deps(e: env, cdata: &@[u8]) -> cstore::cnum_map {
268272
for dep: decoder::crate_dep in decoder::get_crate_deps(cdata) {
269273
let extrn_cnum = dep.cnum;
270274
let cname = dep.ident;
271-
log #fmt["resolving dep %s", cname];
272-
if e.crate_cache.contains_key(istr::from_estr(cname)) {
275+
log #fmt["resolving dep %s", istr::to_estr(cname)];
276+
if e.crate_cache.contains_key(cname) {
273277
log "already have it";
274278
// We've already seen this crate
275-
let local_cnum = e.crate_cache.get(istr::from_estr(cname));
279+
let local_cnum = e.crate_cache.get(cname);
276280
cnum_map.insert(extrn_cnum, local_cnum);
277281
} else {
278282
log "need to load it";
279283
// This is a new one so we've got to load it
280284
// FIXME: Need better error reporting than just a bogus span
281285
let fake_span = ast_util::dummy_sp();
282286
let local_cnum = resolve_crate(e,
283-
istr::from_estr(cname),
287+
cname,
284288
[], fake_span);
285289
cnum_map.insert(extrn_cnum, local_cnum);
286290
}

trunk/src/comp/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export lookup_defs;
1111
export get_tag_variants;
1212
export get_type;
1313

14-
fn get_symbol(cstore: &cstore::cstore, def: ast::def_id) -> str {
14+
fn get_symbol(cstore: &cstore::cstore, def: ast::def_id) -> istr {
1515
let cdata = cstore::get_crate_data(cstore, def.crate).data;
1616
ret decoder::get_symbol(cdata, def.node);
1717
}

trunk/src/comp/metadata/cstore.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import std::vec;
55
import std::map;
66
import std::str;
7+
import std::istr;
78
import syntax::ast;
89

910
export cstore;
@@ -29,7 +30,7 @@ export get_use_stmt_cnum;
2930
// own crate numbers.
3031
type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>;
3132

32-
type crate_metadata = {name: str, data: @[u8], cnum_map: cnum_map};
33+
type crate_metadata = {name: istr, data: @[u8], cnum_map: cnum_map};
3334

3435
// This is a bit of an experiment at encapsulating the data in cstore. By
3536
// keeping all the data in a non-exported tag variant, it's impossible for
@@ -41,9 +42,9 @@ tag cstore { private(cstore_private); }
4142
type cstore_private =
4243
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
4344
use_crate_map: use_crate_map,
44-
mutable used_crate_files: [str],
45-
mutable used_libraries: [str],
46-
mutable used_link_args: [str]};
45+
mutable used_crate_files: [istr],
46+
mutable used_libraries: [istr],
47+
mutable used_link_args: [istr]};
4748

4849
// Map from node_id's of local use statements to crate numbers
4950
type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>;
@@ -82,34 +83,34 @@ iter iter_crate_data(cstore: &cstore) ->
8283
}
8384
}
8485

85-
fn add_used_crate_file(cstore: &cstore, lib: &str) {
86+
fn add_used_crate_file(cstore: &cstore, lib: &istr) {
8687
if !vec::member(lib, p(cstore).used_crate_files) {
8788
p(cstore).used_crate_files += [lib];
8889
}
8990
}
9091

91-
fn get_used_crate_files(cstore: &cstore) -> [str] {
92+
fn get_used_crate_files(cstore: &cstore) -> [istr] {
9293
ret p(cstore).used_crate_files;
9394
}
9495

95-
fn add_used_library(cstore: &cstore, lib: &str) -> bool {
96-
if lib == "" { ret false; }
96+
fn add_used_library(cstore: &cstore, lib: &istr) -> bool {
97+
if lib == ~"" { ret false; }
9798

9899
if vec::member(lib, p(cstore).used_libraries) { ret false; }
99100

100101
p(cstore).used_libraries += [lib];
101102
ret true;
102103
}
103104

104-
fn get_used_libraries(cstore: &cstore) -> [str] {
105+
fn get_used_libraries(cstore: &cstore) -> [istr] {
105106
ret p(cstore).used_libraries;
106107
}
107108

108-
fn add_used_link_args(cstore: &cstore, args: &str) {
109-
p(cstore).used_link_args += str::split(args, ' ' as u8);
109+
fn add_used_link_args(cstore: &cstore, args: &istr) {
110+
p(cstore).used_link_args += istr::split(args, ' ' as u8);
110111
}
111112

112-
fn get_used_link_args(cstore: &cstore) -> [str] {
113+
fn get_used_link_args(cstore: &cstore) -> [istr] {
113114
ret p(cstore).used_link_args;
114115
}
115116

0 commit comments

Comments
 (0)