@@ -43,7 +43,8 @@ use syntax::ast_map::{path, path_mod, path_name};
43
43
use syntax:: attr;
44
44
use syntax:: print:: pprust;
45
45
46
- enum output_type {
46
+ #[ deriving_eq]
47
+ pub enum output_type {
47
48
output_type_none,
48
49
output_type_bitcode,
49
50
output_type_assembly,
@@ -52,13 +53,6 @@ enum output_type {
52
53
output_type_exe,
53
54
}
54
55
55
- impl output_type : cmp:: Eq {
56
- pure fn eq ( & self , other : & output_type ) -> bool {
57
- ( ( * self ) as uint ) == ( ( * other) as uint )
58
- }
59
- pure fn ne ( & self , other : & output_type ) -> bool { !( * self ) . eq ( other) }
60
- }
61
-
62
56
pub fn llvm_err ( sess : Session , +msg : ~str ) -> ! {
63
57
unsafe {
64
58
let cstr = llvm:: LLVMRustGetLastError ( ) ;
@@ -170,15 +164,15 @@ pub mod jit {
170
164
}
171
165
}
172
166
173
- mod write {
167
+ pub mod write {
174
168
use back:: link:: jit;
175
- use back:: link:: { ModuleRef , WriteOutputFile , output_type} ;
169
+ use back:: link:: { WriteOutputFile , output_type} ;
176
170
use back:: link:: { output_type_assembly, output_type_bitcode} ;
177
171
use back:: link:: { output_type_exe, output_type_llvm_assembly} ;
178
172
use back:: link:: { output_type_object} ;
179
173
use driver:: session;
180
174
use lib:: llvm:: llvm;
181
- use lib:: llvm:: { False , True , mk_pass_manager, mk_target_data} ;
175
+ use lib:: llvm:: { False , True , ModuleRef , mk_pass_manager, mk_target_data} ;
182
176
use lib;
183
177
use session:: Session ;
184
178
@@ -456,7 +450,7 @@ mod write {
456
450
*
457
451
*/
458
452
459
- fn build_link_meta ( sess : Session , c : & ast:: crate , output : & Path ,
453
+ pub fn build_link_meta ( sess : Session , c : & ast:: crate , output : & Path ,
460
454
symbol_hasher : & hash:: State ) -> link_meta {
461
455
462
456
type provided_metas =
@@ -575,15 +569,15 @@ fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
575
569
return { name: name, vers: vers, extras_hash: extras_hash} ;
576
570
}
577
571
578
- fn truncated_hash_result ( symbol_hasher : & hash:: State ) -> ~str {
572
+ pub fn truncated_hash_result ( symbol_hasher : & hash:: State ) -> ~str {
579
573
unsafe {
580
574
symbol_hasher. result_str ( )
581
575
}
582
576
}
583
577
584
578
585
579
// This calculates STH for a symbol, as defined above
586
- fn symbol_hash( tcx : ty:: ctxt , symbol_hasher : & hash:: State , t : ty:: t ,
580
+ pub fn symbol_hash( tcx : ty:: ctxt , symbol_hasher : & hash:: State , t : ty:: t ,
587
581
link_meta : link_meta ) -> @str {
588
582
// NB: do *not* use abbrevs here as we want the symbol names
589
583
// to be independent of one another in the crate.
@@ -601,7 +595,7 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t,
601
595
hash.to_managed()
602
596
}
603
597
604
- fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
598
+ pub fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
605
599
match ccx.type_hashcodes.find(t) {
606
600
Some(h) => h,
607
601
None => {
@@ -615,7 +609,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
615
609
616
610
// Name sanitation. LLVM will happily accept identifiers with weird names, but
617
611
// gas doesn't!
618
- fn sanitize(s: ~str) -> ~str {
612
+ pub fn sanitize(s: ~str) -> ~str {
619
613
let mut result = ~" ";
620
614
for str :: chars_each( s) |c| {
621
615
match c {
@@ -648,7 +642,7 @@ fn sanitize(s: ~str) -> ~str {
648
642
return result;
649
643
}
650
644
651
- fn mangle ( sess : Session , ss : path ) -> ~str {
645
+ pub fn mangle ( sess : Session , ss : path ) -> ~str {
652
646
// Follow C++ namespace-mangling style
653
647
654
648
let mut n = ~"_ZN"; // Begin name-sequence.
@@ -663,26 +657,26 @@ fn mangle(sess: Session, ss: path) -> ~str {
663
657
n
664
658
}
665
659
666
- fn exported_name ( sess : Session ,
667
- +path : path,
668
- hash : & str ,
669
- vers : & str ) -> ~str {
660
+ pub fn exported_name ( sess : Session ,
661
+ +path : path,
662
+ hash : & str ,
663
+ vers : & str ) -> ~str {
670
664
return mangle ( sess,
671
665
vec:: append_one (
672
666
vec:: append_one ( path, path_name ( sess. ident_of ( hash. to_owned ( ) ) ) ) ,
673
667
path_name ( sess. ident_of ( vers. to_owned ( ) ) ) ) ) ;
674
668
}
675
669
676
- fn mangle_exported_name ( ccx : @crate_ctxt , +path : path, t : ty:: t ) -> ~str {
670
+ pub fn mangle_exported_name ( ccx : @crate_ctxt , +path : path, t : ty:: t ) -> ~str {
677
671
let hash = get_symbol_hash ( ccx, t) ;
678
672
return exported_name ( ccx. sess , path,
679
673
hash,
680
674
ccx. link_meta . vers ) ;
681
675
}
682
676
683
- fn mangle_internal_name_by_type_only ( ccx : @crate_ctxt ,
684
- t : ty:: t ,
685
- name : & str ) -> ~str {
677
+ pub fn mangle_internal_name_by_type_only ( ccx : @crate_ctxt ,
678
+ t : ty:: t ,
679
+ name : & str ) -> ~str {
686
680
let s = ppaux:: ty_to_short_str ( ccx. tcx , t) ;
687
681
let hash = get_symbol_hash ( ccx, t) ;
688
682
return mangle ( ccx. sess ,
@@ -691,23 +685,23 @@ fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
691
685
path_name ( ccx. sess . ident_of ( hash. to_owned ( ) ) ) ] ) ;
692
686
}
693
687
694
- fn mangle_internal_name_by_path_and_seq ( ccx : @crate_ctxt ,
695
- +path : path,
696
- +flav : ~str ) -> ~str {
688
+ pub fn mangle_internal_name_by_path_and_seq ( ccx : @crate_ctxt ,
689
+ +path : path,
690
+ +flav : ~str ) -> ~str {
697
691
return mangle ( ccx. sess ,
698
692
vec:: append_one ( path, path_name ( ( ccx. names ) ( flav) ) ) ) ;
699
693
}
700
694
701
- fn mangle_internal_name_by_path ( ccx : @crate_ctxt , +path : path) -> ~str {
695
+ pub fn mangle_internal_name_by_path ( ccx : @crate_ctxt , +path : path) -> ~str {
702
696
return mangle ( ccx. sess , path) ;
703
697
}
704
698
705
- fn mangle_internal_name_by_seq ( ccx : @crate_ctxt , +flav : ~str ) -> ~str {
699
+ pub fn mangle_internal_name_by_seq ( ccx : @crate_ctxt , +flav : ~str ) -> ~str {
706
700
return fmt ! ( "%s_%u" , flav, ( ccx. names) ( flav) . repr) ;
707
701
}
708
702
709
703
710
- fn output_dll_filename ( os : session:: os , lm : link_meta ) -> ~str {
704
+ pub fn output_dll_filename ( os : session:: os , lm : link_meta ) -> ~str {
711
705
let libname = fmt ! ( "%s-%s-%s" , lm. name, lm. extras_hash, lm. vers) ;
712
706
let ( dll_prefix, dll_suffix) = match os {
713
707
session:: os_win32 => ( win32:: DLL_PREFIX , win32:: DLL_SUFFIX ) ,
@@ -722,10 +716,10 @@ fn output_dll_filename(os: session::os, lm: link_meta) -> ~str {
722
716
723
717
// If the user wants an exe generated we need to invoke
724
718
// cc to link the object file with some libs
725
- fn link_binary( sess : Session ,
726
- obj_filename : & Path ,
727
- out_filename : & Path ,
728
- lm : link_meta ) {
719
+ pub fn link_binary( sess : Session ,
720
+ obj_filename : & Path ,
721
+ out_filename : & Path ,
722
+ lm : link_meta ) {
729
723
// Converts a library file-stem into a cc -l argument
730
724
fn unlib ( config : @session:: config , +stem : ~str ) -> ~str {
731
725
if stem. starts_with ( "lib" ) &&
0 commit comments