@@ -330,45 +330,47 @@ fn build_target_config() -> @session::config {
330
330
ret target_cfg;
331
331
}
332
332
333
- fn build_session_options( binary : str , match : getopts:: match , binary_dir : str )
333
+ fn build_session_options( binary : str , match : & getopts:: match , binary_dir : str )
334
334
-> @session:: options {
335
- let library = opt_present ( match , "lib" ) ;
336
- let static = opt_present ( match , "static" ) ;
335
+ let library = opt_present( match , ~ "lib") ;
336
+ let static = opt_present( match , ~ "static ") ;
337
337
338
338
let library_search_paths = [ binary_dir + "/lib" ] ;
339
- let lsp_vec = getopts:: opt_strs( match , "L" ) ;
340
- for lsp: str in lsp_vec { library_search_paths += [ lsp] ; }
339
+ let lsp_vec = getopts:: opt_strs( match , ~"L ") ;
340
+ for lsp: istr in lsp_vec {
341
+ library_search_paths += [ istr:: to_estr ( lsp) ] ;
342
+ }
341
343
342
- let parse_only = opt_present ( match , "parse-only" ) ;
343
- let no_trans = opt_present ( match , "no-trans" ) ;
344
+ let parse_only = opt_present( match , ~ "parse-only") ;
345
+ let no_trans = opt_present( match , ~ "no-trans") ;
344
346
345
347
let output_type =
346
348
if parse_only || no_trans {
347
349
link:: output_type_none
348
- } else if opt_present ( match , "S" ) {
350
+ } else if opt_present( match , ~ "S ") {
349
351
link:: output_type_assembly
350
- } else if opt_present ( match , "c" ) {
352
+ } else if opt_present( match , ~ "c") {
351
353
link::output_type_object
352
- } else if opt_present ( match , "emit-llvm" ) {
354
+ } else if opt_present(match, ~ " emit-llvm") {
353
355
link:: output_type_bitcode
354
356
} else { link : : output_type_exe } ;
355
- let verify = !opt_present ( match , "noverify" ) ;
356
- let save_temps = opt_present ( match , "save-temps" ) ;
357
- let debuginfo = opt_present ( match , "g" ) ;
358
- let stats = opt_present ( match , "stats" ) ;
359
- let time_passes = opt_present ( match , "time-passes" ) ;
360
- let time_llvm_passes = opt_present ( match , "time-llvm-passes" ) ;
361
- let run_typestate = !opt_present ( match , "no-typestate" ) ;
362
- let sysroot_opt = getopts:: opt_maybe_str ( match , "sysroot" ) ;
357
+ let verify = !opt_present( match , ~ "noverify") ;
358
+ let save_temps = opt_present( match , ~ "save-temps") ;
359
+ let debuginfo = opt_present( match , ~ "g") ;
360
+ let stats = opt_present( match , ~ "stats") ;
361
+ let time_passes = opt_present( match , ~ "time-passes") ;
362
+ let time_llvm_passes = opt_present( match , ~ "time-llvm-passes") ;
363
+ let run_typestate = !opt_present( match , ~ "no-typestate") ;
364
+ let sysroot_opt = getopts:: opt_maybe_str( match , ~ "sysroot") ;
363
365
let opt_level: uint =
364
- if opt_present ( match , "O" ) {
365
- if opt_present( match , "OptLevel" ) {
366
+ if opt_present( match , ~ "O ") {
367
+ if opt_present( match, ~ "OptLevel ") {
366
368
log_err "error: -O and --OptLevel both provided" ;
367
369
fail;
368
370
}
369
371
2 u
370
- } else if opt_present ( match , "OptLevel" ) {
371
- alt getopts:: opt_str( match, "OptLevel" ) {
372
+ } else if opt_present ( match , ~ "OptLevel ") {
373
+ alt istr :: to_estr ( getopts:: opt_str( match, ~ "OptLevel ") ) {
372
374
"0" { 0 u }
373
375
"1" { 1 u }
374
376
"2" { 2 u }
@@ -383,11 +385,12 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
383
385
let sysroot =
384
386
alt sysroot_opt {
385
387
none. { get_default_sysroot( binary) }
386
- some( s) { s }
388
+ some( s) { istr :: to_estr ( s ) }
387
389
} ;
388
- let cfg = parse_cfgspecs( getopts:: opt_strs( match , "cfg" ) ) ;
389
- let test = opt_present( match , "test" ) ;
390
- let do_gc = opt_present( match , "gc" ) ;
390
+ let cfg = parse_cfgspecs(
391
+ istr:: to_estrs( getopts:: opt_strs( match , ~"cfg") ) ) ;
392
+ let test = opt_present( match , ~"test") ;
393
+ let do_gc = opt_present( match , ~"gc") ;
391
394
let sopts: @session:: options =
392
395
@{ library: library,
393
396
static : static ,
@@ -418,60 +421,62 @@ fn build_session(sopts: @session::options) -> session::session {
418
421
none, 0 u) ;
419
422
}
420
423
421
- fn parse_pretty ( sess : session:: session , name : & str ) -> pp_mode {
422
- if str :: eq ( name, "normal" ) {
424
+ fn parse_pretty ( sess : session:: session , name : & istr ) -> pp_mode {
425
+ if istr :: eq ( name, ~ "normal") {
423
426
ret ppm_normal;
424
- } else if str :: eq ( name, "expanded" ) {
427
+ } else if istr :: eq ( name, ~ "expanded") {
425
428
ret ppm_expanded;
426
- } else if str :: eq ( name, "typed" ) {
429
+ } else if istr :: eq ( name, ~ "typed") {
427
430
ret ppm_typed;
428
- } else if str :: eq ( name, "identified" ) { ret ppm_identified; }
431
+ } else if istr :: eq ( name, ~ "identified") { ret ppm_identified; }
429
432
sess. fatal ( "argument to `pretty` must be one of `normal`, `typed`, or "
430
433
+ "`identified`" ) ;
431
434
}
432
435
433
436
fn opts ( ) -> [ getopts:: opt ] {
434
- ret [ optflag ( "h" ) , optflag ( "help" ) , optflag ( "v" ) , optflag ( "version" ) ,
435
- optflag ( "glue" ) , optflag ( "emit-llvm" ) , optflagopt ( "pretty" ) ,
436
- optflag ( "ls" ) , optflag ( "parse-only" ) , optflag ( "no-trans" ) ,
437
- optflag ( "O" ) , optopt ( "OptLevel" ) , optmulti ( "L" ) ,
438
- optflag ( "S" ) , optflag ( "c" ) , optopt ( "o" ) , optflag ( "g" ) ,
439
- optflag ( "save-temps" ) , optopt ( "sysroot" ) , optflag ( "stats" ) ,
440
- optflag ( "time-passes" ) , optflag ( "time-llvm-passes" ) ,
441
- optflag ( "no-typestate" ) , optflag ( "noverify" ) , optmulti ( "cfg" ) ,
442
- optflag ( "test" ) , optflag ( "lib" ) , optflag ( "static" ) , optflag ( "gc" ) ] ;
437
+ ret [ optflag ( ~"h") , optflag ( ~"help") , optflag ( ~"v") , optflag ( ~"version") ,
438
+ optflag ( ~"glue") , optflag ( ~"emit-llvm") , optflagopt ( ~"pretty") ,
439
+ optflag ( ~"ls") , optflag ( ~"parse-only") , optflag ( ~"no-trans") ,
440
+ optflag ( ~"O ") , optopt ( ~"OptLevel ") , optmulti ( ~"L ") ,
441
+ optflag ( ~"S ") , optflag ( ~"c"), optopt(~" o") , optflag ( ~"g") ,
442
+ optflag ( ~"save-temps") , optopt ( ~"sysroot") , optflag ( ~"stats") ,
443
+ optflag ( ~"time-passes") , optflag ( ~"time-llvm-passes") ,
444
+ optflag ( ~"no-typestate") , optflag ( ~"noverify") , optmulti ( ~"cfg") ,
445
+ optflag ( ~"test") , optflag ( ~"lib") , optflag ( ~"static ") ,
446
+ optflag ( ~"gc") ] ;
443
447
}
444
448
445
449
fn main( args : [ str ] ) {
446
450
let binary = vec:: shift ( args) ;
447
451
let binary_dir = istr:: to_estr (
448
452
fs:: dirname ( istr:: from_estr ( binary) ) ) ;
449
453
let match =
450
- alt getopts:: getopts ( args, opts ( ) ) {
454
+ alt getopts:: getopts ( istr :: from_estrs ( args) , opts ( ) ) {
451
455
getopts:: success ( m) { m }
452
456
getopts:: failure ( f) {
453
- log_err #fmt[ "error: %s" , getopts:: fail_str ( f) ] ;
457
+ log_err #fmt[ "error: %s" , istr :: to_estr ( getopts:: fail_str ( f) ) ] ;
454
458
fail
455
459
}
456
460
} ;
457
- if opt_present( match , "h" ) || opt_present( match , "help" ) {
461
+ if opt_present( match , ~ "h") || opt_present ( match , ~ "help") {
458
462
usage( binary) ;
459
463
ret;
460
464
}
461
- if opt_present( match, "v" ) || opt_present( match, "version" ) {
465
+ if opt_present( match, ~ "v") || opt_present( match, ~ "version") {
462
466
version( binary) ;
463
467
ret;
464
468
}
465
469
let sopts = build_session_options( binary, match, binary_dir) ;
466
470
let sess = build_session( sopts) ;
467
- let n_inputs = vec:: len:: < str > ( match. free) ;
468
- let output_file = getopts:: opt_maybe_str( match, "o" ) ;
469
- let glue = opt_present( match, "glue" ) ;
471
+ let n_inputs = vec:: len:: < istr > ( match. free) ;
472
+ let output_file = getopts:: opt_maybe_str( match, ~ "o") ;
473
+ let glue = opt_present( match, ~ "glue") ;
470
474
if glue {
471
475
if n_inputs > 0 u {
472
476
sess. fatal ( "No input files allowed with --glue." ) ;
473
477
}
474
- let out = option:: from_maybe:: < str > ( "glue.bc" , output_file) ;
478
+ let out = option:: from_maybe:: < istr > ( ~"glue. bc", output_file) ;
479
+ let out = istr:: to_estr( out) ;
475
480
middle:: trans:: make_common_glue( sess, out) ;
476
481
ret;
477
482
}
@@ -480,22 +485,22 @@ fn main(args: [str]) {
480
485
} else if n_inputs > 1 u {
481
486
sess. fatal ( "Multiple input filenames provided." ) ;
482
487
}
483
- let ifile = match . free [ 0 ] ;
488
+ let ifile = istr :: to_estr ( match . free [ 0 ] ) ;
484
489
let saved_out_filename: str = "" ;
485
490
let cfg = build_configuration ( sess, binary, ifile) ;
486
491
let pretty =
487
- option:: map :: < str ,
492
+ option:: map :: < istr ,
488
493
pp_mode > ( bind parse_pretty ( sess, _) ,
489
- getopts:: opt_default( match , "pretty" ,
490
- "normal" ) ) ;
494
+ getopts:: opt_default( match , ~ "pretty",
495
+ ~ "normal") ) ;
491
496
alt pretty {
492
497
some :: < pp_mode > ( ppm) {
493
498
pretty_print_input( sess, cfg, ifile, ppm) ;
494
499
ret;
495
500
}
496
501
none :: < pp_mode > . { /* continue * / }
497
502
}
498
- let ls = opt_present( match , "ls" ) ;
503
+ let ls = opt_present( match , ~ "ls") ;
499
504
if ls { metadata:: creader:: list_file_metadata ( ifile, io:: stdout ( ) ) ; ret; }
500
505
501
506
let stop_after_codegen =
@@ -528,6 +533,7 @@ fn main(args: [str]) {
528
533
compile_input ( sess, cfg, ifile, ofile) ;
529
534
}
530
535
some( ofile) {
536
+ let ofile = istr:: to_estr( ofile) ;
531
537
// FIXME: what about windows? This will create a foo.exe.o.
532
538
saved_out_filename = ofile;
533
539
let temp_filename =
@@ -634,7 +640,7 @@ mod test {
634
640
#[ test]
635
641
fn test_switch_implies_cfg_test ( ) {
636
642
let match =
637
- alt getopts:: getopts ( [ "--test" ] , opts ( ) ) {
643
+ alt getopts:: getopts ( [ ~ "--test"] , opts ( ) ) {
638
644
getopts:: success ( m) { m }
639
645
} ;
640
646
let sessopts = build_session_options ( "whatever" , match , "whatever" ) ;
@@ -648,7 +654,7 @@ mod test {
648
654
#[ test]
649
655
fn test_switch_implies_cfg_test_unless_cfg_test ( ) {
650
656
let match =
651
- alt getopts:: getopts ( [ "--test" , "--cfg=test" ] , opts ( ) ) {
657
+ alt getopts:: getopts ( [ ~ "--test", ~ "--cfg=test"] , opts ( ) ) {
652
658
getopts:: success ( m) { m }
653
659
} ;
654
660
let sessopts = build_session_options ( "whatever" , match , "whatever" ) ;
0 commit comments