@@ -37,6 +37,7 @@ use util::ppaux::ty_to_short_str;
37
37
use middle:: trans:: type_:: Type ;
38
38
39
39
use std:: c_str:: ToCStr ;
40
+ use std:: cell:: Cell ;
40
41
use std:: libc:: c_uint;
41
42
use syntax:: ast;
42
43
@@ -183,13 +184,13 @@ pub fn lazily_emit_simplified_tydesc_glue(ccx: @CrateContext,
183
184
lazily_emit_tydesc_glue ( ccx, field, simpl_ti) ;
184
185
{
185
186
if field == abi:: tydesc_field_take_glue {
186
- ti. take_glue = simpl_ti. take_glue ;
187
+ ti. take_glue . set ( simpl_ti. take_glue . get ( ) ) ;
187
188
} else if field == abi:: tydesc_field_drop_glue {
188
- ti. drop_glue = simpl_ti. drop_glue ;
189
+ ti. drop_glue . set ( simpl_ti. drop_glue . get ( ) ) ;
189
190
} else if field == abi:: tydesc_field_free_glue {
190
- ti. free_glue = simpl_ti. free_glue ;
191
+ ti. free_glue . set ( simpl_ti. free_glue . get ( ) ) ;
191
192
} else if field == abi:: tydesc_field_visit_glue {
192
- ti. visit_glue = simpl_ti. visit_glue ;
193
+ ti. visit_glue . set ( simpl_ti. visit_glue . get ( ) ) ;
193
194
}
194
195
}
195
196
return true ;
@@ -209,52 +210,52 @@ pub fn lazily_emit_tydesc_glue(ccx: @CrateContext,
209
210
}
210
211
211
212
if field == abi:: tydesc_field_take_glue {
212
- match ti. take_glue {
213
+ match ti. take_glue . get ( ) {
213
214
Some ( _) => ( ) ,
214
215
None => {
215
216
debug ! ( "+++ lazily_emit_tydesc_glue TAKE {}" ,
216
217
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
217
218
let glue_fn = declare_generic_glue ( ccx, ti. ty , llfnty, "take" ) ;
218
- ti. take_glue = Some ( glue_fn) ;
219
+ ti. take_glue . set ( Some ( glue_fn) ) ;
219
220
make_generic_glue ( ccx, ti. ty , glue_fn, make_take_glue, "take" ) ;
220
221
debug ! ( "--- lazily_emit_tydesc_glue TAKE {}" ,
221
222
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
222
223
}
223
224
}
224
225
} else if field == abi:: tydesc_field_drop_glue {
225
- match ti. drop_glue {
226
+ match ti. drop_glue . get ( ) {
226
227
Some ( _) => ( ) ,
227
228
None => {
228
229
debug ! ( "+++ lazily_emit_tydesc_glue DROP {}" ,
229
230
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
230
231
let glue_fn = declare_generic_glue ( ccx, ti. ty , llfnty, "drop" ) ;
231
- ti. drop_glue = Some ( glue_fn) ;
232
+ ti. drop_glue . set ( Some ( glue_fn) ) ;
232
233
make_generic_glue ( ccx, ti. ty , glue_fn, make_drop_glue, "drop" ) ;
233
234
debug ! ( "--- lazily_emit_tydesc_glue DROP {}" ,
234
235
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
235
236
}
236
237
}
237
238
} else if field == abi:: tydesc_field_free_glue {
238
- match ti. free_glue {
239
+ match ti. free_glue . get ( ) {
239
240
Some ( _) => ( ) ,
240
241
None => {
241
242
debug ! ( "+++ lazily_emit_tydesc_glue FREE {}" ,
242
243
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
243
244
let glue_fn = declare_generic_glue ( ccx, ti. ty , llfnty, "free" ) ;
244
- ti. free_glue = Some ( glue_fn) ;
245
+ ti. free_glue . set ( Some ( glue_fn) ) ;
245
246
make_generic_glue ( ccx, ti. ty , glue_fn, make_free_glue, "free" ) ;
246
247
debug ! ( "--- lazily_emit_tydesc_glue FREE {}" ,
247
248
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
248
249
}
249
250
}
250
251
} else if field == abi:: tydesc_field_visit_glue {
251
- match ti. visit_glue {
252
+ match ti. visit_glue . get ( ) {
252
253
Some ( _) => ( ) ,
253
254
None => {
254
255
debug ! ( "+++ lazily_emit_tydesc_glue VISIT {}" ,
255
256
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
256
257
let glue_fn = declare_generic_glue ( ccx, ti. ty , llfnty, "visit" ) ;
257
- ti. visit_glue = Some ( glue_fn) ;
258
+ ti. visit_glue . set ( Some ( glue_fn) ) ;
258
259
make_generic_glue ( ccx, ti. ty , glue_fn, make_visit_glue, "visit" ) ;
259
260
debug ! ( "--- lazily_emit_tydesc_glue VISIT {}" ,
260
261
ppaux:: ty_to_str( ccx. tcx, ti. ty) ) ;
@@ -280,13 +281,13 @@ pub fn call_tydesc_glue_full(bcx: @Block,
280
281
Some ( sti) => {
281
282
lazily_emit_tydesc_glue ( ccx, field, sti) ;
282
283
if field == abi:: tydesc_field_take_glue {
283
- sti. take_glue
284
+ sti. take_glue . get ( )
284
285
} else if field == abi:: tydesc_field_drop_glue {
285
- sti. drop_glue
286
+ sti. drop_glue . get ( )
286
287
} else if field == abi:: tydesc_field_free_glue {
287
- sti. free_glue
288
+ sti. free_glue . get ( )
288
289
} else if field == abi:: tydesc_field_visit_glue {
289
- sti. visit_glue
290
+ sti. visit_glue . get ( )
290
291
} else {
291
292
None
292
293
}
@@ -630,10 +631,10 @@ pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> @mut tydesc_info {
630
631
align : llalign,
631
632
borrow_offset : borrow_offset,
632
633
name : ty_name,
633
- take_glue : None ,
634
- drop_glue : None ,
635
- free_glue : None ,
636
- visit_glue : None
634
+ take_glue : Cell :: new ( None ) ,
635
+ drop_glue : Cell :: new ( None ) ,
636
+ free_glue : Cell :: new ( None ) ,
637
+ visit_glue : Cell :: new ( None ) ,
637
638
} ;
638
639
debug ! ( "--- declare_tydesc {}" , ppaux:: ty_to_str( ccx. tcx, t) ) ;
639
640
return inf;
@@ -705,7 +706,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
705
706
// tydesc type. Then we'll recast each function to its real type when
706
707
// calling it.
707
708
let take_glue =
708
- match ti. take_glue {
709
+ match ti. take_glue . get ( ) {
709
710
None => { ccx. stats . n_null_glues += 1 u; C_null ( glue_fn_ty) }
710
711
Some ( v) => {
711
712
unsafe {
@@ -715,7 +716,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
715
716
}
716
717
} ;
717
718
let drop_glue =
718
- match ti. drop_glue {
719
+ match ti. drop_glue . get ( ) {
719
720
None => { ccx. stats . n_null_glues += 1 u; C_null ( glue_fn_ty) }
720
721
Some ( v) => {
721
722
unsafe {
@@ -725,7 +726,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
725
726
}
726
727
} ;
727
728
let free_glue =
728
- match ti. free_glue {
729
+ match ti. free_glue . get ( ) {
729
730
None => { ccx. stats . n_null_glues += 1 u; C_null ( glue_fn_ty) }
730
731
Some ( v) => {
731
732
unsafe {
@@ -735,7 +736,7 @@ pub fn emit_tydescs(ccx: &CrateContext) {
735
736
}
736
737
} ;
737
738
let visit_glue =
738
- match ti. visit_glue {
739
+ match ti. visit_glue . get ( ) {
739
740
None => { ccx. stats . n_null_glues += 1 u; C_null ( glue_fn_ty) }
740
741
Some ( v) => {
741
742
unsafe {
0 commit comments