ret take_ty(bcx, dst, t);
}
if ty::type_is_unique_box(ccx.tcx, t) {
- //let bcx = cx;
+ let bcx = cx;
// FIXME (409): Write a test and uncomment
//if action == DROP_EXISTING { bcx = drop_ty(cx, dst, t); }
- //ret trans_uniq::copy_val(bcx, dst, src, t);
- fail;
+ check trans_uniq::type_is_unique_box(bcx, t);
+ ret trans_uniq::copy_val(bcx, dst, src, t);
}
if type_is_structural_or_param(ccx.tcx, t) || ty::type_is_vec(ccx.tcx, t)
{
new_sub_block_ctxt
};
-export trans_uniq, make_free_glue, type_is_unique_box;
+export trans_uniq, make_free_glue, type_is_unique_box, copy_val;
pure fn type_is_unique_box(bcx: @block_ctxt, ty: ty::t) -> bool {
unchecked {
let content_ty = content_ty(bcx, uniq_ty);
let {bcx, val: llptr} = alloc_uniq(bcx, uniq_ty);
+ add_clean_temp(bcx, llptr, uniq_ty);
+
bcx = move_val_if_temp(bcx, INIT, llptr, lv,
content_ty);
bcx = r.bcx;
let llptr = r.val;
- add_clean_temp(bcx, llptr, uniq_ty);
-
ret rslt(bcx, llptr);
}
alt ty::struct(bcx_tcx(bcx), t) {
ty::ty_uniq({ty: ct, _}) { ct }
}
+}
+
+fn copy_val(cx: @block_ctxt, dst: ValueRef, src: ValueRef,
+ ty: ty::t) : type_is_unique_box(cx, ty) -> @block_ctxt {
+
+ let content_ty = content_ty(cx, ty);
+ let {bcx, val: llptr} = alloc_uniq(cx, ty);
+ Store(bcx, llptr, dst);
+
+ let src = Load(bcx, src);
+ let dst = Load(bcx, dst);
+ let bcx = trans::copy_val(bcx, INIT, dst, src, content_ty);
+ Store(bcx, src, llptr);
+ ret bcx;
}
\ No newline at end of file