use super::Instruction;
#[derive(Debug, Copy, Clone)]
pub struct InstructionPtr {
ptr: *const Instruction,
}
unsafe impl Send for InstructionPtr {}
impl InstructionPtr {
#[inline]
pub fn new(ptr: *const Instruction) -> Self {
Self { ptr }
}
#[inline(always)]
pub fn offset(&mut self, by: isize) {
self.ptr = unsafe { self.ptr.offset(by) };
}
#[inline(always)]
pub fn add(&mut self, delta: usize) {
self.ptr = unsafe { self.ptr.add(delta) };
}
#[inline(always)]
pub fn get(&self) -> &Instruction {
unsafe { &*self.ptr }
}
}