@@ -172,15 +172,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
172
172
let ptr = self . memory . allocate ( s. len ( ) as u64 , 1 ) ?;
173
173
self . memory . write_bytes ( ptr, s. as_bytes ( ) ) ?;
174
174
self . memory . freeze ( ptr. alloc_id ) ?;
175
- Ok ( Value :: ByValPair ( PrimVal :: from_ptr ( ptr) , PrimVal :: from_uint ( s. len ( ) as u64 ) ) )
175
+ Ok ( Value :: ByValPair ( PrimVal :: Pointer ( ptr) , PrimVal :: from_uint ( s. len ( ) as u64 ) ) )
176
176
}
177
177
178
178
pub ( super ) fn const_to_value ( & mut self , const_val : & ConstVal ) -> EvalResult < ' tcx , Value > {
179
179
use rustc:: middle:: const_val:: ConstVal :: * ;
180
180
use rustc_const_math:: ConstFloat ;
181
181
182
182
let primval = match * const_val {
183
- Integral ( const_int) => PrimVal :: new ( const_int. to_u64_unchecked ( ) ) ,
183
+ Integral ( const_int) => PrimVal :: Bytes ( const_int. to_u64_unchecked ( ) ) ,
184
184
185
185
Float ( ConstFloat :: F32 ( f) ) => PrimVal :: from_f32 ( f) ,
186
186
Float ( ConstFloat :: F64 ( f) ) => PrimVal :: from_f64 ( f) ,
@@ -196,7 +196,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
196
196
let ptr = self . memory . allocate ( bs. len ( ) as u64 , 1 ) ?;
197
197
self . memory . write_bytes ( ptr, bs) ?;
198
198
self . memory . freeze ( ptr. alloc_id ) ?;
199
- PrimVal :: from_ptr ( ptr)
199
+ PrimVal :: Pointer ( ptr)
200
200
}
201
201
202
202
Struct ( _) => unimplemented ! ( ) ,
@@ -315,14 +315,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
315
315
. expect ( "global should have been cached (freeze)" ) ;
316
316
match global_value. data . expect ( "global should have been initialized" ) {
317
317
Value :: ByRef ( ptr) => self . memory . freeze ( ptr. alloc_id ) ?,
318
- Value :: ByVal ( val) => if let Some ( alloc_id) = val. relocation {
318
+ Value :: ByVal ( val) => if let Some ( alloc_id) = val. relocation ( ) {
319
319
self . memory . freeze ( alloc_id) ?;
320
320
} ,
321
321
Value :: ByValPair ( a, b) => {
322
- if let Some ( alloc_id) = a. relocation {
322
+ if let Some ( alloc_id) = a. relocation ( ) {
323
323
self . memory . freeze ( alloc_id) ?;
324
324
}
325
- if let Some ( alloc_id) = b. relocation {
325
+ if let Some ( alloc_id) = b. relocation ( ) {
326
326
self . memory . freeze ( alloc_id) ?;
327
327
}
328
328
} ,
@@ -500,7 +500,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
500
500
assert_eq ! ( operands. len( ) , 0 ) ;
501
501
if let mir:: AggregateKind :: Adt ( adt_def, variant, _, _) = * kind {
502
502
let n = adt_def. variants [ variant] . disr_val . to_u64_unchecked ( ) ;
503
- self . write_primval ( dest, PrimVal :: new ( n) , dest_ty) ?;
503
+ self . write_primval ( dest, PrimVal :: Bytes ( n) , dest_ty) ?;
504
504
} else {
505
505
bug ! ( "tried to assign {:?} to Layout::CEnum" , kind) ;
506
506
}
@@ -563,12 +563,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
563
563
Ref ( _, _, ref lvalue) => {
564
564
let src = self . eval_lvalue ( lvalue) ?;
565
565
let ( raw_ptr, extra) = self . force_allocation ( src) ?. to_ptr_and_extra ( ) ;
566
- let ptr = PrimVal :: from_ptr ( raw_ptr) ;
566
+ let ptr = PrimVal :: Pointer ( raw_ptr) ;
567
567
568
568
let val = match extra {
569
569
LvalueExtra :: None => Value :: ByVal ( ptr) ,
570
570
LvalueExtra :: Length ( len) => Value :: ByValPair ( ptr, PrimVal :: from_uint ( len) ) ,
571
- LvalueExtra :: Vtable ( vtable) => Value :: ByValPair ( ptr, PrimVal :: from_ptr ( vtable) ) ,
571
+ LvalueExtra :: Vtable ( vtable) => Value :: ByValPair ( ptr, PrimVal :: Pointer ( vtable) ) ,
572
572
LvalueExtra :: DowncastVariant ( ..) =>
573
573
bug ! ( "attempted to take a reference to an enum downcast lvalue" ) ,
574
574
} ;
@@ -578,7 +578,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
578
578
579
579
Box ( ty) => {
580
580
let ptr = self . alloc_ptr ( ty) ?;
581
- self . write_primval ( dest, PrimVal :: from_ptr ( ptr) , dest_ty) ?;
581
+ self . write_primval ( dest, PrimVal :: Pointer ( ptr) , dest_ty) ?;
582
582
}
583
583
584
584
Cast ( kind, ref operand, cast_ty) => {
@@ -617,7 +617,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
617
617
ty:: TyFnDef ( def_id, substs, fn_ty) => {
618
618
let fn_ty = self . tcx . erase_regions ( & fn_ty) ;
619
619
let fn_ptr = self . memory . create_fn_ptr ( self . tcx , def_id, substs, fn_ty) ;
620
- self . write_value ( Value :: ByVal ( PrimVal :: from_ptr ( fn_ptr) ) , dest, dest_ty) ?;
620
+ self . write_value ( Value :: ByVal ( PrimVal :: Pointer ( fn_ptr) ) , dest, dest_ty) ?;
621
621
} ,
622
622
ref other => bug ! ( "reify fn pointer on {:?}" , other) ,
623
623
} ,
@@ -629,7 +629,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
629
629
let ( def_id, substs, _, _) = self . memory . get_fn ( ptr. alloc_id ) ?;
630
630
let unsafe_fn_ty = self . tcx . erase_regions ( & unsafe_fn_ty) ;
631
631
let fn_ptr = self . memory . create_fn_ptr ( self . tcx , def_id, substs, unsafe_fn_ty) ;
632
- self . write_value ( Value :: ByVal ( PrimVal :: from_ptr ( fn_ptr) ) , dest, dest_ty) ?;
632
+ self . write_value ( Value :: ByVal ( PrimVal :: Pointer ( fn_ptr) ) , dest, dest_ty) ?;
633
633
} ,
634
634
ref other => bug ! ( "fn to unsafe fn cast on {:?}" , other) ,
635
635
} ,
@@ -1093,10 +1093,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1093
1093
1094
1094
fn ensure_valid_value ( & self , val : PrimVal , ty : Ty < ' tcx > ) -> EvalResult < ' tcx , ( ) > {
1095
1095
match ty. sty {
1096
- ty:: TyBool if val. bits > 1 => Err ( EvalError :: InvalidBool ) ,
1096
+ ty:: TyBool if val. bits ( ) > 1 => Err ( EvalError :: InvalidBool ) ,
1097
1097
1098
- ty:: TyChar if :: std:: char:: from_u32 ( val. bits as u32 ) . is_none ( )
1099
- => Err ( EvalError :: InvalidChar ( val. bits as u32 as u64 ) ) ,
1098
+ ty:: TyChar if :: std:: char:: from_u32 ( val. bits ( ) as u32 ) . is_none ( )
1099
+ => Err ( EvalError :: InvalidChar ( val. bits ( ) as u32 as u64 ) ) ,
1100
1100
1101
1101
_ => Ok ( ( ) ) ,
1102
1102
}
@@ -1150,23 +1150,23 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1150
1150
ty:: TyFloat ( FloatTy :: F32 ) => PrimVal :: from_f32 ( self . memory . read_f32 ( ptr) ?) ,
1151
1151
ty:: TyFloat ( FloatTy :: F64 ) => PrimVal :: from_f64 ( self . memory . read_f64 ( ptr) ?) ,
1152
1152
1153
- ty:: TyFnPtr ( _) => self . memory . read_ptr ( ptr) . map ( PrimVal :: from_ptr ) ?,
1153
+ ty:: TyFnPtr ( _) => self . memory . read_ptr ( ptr) . map ( PrimVal :: Pointer ) ?,
1154
1154
ty:: TyBox ( ty) |
1155
1155
ty:: TyRef ( _, ty:: TypeAndMut { ty, .. } ) |
1156
1156
ty:: TyRawPtr ( ty:: TypeAndMut { ty, .. } ) => {
1157
1157
let p = self . memory . read_ptr ( ptr) ?;
1158
1158
if self . type_is_sized ( ty) {
1159
- PrimVal :: from_ptr ( p)
1159
+ PrimVal :: Pointer ( p)
1160
1160
} else {
1161
1161
trace ! ( "reading fat pointer extra of type {}" , ty) ;
1162
1162
let extra = ptr. offset ( self . memory . pointer_size ( ) ) ;
1163
1163
let extra = match self . tcx . struct_tail ( ty) . sty {
1164
- ty:: TyDynamic ( ..) => PrimVal :: from_ptr ( self . memory . read_ptr ( extra) ?) ,
1164
+ ty:: TyDynamic ( ..) => PrimVal :: Pointer ( self . memory . read_ptr ( extra) ?) ,
1165
1165
ty:: TySlice ( ..) |
1166
1166
ty:: TyStr => PrimVal :: from_uint ( self . memory . read_usize ( extra) ?) ,
1167
1167
_ => bug ! ( "unsized primval ptr read from {:?}" , ty) ,
1168
1168
} ;
1169
- return Ok ( Some ( Value :: ByValPair ( PrimVal :: from_ptr ( p) , extra) ) ) ;
1169
+ return Ok ( Some ( Value :: ByValPair ( PrimVal :: Pointer ( p) , extra) ) ) ;
1170
1170
}
1171
1171
}
1172
1172
@@ -1225,7 +1225,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1225
1225
( & ty:: TyArray ( _, length) , & ty:: TySlice ( _) ) => {
1226
1226
let ptr = src. read_ptr ( & self . memory ) ?;
1227
1227
let len = PrimVal :: from_uint ( length as u64 ) ;
1228
- let ptr = PrimVal :: from_ptr ( ptr) ;
1228
+ let ptr = PrimVal :: Pointer ( ptr) ;
1229
1229
self . write_value ( Value :: ByValPair ( ptr, len) , dest, dest_ty) ?;
1230
1230
}
1231
1231
( & ty:: TyDynamic ( ..) , & ty:: TyDynamic ( ..) ) => {
@@ -1239,8 +1239,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1239
1239
let trait_ref = self . tcx . erase_regions ( & trait_ref) ;
1240
1240
let vtable = self . get_vtable ( trait_ref) ?;
1241
1241
let ptr = src. read_ptr ( & self . memory ) ?;
1242
- let ptr = PrimVal :: from_ptr ( ptr) ;
1243
- let extra = PrimVal :: from_ptr ( vtable) ;
1242
+ let ptr = PrimVal :: Pointer ( ptr) ;
1243
+ let extra = PrimVal :: Pointer ( vtable) ;
1244
1244
self . write_value ( Value :: ByValPair ( ptr, extra) , dest, dest_ty) ?;
1245
1245
} ,
1246
1246
@@ -1301,12 +1301,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
1301
1301
}
1302
1302
Value :: ByVal ( val) => {
1303
1303
trace ! ( "frame[{}] {:?}: {:?}" , frame, local, val) ;
1304
- if let Some ( alloc_id) = val. relocation { allocs. push ( alloc_id) ; }
1304
+ if let Some ( alloc_id) = val. relocation ( ) { allocs. push ( alloc_id) ; }
1305
1305
}
1306
1306
Value :: ByValPair ( val1, val2) => {
1307
1307
trace ! ( "frame[{}] {:?}: ({:?}, {:?})" , frame, local, val1, val2) ;
1308
- if let Some ( alloc_id) = val1. relocation { allocs. push ( alloc_id) ; }
1309
- if let Some ( alloc_id) = val2. relocation { allocs. push ( alloc_id) ; }
1308
+ if let Some ( alloc_id) = val1. relocation ( ) { allocs. push ( alloc_id) ; }
1309
+ if let Some ( alloc_id) = val2. relocation ( ) { allocs. push ( alloc_id) ; }
1310
1310
}
1311
1311
}
1312
1312
}
0 commit comments