rustup (part 1/2)
This commit is contained in:
parent
d5d3e3b348
commit
79993e63a0
5 changed files with 9 additions and 14 deletions
|
|
@ -60,14 +60,12 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
TyUint(UintTy::U128) => Ok(PrimVal::Bytes(v)),
|
||||
|
||||
TyInt(IntTy::Is) => {
|
||||
let int_ty = self.tcx.sess.target.int_type;
|
||||
let ty = self.tcx.mk_mach_int(int_ty);
|
||||
let ty = self.tcx.types.isize;
|
||||
self.cast_from_int(v, ty, negative)
|
||||
}
|
||||
|
||||
TyUint(UintTy::Us) => {
|
||||
let uint_ty = self.tcx.sess.target.uint_type;
|
||||
let ty = self.tcx.mk_mach_uint(uint_ty);
|
||||
let ty = self.tcx.types.usize;
|
||||
self.cast_from_int(v, ty, negative)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ pub fn eval_body_as_integer<'a, 'tcx>(
|
|||
TyInt(IntTy::I64) => ConstInt::I64(prim as i128 as i64),
|
||||
TyInt(IntTy::I128) => ConstInt::I128(prim as i128),
|
||||
TyInt(IntTy::Is) => ConstInt::Isize(
|
||||
ConstIsize::new(prim as i128 as i64, tcx.sess.target.int_type)
|
||||
ConstIsize::new(prim as i128 as i64, tcx.sess.target.isize_ty)
|
||||
.expect("miri should already have errored"),
|
||||
),
|
||||
TyUint(UintTy::U8) => ConstInt::U8(prim as u8),
|
||||
|
|
@ -101,7 +101,7 @@ pub fn eval_body_as_integer<'a, 'tcx>(
|
|||
TyUint(UintTy::U64) => ConstInt::U64(prim as u64),
|
||||
TyUint(UintTy::U128) => ConstInt::U128(prim),
|
||||
TyUint(UintTy::Us) => ConstInt::Usize(
|
||||
ConstUsize::new(prim as u64, tcx.sess.target.uint_type)
|
||||
ConstUsize::new(prim as u64, tcx.sess.target.usize_ty)
|
||||
.expect("miri should already have errored"),
|
||||
),
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -245,12 +245,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
}
|
||||
|
||||
Variant(_) => unimplemented!(),
|
||||
Struct(_) => unimplemented!(),
|
||||
Tuple(_) => unimplemented!(),
|
||||
// function items are zero sized and thus have no readable value
|
||||
Function(..) => PrimVal::Undef,
|
||||
Array(_) => unimplemented!(),
|
||||
Repeat(_, _) => unimplemented!(),
|
||||
};
|
||||
|
||||
Ok(Value::ByVal(primval))
|
||||
|
|
@ -817,7 +813,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
|
||||
Repeat(ref operand, _) => {
|
||||
let (elem_ty, length) = match dest_ty.sty {
|
||||
ty::TyArray(elem_ty, n) => (elem_ty, n as u64),
|
||||
ty::TyArray(elem_ty, n) => (elem_ty, n.val.to_const_int().unwrap().to_u64().unwrap()),
|
||||
_ => {
|
||||
bug!(
|
||||
"tried to assign array-repeat to non-array type {:?}",
|
||||
|
|
@ -1920,7 +1916,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
let ptr = src.into_ptr(&self.memory)?;
|
||||
// u64 cast is from usize to u64, which is always good
|
||||
let valty = ValTy {
|
||||
value: ptr.to_value_with_len(length as u64),
|
||||
value: ptr.to_value_with_len(length.val.to_const_int().unwrap().to_u64().unwrap() ),
|
||||
ty: dest_ty,
|
||||
};
|
||||
self.write_value(valty, dest)
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ impl<'tcx> Lvalue {
|
|||
|
||||
pub(super) fn elem_ty_and_len(self, ty: Ty<'tcx>) -> (Ty<'tcx>, u64) {
|
||||
match ty.sty {
|
||||
ty::TyArray(elem, n) => (elem, n as u64),
|
||||
ty::TyArray(elem, n) => (elem, n.val.to_const_int().unwrap().to_u64().unwrap() as u64),
|
||||
|
||||
ty::TySlice(elem) => {
|
||||
match self {
|
||||
|
|
@ -266,7 +266,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
let field = field_index as u64;
|
||||
let elem_size = match base_ty.sty {
|
||||
ty::TyArray(elem_ty, n) => {
|
||||
assert!(field < n as u64);
|
||||
assert!(field < n.val.to_const_int().unwrap().to_u64().unwrap() as u64);
|
||||
self.type_size(elem_ty)?.expect("array elements are sized") as u64
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
|
|||
Ok(())
|
||||
}
|
||||
TyArray(elem_ty, len) => {
|
||||
let len = len.val.to_const_int().unwrap().to_u64().unwrap();
|
||||
for i in 0..len {
|
||||
let inner_lvalue = self.lvalue_index(query.lval, query.ty, i as u64)?;
|
||||
self.validate(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue