@@ -1272,7 +1272,10 @@ fn emit_tydescs(ccx: &@crate_ctxt) {
1272
1272
}
1273
1273
}
1274
1274
1275
- fn make_copy_glue ( cx : & @block_ctxt , dst : ValueRef , src : ValueRef , t : ty:: t ) {
1275
+ // NOTE this is currently just a complicated way to do memmove. I'm working on
1276
+ // a representation of ivecs that will need pointers into itself, which must
1277
+ // be adjusted when copying. Will flesh this out when the time comes.
1278
+ fn make_copy_glue ( cx : & @block_ctxt , src : ValueRef , dst : ValueRef , t : ty:: t ) {
1276
1279
let bcx = memmove_ty ( cx, dst, src, t) . bcx ;
1277
1280
build_return ( bcx) ;
1278
1281
}
@@ -2369,9 +2372,12 @@ fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef,
2369
2372
let bcx = if action == DROP_EXISTING {
2370
2373
drop_ty ( cx, dst, t) . bcx
2371
2374
} else { cx } ;
2372
- bcx = memmove_ty ( bcx, dst, src, t) . bcx ;
2373
- bcx = take_ty ( bcx, dst, t) . bcx ;
2374
- ret bcx;
2375
+ if ty:: type_needs_copy_glue ( ccx. tcx , t) {
2376
+ ret call_copy_glue ( bcx, dst, src, t, true ) ;
2377
+ } else {
2378
+ bcx = memmove_ty ( bcx, dst, src, t) . bcx ;
2379
+ ret take_ty( bcx, dst, t) . bcx ;
2380
+ }
2375
2381
}
2376
2382
ccx. sess . bug ( "unexpected type in trans::copy_val_no_check: " +
2377
2383
ty_to_str ( ccx. tcx , t) ) ;
@@ -2386,16 +2392,16 @@ fn copy_val_no_check(cx: &@block_ctxt, action: copy_action, dst: ValueRef,
2386
2392
fn move_val ( cx : @block_ctxt , action : copy_action , dst : ValueRef ,
2387
2393
src : & lval_result , t : ty:: t ) -> @block_ctxt {
2388
2394
let src_val = src. res . val ;
2389
- if ty:: type_is_scalar ( bcx_tcx ( cx) , t) ||
2390
- ty:: type_is_native ( bcx_tcx ( cx) , t) {
2395
+ let tcx = bcx_tcx ( cx) ;
2396
+ if ty:: type_is_scalar ( tcx, t) ||
2397
+ ty:: type_is_native ( tcx, t) {
2391
2398
if src. is_mem { src_val = cx. build . Load ( src_val) ; }
2392
2399
cx. build . Store ( src_val, dst) ;
2393
2400
ret cx;
2394
- } else if ty:: type_is_nil ( bcx_tcx ( cx) , t) ||
2395
- ty:: type_is_bot ( bcx_tcx ( cx) , t) {
2401
+ } else if ty:: type_is_nil ( tcx, t) || ty:: type_is_bot ( tcx, t) {
2396
2402
ret cx;
2397
- } else if ty:: type_is_unique ( bcx_tcx ( cx ) , t) ||
2398
- ty:: type_is_boxed ( bcx_tcx ( cx ) , t) {
2403
+ } else if ty:: type_is_unique ( tcx , t) ||
2404
+ ty:: type_is_boxed ( tcx , t) {
2399
2405
if src. is_mem { src_val = cx. build . Load ( src_val) ; }
2400
2406
if action == DROP_EXISTING {
2401
2407
cx = drop_ty ( cx, cx. build . Load ( dst) , t) . bcx ;
@@ -2406,10 +2412,13 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
2406
2412
// If we're here, it must be a temporary.
2407
2413
revoke_clean ( cx, src_val) ;
2408
2414
ret cx;
2409
- } else if ty:: type_is_structural ( bcx_tcx ( cx) , t) ||
2410
- ty:: type_has_dynamic_size ( bcx_tcx ( cx) , t) {
2415
+ } else if type_is_structural_or_param ( tcx, t) {
2411
2416
if action == DROP_EXISTING { cx = drop_ty ( cx, dst, t) . bcx ; }
2412
- cx = memmove_ty ( cx, dst, src_val, t) . bcx ;
2417
+ if ty:: type_needs_copy_glue ( tcx, t) {
2418
+ cx = call_copy_glue ( cx, dst, src_val, t, false ) ;
2419
+ } else {
2420
+ cx = memmove_ty ( cx, dst, src_val, t) . bcx ;
2421
+ }
2413
2422
if src. is_mem {
2414
2423
ret zero_alloca ( cx, src_val, t) . bcx ;
2415
2424
} else { // Temporary value
@@ -2418,7 +2427,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
2418
2427
}
2419
2428
}
2420
2429
bcx_ccx ( cx) . sess . bug ( "unexpected type in trans::move_val: " +
2421
- ty_to_str ( bcx_tcx ( cx ) , t) ) ;
2430
+ ty_to_str ( tcx , t) ) ;
2422
2431
}
2423
2432
2424
2433
fn move_val_if_temp ( cx : @block_ctxt , action : copy_action , dst : ValueRef ,
@@ -5049,16 +5058,14 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
5049
5058
5050
5059
let rhs_res = trans_lval ( lhs_res. res . bcx , src) ;
5051
5060
let t = ty:: expr_ty ( bcx_tcx ( cx) , src) ;
5052
- let tmp_res = alloc_ty ( rhs_res. res . bcx , t) ;
5061
+ let { bcx , val : tmp_alloc } = alloc_ty ( rhs_res. res . bcx , t) ;
5053
5062
// Swap through a temporary.
5054
5063
5055
- let move1_res =
5056
- memmove_ty ( tmp_res. bcx , tmp_res. val , lhs_res. res . val , t) ;
5057
- let move2_res =
5058
- memmove_ty ( move1_res. bcx , lhs_res. res . val , rhs_res. res . val , t) ;
5059
- let move3_res =
5060
- memmove_ty ( move2_res. bcx , rhs_res. res . val , tmp_res. val , t) ;
5061
- ret rslt( move3_res. bcx , C_nil ( ) ) ;
5064
+ bcx = move_val ( bcx, INIT , tmp_alloc, lhs_res, t) ;
5065
+ bcx = move_val ( bcx, INIT , lhs_res. res . val , rhs_res, t) ;
5066
+ bcx = move_val ( bcx, INIT , rhs_res. res . val ,
5067
+ lval_mem ( bcx, tmp_alloc) , t) ;
5068
+ ret rslt( bcx, C_nil ( ) ) ;
5062
5069
}
5063
5070
ast:: expr_assign_op ( op, dst, src) {
5064
5071
let t = ty:: expr_ty ( bcx_tcx ( cx) , src) ;
0 commit comments