Skip to content

Commit 2db1124

Browse files
committed
---
yaml --- r: 4582 b: refs/heads/master c: 4caeba9 h: refs/heads/master v: v3
1 parent 8c88155 commit 2db1124

File tree

5 files changed

+53
-41
lines changed

5 files changed

+53
-41
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: b32889d82c959642d1595cf588ec75d76e6fa142
2+
refs/heads/master: 4caeba917860e64bda52174cec3895b4430e7ca8

trunk/src/comp/driver/rustc.rs

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import std::option::some;
2828
import std::option::none;
2929
import std::str;
3030
import std::vec;
31+
import std::ivec;
3132
import std::int;
3233
import std::ioivec;
3334
import std::run;
@@ -78,7 +79,7 @@ fn build_configuration(sess: session::session, argv0: str, input: str) ->
7879
}
7980

8081
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
81-
fn parse_cfgspecs(cfgspecs: &vec[str]) -> ast::crate_cfg {
82+
fn parse_cfgspecs(cfgspecs: &[str]) -> ast::crate_cfg {
8283
// FIXME: It would be nice to use the parser to parse all varieties of
8384
// meta_item here. At the moment we just support the meta_word variant.
8485
let words = ~[];
@@ -383,7 +384,7 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
383384
none. { get_default_sysroot(binary) }
384385
some(s) { s }
385386
};
386-
let cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
387+
let cfg = parse_cfgspecs(getopts::opt_strs_ivec(match, "cfg"));
387388
let test = opt_present(match, "test");
388389
let dps = opt_present(match, "dps");
389390
let do_gc = opt_present(match, "gc");
@@ -428,24 +429,25 @@ fn parse_pretty(sess: session::session, name: &str) -> pp_mode {
428429
"`typed`, or `identified`");
429430
}
430431

