use crate::vm::{Exception, Long, Vm};
#[derive(Copy, Debug)]
#[derive_const(Clone)]
pub struct Op {
instruction: Long,
f: fn(&mut Vm, Long) -> Result<(), Exception>,
}
impl Op {
#[inline]
#[must_use]
pub const fn new(f: fn(&mut Vm, Long) -> Result<(), Exception>, instruction: Long) -> Self {
Self { instruction, f }
}
#[inline]
pub fn exec(&self, vm: &mut Vm) -> Result<(), Exception> {
(self.f)(vm, self.instruction)
}
#[inline]
#[must_use]
pub const fn instruction(&self) -> Long {
self.instruction
}
}