@@ -116,7 +116,7 @@ pub fn represent_node(bcx: @Block, node: ast::NodeId) -> @Repr {
116
116
}
117
117
118
118
/// Decides how to represent a given type.
119
- pub fn represent_type ( cx : & mut CrateContext , t : ty:: t ) -> @Repr {
119
+ pub fn represent_type ( cx : & CrateContext , t : ty:: t ) -> @Repr {
120
120
debug ! ( "Representing: {}" , ty_to_str( cx. tcx, t) ) ;
121
121
{
122
122
let adt_reprs = cx. adt_reprs . borrow ( ) ;
@@ -133,7 +133,7 @@ pub fn represent_type(cx: &mut CrateContext, t: ty::t) -> @Repr {
133
133
return repr;
134
134
}
135
135
136
- fn represent_type_uncached ( cx : & mut CrateContext , t : ty:: t ) -> Repr {
136
+ fn represent_type_uncached ( cx : & CrateContext , t : ty:: t ) -> Repr {
137
137
match ty:: get ( t) . sty {
138
138
ty:: ty_tup( ref elems) => {
139
139
return Univariant ( mk_struct ( cx, * elems, false ) , false )
@@ -255,7 +255,7 @@ pub fn is_ffi_safe(tcx: ty::ctxt, def_id: ast::DefId) -> bool {
255
255
// this should probably all be in ty
256
256
struct Case { discr : Disr , tys : ~[ ty:: t ] }
257
257
impl Case {
258
- fn is_zerolen ( & self , cx : & mut CrateContext ) -> bool {
258
+ fn is_zerolen ( & self , cx : & CrateContext ) -> bool {
259
259
mk_struct ( cx, self . tys , false ) . size == 0
260
260
}
261
261
fn find_ptr ( & self ) -> Option < uint > {
@@ -273,7 +273,7 @@ fn get_cases(tcx: ty::ctxt, def_id: ast::DefId, substs: &ty::substs) -> ~[Case]
273
273
}
274
274
275
275
276
- fn mk_struct ( cx : & mut CrateContext , tys : & [ ty:: t ] , packed : bool ) -> Struct {
276
+ fn mk_struct ( cx : & CrateContext , tys : & [ ty:: t ] , packed : bool ) -> Struct {
277
277
let lltys = tys. map ( |& ty| type_of:: sizing_type_of ( cx, ty) ) ;
278
278
let llty_rec = Type :: struct_ ( lltys, packed) ;
279
279
Struct {
@@ -291,15 +291,15 @@ struct IntBounds {
291
291
uhi : u64
292
292
}
293
293
294
- fn mk_cenum ( cx : & mut CrateContext , hint : Hint , bounds : & IntBounds ) -> Repr {
294
+ fn mk_cenum ( cx : & CrateContext , hint : Hint , bounds : & IntBounds ) -> Repr {
295
295
let it = range_to_inttype ( cx, hint, bounds) ;
296
296
match it {
297
297
attr:: SignedInt ( _) => CEnum ( it, bounds. slo as Disr , bounds. shi as Disr ) ,
298
298
attr:: UnsignedInt ( _) => CEnum ( it, bounds. ulo , bounds. uhi )
299
299
}
300
300
}
301
301
302
- fn range_to_inttype ( cx : & mut CrateContext , hint : Hint , bounds : & IntBounds ) -> IntType {
302
+ fn range_to_inttype ( cx : & CrateContext , hint : Hint , bounds : & IntBounds ) -> IntType {
303
303
debug ! ( "range_to_inttype: {:?} {:?}" , hint, bounds) ;
304
304
// Lists of sizes to try. u64 is always allowed as a fallback.
305
305
static choose_shortest: & ' static [ IntType ] = & [
@@ -339,14 +339,14 @@ fn range_to_inttype(cx: &mut CrateContext, hint: Hint, bounds: &IntBounds) -> In
339
339
return attr:: UnsignedInt ( ast:: ty_u64) ;
340
340
}
341
341
342
- pub fn ll_inttype ( cx : & mut CrateContext , ity : IntType ) -> Type {
342
+ pub fn ll_inttype ( cx : & CrateContext , ity : IntType ) -> Type {
343
343
match ity {
344
344
attr:: SignedInt ( t) => Type :: int_from_ty ( cx, t) ,
345
345
attr:: UnsignedInt ( t) => Type :: uint_from_ty ( cx, t)
346
346
}
347
347
}
348
348
349
- fn bounds_usable ( cx : & mut CrateContext , ity : IntType , bounds : & IntBounds ) -> bool {
349
+ fn bounds_usable ( cx : & CrateContext , ity : IntType , bounds : & IntBounds ) -> bool {
350
350
debug ! ( "bounds_usable: {:?} {:?}" , ity, bounds) ;
351
351
match ity {
352
352
attr:: SignedInt ( _) => {
@@ -380,24 +380,24 @@ pub fn ty_of_inttype(ity: IntType) -> ty::t {
380
380
* and fill in the actual contents in a second pass to prevent
381
381
* unbounded recursion; see also the comments in `trans::type_of`.
382
382
*/
383
- pub fn type_of ( cx : & mut CrateContext , r : & Repr ) -> Type {
383
+ pub fn type_of ( cx : & CrateContext , r : & Repr ) -> Type {
384
384
generic_type_of ( cx, r, None , false )
385
385
}
386
- pub fn sizing_type_of ( cx : & mut CrateContext , r : & Repr ) -> Type {
386
+ pub fn sizing_type_of ( cx : & CrateContext , r : & Repr ) -> Type {
387
387
generic_type_of ( cx, r, None , true )
388
388
}
389
- pub fn incomplete_type_of ( cx : & mut CrateContext , r : & Repr , name : & str ) -> Type {
389
+ pub fn incomplete_type_of ( cx : & CrateContext , r : & Repr , name : & str ) -> Type {
390
390
generic_type_of ( cx, r, Some ( name) , false )
391
391
}
392
- pub fn finish_type_of ( cx : & mut CrateContext , r : & Repr , llty : & mut Type ) {
392
+ pub fn finish_type_of ( cx : & CrateContext , r : & Repr , llty : & mut Type ) {
393
393
match * r {
394
394
CEnum ( ..) | General ( ..) => { }
395
395
Univariant ( ref st, _) | NullablePointer { nonnull : ref st, .. } =>
396
396
llty. set_struct_body ( struct_llfields ( cx, st, false ) , st. packed )
397
397
}
398
398
}
399
399
400
- fn generic_type_of ( cx : & mut CrateContext , r : & Repr , name : Option < & str > , sizing : bool ) -> Type {
400
+ fn generic_type_of ( cx : & CrateContext , r : & Repr , name : Option < & str > , sizing : bool ) -> Type {
401
401
match * r {
402
402
CEnum ( ity, _, _) => ll_inttype ( cx, ity) ,
403
403
Univariant ( ref st, _) | NullablePointer { nonnull : ref st, .. } => {
@@ -449,7 +449,7 @@ fn generic_type_of(cx: &mut CrateContext, r: &Repr, name: Option<&str>, sizing:
449
449
}
450
450
}
451
451
452
- fn struct_llfields ( cx : & mut CrateContext , st : & Struct , sizing : bool ) -> ~[ Type ] {
452
+ fn struct_llfields ( cx : & CrateContext , st : & Struct , sizing : bool ) -> ~[ Type ] {
453
453
if sizing {
454
454
st. fields . map ( |& ty| type_of:: sizing_type_of ( cx, ty) )
455
455
} else {
@@ -705,7 +705,7 @@ pub fn trans_drop_flag_ptr(bcx: @Block, r: &Repr, val: ValueRef) -> ValueRef {
705
705
* this could be changed in the future to avoid allocating unnecessary
706
706
* space after values of shorter-than-maximum cases.
707
707
*/
708
- pub fn trans_const ( ccx : & mut CrateContext , r : & Repr , discr : Disr ,
708
+ pub fn trans_const ( ccx : & CrateContext , r : & Repr , discr : Disr ,
709
709
vals : & [ ValueRef ] ) -> ValueRef {
710
710
match * r {
711
711
CEnum ( ity, min, max) => {
@@ -750,7 +750,7 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: Disr,
750
750
* a two-element struct will locate it at offset 4, and accesses to it
751
751
* will read the wrong memory.
752
752
*/
753
- fn build_const_struct ( ccx : & mut CrateContext , st : & Struct , vals : & [ ValueRef ] )
753
+ fn build_const_struct ( ccx : & CrateContext , st : & Struct , vals : & [ ValueRef ] )
754
754
-> ~[ ValueRef ] {
755
755
assert_eq ! ( vals. len( ) , st. fields. len( ) ) ;
756
756
@@ -791,7 +791,7 @@ fn padding(size: u64) -> ValueRef {
791
791
fn roundup ( x : u64 , a : u64 ) -> u64 { ( ( x + ( a - 1 ) ) / a) * a }
792
792
793
793
/// Get the discriminant of a constant value. (Not currently used.)
794
- pub fn const_get_discrim ( ccx : & mut CrateContext , r : & Repr , val : ValueRef )
794
+ pub fn const_get_discrim ( ccx : & CrateContext , r : & Repr , val : ValueRef )
795
795
-> Disr {
796
796
match * r {
797
797
CEnum ( ity, _, _) => {
@@ -825,7 +825,7 @@ pub fn const_get_discrim(ccx: &mut CrateContext, r: &Repr, val: ValueRef)
825
825
* (Not to be confused with `common::const_get_elt`, which operates on
826
826
* raw LLVM-level structs and arrays.)
827
827
*/
828
- pub fn const_get_field ( ccx : & mut CrateContext , r : & Repr , val : ValueRef ,
828
+ pub fn const_get_field ( ccx : & CrateContext , r : & Repr , val : ValueRef ,
829
829
_discr : Disr , ix : uint ) -> ValueRef {
830
830
match * r {
831
831
CEnum ( ..) => ccx. sess . bug ( "element access in C-like enum const" ) ,
@@ -836,7 +836,7 @@ pub fn const_get_field(ccx: &mut CrateContext, r: &Repr, val: ValueRef,
836
836
}
837
837
838
838
/// Extract field of struct-like const, skipping our alignment padding.
839
- fn const_struct_field ( ccx : & mut CrateContext , val : ValueRef , ix : uint )
839
+ fn const_struct_field ( ccx : & CrateContext , val : ValueRef , ix : uint )
840
840
-> ValueRef {
841
841
// Get the ix-th non-undef element of the struct.
842
842
let mut real_ix = 0 ; // actual position in the struct
0 commit comments