fn try_read_immediate_from_mplace(
        &self,
        mplace: &MPlaceTy<'tcx, M::PointerTag>,
    ) -> InterpResult<'tcx, Option<ImmTy<'tcx, M::PointerTag>>> {
        if mplace.layout.is_unsized() {
            // Don't touch unsized
            return Ok(None);
        }

        let alloc = match self.get_alloc(mplace)? {
            Some(ptr) => ptr,
            None => {
                return Ok(Some(ImmTy {
                    // zero-sized type
                    imm: Scalar::ZST.into(),
                    layout: mplace.layout,
                }));
            }
        };

        match mplace.layout.abi {
            Abi::Scalar(..) => {
                let scalar = alloc.read_scalar(alloc_range(Size::ZERO, mplace.layout.size))?;
                Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout }))
            }
            Abi::ScalarPair(ref a, ref b) => {
                // We checked `ptr_align` above, so all fields will have the alignment they need.
                // We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
                // which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
                let (a, b) = (&a.value, &b.value);
                let (a_size, b_size) = (a.size(self), b.size(self));
                let b_offset = a_size.align_to(b.align(self).abi);
                assert!(b_offset.bytes() > 0); // we later use the offset to tell apart the fields
                let a_val = alloc.read_scalar(alloc_range(Size::ZERO, a_size))?;
                let b_val = alloc.read_scalar(alloc_range(b_offset, b_size))?;
                Ok(Some(ImmTy { imm: Immediate::ScalarPair(a_val, b_val), layout: mplace.layout }))
            }
            _ => Ok(None),
        }
    }
/// Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
/// Returns `None` if the layout does not permit loading this as a value.
Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
Returns `None` if the layout does not permit loading this as a value.
Try reading an immediate in memory ; this is interesting particularly for ` ScalarPair ` . Returns ` None ` if the layout does not permit loading this as a value .
fn try_read_immediate_from_mplace(
        &self,
        mplace: &MPlaceTy<'tcx, M::PointerTag>,
    ) -> InterpResult<'tcx, Option<ImmTy<'tcx, M::PointerTag>>> {
        if mplace.layout.is_unsized() {
            // Don't touch unsized
            return Ok(None);
        }
        let alloc = match self.get_alloc(mplace)? {
            Some(ptr) => ptr,
            None => {
                return Ok(Some(ImmTy {
                    // zero-sized type
                    imm: Scalar::ZST.into(),
                    layout: mplace.layout,
                }));
            }
        };
        match mplace.layout.abi {
            Abi::Scalar(..) => {
                let scalar = alloc.read_scalar(alloc_range(Size::ZERO, mplace.layout.size))?;
                Ok(Some(ImmTy { imm: scalar.into(), layout: mplace.layout }))
            }
            Abi::ScalarPair(ref a, ref b) => {
                // We checked `ptr_align` above, so all fields will have the alignment they need.
                // We would anyway check against `ptr_align.restrict_for_offset(b_offset)`,
                // which `ptr.offset(b_offset)` cannot possibly fail to satisfy.
                let (a, b) = (&a.value, &b.value);
                let (a_size, b_size) = (a.size(self), b.size(self));
                let b_offset = a_size.align_to(b.align(self).abi);
                assert!(b_offset.bytes() > 0); // we later use the offset to tell apart the fields
                let a_val = alloc.read_scalar(alloc_range(Size::ZERO, a_size))?;
                let b_val = alloc.read_scalar(alloc_range(b_offset, b_size))?;
                Ok(Some(ImmTy { imm: Immediate::ScalarPair(a_val, b_val), layout: mplace.layout }))
            }
            _ => Ok(None),
        }
    }
fn try_read_immediate_from_mplace ( & self , mplace : & MPlaceTy < ' tcx , M :: PointerTag > , ) -> InterpResult < ' tcx , Option < ImmTy < ' tcx , M :: PointerTag > > > { if mplace . layout . is_unsized ( ) { // Don't touch unsized return Ok ( None ) ; } let alloc = match self . get_alloc ( mplace ) ? { Some ( ptr ) => ptr , None => { return Ok ( Some ( ImmTy { // zero-sized type imm : Scalar :: ZST . into ( ) , layout : mplace . layout , } ) ) ; } } ; match mplace . layout . abi { Abi :: Scalar ( .. ) => { let scalar = alloc . read_scalar ( alloc_range ( Size :: ZERO , mplace . layout . size ) ) ? ; Ok ( Some ( ImmTy { imm : scalar . into ( ) , layout : mplace . layout } ) ) } Abi :: ScalarPair ( ref a , ref b ) => { // We checked `ptr_align` above, so all fields will have the alignment they need. // We would anyway check against `ptr_align.restrict_for_offset(b_offset)`, // which `ptr.offset(b_offset)` cannot possibly fail to satisfy. let ( a , b ) = ( & a . value , & b . value ) ; let ( a_size , b_size ) = ( a . size ( self ) , b . size ( self ) ) ; let b_offset = a_size . align_to ( b . align ( self ) . abi ) ; assert ! ( b_offset bytes ( ) 0 ) ; // we later use the offset to tell apart the fields let a_val = alloc . read_scalar ( alloc_range ( Size :: ZERO , a_size ) ) ? ; let b_val = alloc . read_scalar ( alloc_range ( b_offset , b_size ) ) ? ; Ok ( Some ( ImmTy { imm : Immediate :: ScalarPair ( a_val , b_val ) , layout : mplace . layout } ) ) } _ => Ok ( None ) , } }
Try reading an immediate in memory; this is interesting particularly for `ScalarPair`.
Try reading an immediate in memory ; this is interesting particularly for ` ScalarPair ` .
&self
mplace
&MPlaceTy<'tcx, M::PointerTag>
&self
mplace
&MPlaceTy<'tcx, M::PointerTag>