@@ -899,26 +899,26 @@ native "cdecl" mod llvm = "rustllvm" {
899
899
900
900
/* Memory-managed object interface to type handles. */
901
901
902
- obj type_names( type_names: std:: map:: hashmap<TypeRef , str >,
902
+ obj type_names( type_names: std:: map:: hashmap<TypeRef , istr >,
903
903
named_types: std:: map:: hashmap<istr, TypeRef >) {
904
904
905
- fn associate ( s : str , t : TypeRef ) {
906
- assert ( !named_types. contains_key ( istr :: from_estr ( s ) ) ) ;
905
+ fn associate ( s : & istr , t : TypeRef ) {
906
+ assert ( !named_types. contains_key ( s ) ) ;
907
907
assert ( !type_names. contains_key ( t) ) ;
908
908
type_names. insert ( t, s) ;
909
- named_types. insert ( istr :: from_estr ( s ) , t) ;
909
+ named_types. insert ( s , t) ;
910
910
}
911
911
912
912
fn type_has_name ( t : TypeRef ) -> bool { ret type_names. contains_key ( t) ; }
913
913
914
- fn get_name ( t : TypeRef ) -> str { ret type_names. get ( t) ; }
914
+ fn get_name ( t : TypeRef ) -> istr { ret type_names. get ( t) ; }
915
915
916
- fn name_has_type ( s : str ) -> bool {
917
- ret named_types. contains_key ( istr :: from_estr ( s ) ) ;
916
+ fn name_has_type ( s : & istr ) -> bool {
917
+ ret named_types. contains_key ( s ) ;
918
918
}
919
919
920
- fn get_type ( s : str ) -> TypeRef {
921
- ret named_types. get ( istr :: from_estr ( s ) ) ;
920
+ fn get_type ( s : & istr ) -> TypeRef {
921
+ ret named_types. get ( s ) ;
922
922
}
923
923
}
924
924
@@ -931,29 +931,30 @@ fn mk_type_names() -> type_names {
931
931
932
932
let hasher: std:: map:: hashfn < TypeRef > = hash;
933
933
let eqer: std:: map:: eqfn < TypeRef > = eq;
934
- let tn = std:: map:: mk_hashmap :: < TypeRef , str > ( hasher, eqer) ;
934
+ let tn = std:: map:: mk_hashmap :: < TypeRef , istr > ( hasher, eqer) ;
935
935
936
936
ret type_names( tn, nt) ;
937
937
}
938
938
939
- fn type_to_str ( names : type_names , ty : TypeRef ) -> str {
939
+ fn type_to_str ( names : type_names , ty : TypeRef ) -> istr {
940
940
ret type_to_str_inner ( names, [ ] , ty) ;
941
941
}
942
942
943
943
fn type_to_str_inner ( names : type_names , outer0 : & [ TypeRef ] , ty : TypeRef ) ->
944
- str {
944
+ istr {
945
945
946
946
if names. type_has_name ( ty) { ret names. get_name ( ty) ; }
947
947
948
948
let outer = outer0 + [ ty] ;
949
949
950
950
let kind: int = llvm:: LLVMGetTypeKind ( ty) ;
951
951
952
- fn tys_str ( names : type_names , outer : & [ TypeRef ] , tys : & [ TypeRef ] ) -> str {
953
- let s: str = "" ;
952
+ fn tys_str ( names : type_names , outer : & [ TypeRef ] ,
953
+ tys : & [ TypeRef ] ) -> istr {
954
+ let s: istr = ~"";
954
955
let first: bool = true ;
955
956
for t: TypeRef in tys {
956
- if first { first = false ; } else { s += ", " ; }
957
+ if first { first = false ; } else { s += ~ ", "; }
957
958
s += type_to_str_inner(names, outer, t);
958
959
}
959
960
ret s;
@@ -968,53 +969,53 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
968
969
// horrible, horrible. Complete as needed.
969
970
970
971
0 {
971
- ret "Void ";
972
+ ret ~ " Void ";
972
973
}
973
- 1 { ret "Float" ; }
974
- 2 { ret "Double" ; }
975
- 3 { ret "X86_FP80" ; }
976
- 4 { ret "FP128" ; }
977
- 5 { ret "PPC_FP128" ; }
978
- 6 { ret "Label" ; }
974
+ 1 { ret ~ "Float "; }
975
+ 2 { ret ~ "Double "; }
976
+ 3 { ret ~ "X86_FP80 "; }
977
+ 4 { ret ~ "FP128 "; }
978
+ 5 { ret ~ "PPC_FP128 "; }
979
+ 6 { ret ~ "Label "; }
979
980
980
981
981
982
982
983
7 {
983
- ret "i" + istr :: to_estr ( std:: int:: str (
984
- llvm:: LLVMGetIntTypeWidth ( ty) as int ) ) ;
984
+ ret ~ "i" + std:: int:: str (
985
+ llvm:: LLVMGetIntTypeWidth ( ty) as int ) ;
985
986
}
986
987
987
988
988
989
989
990
8 {
990
- let s = "fn(" ;
991
+ let s = ~ "fn ( ";
991
992
let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
992
993
let n_args: uint = llvm::LLVMCountParamTypes(ty);
993
994
let args: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_args);
994
995
llvm::LLVMGetParamTypes(ty, vec::to_ptr(args));
995
996
s += tys_str(names, outer, args);
996
- s += ") -> " ;
997
+ s += ~ " ) -> ";
997
998
s += type_to_str_inner(names, outer, out_ty);
998
999
ret s;
999
1000
}
1000
1001
1001
1002
1002
1003
1003
1004
9 {
1004
- let s: str = "{" ;
1005
+ let s: istr = ~ " { ";
1005
1006
let n_elts: uint = llvm::LLVMCountStructElementTypes(ty);
1006
1007
let elts: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_elts);
1007
1008
llvm::LLVMGetStructElementTypes(ty, vec::to_ptr(elts));
1008
1009
s += tys_str(names, outer, elts);
1009
- s += "}" ;
1010
+ s += ~ " } ";
1010
1011
ret s;
1011
1012
}
1012
1013
1013
1014
1014
1015
1015
1016
10 {
1016
1017
let el_ty = llvm::LLVMGetElementType(ty);
1017
- ret "[" + type_to_str_inner ( names, outer, el_ty) + "]" ;
1018
+ ret ~ " [ " + type_to_str_inner(names, outer, el_ty) + ~ " ] ";
1018
1019
}
1019
1020
1020
1021
@@ -1025,20 +1026,20 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
1025
1026
i += 1 u;
1026
1027
if tout as int == ty as int {
1027
1028
let n: uint = vec:: len :: < TypeRef > ( outer0) - i;
1028
- ret "*\\ " + istr :: to_estr ( std:: int:: str ( n as int ) ) ;
1029
+ ret ~ "* \\ " + std:: int:: str ( n as int ) ;
1029
1030
}
1030
1031
}
1031
- ret "* " +
1032
+ ret ~ "* " +
1032
1033
type_to_str_inner(names, outer, llvm::LLVMGetElementType(ty));
1033
1034
}
1034
1035
1035
1036
1036
1037
1037
1038
12 {
1038
- ret " Opaque ";
1039
+ ret ~ " Opaque ";
1039
1040
}
1040
- 13 { ret "Vector" ; }
1041
- 14 { ret "Metadata" ; }
1041
+ 13 { ret ~ "Vector "; }
1042
+ 14 { ret ~ "Metadata "; }
1042
1043
_ { log_err #fmt[ "unknown TypeKind %d" , kind as int ] ; fail; }
1043
1044
}
1044
1045
}
@@ -1068,8 +1069,8 @@ resource target_data_res(TD: TargetDataRef) {
1068
1069
1069
1070
type target_data = { lltd : TargetDataRef , dtor : @target_data_res } ;
1070
1071
1071
- fn mk_target_data ( string_rep : str ) -> target_data {
1072
- let lltd = istr:: as_buf ( istr :: from_estr ( string_rep) , { |buf|
1072
+ fn mk_target_data ( string_rep : & istr ) -> target_data {
1073
+ let lltd = istr:: as_buf ( string_rep, { |buf|
1073
1074
llvm:: LLVMCreateTargetData ( buf)
1074
1075
} ) ;
1075
1076
ret { lltd : lltd, dtor : @target_data_res ( lltd) } ;
0 commit comments