@@ -289,36 +289,42 @@ fn pretty_print_input(sess: session::session, cfg: ast::crate_cfg, input: str,
289
289
io:: string_reader ( src) , io:: stdout ( ) , ann) ;
290
290
}
291
291
292
- fn get_os ( triple : str ) -> session:: os {
292
+ fn get_os ( triple : str ) -> option < session:: os > {
293
293
ret if str:: find ( triple, "win32" ) >= 0 ||
294
294
str:: find ( triple, "mingw32" ) >= 0 {
295
- session:: os_win32
295
+ some ( session:: os_win32)
296
296
} else if str:: find ( triple, "darwin" ) >= 0 {
297
- session:: os_macos
297
+ some ( session:: os_macos)
298
298
} else if str:: find ( triple, "linux" ) >= 0 {
299
- session:: os_linux
299
+ some ( session:: os_linux)
300
300
} else if str:: find ( triple, "freebsd" ) >= 0 {
301
- session:: os_freebsd
302
- } else { early_error ( "Unknown operating system!" ) } ;
301
+ some ( session:: os_freebsd)
302
+ } else { none } ;
303
303
}
304
304
305
- fn get_arch ( triple : str ) -> session:: arch {
305
+ fn get_arch ( triple : str ) -> option < session:: arch > {
306
306
ret if str:: find ( triple, "i386" ) >= 0 || str:: find ( triple, "i486" ) >= 0 ||
307
307
str:: find ( triple, "i586" ) >= 0 ||
308
308
str:: find ( triple, "i686" ) >= 0 ||
309
309
str:: find ( triple, "i786" ) >= 0 {
310
- session:: arch_x86
310
+ some ( session:: arch_x86)
311
311
} else if str:: find ( triple, "x86_64" ) >= 0 {
312
- session:: arch_x86_64
312
+ some ( session:: arch_x86_64)
313
313
} else if str:: find ( triple, "arm" ) >= 0 ||
314
314
str:: find ( triple, "xscale" ) >= 0 {
315
- session:: arch_arm
316
- } else { early_error ( "Unknown architecture! " + triple ) } ;
315
+ some ( session:: arch_arm)
316
+ } else { none } ;
317
317
}
318
318
319
319
fn build_target_config ( sopts : @session:: options ) -> @session:: config {
320
- let os = get_os ( sopts. target_triple ) ;
321
- let arch = get_arch ( sopts. target_triple ) ;
320
+ let os = alt get_os ( sopts. target_triple ) {
321
+ some ( os) { os }
322
+ none. { early_error ( "Unknown operating system!" ) }
323
+ } ;
324
+ let arch = alt get_arch ( sopts. target_triple ) {
325
+ some ( arch) { arch }
326
+ none. { early_error ( "Unknown architecture! " + sopts. target_triple ) }
327
+ } ;
322
328
let ( int_type, uint_type, float_type) = alt arch {
323
329
session : : arch_x86. { ( ast:: ty_i32, ast:: ty_u32, ast:: ty_f64) }
324
330
session:: arch_x86_64. { ( ast:: ty_i64, ast:: ty_u64, ast:: ty_f64) }
0 commit comments