431-
fn opts() -> vec[getopts::opt] {
432-
ret [optflag("h"), optflag("help"), optflag("v"), optflag("version"),
433-
optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
434-
optflagopt("expand"), optflag("ls"), optflag("parse-only"),
435-
optflag("no-trans"),
436-
optflag("O"), optopt("OptLevel"), optmulti("L"), optflag("S"),
437-
optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
438-
optopt("sysroot"), optflag("stats"), optflag("time-passes"),
439-
optflag("time-llvm-passes"), optflag("no-typestate"),
440-
optflag("noverify"), optmulti("cfg"), optflag("test"),
441-
optflag("lib"), optflag("static"), optflag("dps"), optflag("gc")];
432+
fn opts() -> [getopts::opt] {
433+
ret ~[optflag("h"), optflag("help"), optflag("v"), optflag("version"),
434+
optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
435+
optflagopt("expand"), optflag("ls"), optflag("parse-only"),
436+
optflag("no-trans"),
437+
optflag("O"), optopt("OptLevel"), optmulti("L"), optflag("S"),
438+
optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
439+
optopt("sysroot"), optflag("stats"), optflag("time-passes"),
440+
optflag("time-llvm-passes"), optflag("no-typestate"),
441+
optflag("noverify"), optmulti("cfg"), optflag("test"),
442+
optflag("lib"), optflag("static"), optflag("dps"), optflag("gc")];
442443
}
443444

444445
fn main(args: vec[str]) {
445-
let binary = vec::shift(args);
446+
let args_ivec = ivec::from_vec(args);
447+
let binary = ivec::shift(args_ivec);
446448
let binary_dir = fs::dirname(binary);
447449
let match =
448-
alt getopts::getopts(args, opts()) {
450+
alt getopts::getopts_ivec(args_ivec, opts()) {
449451
getopts::success(m) { m }
450452
getopts::failure(f) {
451453
log_err #fmt("error: %s", getopts::fail_str(f));
@@ -517,25 +519,25 @@ fn main(args: vec[str]) {
517519
none. {
518520
// "-" as input file will cause the parser to read from stdin so we
519521
// have to make up a name
520-
let parts: vec[str] = if !input_is_stdin(ifile) {
521-
str::split(ifile, '.' as u8)
522+
let parts = if !input_is_stdin(ifile) {
523+
str::split_ivec(ifile, '.' as u8)
522524
} else {
523-
["default", "rs"]
525+
~["default", "rs"]
524526
};
525-
vec::pop[str](parts);
527+
ivec::pop(parts);
526528
saved_out_filename = parts.(0);
527529
alt sopts.output_type {
528-
link::output_type_none. { parts += ["none"]; }
529-
link::output_type_bitcode. { parts += ["bc"]; }
530-
link::output_type_assembly. { parts += ["s"]; }
530+
link::output_type_none. { parts += ~["none"]; }
531+
link::output_type_bitcode. { parts += ~["bc"]; }
532+
link::output_type_assembly. { parts += ~["s"]; }
531533

532534
// Object and exe output both use the '.o' extension here
533535
link::output_type_object. {
534-
parts += ["o"];
536+
parts += ~["o"];
535537
}
536-
link::output_type_exe. { parts += ["o"]; }
538+
link::output_type_exe. { parts += ~["o"]; }
537539
}
538-
let ofile = str::connect(parts, ".");
540+
let ofile = str::connect_ivec(parts, ".");
539541
compile_input(sess, cfg, ifile, ofile);
540542
}
541543
some(ofile) {
@@ -562,9 +564,9 @@ fn main(args: vec[str]) {
562564
let prog: str = "gcc";
563565
// The invocations of gcc share some flags across platforms
564566

565-
let gcc_args: vec[str] =
566-
[stage, "-Lrt", "-lrustrt", glu, "-m32", "-o", saved_out_filename,
567-
saved_out_filename + ".o"];
567+
let gcc_args =
568+
~[stage, "-Lrt", "-lrustrt", glu, "-m32", "-o", saved_out_filename,
569+
saved_out_filename + ".o"];
568570
let lib_cmd;
569571

570572
let os = sess.get_targ_cfg().os;
@@ -598,34 +600,34 @@ fn main(args: vec[str]) {
598600
let cstore = sess.get_cstore();
599601
for cratepath: str in cstore::get_used_crate_files(cstore) {
600602
if str::ends_with(cratepath, ".rlib") {
601-
gcc_args += [cratepath];
603+
gcc_args += ~[cratepath];
602604
cont;
603605
}
604606
let dir = fs::dirname(cratepath);
605-
if dir != "" { gcc_args += ["-L" + dir]; }
607+
if dir != "" { gcc_args += ~["-L" + dir]; }
606608
let libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
607-
gcc_args += ["-l" + libarg];
609+
gcc_args += ~["-l" + libarg];
608610
}
609611

610-
// FIXME: Remove this ivec->vec conversion.
611612
let ula = cstore::get_used_link_args(cstore);
612-
for arg: str in ula { gcc_args += [arg]; }
613+
for arg: str 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" + l]; }
616+
for l: str in used_libs { gcc_args += ~["-l" + l]; }
616617

617618
if sopts.library {
618-
gcc_args += [lib_cmd];
619+
gcc_args += ~[lib_cmd];
619620
} else {
620621
// FIXME: why do we hardcode -lm?
621-
gcc_args += ["-lm", main];
622+
gcc_args += ~["-lm", main];
622623
}
623624
// We run 'gcc' here
624625

625-
let err_code = run::run_program(prog, gcc_args);
626+
let err_code = run::run_program(prog, ivec::to_vec(gcc_args));
626627
if 0 != err_code {
627628
sess.err(#fmt("linking with gcc failed with code %d", err_code));
628-
sess.note(#fmt("gcc arguments: %s", str::connect(gcc_args, " ")));
629+
sess.note(#fmt("gcc arguments: %s",
630+
str::connect_ivec(gcc_args, " ")));
629631
sess.abort_if_errors();
630632
}
631633
// Clean up on Darwin
@@ -650,7 +652,7 @@ mod test {
650652
#[test]
651653
fn test_switch_implies_cfg_test() {
652654
let match =
653-
alt getopts::getopts(["--test"], opts()) {
655+
alt getopts::getopts_ivec(~["--test"], opts()) {
654656
getopts::success(m) { m }
655657
};
656658
let sessopts = build_session_options("whatever", match, "whatever");
@@ -664,7 +666,7 @@ mod test {
664666
#[test]
665667
fn test_switch_implies_cfg_test_unless_cfg_test() {
666668
let match =
667-
alt getopts::getopts(["--test", "--cfg=test"], opts()) {
669+
alt getopts::getopts_ivec(~["--test", "--cfg=test"], opts()) {
668670
getopts::success(m) { m }
669671
};
670672
let sessopts = build_session_options("whatever", match, "whatever");

trunk/src/lib/getopts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export fail_str;
2727
export opt_present;
2828
export opt_str;
2929
export opt_strs;
30+
export opt_strs_ivec;
3031
export opt_maybe_str;
3132
export opt_default;
3233

trunk/src/lib/ivec.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ fn slice_mut[@T](v: &[mutable? T], start: uint, end: uint) -> [mutable T] {
142142

143143
// Mutators
144144

145+
fn shift[@T](v: &mutable [mutable? T]) -> T {
146+
let ln = len[T](v);
147+
assert (ln > 0u);
148+
let e = v.(0);
149+
v = slice[T](v, 1u, ln);
150+
ret e;
151+
}
152+
145153
// TODO: Write this, unsafely, in a way that's not O(n).
146154
fn pop[@T](v: &mutable [mutable? T]) -> T {
147155
let ln = len(v);

trunk/src/lib/str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export pop_byte;
4343
export push_byte;
4444
export unshift_byte;
4545
export split;
46+
export split_ivec;
4647
export concat;
4748
export connect;
4849
export connect_ivec;

0 commit comments

Comments
 (0)