@@ -93,7 +93,7 @@ fn type_of_fn(cx: @crate_ctxt, sp: span, is_method: bool, inputs: [ty::arg],
93
93
if is_method {
94
94
atys += [ T_ptr ( cx. rust_object_type ) ] ;
95
95
} else {
96
- atys += [ T_opaque_boxed_closure_ptr ( cx) ] ;
96
+ atys += [ T_opaque_cbox_ptr ( cx) ] ;
97
97
}
98
98
99
99
// Args >2: ty params, if not acquired via capture...
@@ -202,8 +202,8 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
202
202
}
203
203
T_struct ( tys)
204
204
}
205
- ty:: ty_opaque_closure . {
206
- T_opaque_closure ( cx)
205
+ ty:: ty_opaque_closure_ptr ( _ ) {
206
+ T_opaque_cbox_ptr ( cx)
207
207
}
208
208
ty:: ty_constr ( subt, _) {
209
209
// FIXME: could be a constraint on ty_fn
@@ -415,25 +415,13 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
415
415
}
416
416
417
417
fn size_of ( bcx : @block_ctxt , t : ty:: t ) -> result {
418
- assert !ty:: type_has_opaque_size ( bcx_tcx ( bcx) , t) ;
419
418
let { bcx, sz, align: _ } = metrics ( bcx, t, none) ;
420
419
rslt ( bcx, sz)
421
420
}
422
421
423
422
fn align_of ( bcx : @block_ctxt , t : ty:: t ) -> result {
424
- assert !ty:: type_has_opaque_size ( bcx_tcx ( bcx) , t) ;
425
- alt ty:: struct ( ccx. tcx , t) {
426
- ty:: ty_opaque_closure. {
427
- // Hack: the alignment of an opaque closure is always defined as the
428
- // alignment of a pointer. This is not, however, strictly correct,
429
- // depending on your point of view.
430
- llalign_of ( bcx, T_ptr ( T_i8 ( ) ) ) ;
431
- }
432
- _ {
433
- let { bcx, sz : _, align} = metrics ( bcx, t, none) ;
434
- rslt ( bcx, align)
435
- }
436
- }
423
+ let { bcx, sz: _ , align } = metrics ( bcx, t, none) ;
424
+ rslt ( bcx, align)
437
425
}
438
426
439
427
// Computes the size/alignment of the type `t`. `opt_v`, if provided, should
@@ -443,8 +431,6 @@ fn align_of(bcx: @block_ctxt, t: ty::t) -> result {
443
431
// instance is required.
444
432
fn metrics ( bcx : @block_ctxt , t : ty:: t , opt_v : option < ValueRef > )
445
433
-> metrics_result {
446
- assert ( option:: is_some ( opt_v) ||
447
- !ty:: type_has_opaque_size ( bcx_tcx ( bcx) , t) ) ;
448
434
let ccx = bcx_ccx ( bcx) ;
449
435
if check type_has_static_size ( ccx, t) {
450
436
let sp = bcx. sp ;
@@ -651,29 +637,6 @@ fn dynamic_metrics(bcx: @block_ctxt,
651
637
let total_align = C_int ( bcx_ccx ( bcx) , 1 ) ; // FIXME: stub
652
638
ret { bcx : bcx, sz : total_size, align : total_align} ;
653
639
}
654
- ty:: ty_opaque_closure. {
655
- // Unlike most other types, the type of an opaque closure does not
656
- // fully specify its size. This is because the opaque closure type
657
- // only says that this is a closure over some data, but doesn't say
658
- // how much data there is (hence the word opaque). This is an
659
- // unavoidable consequence of the way that closures encapsulate the
660
- // closed over data. Therefore the only way to know the
661
- // size/alignment of a particular opaque closure instance is to load
662
- // the type descriptor from the instance and consult its
663
- // size/alignment fields. Note that it is meaningless to say "what is
664
- // the size of the type opaque closure?" One can only ask "what is the
665
- // size of this particular opaque closure?"
666
- let v = alt opt_v {
667
- none. { fail "Require value to compute metrics of opaque closures" ; }
668
- some ( v) { v }
669
- } ;
670
- let v = PointerCast ( bcx, v, T_ptr ( T_opaque_closure ( bcx_ccx ( bcx) ) ) ) ;
671
- let tdptrptr = GEPi ( bcx, v, [ 0 , abi:: closure_elt_tydesc] ) ;
672
- let tdptr = Load ( bcx, tdptrptr) ;
673
- let sz = Load ( bcx, GEPi ( bcx, tdptr, [ 0 , abi:: tydesc_field_size] ) ) ;
674
- let align = Load ( bcx, GEPi ( bcx, tdptr, [ 0 , abi:: tydesc_field_align] ) ) ;
675
- ret { bcx : bcx, sz : sz, align : align } ;
676
- }
677
640
}
678
641
}
679
642
@@ -1354,9 +1317,8 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
1354
1317
ty:: ty_native_fn ( _, _) | ty:: ty_fn ( _) {
1355
1318
trans_closure:: make_fn_glue ( bcx, v, t, take_ty)
1356
1319
}
1357
- ty:: ty_opaque_closure. {
1358
- trans_closure:: call_opaque_closure_glue (
1359
- bcx, v, abi:: tydesc_field_take_glue)
1320
+ ty:: ty_opaque_closure_ptr ( ck) {
1321
+ trans_closure:: make_opaque_cbox_take_glue ( bcx, ck, v)
1360
1322
}
1361
1323
_ when ty:: type_is_structural ( bcx_tcx ( bcx) , t) {
1362
1324
iter_structural_ty ( bcx, v, t, take_ty)
@@ -1429,9 +1391,8 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
1429
1391
ty:: ty_native_fn ( _, _) | ty:: ty_fn ( _) {
1430
1392
trans_closure:: make_fn_glue ( bcx, v, t, free_ty)
1431
1393
}
1432
- ty:: ty_opaque_closure. {
1433
- trans_closure:: call_opaque_closure_glue (
1434
- bcx, v, abi:: tydesc_field_free_glue)
1394
+ ty:: ty_opaque_closure_ptr ( ck) {
1395
+ trans_closure:: make_opaque_cbox_free_glue ( bcx, ck, v)
1435
1396
}
1436
1397
_ { bcx }
1437
1398
} ;
@@ -1458,9 +1419,8 @@ fn make_drop_glue(bcx: @block_ctxt, v0: ValueRef, t: ty::t) {
1458
1419
ty:: ty_native_fn ( _, _) | ty:: ty_fn ( _) {
1459
1420
trans_closure:: make_fn_glue ( bcx, v0, t, drop_ty)
1460
1421
}
1461
- ty:: ty_opaque_closure. {
1462
- trans_closure:: call_opaque_closure_glue (
1463
- bcx, v0, abi:: tydesc_field_drop_glue)
1422
+ ty:: ty_opaque_closure_ptr ( ck) {
1423
+ trans_closure:: make_opaque_cbox_drop_glue ( bcx, ck, v0)
1464
1424
}
1465
1425
_ {
1466
1426
if ty:: type_needs_drop ( ccx. tcx , t) &&
@@ -2617,7 +2577,7 @@ type lval_maybe_callee = {bcx: @block_ctxt,
2617
2577
generic: option:: t<generic_info>} ;
2618
2578
2619
2579
fn null_env_ptr ( bcx : @block_ctxt ) -> ValueRef {
2620
- C_null ( T_opaque_boxed_closure_ptr ( bcx_ccx ( bcx) ) )
2580
+ C_null ( T_opaque_cbox_ptr ( bcx_ccx ( bcx) ) )
2621
2581
}
2622
2582
2623
2583
fn lval_from_local_var ( bcx : @block_ctxt , r : local_var_result ) -> lval_result {
@@ -3274,7 +3234,7 @@ fn trans_call(in_cx: @block_ctxt, f: @ast::expr,
3274
3234
let llenv, dict_param = none;
3275
3235
alt f_res. env {
3276
3236
null_env. {
3277
- llenv = llvm:: LLVMGetUndef ( T_opaque_boxed_closure_ptr ( bcx_ccx ( cx) ) ) ;
3237
+ llenv = llvm:: LLVMGetUndef ( T_opaque_cbox_ptr ( bcx_ccx ( cx) ) ) ;
3278
3238
}
3279
3239
obj_env ( e) { llenv = e; }
3280
3240
dict_env ( dict, e) { llenv = e; dict_param = some ( dict) ; }
@@ -5257,7 +5217,7 @@ fn fill_fn_pair(bcx: @block_ctxt, pair: ValueRef, llfn: ValueRef,
5257
5217
Store ( bcx, llfn, code_cell) ;
5258
5218
let env_cell = GEPi ( bcx, pair, [ 0 , abi:: fn_field_box] ) ;
5259
5219
let llenvblobptr =
5260
- PointerCast ( bcx, llenvptr, T_opaque_boxed_closure_ptr ( ccx) ) ;
5220
+ PointerCast ( bcx, llenvptr, T_opaque_cbox_ptr ( ccx) ) ;
5261
5221
Store ( bcx, llenvblobptr, env_cell) ;
5262
5222
}
5263
5223
0 commit comments