macros, vm, bytecode: add #[primop] await-style primop macro
This commit is contained in:
@@ -6,6 +6,11 @@ use gc_arena::Mutation;
|
||||
|
||||
use crate::{Break, Forced, Machine, NixType, Step, StrictValue, Value, ValueVariant};
|
||||
|
||||
pub struct TypeError {
|
||||
pub expected: NixType,
|
||||
pub got: NixType,
|
||||
}
|
||||
|
||||
pub trait SlotContent<'gc> {
|
||||
type Ty: Into<Value<'gc>> + TryFrom<Value<'gc>> + 'gc;
|
||||
}
|
||||
@@ -50,12 +55,6 @@ where
|
||||
T::Ty::try_from(m.peek(self.depth as usize)).expect("slot held a value of the wrong type")
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn read_checked<M: Machine<'gc>>(&self, m: &M) -> Result<T::Ty, NixType> {
|
||||
let val = m.peek(self.depth as usize);
|
||||
T::Ty::try_from(val).map_err(|_err| val.ty())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn write<M: Machine<'gc>>(&self, m: &mut M, val: T::Ty) {
|
||||
m.replace(self.depth as usize, T::Ty::into(val));
|
||||
|
||||
Reference in New Issue
Block a user