pub(super) fn try_read_value_from_mplace(
        &self,
        mplace: MPlaceTy<'tcx>,
    ) -> EvalResult<'tcx, Option<Value>> {
        if mplace.extra != PlaceExtra::None {
            return Ok(None);
        }
        let (ptr, ptr_align) = mplace.to_scalar_ptr_align();

        if mplace.layout.size.bytes() == 0 {
            // Not all ZSTs have a layout we would handle below, so just short-circuit them
            // all here.
            self.memory.check_align(ptr, ptr_align)?;
            return Ok(Some(Value::Scalar(Scalar::zst().into())));
        }

        let ptr = ptr.to_ptr()?;
        match mplace.layout.abi {
            layout::Abi::Scalar(..) => {
                let scalar = self.memory.read_scalar(ptr, ptr_align, mplace.layout.size)?;
                Ok(Some(Value::Scalar(scalar)))
            }
            layout::Abi::ScalarPair(ref a, ref b) => {
                let (a, b) = (&a.value, &b.value);
                let (a_size, b_size) = (a.size(self), b.size(self));
                let a_ptr = ptr;
                let b_offset = a_size.abi_align(b.align(self));
                assert!(b_offset.bytes() > 0); // we later use the offset to test which field to use
                let b_ptr = ptr.offset(b_offset, self)?.into();
                let a_val = self.memory.read_scalar(a_ptr, ptr_align, a_size)?;
                let b_val = self.memory.read_scalar(b_ptr, ptr_align, b_size)?;
                Ok(Some(Value::ScalarPair(a_val, b_val)))
            }
            _ => Ok(None),
        }
    }
/// Try reading a value in memory; this is interesting particularily for ScalarPair.
/// Return None if the layout does not permit loading this as a value.
Try reading a value in memory; this is interesting particularily for ScalarPair.
Return None if the layout does not permit loading this as a value.
Try reading a value in memory ; this is interesting particularily for ScalarPair . Return None if the layout does not permit loading this as a value .
pub(super) fn try_read_value_from_mplace(
        &self,
        mplace: MPlaceTy<'tcx>,
    ) -> EvalResult<'tcx, Option<Value>> {
        if mplace.extra != PlaceExtra::None {
            return Ok(None);
        }
        let (ptr, ptr_align) = mplace.to_scalar_ptr_align();
        if mplace.layout.size.bytes() == 0 {
            // Not all ZSTs have a layout we would handle below, so just short-circuit them
            // all here.
            self.memory.check_align(ptr, ptr_align)?;
            return Ok(Some(Value::Scalar(Scalar::zst().into())));
        }
        let ptr = ptr.to_ptr()?;
        match mplace.layout.abi {
            layout::Abi::Scalar(..) => {
                let scalar = self.memory.read_scalar(ptr, ptr_align, mplace.layout.size)?;
                Ok(Some(Value::Scalar(scalar)))
            }
            layout::Abi::ScalarPair(ref a, ref b) => {
                let (a, b) = (&a.value, &b.value);
                let (a_size, b_size) = (a.size(self), b.size(self));
                let a_ptr = ptr;
                let b_offset = a_size.abi_align(b.align(self));
                assert!(b_offset.bytes() > 0); // we later use the offset to test which field to use
                let b_ptr = ptr.offset(b_offset, self)?.into();
                let a_val = self.memory.read_scalar(a_ptr, ptr_align, a_size)?;
                let b_val = self.memory.read_scalar(b_ptr, ptr_align, b_size)?;
                Ok(Some(Value::ScalarPair(a_val, b_val)))
            }
            _ => Ok(None),
        }
    }
pub ( super ) fn try_read_value_from_mplace ( & self , mplace : MPlaceTy < ' tcx > , ) -> EvalResult < ' tcx , Option < Value > > { if mplace . extra != PlaceExtra :: None { return Ok ( None ) ; } let ( ptr , ptr_align ) = mplace . to_scalar_ptr_align ( ) ; if mplace . layout . size . bytes ( ) == 0 { // Not all ZSTs have a layout we would handle below, so just short-circuit them // all here. self . memory . check_align ( ptr , ptr_align ) ? ; return Ok ( Some ( Value :: Scalar ( Scalar :: zst ( ) . into ( ) ) ) ) ; } let ptr = ptr . to_ptr ( ) ? ; match mplace . layout . abi { layout :: Abi :: Scalar ( .. ) => { let scalar = self . memory . read_scalar ( ptr , ptr_align , mplace . layout . size ) ? ; Ok ( Some ( Value :: Scalar ( scalar ) ) ) } layout :: Abi :: ScalarPair ( ref a , ref b ) => { let ( a , b ) = ( & a . value , & b . value ) ; let ( a_size , b_size ) = ( a . size ( self ) , b . size ( self ) ) ; let a_ptr = ptr ; let b_offset = a_size . abi_align ( b . align ( self ) ) ; assert ! ( b_offset bytes ( ) 0 ) ; // we later use the offset to test which field to use let b_ptr = ptr . offset ( b_offset , self ) ? . into ( ) ; let a_val = self . memory . read_scalar ( a_ptr , ptr_align , a_size ) ? ; let b_val = self . memory . read_scalar ( b_ptr , ptr_align , b_size ) ? ; Ok ( Some ( Value :: ScalarPair ( a_val , b_val ) ) ) } _ => Ok ( None ) , } }
Try reading a value in memory; this is interesting particularily for ScalarPair.
Try reading a value in memory ; this is interesting particularily for ScalarPair .
&self
mplace
MPlaceTy<'tcx>