@@ -1317,19 +1317,7 @@ fn make_free_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
1317
1317
} else { bcx }
1318
1318
}
1319
1319
ty:: ty_uniq ( content_mt) {
1320
- let free_cx = new_sub_block_ctxt ( bcx, "uniq_free" ) ;
1321
- let next_cx = new_sub_block_ctxt ( bcx, "uniq_free_next" ) ;
1322
- let vptr = Load ( bcx, v0) ;
1323
- let null_test = IsNull ( bcx, vptr) ;
1324
- CondBr ( bcx, null_test, next_cx. llbb , free_cx. llbb ) ;
1325
-
1326
- let bcx = free_cx;
1327
- let bcx = drop_ty ( bcx, vptr, content_mt. ty ) ;
1328
- let bcx = trans_shared_free ( bcx, vptr) ;
1329
- Store ( bcx, C_null ( val_ty ( vptr) ) , v0) ;
1330
- Br ( bcx, next_cx. llbb ) ;
1331
-
1332
- next_cx
1320
+ trans_uniq:: make_free_glue ( bcx, v0, t)
1333
1321
}
1334
1322
ty:: ty_obj ( _) {
1335
1323
// Call through the obj's own fields-drop glue first.
@@ -2198,7 +2186,7 @@ fn trans_unary(cx: @block_ctxt, op: ast::unop, e: @ast::expr,
2198
2186
ret rslt( bcx, sub. box ) ;
2199
2187
}
2200
2188
ast:: uniq ( _) {
2201
- ret trans_uniq ( cx, e, id) ;
2189
+ ret trans_uniq:: trans_uniq ( cx, e, id) ;
2202
2190
}
2203
2191
ast:: deref. {
2204
2192
bcx_ccx ( cx) . sess . bug ( "deref expressions should have been \
@@ -4511,46 +4499,6 @@ fn trans_put(in_cx: @block_ctxt, e: option::t<@ast::expr>) -> result {
4511
4499
ret rslt( next_cx, C_nil ( ) ) ;
4512
4500
}
4513
4501
4514
- fn trans_uniq ( cx : @block_ctxt , contents : @ast:: expr ,
4515
- node_id : ast:: node_id ) -> result {
4516
- let bcx = cx;
4517
-
4518
- let lv = trans_lval ( bcx, contents) ;
4519
- bcx = lv. bcx ;
4520
-
4521
- let uniq_ty = node_id_type ( bcx_ccx ( cx) , node_id) ;
4522
- let { bcx, val: llptr } = alloc_uniq ( bcx, uniq_ty) ;
4523
-
4524
- bcx = move_val_if_temp ( bcx, INIT , llptr, lv,
4525
- ty_uniq_contents ( bcx, uniq_ty) ) ;
4526
-
4527
- ret rslt( bcx, llptr) ;
4528
- }
4529
-
4530
- fn ty_uniq_contents ( cx : @block_ctxt , uniq_ty : ty:: t ) -> ty:: t {
4531
- alt ty:: struct ( bcx_tcx ( cx) , uniq_ty) {
4532
- ty:: ty_uniq ( { ty: ct, _} ) { ct }
4533
- }
4534
- }
4535
-
4536
- fn alloc_uniq ( cx : @block_ctxt , uniq_ty : ty:: t ) -> result {
4537
- let bcx = cx;
4538
- let contents_ty = ty_uniq_contents ( cx, uniq_ty) ;
4539
- let r = size_of ( bcx, contents_ty) ;
4540
- bcx = r. bcx ;
4541
- let llsz = r. val ;
4542
-
4543
- let llptrty = T_ptr ( type_of_or_i8 ( bcx, contents_ty) ) ;
4544
-
4545
- r = trans_shared_malloc ( bcx, llptrty, llsz) ;
4546
- bcx = r. bcx ;
4547
- let llptr = r. val ;
4548
-
4549
- add_clean_temp ( bcx, llptr, uniq_ty) ;
4550
-
4551
- ret rslt( bcx, llptr) ;
4552
- }
4553
-
4554
4502
fn trans_break_cont ( sp : span , cx : @block_ctxt , to_end : bool ) -> result {
4555
4503
let bcx = cx;
4556
4504
// Locate closest loop block, outputting cleanup as we go.
0 commit comments