@@ -49,7 +49,7 @@ use core::libc::c_ulonglong;
49
49
use core:: option:: { Option , Some , None } ;
50
50
use core:: vec;
51
51
52
- use lib:: llvm:: { ValueRef , TypeRef , True , IntEQ , IntNE } ;
52
+ use lib:: llvm:: { ValueRef , True , IntEQ , IntNE } ;
53
53
use middle:: trans:: _match;
54
54
use middle:: trans:: build:: * ;
55
55
use middle:: trans:: common:: * ;
@@ -212,7 +212,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
212
212
213
213
fn mk_struct ( cx : & mut CrateContext , tys : & [ ty:: t ] , packed : bool ) -> Struct {
214
214
let lltys = tys. map ( |& ty| type_of:: sizing_type_of ( cx, ty) ) ;
215
- let llty_rec = T_struct ( lltys, packed) ;
215
+ let llty_rec = Type :: struct_ ( lltys, packed) ;
216
216
Struct {
217
217
size : machine:: llsize_of_alloc ( cx, llty_rec) /*bad*/ as u64 ,
218
218
align : machine:: llalign_of_min ( cx, llty_rec) /*bad*/ as u64 ,
@@ -226,17 +226,16 @@ fn mk_struct(cx: &mut CrateContext, tys: &[ty::t], packed: bool) -> Struct {
226
226
* All nominal types are LLVM structs, in order to be able to use
227
227
* forward-declared opaque types to prevent circularity in `type_of`.
228
228
*/
229
- pub fn fields_of ( cx : & mut CrateContext , r : & Repr ) -> ~[ TypeRef ] {
229
+ pub fn fields_of ( cx : & mut CrateContext , r : & Repr ) -> ~[ Type ] {
230
230
generic_fields_of ( cx, r, false )
231
231
}
232
232
/// Like `fields_of`, but for `type_of::sizing_type_of` (q.v.).
233
- pub fn sizing_fields_of ( cx : & mut CrateContext , r : & Repr ) -> ~[ TypeRef ] {
233
+ pub fn sizing_fields_of ( cx : & mut CrateContext , r : & Repr ) -> ~[ Type ] {
234
234
generic_fields_of ( cx, r, true )
235
235
}
236
- fn generic_fields_of ( cx : & mut CrateContext , r : & Repr , sizing : bool )
237
- -> ~[ TypeRef ] {
236
+ fn generic_fields_of ( cx : & mut CrateContext , r : & Repr , sizing : bool ) -> ~[ Type ] {
238
237
match * r {
239
- CEnum ( * ) => ~[ T_enum_discrim ( cx) ] ,
238
+ CEnum ( * ) => ~[ Type :: enum_discrim ( cx) ] ,
240
239
Univariant ( ref st, _dtor) => struct_llfields ( cx, st, sizing) ,
241
240
NullablePointer { nonnull : ref st, _ } => struct_llfields ( cx, st, sizing) ,
242
241
General ( ref sts) => {
@@ -261,14 +260,15 @@ fn generic_fields_of(cx: &mut CrateContext, r: &Repr, sizing: bool)
261
260
let most_aligned = most_aligned. get ( ) ;
262
261
let padding = largest_size - most_aligned. size ;
263
262
263
+ assert ! ( padding >= 0 ) ;
264
+
264
265
struct_llfields ( cx, most_aligned, sizing)
265
- + [ T_array ( T_i8 ( ) , padding /*bad*/ as uint ) ]
266
+ + [ Type :: array ( Type :: i8 ( ) , padding /*bad*/ as uint ) ]
266
267
}
267
268
}
268
269
}
269
270
270
- fn struct_llfields ( cx : & mut CrateContext , st : & Struct , sizing : bool )
271
- -> ~[ TypeRef ] {
271
+ fn struct_llfields ( cx : & mut CrateContext , st : & Struct , sizing : bool ) -> ~[ Type ] {
272
272
if sizing {
273
273
st. fields . map ( |& ty| type_of:: sizing_type_of ( cx, ty) )
274
274
} else {
@@ -309,7 +309,7 @@ pub fn trans_get_discr(bcx: block, r: &Repr, scrutinee: ValueRef)
309
309
( cases. len ( ) - 1 ) as int ) ,
310
310
NullablePointer { nonnull : ref nonnull, nndiscr, ptrfield, _ } => {
311
311
ZExt ( bcx, nullable_bitdiscr ( bcx, nonnull, nndiscr, ptrfield, scrutinee) ,
312
- T_enum_discrim ( bcx. ccx ( ) ) )
312
+ Type :: enum_discrim ( bcx. ccx ( ) ) )
313
313
}
314
314
}
315
315
}
@@ -438,11 +438,11 @@ pub fn trans_field_ptr(bcx: block, r: &Repr, val: ValueRef, discr: int,
438
438
} else {
439
439
// The unit-like case might have a nonzero number of unit-like fields.
440
440
// (e.g., Result or Either with () as one side.)
441
- let llty = type_of:: type_of ( bcx. ccx ( ) , nullfields[ ix] ) ;
441
+ let ty = type_of:: type_of ( bcx. ccx ( ) , nullfields[ ix] ) ;
442
442
assert_eq ! ( machine:: llsize_of_alloc( bcx. ccx( ) , llty) , 0 ) ;
443
443
// The contents of memory at this pointer can't matter, but use
444
444
// the value that's "reasonable" in case of pointer comparison.
445
- PointerCast ( bcx, val, T_ptr ( llty ) )
445
+ PointerCast ( bcx, val, ty . ptr_to ( ) )
446
446
}
447
447
}
448
448
}
@@ -456,8 +456,8 @@ fn struct_field_ptr(bcx: block, st: &Struct, val: ValueRef, ix: uint,
456
456
let fields = do st. fields . map |& ty| {
457
457
type_of:: type_of ( ccx, ty)
458
458
} ;
459
- let real_llty = T_struct ( fields, st. packed ) ;
460
- PointerCast ( bcx, val, T_ptr ( real_llty) )
459
+ let real_ty = Type :: struct_ ( fields, st. packed ) ;
460
+ PointerCast ( bcx, val, real_llty. to_ptr ( ) . to_ref ( ) )
461
461
} else {
462
462
val
463
463
} ;
@@ -572,7 +572,7 @@ fn build_const_struct(ccx: &mut CrateContext, st: &Struct, vals: &[ValueRef])
572
572
}
573
573
574
574
fn padding( size: u64 ) -> ValueRef {
575
- C_undef ( T_array ( T_i8 ( ) , size /*bad*/ as uint ) )
575
+ C_undef ( Type :: array ( Type :: i8 ( ) , size) . to_ref ( ) )
576
576
}
577
577
578
578
// XXX this utility routine should be somewhere more general
0 commit comments