about summary refs log tree commit diff
path: root/src/comp/middle
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-06-20 13:46:44 -0700
committerEric Holk <eholk@mozilla.com>2011-06-20 13:47:02 -0700
commita2dcd08cc273bcc880fc9687bffc98796fa1f3c4 (patch)
treef794a78f7e6723995ed983e779ee9cbbbd896ad4 /src/comp/middle
parentc0515017842a4b7872ff31bd91acec4a54d2ef2d (diff)
downloadrust-a2dcd08cc273bcc880fc9687bffc98796fa1f3c4.tar.gz
rust-a2dcd08cc273bcc880fc9687bffc98796fa1f3c4.zip
Added string duplication to deep_copy. Closes #520.
Diffstat (limited to 'src/comp/middle')
-rw-r--r--src/comp/middle/trans.rs29
-rw-r--r--src/comp/middle/ty.rs8
2 files changed, 15 insertions, 22 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 483d6f7a5b0..408a9f3e7db 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -6340,28 +6340,13 @@ fn deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t, ValueRef target_task)
     if(ty::type_is_scalar(tcx, t)) {
         ret res(bcx, v);
     }
+    else if(ty::type_is_str(tcx, t)) {
+        ret res(bcx,
+                bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.dup_str,
+                               [bcx.fcx.lltaskptr, v]));
+    }
     else if(ty::type_is_chan(tcx, t)) {
         // If this is a channel, we need to clone it.
-        /*
-        log_err "Generating clone call for channel argument.";
-      
-        log_err #fmt("ty(clone_chan) = %s", 
-                     val_str(bcx.fcx.lcx.ccx.tn,
-                             bcx.fcx.lcx.ccx.upcalls.clone_chan));
-      
-        log_err #fmt("ty(lltaskptr) = %s", 
-                     val_str(bcx.fcx.lcx.ccx.tn, 
-                             bcx.fcx.lltaskptr));
-      
-        log_err #fmt("ty(target_task) = %s", 
-                     val_str(bcx.fcx.lcx.ccx.tn, 
-                             target_task));
-      
-        log_err #fmt("ty(chan) = %s", 
-                     val_str(bcx.fcx.lcx.ccx.tn, 
-                             v));
-        */
-
         auto chan_ptr = bcx.build.PointerCast(v, T_opaque_chan_ptr());
       
         auto chan_raw_val = 
@@ -6386,8 +6371,8 @@ fn deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t, ValueRef target_task)
     }
     else {
         bcx.fcx.lcx.ccx.sess.bug("unexpected type in " +
-                                "trans::deep_copy: " +
-                                ty_to_str(tcx, t));
+                                 "trans::deep_copy: " +
+                                 ty_to_str(tcx, t));
     }
 }
 
diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs
index df33890ea7f..d3e6dbfed3f 100644
--- a/src/comp/middle/ty.rs
+++ b/src/comp/middle/ty.rs
@@ -168,6 +168,7 @@ export type_is_sequence;
 export type_is_signed;
 export type_is_structural;
 export type_is_tup_like;
+export type_is_str;
 export type_owns_heap_mem;
 export type_param;
 export unify;
@@ -899,6 +900,13 @@ fn type_is_sequence(&ctxt cx, &t ty) -> bool {
     }
 }
 
+fn type_is_str(&ctxt cx, &t ty) -> bool {
+    alt (struct(cx, ty)) {
+        case (ty_str) { ret true; }
+        case (_) { ret false; }
+    }
+}
+
 fn sequence_is_interior(&ctxt cx, &t ty) -> bool {
     alt (struct(cx, ty)) {
         case (