vm, runtime: add slots! macro and port filter primop to typed slots
This commit is contained in:
@@ -18,6 +18,27 @@ pub use io::*;
|
||||
pub use list::*;
|
||||
pub use path::*;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! slots {
|
||||
{ $($ident:ident : $ty:ty);* $(;)? } => {
|
||||
slots! { @acc [ 0 ] $($ident : $ty;)* }
|
||||
};
|
||||
/* { $($ident:ident : $ty:ty);* $(;)? } => {
|
||||
slots! { @reverse [ $($ident : $ty;)* ] [] }
|
||||
};
|
||||
{ @reverse [ $ident:ident : $ty:ty; $($remain:tt)* ] [ $($acc:tt)* ] } => {
|
||||
slots! { @reverse [ $($remain)* ] [ $ident : $ty; $($acc)* ] }
|
||||
};
|
||||
{ @reverse [] [ $($rev_id:ident : $rev_ty:ty;)* ] } => {
|
||||
slots! { @acc [ 0 ] $($rev_id : $rev_ty;)* }
|
||||
}; */
|
||||
{ @acc [ $($acc:tt)* ] $ident:ident : $ty:ty; $($remain:tt)* } => {
|
||||
let $ident : Slot<$ty> = Slot::new($($acc)*);
|
||||
slots! { @acc [ $($acc)* + 1 ] $($remain)* }
|
||||
};
|
||||
{ @acc [ $($acc:tt)* ] } => {};
|
||||
}
|
||||
|
||||
pub fn dispatch_cont<'gc, M: Machine<'gc>>(
|
||||
m: &mut M,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
@@ -45,9 +66,9 @@ pub fn dispatch_cont<'gc, M: Machine<'gc>>(
|
||||
PDeepSeqLoop => deep_seq_loop(m, reader, mc),
|
||||
PSeq => seq(m, reader, mc),
|
||||
|
||||
PFilterForceList => filter_force_list(m, reader, mc),
|
||||
PFilterCallPred => filter_call_pred(m, reader, mc),
|
||||
PFilterCheck => filter_check(m, reader, mc),
|
||||
PFilterForceList | PFilterSetupStack | PFilterCallPred | PFilterCheck => {
|
||||
filter::dispatch(m, reader, mc, cont)
|
||||
}
|
||||
|
||||
PFoldlStrict => foldl_strict_entry(m, reader, mc),
|
||||
PFoldlStrictEmpty => foldl_strict_empty(m, reader, mc),
|
||||
|
||||
Reference in New Issue
Block a user