diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-01-13 23:03:37 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-01-14 15:14:43 -0800 |
| commit | e78b1040e76ad2cd7b07c93289fce10cb79f2363 (patch) | |
| tree | f7aaa6e1c3a188b5ce36525b464e4eaef01e3a9c /src/comp/driver | |
| parent | 876e9fdc06563af60e1213f3e29cc325331e2a3d (diff) | |
| download | rust-e78b1040e76ad2cd7b07c93289fce10cb79f2363.tar.gz rust-e78b1040e76ad2cd7b07c93289fce10cb79f2363.zip | |
rustc: Pull some uses of early_error up into build_target_config
Diffstat (limited to 'src/comp/driver')
| -rw-r--r-- | src/comp/driver/driver.rs | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/comp/driver/driver.rs b/src/comp/driver/driver.rs index 6a578a3f0cf..03544c3d5fc 100644 --- a/src/comp/driver/driver.rs +++ b/src/comp/driver/driver.rs @@ -289,36 +289,42 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str, io::string_reader(src), io::stdout(), ann); } -fn get_os(triple: str) -> session::os { +fn get_os(triple: str) -> option<session::os> { ret if str::find(triple, "win32") >= 0 || str::find(triple, "mingw32") >= 0 { - session::os_win32 + some(session::os_win32) } else if str::find(triple, "darwin") >= 0 { - session::os_macos + some(session::os_macos) } else if str::find(triple, "linux") >= 0 { - session::os_linux + some(session::os_linux) } else if str::find(triple, "freebsd") >= 0 { - session::os_freebsd - } else { early_error("Unknown operating system!") }; + some(session::os_freebsd) + } else { none }; } -fn get_arch(triple: str) -> session::arch { +fn get_arch(triple: str) -> option<session::arch> { ret if str::find(triple, "i386") >= 0 || str::find(triple, "i486") >= 0 || str::find(triple, "i586") >= 0 || str::find(triple, "i686") >= 0 || str::find(triple, "i786") >= 0 { - session::arch_x86 + some(session::arch_x86) } else if str::find(triple, "x86_64") >= 0 { - session::arch_x86_64 + some(session::arch_x86_64) } else if str::find(triple, "arm") >= 0 || str::find(triple, "xscale") >= 0 { - session::arch_arm - } else { early_error("Unknown architecture! " + triple) }; + some(session::arch_arm) + } else { none }; } fn build_target_config(sopts: @session::options) -> @session::config { - let os = get_os(sopts.target_triple); - let arch = get_arch(sopts.target_triple); + let os = alt get_os(sopts.target_triple) { + some(os) { os } + none. { early_error("Unknown operating system!") } + }; + let arch = alt get_arch(sopts.target_triple) { + some(arch) { arch } + none. { early_error("Unknown architecture! " + sopts.target_triple) } + }; let (int_type, uint_type, float_type) = alt arch { session::arch_x86. {(ast::ty_i32, ast::ty_u32, ast::ty_f64)} session::arch_x86_64. {(ast::ty_i64, ast::ty_u64, ast::ty_f64)} |
