Move the memory_accessed
hook onto the Extra
value
This commit is contained in:
parent
48f6941acf
commit
6def30ba6a
@ -40,6 +40,36 @@ pub struct Allocation<Tag=(),Extra=()> {
|
||||
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 {
|
||||
|
@ -26,7 +26,7 @@ pub use self::error::{
|
||||
|
||||
pub use self::value::{Scalar, ConstValue};
|
||||
|
||||
pub use self::allocation::Allocation;
|
||||
pub use self::allocation::{Allocation, MemoryAccess};
|
||||
|
||||
use std::fmt;
|
||||
use mir;
|
||||
|
@ -174,26 +174,6 @@ pub trait Machine<'a, 'mir, 'tcx>: Sized {
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user