pub extra: Extra,
}
+trait AllocationExtra<Tag> {
+ /// Hook for performing extra checks on a memory read access.
+ ///
+ /// Takes read-only access to the allocation so we can keep all the memory read
+ /// operations take `&self`. Use a `RefCell` in `AllocExtra` if you
+ /// need to mutate.
+ #[inline]
+ fn memory_read(
+ &self,
+ _ptr: Pointer<Self::PointerTag>,
+ _size: Size,
+ ) -> EvalResult<'tcx> {
+ Ok(())
+ }
+
+ /// Hook for performing extra checks on a memory write access.
+ ///
+ /// Takes read-only access to the allocation so we can keep all the memory read
+ /// operations take `&self`. Use a `RefCell` in `AllocExtra` if you
+ /// need to mutate.
+ #[inline]
+ fn memory_written(
+ &mut self,
+ _ptr: Pointer<Self::PointerTag>,
+ _size: Size,
+ ) -> EvalResult<'tcx> {
+ Ok(())
+ }
+}
+
impl<Tag, Extra: Default> Allocation<Tag, Extra> {
/// Creates a read-only allocation initialized by the given bytes
pub fn from_bytes(slice: &[u8], align: Align) -> Self {
pub use self::value::{Scalar, ConstValue};
-pub use self::allocation::Allocation;
+pub use self::allocation::{Allocation, MemoryAccess};
use std::fmt;
use mir;
dest: PlaceTy<'tcx, Self::PointerTag>,
) -> EvalResult<'tcx>;
- /// Hook for performing extra checks on a memory read access.
- #[inline]
- fn memory_read(
- _alloc: &Allocation<Self::PointerTag, Self::AllocExtra>,
- _ptr: Pointer<Self::PointerTag>,
- _size: Size,
- ) -> EvalResult<'tcx> {
- Ok(())
- }
-
- /// Hook for performing extra checks on a memory write access.
- #[inline]
- fn memory_written(
- _alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
- _ptr: Pointer<Self::PointerTag>,
- _size: Size,
- ) -> EvalResult<'tcx> {
- Ok(())
- }
-
/// Hook for performing extra checks when memory gets deallocated.
#[inline]
fn memory_deallocated(