Replace MemoryExtra by Memory in intptrcast methods

This commit is contained in:
Christian Poveda 2019-06-20 14:07:34 -05:00
parent b25ee64497
commit 9cc28d4541
2 changed files with 8 additions and 9 deletions

View File

@ -11,8 +11,7 @@
use super::{
Allocation, AllocId, InterpResult, Scalar, AllocationExtra,
InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer,
InterpErrorInfo, InterpError
InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory
};
/// Whether this kind of memory is allowed to leak
@ -212,19 +211,19 @@ fn stack_pop(
fn int_to_ptr(
int: u64,
_extra: &Self::MemoryExtra,
_mem: &Memory<'mir, 'tcx, Self>,
) -> InterpResult<'tcx, Pointer<Self::PointerTag>> {
if int == 0 {
Err(InterpErrorInfo::from(InterpError::InvalidNullPointerUsage))
err!(InvalidNullPointerUsage)
} else {
Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer))
err!(ReadBytesAsPointer)
}
}
fn ptr_to_int(
_ptr: Pointer<Self::PointerTag>,
_extra: &Self::MemoryExtra,
_mem: &Memory<'mir, 'tcx, Self>,
) -> InterpResult<'tcx, u64> {
Err(InterpErrorInfo::from(InterpError::ReadPointerAsBytes))
err!(ReadPointerAsBytes)
}
}

View File

@ -881,7 +881,7 @@ pub fn force_ptr(
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
match scalar {
Scalar::Ptr(ptr) => Ok(ptr),
_ => M::int_to_ptr(scalar.to_usize(self)?, &self.extra)
_ => M::int_to_ptr(scalar.to_usize(self)?, self)
}
}
@ -892,7 +892,7 @@ pub fn force_bits(
) -> InterpResult<'tcx, u128> {
match scalar.to_bits_or_ptr(size, self) {
Ok(bits) => Ok(bits),
Err(ptr) => Ok(M::ptr_to_int(ptr, &self.extra)? as u128)
Err(ptr) => Ok(M::ptr_to_int(ptr, self)? as u128)
}
}
}