refactor: abstract VM
This commit is contained in:
+12
-1
@@ -124,7 +124,7 @@ define_builtins! {
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, TryFromPrimitive)]
|
||||
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
|
||||
pub enum PrimOpPhase {
|
||||
Abort,
|
||||
Add,
|
||||
@@ -257,6 +257,17 @@ pub enum PrimOpPhase {
|
||||
Illegal,
|
||||
}
|
||||
|
||||
impl TryFrom<u8> for PrimOpPhase {
|
||||
type Error = u8;
|
||||
fn try_from(value: u8) -> Result<Self, Self::Error> {
|
||||
if (0..Self::Illegal as u8).contains(&value) {
|
||||
Ok(unsafe { std::mem::transmute::<u8, Self>(value) })
|
||||
} else {
|
||||
Err(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BuiltinId {
|
||||
#[inline(always)]
|
||||
pub fn entry_phase(self) -> PrimOpPhase {
|
||||
|
||||
Reference in New Issue
Block a user