@@ -384,6 +384,32 @@ fn malloc_boxed(bcx: block, t: ty::t) -> {box: ValueRef, body: ValueRef} {
384
384
ret { box : box, body : body} ;
385
385
}
386
386
387
+ fn malloc_unique_raw ( bcx : block , t : ty:: t ) -> ValueRef {
388
+ let _icx = bcx. insn_ctxt ( "malloc_unique_box_raw" ) ;
389
+ let ccx = bcx. ccx ( ) ;
390
+
391
+ // Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
392
+ // wants.
393
+ let box_ptr = ty:: mk_imm_uniq ( ccx. tcx , t) ;
394
+ let llty = type_of ( ccx, box_ptr) ;
395
+
396
+ // Get the tydesc for the body:
397
+ let mut static_ti = none;
398
+ let lltydesc = get_tydesc ( ccx, t, static_ti) ;
399
+ lazily_emit_all_tydesc_glue ( ccx, static_ti) ;
400
+
401
+ // Allocate space:
402
+ let rval = Call ( bcx, ccx. upcalls . exchange_malloc , [ lltydesc] ) ;
403
+ ret PointerCast ( bcx, rval, llty) ;
404
+ }
405
+
406
+ fn malloc_unique ( bcx : block , t : ty:: t ) -> { box : ValueRef , body : ValueRef } {
407
+ let _icx = bcx. insn_ctxt ( "malloc_unique_box" ) ;
408
+ let box = malloc_unique_raw ( bcx, t) ;
409
+ let body = GEPi ( bcx, box, [ 0 u, abi:: box_field_body] ) ;
410
+ ret { box : box, body : body} ;
411
+ }
412
+
387
413
// Type descriptor and type glue stuff
388
414
389
415
fn get_tydesc_simple ( ccx : @crate_ctxt , t : ty:: t ) -> ValueRef {
0 commit comments