Convert most main functions to the ivec signature

Converting rustc will still take a snapshot
This commit is contained in:
Brian Anderson
2011-08-13 22:34:16 -07:00
parent 184eac90ab
commit f32079f7c0
25 changed files with 39 additions and 48 deletions

View File

@@ -29,7 +29,7 @@ for t in os.listdir(run_pass):
if not ("xfail-stage2" in s or if not ("xfail-stage2" in s or
"xfail-fast" in s): "xfail-fast" in s):
stage2_tests.append(t) stage2_tests.append(t)
if "main(args: vec[str])" in s: if "main(args: [str])" in s:
take_args[t] = True take_args[t] = True
f.close() f.close()
@@ -60,7 +60,7 @@ for t in stage2_tests:
p = p.replace("\\", "\\\\") p = p.replace("\\", "\\\\")
d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p) d.write(" out.write_str(\"run-pass [stage2]: %s\\n\");\n" % p)
if t in take_args: if t in take_args:
d.write(" t_%d::main([\"arg0\"]);\n" % i) d.write(" t_%d::main(~[\"arg0\"]);\n" % i)
else: else:
d.write(" t_%d::main();\n" % i) d.write(" t_%d::main();\n" % i)
i += 1 i += 1

View File

@@ -345,14 +345,13 @@ fn check_variants(files: &[str]) {
} }
} }
fn main(args: vec[str]) { fn main(args: [str]) {
let iargs = ivec::from_vec(args); if ivec::len(args) != 2u {
if ivec::len(iargs) != 2u { log_err #fmt("usage: %s <testdir>", args.(0));
log_err #fmt("usage: %s <testdir>", iargs.(0));
ret; ret;
} }
let files = ~[]; let files = ~[];
let root = iargs.(1); let root = args.(1);
find_rust_files(files, root); find_rust_files(files, root);
check_convergence(files); check_convergence(files);

View File

@@ -56,7 +56,7 @@ fn fannkuch(n: int) -> int {
ret flips; ret flips;
} }
fn main(args: vec[str]) { fn main(args: [str]) {
let n = 7; let n = 7;
log #fmt("Pfannkuchen(%d) = %d", n, fannkuch(n)); log #fmt("Pfannkuchen(%d) = %d", n, fannkuch(n));
} }

View File

@@ -67,7 +67,7 @@ fn make_repeat_fasta(id: str, desc: str, s: str, n: int) {
fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; } fn acid(ch: char, prob: u32) -> aminoacids { ret {ch: ch, prob: prob}; }
fn main(args: vec[str]) { fn main(args: [str]) {
let iub: [aminoacids] = let iub: [aminoacids] =
make_cumulative( make_cumulative(
~[acid('a', 27u32), acid('c', 12u32), acid('g', 12u32), ~[acid('a', 27u32), acid('c', 12u32), acid('g', 12u32),

View File

@@ -79,20 +79,19 @@ fn stress(num_tasks: int) {
for t in tasks { task::join_id(t); } for t in tasks { task::join_id(t); }
} }
fn main(argv: vec[str]) { fn main(argv: [str]) {
let iargv = ivec::from_vec(argv); if ivec::len(argv) == 1u {
if ivec::len(iargv) == 1u {
assert (fib(8) == 21); assert (fib(8) == 21);
log fib(8); log fib(8);
} else { } else {
// Interactive mode! Wooo!!!! // Interactive mode! Wooo!!!!
let opts = parse_opts(iargv); let opts = parse_opts(argv);
if opts.stress { if opts.stress {
stress(2); stress(2);
} else { } else {
let max = uint::parse_buf(str::bytes(iargv.(1)), 10u) as int; let max = uint::parse_buf(str::bytes(argv.(1)), 10u) as int;
let num_trials = 10; let num_trials = 10;

View File

@@ -14,13 +14,12 @@ fn f(n: uint) {
fn g() {} fn g() {}
fn main(args: vec[str]) { fn main(args: [str]) {
let iargs = ivec::from_vec(args); let n = if ivec::len(args) < 2u {
let n = if ivec::len(iargs) < 2u {
10u 10u
} else { } else {
uint::parse_buf(str::bytes(iargs.(1)), 10u) uint::parse_buf(str::bytes(args.(1)), 10u)
}; };
let i = 0u; let i = 0u;
while i < n { while i < n {

View File

@@ -198,12 +198,11 @@ mod map_reduce {
} }
} }
fn main(argv: vec[str]) { fn main(argv: [str]) {
let iargv = ivec::from_vec(argv); if ivec::len(argv) < 2u {
if ivec::len(iargv) < 2u {
let out = io::stdout(); let out = io::stdout();
out.write_line(#fmt("Usage: %s <filename> ...", iargv.(0))); out.write_line(#fmt("Usage: %s <filename> ...", argv.(0)));
// TODO: run something just to make sure the code hasn't // TODO: run something just to make sure the code hasn't
// broken yet. This is the unit test mode of this program. // broken yet. This is the unit test mode of this program.
@@ -217,7 +216,7 @@ fn main(argv: vec[str]) {
let start = time::precise_time_ns(); let start = time::precise_time_ns();
map_reduce::map_reduce(ivec::slice(iargv, 1u, ivec::len(iargv))); map_reduce::map_reduce(ivec::slice(argv, 1u, ivec::len(argv)));
let stop = time::precise_time_ns(); let stop = time::precise_time_ns();
let elapsed = stop - start; let elapsed = stop - start;

View File

@@ -2,4 +2,4 @@
mod m1 { } mod m1 { }
fn main(args: vec[str]) { log m1::a; } fn main(args: [str]) { log m1::a; }

View File

@@ -4,4 +4,4 @@ mod m1 {
mod a { } mod a { }
} }
fn main(args: vec[str]) { log m1::a; } fn main(args: [str]) { log m1::a; }

View File

@@ -4,4 +4,4 @@ import zed::baz;
mod zed { mod zed {
fn bar() { log "bar"; } fn bar() { log "bar"; }
} }
fn main(args: vec[str]) { bar(); } fn main(args: [str]) { bar(); }

View File

@@ -4,4 +4,4 @@ mod baz { }
mod zed { mod zed {
fn bar() { log "bar3"; } fn bar() { log "bar3"; }
} }
fn main(args: vec[str]) { bar(); } fn main(args: [str]) { bar(); }

View File

@@ -1,4 +1,4 @@
// error-pattern: unresolved modulename // error-pattern: unresolved modulename
import main::bar; import main::bar;
fn main(args: vec[str]) { log "foo"; } fn main(args: [str]) { log "foo"; }

View File

@@ -3,4 +3,4 @@
import zed::bar; import zed::bar;
import bar::zed; import bar::zed;
fn main(args: vec[str]) { log "loop"; } fn main(args: [str]) { log "loop"; }

View File

@@ -22,11 +22,9 @@ import common::mode_pretty;
import common::mode; import common::mode;
import util::logv; import util::logv;
fn main(args: vec[str]) { fn main(args: [str]) {
let ivec_args = ivec::from_vec(args); let config = parse_config(args);
let config = parse_config(ivec_args);
log_config(config); log_config(config);
run_tests(config); run_tests(config);
} }

View File

@@ -1,8 +1,5 @@
use std; fn main(args: [str]) {
import std::ivec;
fn main(args: vec[str]) {
let vs: [str] = ~["hi", "there", "this", "is", "a", "vec"]; let vs: [str] = ~["hi", "there", "this", "is", "a", "vec"];
let vvs: [[str]] = ~[ivec::from_vec(args), vs]; let vvs: [[str]] = ~[args, vs];
for vs: [str] in vvs { for s: str in vs { log s; } } for vs: [str] in vvs { for s: str in vs { log s; } }
} }

View File

@@ -1,3 +1,3 @@
fn main(args: vec[str]) { log args.(0); } fn main(args: [str]) { log args.(0); }

View File

@@ -5,4 +5,4 @@ mod zed {
fn bar() { log "bar"; } fn bar() { log "bar"; }
} }
fn main(args: vec[str]) { let zed = 42; bar(); } fn main(args: [str]) { let zed = 42; bar(); }

View File

@@ -7,4 +7,4 @@ mod foo {
} }
} }
fn main(args: vec[str]) { bar(); } fn main(args: [str]) { bar(); }

View File

@@ -12,4 +12,4 @@ mod bar {
mod zed { } mod zed { }
} }
} }
fn main(args: vec[str]) { baz(); } fn main(args: [str]) { baz(); }

View File

@@ -4,4 +4,4 @@ iter x() -> int { }
fn f() -> bool { for each i: int in x() { ret true; } ret false; } fn f() -> bool { for each i: int in x() { ret true; } ret false; }
fn main(args: vec[str]) { f(); } fn main(args: [str]) { f(); }

View File

@@ -15,4 +15,4 @@ native "cdecl" mod libc = "" {
native "cdecl" mod baz = "" { } native "cdecl" mod baz = "" { }
fn main(args: vec[str]) { } fn main(args: [str]) { }

View File

@@ -4,4 +4,4 @@ mod foo {
fn bar(offset: uint) { } fn bar(offset: uint) { }
} }
fn main(args: vec[str]) { foo::bar(0u); } fn main(args: [str]) { foo::bar(0u); }

View File

@@ -6,4 +6,4 @@ fn foo() {
fn baz() { zed(nil); } fn baz() { zed(nil); }
} }
fn main(args: vec[str]) { } fn main(args: [str]) { }

View File

@@ -2,4 +2,4 @@
type lteq[T] = fn(&T) -> bool ; type lteq[T] = fn(&T) -> bool ;
fn main(args: vec[str]) { } fn main(args: [str]) { }

View File

@@ -2,4 +2,4 @@ fn f(a: *int) -> *int { ret a; }
fn g(a: *int) -> *int { let b = f(a); ret b; } fn g(a: *int) -> *int { let b = f(a); ret b; }
fn main(args: vec[str]) { ret; } fn main(args: [str]) { ret; }