@@ -110,11 +110,10 @@ pub fn alloc_uniq_raw<'a>(
110
110
alloc_raw ( bcx, unit_ty, fill, alloc, heap_exchange)
111
111
}
112
112
113
- pub fn alloc_vec < ' a > (
113
+ pub fn alloc_uniq_vec < ' a > (
114
114
bcx : & ' a Block < ' a > ,
115
115
unit_ty : ty:: t ,
116
- elts : uint ,
117
- heap : heap )
116
+ elts : uint )
118
117
-> Result < ' a > {
119
118
let _icx = push_ctxt ( "tvec::alloc_uniq" ) ;
120
119
let ccx = bcx. ccx ( ) ;
@@ -125,7 +124,7 @@ pub fn alloc_vec<'a>(
125
124
let alloc = if elts < 4 u { Mul ( bcx, C_int ( ccx, 4 ) , unit_sz) }
126
125
else { fill } ;
127
126
let Result { bcx : bcx, val : vptr} =
128
- alloc_raw ( bcx, unit_ty, fill, alloc, heap ) ;
127
+ alloc_raw ( bcx, unit_ty, fill, alloc, heap_exchange ) ;
129
128
return rslt ( bcx, vptr) ;
130
129
}
131
130
@@ -302,70 +301,62 @@ pub fn trans_lit_str<'a>(
302
301
}
303
302
304
303
305
- pub fn trans_uniq_or_managed_vstore < ' a > ( bcx : & ' a Block < ' a > ,
306
- heap : heap ,
307
- vstore_expr : & ast:: Expr ,
308
- content_expr : & ast:: Expr )
309
- -> DatumBlock < ' a , Expr > {
304
+ pub fn trans_uniq_vstore < ' a > ( bcx : & ' a Block < ' a > ,
305
+ vstore_expr : & ast:: Expr ,
306
+ content_expr : & ast:: Expr )
307
+ -> DatumBlock < ' a , Expr > {
310
308
/*!
311
- * @[...] or ~[...] (also @"..." or ~"...") allocate boxes in the
312
- * appropriate heap and write the array elements into them.
309
+ * ~[...] and ~"..." allocate boxes in the exchange heap and write
310
+ * the array elements into them.
313
311
*/
314
312
315
- debug ! ( "trans_uniq_or_managed_vstore(vstore_expr={}, heap={:?})" ,
316
- bcx. expr_to_str( vstore_expr) , heap) ;
313
+ debug ! ( "trans_uniq_vstore(vstore_expr={})" , bcx. expr_to_str( vstore_expr) ) ;
317
314
let fcx = bcx. fcx ;
318
315
319
316
// Handle ~"".
320
- match heap {
321
- heap_exchange => {
322
- match content_expr. node {
323
- ast:: ExprLit ( lit) => {
324
- match lit. node {
325
- ast:: LitStr ( ref s, _) => {
326
- let llptrval = C_cstr ( bcx. ccx ( ) , ( * s) . clone ( ) ) ;
327
- let llptrval = PointerCast ( bcx,
328
- llptrval,
329
- Type :: i8p ( ) ) ;
330
- let llsizeval = C_uint ( bcx. ccx ( ) , s. get ( ) . len ( ) ) ;
331
- let typ = ty:: mk_str ( bcx. tcx ( ) , ty:: vstore_uniq) ;
332
- let lldestval = rvalue_scratch_datum ( bcx,
333
- typ,
334
- "" ) ;
335
- let alloc_fn = langcall ( bcx,
336
- Some ( lit. span ) ,
337
- "" ,
338
- StrDupUniqFnLangItem ) ;
339
- let bcx = callee:: trans_lang_call (
340
- bcx,
341
- alloc_fn,
342
- [ llptrval, llsizeval ] ,
343
- Some ( expr:: SaveIn ( lldestval. val ) ) ) . bcx ;
344
- return DatumBlock ( bcx, lldestval) . to_expr_datumblock ( ) ;
345
- }
346
- _ => { }
347
- }
317
+ match content_expr. node {
318
+ ast:: ExprLit ( lit) => {
319
+ match lit. node {
320
+ ast:: LitStr ( ref s, _) => {
321
+ let llptrval = C_cstr ( bcx. ccx ( ) , ( * s) . clone ( ) ) ;
322
+ let llptrval = PointerCast ( bcx,
323
+ llptrval,
324
+ Type :: i8p ( ) ) ;
325
+ let llsizeval = C_uint ( bcx. ccx ( ) , s. get ( ) . len ( ) ) ;
326
+ let typ = ty:: mk_str ( bcx. tcx ( ) , ty:: vstore_uniq) ;
327
+ let lldestval = rvalue_scratch_datum ( bcx,
328
+ typ,
329
+ "" ) ;
330
+ let alloc_fn = langcall ( bcx,
331
+ Some ( lit. span ) ,
332
+ "" ,
333
+ StrDupUniqFnLangItem ) ;
334
+ let bcx = callee:: trans_lang_call (
335
+ bcx,
336
+ alloc_fn,
337
+ [ llptrval, llsizeval ] ,
338
+ Some ( expr:: SaveIn ( lldestval. val ) ) ) . bcx ;
339
+ return DatumBlock ( bcx, lldestval) . to_expr_datumblock ( ) ;
348
340
}
349
341
_ => { }
350
342
}
351
343
}
352
- heap_exchange_closure => fail ! ( "vectors use exchange_alloc" ) ,
353
- heap_managed => { }
344
+ _ => { }
354
345
}
355
346
356
347
let vt = vec_types_from_expr ( bcx, vstore_expr) ;
357
348
let count = elements_required ( bcx, content_expr) ;
358
349
359
- let Result { bcx, val} = alloc_vec ( bcx, vt. unit_ty , count, heap ) ;
350
+ let Result { bcx, val} = alloc_uniq_vec ( bcx, vt. unit_ty , count) ;
360
351
361
352
// Create a temporary scope lest execution should fail while
362
353
// constructing the vector.
363
354
let temp_scope = fcx. push_custom_cleanup_scope ( ) ;
364
- fcx. schedule_free_value ( cleanup:: CustomScope ( temp_scope) , val, heap ) ;
355
+ fcx. schedule_free_value ( cleanup:: CustomScope ( temp_scope) , val, heap_exchange ) ;
365
356
366
357
let dataptr = get_dataptr ( bcx, val) ;
367
358
368
- debug ! ( "alloc_vec () returned val={}, dataptr={}" ,
359
+ debug ! ( "alloc_uniq_vec () returned val={}, dataptr={}" ,
369
360
bcx. val_to_str( val) , bcx. val_to_str( dataptr) ) ;
370
361
371
362
let bcx = write_content ( bcx, & vt, vstore_expr,
0 commit comments