Pattern matching works now

This commit is contained in:
2025-11-27 22:47:02 +01:00
parent 4f989271c5
commit ecf151158d
22 changed files with 146 additions and 150 deletions

View File

@@ -123,6 +123,10 @@ impl Format for ForeignAtom {
}
}
impl ToExpr for ForeignAtom {
async fn to_expr(self) -> Expr
where Self: Sized {
self.ex()
}
async fn to_gen(self) -> GExpr { self.ex().to_gen().await }
}

View File

@@ -241,11 +241,20 @@ pub fn extension_init(
})
.await,
api::HostExtReq::SysReq(api::SysReq::SysFwded(fwd)) => {
let fwd_tok = hand.will_handle_as(&fwd);
let api::SysFwded(sys_id, payload) = fwd;
let ctx = get_ctx(sys_id).await;
with_ctx(ctx.clone(), async move {
let sys = ctx.cted().inst();
sys.dyn_request(hand, payload).await
let reply = Rc::new(RefCell::new(None));
let reply2 = reply.clone();
let sub_hand = ExtReq::new(hand.reqnot(), async move |v| {
reply2.borrow_mut().replace(v);
});
sys.dyn_request(sub_hand, payload).await;
let reply_buf =
reply.borrow_mut().take().expect("Request discarded but did not throw");
hand.handle_as(fwd_tok, &reply_buf).await
})
.await
},

View File

@@ -2,6 +2,7 @@ use std::cell::RefCell;
use std::fmt;
use std::hash::Hash;
use std::rc::Rc;
use std::thread::panicking;
use async_once_cell::OnceCell;
use derive_destructure::destructure;
@@ -28,7 +29,7 @@ impl BorrowedExprStore {
}
impl Drop for BorrowedExprStore {
fn drop(&mut self) {
if self.0.borrow().is_some() {
if self.0.borrow().is_some() && !panicking() {
panic!("This should always be explicitly disposed")
}
}

View File

@@ -50,7 +50,9 @@ fn process_args<I, O, F: ExprFunc<I, O>>(f: F) -> FunRecord {
exec(async move |mut hand| {
let mut norm_args = Vec::with_capacity(v.len());
for (expr, typ) in v.into_iter().zip(argtyps) {
if *typ != TypeId::of::<Expr>() {
if *typ == TypeId::of::<Expr>() {
norm_args.push(expr);
} else {
norm_args.push(hand.exec(expr).await?);
}
}