fogtix/crates/fogtix-bytecode/src/consts.rs

53 lines
1.3 KiB
Rust

use crate::parse::intern::Sealed;
use int_enum::IntEnum;
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
pub enum ValueType {
Atom = 0x41, /* A */
Bytes = 0x42, /* B */
Int_ = 0x49, /* I */
Pointer = 0x50, /* P */
}
#[repr(u16)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
pub enum OpType {
Label = 0x6c62, /* lb */
CallRemote = 0x6372, /* cr */
CallLocal = 0x636c, /* cl */
Jump = 0x6a70, /* jp */
JumpCond = 0x6a63, /* jc */
Return = 0x7274, /* rt */
Push = 0x7073, /* ps */
Pop = 0x7071, /* pq */
Dup = 0x6470, /* dp */
Swap = 0x3c3e, /* <> */
OnAtom = 0x613b, /* a; */
DoMath2 = 0x6d3b, /* m; */
}
// the following enum exists to save space for decoded instructions
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
pub enum AtomOp {
Build = 0x2e, /* . */
Decon = 0x2a, /* * */
}
// u16 because we assume we may add many additional math operations in the future
#[repr(u16)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
pub enum MathBinOp {
NotAnd = 0x7e26, /* ~& */
Add = 0x202b, /* + */
Mul = 0x202a, /* * */
}
impl Sealed for ValueType {}
impl Sealed for OpType {}
impl Sealed for AtomOp {}
impl Sealed for MathBinOp {}