about summary refs log tree commit diff
path: root/src/comp/lib
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-26 16:33:30 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-27 15:54:44 -0700
commitfcdbdaf2ab35b9e74c38b71e4760867a795ca623 (patch)
tree0ea55d88e591b3491c1b851add288decbf14f17f /src/comp/lib
parentd7fa75413f4c109b9ecadf4b9b3e1edd762e3056 (diff)
downloadrust-fcdbdaf2ab35b9e74c38b71e4760867a795ca623.tar.gz
rust-fcdbdaf2ab35b9e74c38b71e4760867a795ca623.zip
Convert the rest of rustc::lib::llvm to istrs. Issue #855
Diffstat (limited to 'src/comp/lib')
-rw-r--r--src/comp/lib/llvm.rs73
1 files changed, 37 insertions, 36 deletions
diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs
index a090f7cc667..9bc7dc932f5 100644
--- a/src/comp/lib/llvm.rs
+++ b/src/comp/lib/llvm.rs
@@ -899,26 +899,26 @@ native "cdecl" mod llvm = "rustllvm" {
 
 /* Memory-managed object interface to type handles. */
 
-obj type_names(type_names: std::map::hashmap<TypeRef, str>,
+obj type_names(type_names: std::map::hashmap<TypeRef, istr>,
                named_types: std::map::hashmap<istr, TypeRef>) {
 
-    fn associate(s: str, t: TypeRef) {
-        assert (!named_types.contains_key(istr::from_estr(s)));
+    fn associate(s: &istr, t: TypeRef) {
+        assert (!named_types.contains_key(s));
         assert (!type_names.contains_key(t));
         type_names.insert(t, s);
-        named_types.insert(istr::from_estr(s), t);
+        named_types.insert(s, t);
     }
 
     fn type_has_name(t: TypeRef) -> bool { ret type_names.contains_key(t); }
 
-    fn get_name(t: TypeRef) -> str { ret type_names.get(t); }
+    fn get_name(t: TypeRef) -> istr { ret type_names.get(t); }
 
-    fn name_has_type(s: str) -> bool {
-        ret named_types.contains_key(istr::from_estr(s));
+    fn name_has_type(s: &istr) -> bool {
+        ret named_types.contains_key(s);
     }
 
-    fn get_type(s: str) -> TypeRef {
-        ret named_types.get(istr::from_estr(s));
+    fn get_type(s: &istr) -> TypeRef {
+        ret named_types.get(s);
     }
 }
 
@@ -931,17 +931,17 @@ fn mk_type_names() -> type_names {
 
     let hasher: std::map::hashfn<TypeRef> = hash;
     let eqer: std::map::eqfn<TypeRef> = eq;
-    let tn = std::map::mk_hashmap::<TypeRef, str>(hasher, eqer);
+    let tn = std::map::mk_hashmap::<TypeRef, istr>(hasher, eqer);
 
     ret type_names(tn, nt);
 }
 
-fn type_to_str(names: type_names, ty: TypeRef) -> str {
+fn type_to_str(names: type_names, ty: TypeRef) -> istr {
     ret type_to_str_inner(names, [], ty);
 }
 
 fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
-   str {
+   istr {
 
     if names.type_has_name(ty) { ret names.get_name(ty); }
 
@@ -949,11 +949,12 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
 
     let kind: int = llvm::LLVMGetTypeKind(ty);
 
-    fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str {
-        let s: str = "";
+    fn tys_str(names: type_names, outer: &[TypeRef],
+               tys: &[TypeRef]) -> istr {
+        let s: istr = ~"";
         let first: bool = true;
         for t: TypeRef in tys {
-            if first { first = false; } else { s += ", "; }
+            if first { first = false; } else { s += ~", "; }
             s += type_to_str_inner(names, outer, t);
         }
         ret s;
@@ -968,32 +969,32 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
       // horrible, horrible. Complete as needed.
 
       0 {
-        ret "Void";
+        ret ~"Void";
       }
-      1 { ret "Float"; }
-      2 { ret "Double"; }
-      3 { ret "X86_FP80"; }
-      4 { ret "FP128"; }
-      5 { ret "PPC_FP128"; }
-      6 { ret "Label"; }
+      1 { ret ~"Float"; }
+      2 { ret ~"Double"; }
+      3 { ret ~"X86_FP80"; }
+      4 { ret ~"FP128"; }
+      5 { ret ~"PPC_FP128"; }
+      6 { ret ~"Label"; }
 
 
 
       7 {
-        ret "i" + istr::to_estr(std::int::str(
-            llvm::LLVMGetIntTypeWidth(ty) as int));
+        ret ~"i" + std::int::str(
+            llvm::LLVMGetIntTypeWidth(ty) as int);
       }
 
 
 
       8 {
-        let s = "fn(";
+        let s = ~"fn(";
         let out_ty: TypeRef = llvm::LLVMGetReturnType(ty);
         let n_args: uint = llvm::LLVMCountParamTypes(ty);
         let args: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_args);
         llvm::LLVMGetParamTypes(ty, vec::to_ptr(args));
         s += tys_str(names, outer, args);
-        s += ") -> ";
+        s += ~") -> ";
         s += type_to_str_inner(names, outer, out_ty);
         ret s;
       }
@@ -1001,12 +1002,12 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
 
 
       9 {
-        let s: str = "{";
+        let s: istr = ~"{";
         let n_elts: uint = llvm::LLVMCountStructElementTypes(ty);
         let elts: [TypeRef] = vec::init_elt::<TypeRef>(0 as TypeRef, n_elts);
         llvm::LLVMGetStructElementTypes(ty, vec::to_ptr(elts));
         s += tys_str(names, outer, elts);
-        s += "}";
+        s += ~"}";
         ret s;
       }
 
@@ -1014,7 +1015,7 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
 
       10 {
         let el_ty = llvm::LLVMGetElementType(ty);
-        ret "[" + type_to_str_inner(names, outer, el_ty) + "]";
+        ret ~"[" + type_to_str_inner(names, outer, el_ty) + ~"]";
       }
 
 
@@ -1025,20 +1026,20 @@ fn type_to_str_inner(names: type_names, outer0: &[TypeRef], ty: TypeRef) ->
             i += 1u;
             if tout as int == ty as int {
                 let n: uint = vec::len::<TypeRef>(outer0) - i;
-                ret "*\\" + istr::to_estr(std::int::str(n as int));
+                ret ~"*\\" + std::int::str(n as int);
             }
         }
-        ret "*" +
+        ret ~"*" +
                 type_to_str_inner(names, outer, llvm::LLVMGetElementType(ty));
       }
 
 
 
       12 {
-        ret "Opaque";
+        ret ~"Opaque";
       }
-      13 { ret "Vector"; }
-      14 { ret "Metadata"; }
+      13 { ret ~"Vector"; }
+      14 { ret ~"Metadata"; }
       _ { log_err #fmt["unknown TypeKind %d", kind as int]; fail; }
     }
 }
@@ -1068,8 +1069,8 @@ resource target_data_res(TD: TargetDataRef) {
 
 type target_data = {lltd: TargetDataRef, dtor: @target_data_res};
 
-fn mk_target_data(string_rep: str) -> target_data {
-    let lltd = istr::as_buf(istr::from_estr(string_rep), { |buf|
+fn mk_target_data(string_rep: &istr) -> target_data {
+    let lltd = istr::as_buf(string_rep, { |buf|
         llvm::LLVMCreateTargetData(buf)
     });
     ret {lltd: lltd, dtor: @target_data_res(lltd)};