Replace to_bits by force_bits and move size as parameter
This commit is contained in:
parent
681bd83828
commit
c5c06a5f62
4 changed files with 14 additions and 6 deletions
|
@ -775,7 +775,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn force_bits(&self, scalar: Scalar<M::PointerTag>) -> InterpResult<'tcx, u128> {
|
||||
self.memory.force_bits(scalar)
|
||||
pub fn force_bits(
|
||||
&self,
|
||||
scalar: Scalar<M::PointerTag>,
|
||||
size: Size
|
||||
) -> InterpResult<'tcx, u128> {
|
||||
self.memory.force_bits(scalar, size)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -885,8 +885,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn force_bits(&self, scalar: Scalar<M::PointerTag>) -> InterpResult<'tcx, u128> {
|
||||
match scalar.to_bits_or_ptr(self.pointer_size(), self) {
|
||||
pub fn force_bits(
|
||||
&self,
|
||||
scalar: Scalar<M::PointerTag>,
|
||||
size: Size
|
||||
) -> 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)
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpretCx<'mir, 'tcx, M> {
|
|||
}
|
||||
_ => {
|
||||
assert!(layout.ty.is_integral());
|
||||
let val = val.to_bits(layout.size)?;
|
||||
let val = self.force_bits(val, layout.size)?;
|
||||
let res = match un_op {
|
||||
Not => !val,
|
||||
Neg => {
|
||||
|
|
|
@ -473,7 +473,7 @@ where
|
|||
let layout = self.layout_of(self.tcx.types.usize)?;
|
||||
let n = self.access_local(self.frame(), local, Some(layout))?;
|
||||
let n = self.read_scalar(n)?;
|
||||
let n = n.to_bits(self.tcx.data_layout.pointer_size)?;
|
||||
let n = self.force_bits(n.not_undef()?, self.tcx.data_layout.pointer_size)?;
|
||||
self.mplace_field(base, u64::try_from(n).unwrap())?
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue