Skip to content

Commit 699986d

Browse files
committed
fuzzer: Begin writing main
1 parent 01c13a3 commit 699986d

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

src/fuzzer/fuzzer.rs

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,69 @@
1+
import std::fs;
2+
import std::getopts;
3+
import std::getopts::optopt;
4+
import std::getopts::opt_present;
5+
import std::getopts::opt_str;
6+
import std::io;
7+
import std::vec;
8+
9+
import rustc::front::ast;
10+
11+
type src_gen = iter() -> str;
12+
13+
iter dir_src_gen(str dir) -> str {
14+
}
15+
16+
fn usage(str binary) {
17+
io::stdout().write_line("usage");
18+
}
19+
20+
type session = rec(str srcdir);
21+
22+
fn make_session(vec[str] args) -> session {
23+
// Directory of rust source files to use as input
24+
auto opt_src = "src";
25+
26+
auto binary = vec::shift[str](args);
27+
auto opts = [optopt(opt_src)];
28+
auto match;
29+
alt (getopts::getopts(args, opts)) {
30+
case (getopts::failure(?f)) {
31+
log_err #fmt("error: %s", getopts::fail_str(f));
32+
fail;
33+
}
34+
case (getopts::success(?m)) {
35+
match = m;
36+
}
37+
};
38+
39+
if (!opt_present(match, opt_src)) {
40+
usage(binary);
41+
fail;
42+
}
43+
44+
auto srcdir = opt_str(match, opt_src);
45+
46+
ret rec(srcdir = srcdir);
47+
}
48+
49+
fn log_session(session sess) {
50+
log #fmt("srcdir: %s", sess.srcdir);
51+
}
52+
53+
fn run_session(session sess) {
54+
}
55+
156
fn main(vec[str] args) {
2-
rustc::driver::rustc::main(args);
3-
}
57+
auto sess = make_session(args);
58+
log_session(sess);
59+
run_session(sess);
60+
}
61+
62+
// Local Variables:
63+
// mode: rust;
64+
// fill-column: 78;
65+
// indent-tabs-mode: nil
66+
// c-basic-offset: 4
67+
// buffer-file-coding-system: utf-8-unix
68+
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
69+
// End:

0 commit comments

Comments
 (0)