macros, vm, bytecode: add #[primop] await-style primop macro

This commit is contained in:
2026-08-23 17:38:08 +08:00
parent 89f5d84009
commit 0e344b1097
16 changed files with 1770 additions and 610 deletions
+5 -6
View File
@@ -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));