refactor(bytecode): OnAtom: build <-> decon (replaces: upper, lower)
This commit is contained in:
parent
6557e172e7
commit
391c478647
|
@ -1,13 +1,6 @@
|
|||
use crate::parse::intern::Sealed;
|
||||
use int_enum::IntEnum;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
|
||||
pub enum CallType {
|
||||
Extern = 0x45, /* E */
|
||||
Local = 0x4c, /* L */
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
|
||||
pub enum ValueType {
|
||||
|
@ -41,8 +34,7 @@ pub enum OpType {
|
|||
#[derive(Clone, Copy, Debug, PartialEq, Eq, IntEnum)]
|
||||
pub enum AtomOp {
|
||||
Build = 0x2e, /* . */
|
||||
Upper = 0x30, /* 0 */
|
||||
Lower = 0x31, /* 1 */
|
||||
Decon = 0x2a, /* * */
|
||||
}
|
||||
|
||||
// u16 because we assume we may add many additional math operations in the future
|
||||
|
@ -54,7 +46,6 @@ pub enum MathBinOp {
|
|||
Mul = 0x202a, /* * */
|
||||
}
|
||||
|
||||
impl Sealed for CallType {}
|
||||
impl Sealed for ValueType {}
|
||||
impl Sealed for OpType {}
|
||||
impl Sealed for AtomOp {}
|
||||
|
|
|
@ -286,21 +286,13 @@ impl Process {
|
|||
}
|
||||
}
|
||||
}
|
||||
Instr::OnAtom(AtomOp::Upper) => match self.stack.pop() {
|
||||
Some(StackEntValue::Atom(Atom(b, _))) => {
|
||||
Instr::OnAtom(AtomOp::Decon) => match self.stack.pop() {
|
||||
Some(StackEntValue::Atom(Atom(b, a))) => {
|
||||
self.stack.push(StackEntValue::Int(b));
|
||||
}
|
||||
x => {
|
||||
tracing::error!("BIF :atom:upper @ {} called with {:?}", previptr, x);
|
||||
break;
|
||||
}
|
||||
},
|
||||
Instr::OnAtom(AtomOp::Lower) => match self.stack.pop() {
|
||||
Some(StackEntValue::Atom(Atom(_, a))) => {
|
||||
self.stack.push(StackEntValue::Int(a));
|
||||
}
|
||||
x => {
|
||||
tracing::error!("BIF :atom:lower @ {} called with {:?}", previptr, x);
|
||||
tracing::error!("BIF :atom:decon @ {} called with {:?}", previptr, x);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue