From 8fd3f2af0f3db141064a52c89a7a892f7df1b1e8 Mon Sep 17 00:00:00 2001 From: Lawrence Bethlenfalvy Date: Mon, 20 Jan 2025 08:52:19 +0000 Subject: [PATCH] partway through extension --- orchid-base/src/builtin.rs | 14 +- orchid-base/src/reqnot.rs | 4 +- orchid-extension/src/conv.rs | 9 +- orchid-extension/src/entrypoint.rs | 438 ++++++++++-------- .../rustc-ice-2025-01-19T15_18_56-277370.txt | 31 ++ .../rustc-ice-2025-01-19T15_19_06-277529.txt | 31 ++ .../rustc-ice-2025-01-19T15_19_24-277744.txt | 31 ++ .../rustc-ice-2025-01-19T15_21_19-278933.txt | 31 ++ .../rustc-ice-2025-01-19T15_21_48-279278.txt | 31 ++ .../rustc-ice-2025-01-19T15_22_25-279679.txt | 31 ++ .../rustc-ice-2025-01-19T15_25_47-282159.txt | 31 ++ rustfmt.toml | 2 +- 12 files changed, 470 insertions(+), 214 deletions(-) create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_18_56-277370.txt create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_19_06-277529.txt create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_19_24-277744.txt create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_21_19-278933.txt create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_21_48-279278.txt create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_22_25-279679.txt create mode 100644 orchid-extension/src/rustc-ice-2025-01-19T15_25_47-282159.txt diff --git a/orchid-base/src/builtin.rs b/orchid-base/src/builtin.rs index 3a40361..b86725d 100644 --- a/orchid-base/src/builtin.rs +++ b/orchid-base/src/builtin.rs @@ -11,8 +11,11 @@ use crate::api; /// /// There are no ordering guarantees about these pub trait ExtPort { - fn send(&self, msg: &[u8]) -> LocalBoxFuture<'_, ()>; - fn recv<'s, 'a: 's>(&'s self, cb: Box) -> LocalBoxFuture<'a, ()>; + fn send<'a>(&'a self, msg: &'a [u8]) -> LocalBoxFuture<'a, ()>; + fn recv<'a, 's: 'a>( + &'s self, + cb: Box LocalBoxFuture<'a, ()> + 'a>, + ) -> LocalBoxFuture<'a, ()>; } pub struct ExtInit { @@ -21,7 +24,12 @@ pub struct ExtInit { } impl ExtInit { pub async fn send(&self, msg: &[u8]) { self.port.send(msg).await } - pub async fn recv(&self, cb: impl FnOnce(&[u8]) + Send) { self.port.recv(Box::new(cb)).await } + pub async fn recv<'a, 's: 'a>( + &'s self, + cb: Box LocalBoxFuture<'a, ()> + 'a>, + ) { + self.port.recv(Box::new(cb)).await + } } impl Deref for ExtInit { type Target = api::ExtensionHeader; diff --git a/orchid-base/src/reqnot.rs b/orchid-base/src/reqnot.rs index 48eed67..fea5f3d 100644 --- a/orchid-base/src/reqnot.rs +++ b/orchid-base/src/reqnot.rs @@ -24,8 +24,8 @@ trait_set! { pub trait SendFn = for<'a> FnMut(&'a [u8], ReqNot) -> LocalBoxFuture<'a, ()> + DynClone + Send + 'static; - pub trait ReqFn = - for<'a> FnMut(RequestHandle<'a, T>, ::Req) -> LocalBoxFuture<'a, Receipt<'a>> + pub trait ReqFn = for<'a> FnMut(RequestHandle<'a, T>, ::Req) + -> LocalBoxFuture<'a, Receipt<'a>> + DynClone + Send + Sync + 'static; pub trait NotifFn = FnMut(::Notif, ReqNot) -> LocalBoxFuture<'static, ()> diff --git a/orchid-extension/src/conv.rs b/orchid-extension/src/conv.rs index 921b7bd..5b0685d 100644 --- a/orchid-extension/src/conv.rs +++ b/orchid-extension/src/conv.rs @@ -31,10 +31,11 @@ async fn err_type(pos: Pos) -> OrcErr { } impl TryFromExpr for TypAtom<'_, A> { - fn try_from_expr(expr: Expr) -> OrcRes { - (expr.foreign_atom()) - .map_err(|ex| err_not_atom(ex.pos.clone()).into()) - .and_then(|f| downcast_atom(f).map_err(|f| err_type(f.pos).into())) + async fn try_from_expr(expr: Expr) -> OrcRes { + match expr.foreign_atom() { + Err(ex) => Err(err_not_atom(ex.pos.clone()).await.into()), + Ok(f) => match downcast_atom(f) \.map_err(|f| err_type(f.pos).into()), + } } } diff --git a/orchid-extension/src/entrypoint.rs b/orchid-extension/src/entrypoint.rs index 5d13dc0..a241a63 100644 --- a/orchid-extension/src/entrypoint.rs +++ b/orchid-extension/src/entrypoint.rs @@ -1,12 +1,17 @@ use std::io::Write; use std::num::NonZero; +use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::{Arc, Mutex}; use std::{mem, process, thread}; +use async_std::channel::{Receiver, Sender}; +use async_std::sync::Mutex; +use futures::FutureExt; +use futures::future::LocalBoxFuture; use hashbrown::HashMap; use itertools::Itertools; use orchid_api_traits::{Decode, Encode, enc_vec}; +use orchid_base::builtin::ExtPort; use orchid_base::char_filter::{char_filter_match, char_filter_union, mk_char_filter}; use orchid_base::clone; use orchid_base::interner::{Tok, init_replica, sweep_replica}; @@ -14,7 +19,7 @@ use orchid_base::logging::Logger; use orchid_base::macros::{mtreev_from_api, mtreev_to_api}; use orchid_base::name::{PathSlice, Sym}; use orchid_base::parse::{Comment, Snippet}; -use orchid_base::reqnot::{ReqHandlish, ReqNot, RequestHandle, Requester}; +use orchid_base::reqnot::{Receipt, ReqHandlish, ReqNot, RequestHandle, Requester}; use orchid_base::tree::{ttv_from_api, ttv_to_api}; use substack::Substack; @@ -55,18 +60,23 @@ pub struct SystemRecord { lazy_members: HashMap, } -pub fn with_atom_record( +pub async fn with_atom_record( get_sys_ctx: &impl Fn(api::SysId, ReqNot) -> SysCtx, reqnot: ReqNot, atom: &api::Atom, - cb: impl FnOnce(Box, SysCtx, api::AtomId, &[u8]) -> T, + cb: impl for<'c> FnOnce( + Box, + SysCtx, + api::AtomId, + &'c [u8], + ) -> LocalBoxFuture<'c, T>, ) -> T { let mut data = &atom.data[..]; let ctx = get_sys_ctx(atom.owner, reqnot); let inst = ctx.cted.inst(); let id = api::AtomId::decode(&mut data); let atom_record = atom_by_idx(inst.card(), id).expect("Atom ID reserved"); - cb(atom_record, ctx, id, data) + cb(atom_record, ctx, id, data).await } pub fn extension_main(data: ExtensionData) { @@ -83,7 +93,20 @@ pub fn extension_main(data: ExtensionData) { pub struct ExtensionOwner { rn: ReqNot, - onmessage: Mutex, + out_recv: Receiver>, + out_send: Sender>, +} + +impl ExtPort for ExtensionOwner { + fn send<'a>(&'a self, msg: &'a [u8]) -> LocalBoxFuture<'a, ()> { + self.rn.receive(msg).boxed_local() + } + fn recv<'a, 's: 'a>( + &'s self, + cb: Box LocalBoxFuture<'a, ()> + 'a>, + ) -> LocalBoxFuture<'a, ()> { + async { cb(&self.out_recv.recv().await.unwrap()[..]).await }.boxed_local() + } } fn extension_main_logic(data: ExtensionData) { @@ -99,207 +122,214 @@ fn extension_main_logic(data: ExtensionData) { std::io::stdout().flush().unwrap(); let exiting = Arc::new(AtomicBool::new(false)); let logger = Arc::new(Logger::new(log_strategy)); - let mk_ctx = clone!(logger, systems; move |id: api::SysId, reqnot: ReqNot| { - let cted = systems.lock().unwrap()[&id].cted.clone(); - SysCtx { id, cted, logger: logger.clone(), reqnot } - }); + let mk_ctx = clone!( + logger, systems; + move |id: api::SysId, reqnot: ReqNot| async { + let cted = systems.lock().await[&id].cted.clone(); + SysCtx { id, cted, logger: logger.clone(), reqnot } + }.boxed_local() + ); let rn = ReqNot::::new( - clone!(logger; move |a, _| { + clone!(logger; move |a, _| async { logger.log_buf("Upsending", a); - send_parent_msg(a).unwrap() - }), - clone!(systems, exiting, mk_ctx; move |n, reqnot| match n { - api::HostExtNotif::Exit => exiting.store(true, Ordering::Relaxed), - api::HostExtNotif::SystemDrop(api::SystemDrop(sys_id)) => - mem::drop(systems.lock().unwrap().remove(&sys_id)), - api::HostExtNotif::AtomDrop(api::AtomDrop(sys_id, atom)) => - OBJ_STORE.get(atom.0).unwrap().remove().dyn_free(mk_ctx(sys_id, reqnot)), - }), - clone!(systems, logger; move |hand, req| match req { - api::HostExtReq::Ping(ping@api::Ping) => hand.handle(&ping, &()), - api::HostExtReq::Sweep(sweep@api::Sweep) => hand.handle(&sweep, &sweep_replica()), - api::HostExtReq::SysReq(api::SysReq::NewSystem(new_sys)) => { - let i = decls.iter().enumerate().find(|(_, s)| s.id == new_sys.system).unwrap().0; - let cted = data.systems[i].new_system(&new_sys); - let mut vfses = HashMap::new(); - let lex_filter = cted.inst().dyn_lexers().iter().fold(api::CharFilter(vec![]), |cf, lx| { - let lxcf = mk_char_filter(lx.char_filter().iter().cloned()); - char_filter_union(&cf, &lxcf) - }); - let mut lazy_mems = HashMap::new(); - let ctx = SysCtx{ - cted: cted.clone(), - id: new_sys.id, - logger: logger.clone(), - reqnot: hand.reqnot() - }; - let mut tia_ctx = TIACtxImpl{ - lazy: &mut lazy_mems, - sys: ctx.clone(), - basepath: &[], - path: Substack::Bottom, - }; - let const_root = (cted.inst().dyn_env().into_iter()) - .map(|(k, v)| (k.to_api(), v.into_api(&mut tia_ctx))) - .collect(); - systems.lock().unwrap().insert(new_sys.id, SystemRecord { - declfs: cted.inst().dyn_vfs().to_api_rec(&mut vfses), - vfses, - cted, - lazy_members: lazy_mems - }); - hand.handle(&new_sys, &api::SystemInst { - lex_filter, - const_root, - line_types: vec![] - }) + send_parent_msg(a).await.unwrap() + }.boxed_local()), + clone!(systems, exiting, mk_ctx; move |n, reqnot| async { + match n { + api::HostExtNotif::Exit => exiting.store(true, Ordering::Relaxed), + api::HostExtNotif::SystemDrop(api::SystemDrop(sys_id)) => + mem::drop(systems.lock().await.remove(&sys_id)), + api::HostExtNotif::AtomDrop(api::AtomDrop(sys_id, atom)) => + OBJ_STORE.get(atom.0).unwrap().remove().dyn_free(mk_ctx(sys_id, reqnot).await), } - api::HostExtReq::GetMember(get_tree@api::GetMember(sys_id, tree_id)) => { - let mut systems_g = systems.lock().unwrap(); - let sys = systems_g.get_mut(&sys_id).expect("System not found"); - let lazy = &mut sys.lazy_members; - let (path, cb) = match lazy.insert(tree_id, MemberRecord::Res) { - None => panic!("Tree for ID not found"), - Some(MemberRecord::Res) => panic!("This tree has already been transmitted"), - Some(MemberRecord::Gen(path, cb)) => (path, cb), - }; - let tree = cb.build(path.clone()); - hand.handle(&get_tree, &tree.into_api(&mut TIACtxImpl{ - sys: SysCtx::new(sys_id, &sys.cted, &logger, hand.reqnot()), - path: Substack::Bottom, - basepath: &path, - lazy, - })) - } - api::HostExtReq::VfsReq(api::VfsReq::GetVfs(get_vfs@api::GetVfs(sys_id))) => { - let systems_g = systems.lock().unwrap(); - hand.handle(&get_vfs, &systems_g[&sys_id].declfs) - } - api::HostExtReq::SysReq(api::SysReq::SysFwded(fwd)) => { - let api::SysFwded(sys_id, payload) = fwd; - let ctx = mk_ctx(sys_id, hand.reqnot()); - let sys = ctx.cted.inst(); - sys.dyn_request(hand, payload) - } - api::HostExtReq::VfsReq(api::VfsReq::VfsRead(vfs_read)) => { - let api::VfsRead(sys_id, vfs_id, path) = &vfs_read; - let systems_g = systems.lock().unwrap(); - let path = path.iter().map(|t| Tok::from_api(*t)).collect_vec(); - hand.handle(&vfs_read, &systems_g[sys_id].vfses[vfs_id].load(PathSlice::new(&path))) - } - api::HostExtReq::LexExpr(lex @ api::LexExpr{ sys, text, pos, id }) => { - let systems_g = systems.lock().unwrap(); - let lexers = systems_g[&sys].cted.inst().dyn_lexers(); - mem::drop(systems_g); - let text = Tok::from_api(text); - let ctx = LexContext { sys, id, pos, reqnot: hand.reqnot(), text: &text }; - let trigger_char = text.chars().nth(pos as usize).unwrap(); - for lx in lexers.iter().filter(|l| char_filter_match(l.char_filter(), trigger_char)) { - match lx.lex(&text[pos as usize..], &ctx) { - Err(e) if e.any(|e| *e == err_not_applicable()) => continue, - Err(e) => { - let eopt = e.keep_only(|e| *e != err_cascade()).map(|e| Err(e.to_api())); - return hand.handle(&lex, &eopt) - }, - Ok((s, expr)) => { - let ctx = mk_ctx(sys, hand.reqnot()); - let expr = expr.to_api(&mut |f, r| do_extra(f, r, ctx.clone())); - let pos = (text.len() - s.len()) as u32; - return hand.handle(&lex, &Some(Ok(api::LexedExpr{ pos, expr }))) - } - } - } - writeln!(logger, "Got notified about n/a character '{trigger_char}'"); - hand.handle(&lex, &None) - }, - api::HostExtReq::ParseLine(pline) => { - let api::ParseLine{ exported, comments, sys, line } = &pline; - let mut ctx = mk_ctx(*sys, hand.reqnot()); - let parsers = ctx.cted.inst().dyn_parsers(); - let comments = comments.iter().map(Comment::from_api).collect(); - let line: Vec = ttv_from_api(line, &mut ctx); - let snip = Snippet::new(line.first().expect("Empty line"), &line); - let (head, tail) = snip.pop_front().unwrap(); - let name = if let GenTok::Name(n) = &head.tok { n } else { panic!("No line head") }; - let parser = parsers.iter().find(|p| p.line_head() == **name).expect("No parser candidate"); - let o_line = match parser.parse(*exported, comments, tail) { - Err(e) => Err(e.to_api()), - Ok(t) => Ok(ttv_to_api(t, &mut |f, range| { - api::TokenTree{ range, token: api::Token::Atom(f.clone().build(ctx.clone())) } - })), - }; - hand.handle(&pline, &o_line) - } - api::HostExtReq::AtomReq(atom_req) => { - let atom = atom_req.get_atom(); - with_atom_record(&mk_ctx, hand.reqnot(), atom, |nfo, ctx, id, buf| { - let actx = AtomCtx(buf, atom.drop, ctx.clone()); - match &atom_req { - api::AtomReq::SerializeAtom(ser) => { - let mut buf = enc_vec(&id); - let refs_opt = nfo.serialize(actx, &mut buf); - hand.handle(ser, &refs_opt.map(|refs| (buf, refs))) - } - api::AtomReq::AtomPrint(print@api::AtomPrint(_)) => - hand.handle(print, &nfo.print(actx)), - api::AtomReq::Fwded(fwded) => { - let api::Fwded(_, key, payload) = &fwded; - let mut reply = Vec::new(); - let some = nfo.handle_req(actx, Sym::from_api(*key), &mut &payload[..], &mut reply); - hand.handle(fwded, &some.then_some(reply)) - } - api::AtomReq::CallRef(call@api::CallRef(_, arg)) => { - let ret = nfo.call_ref(actx, *arg); - hand.handle(call, &ret.api_return(ctx.clone(), &mut |h| hand.defer_drop(h))) - }, - api::AtomReq::FinalCall(call@api::FinalCall(_, arg)) => { - let ret = nfo.call(actx, *arg); - hand.handle(call, &ret.api_return(ctx.clone(), &mut |h| hand.defer_drop(h))) - } - api::AtomReq::Command(cmd@api::Command(_)) => { - hand.handle(cmd, &match nfo.command(actx) { - Err(e) => Err(e.to_api()), - Ok(opt) => Ok(match opt { - None => api::NextStep::Halt, - Some(cont) => api::NextStep::Continue( - cont.api_return(ctx.clone(), &mut |h| hand.defer_drop(h)) - ), - }) - }) - } - } - }) - }, - api::HostExtReq::DeserAtom(deser) => { - let api::DeserAtom(sys, buf, refs) = &deser; - let mut read = &mut &buf[..]; - let ctx = mk_ctx(*sys, hand.reqnot()); - let id = api::AtomId::decode(&mut read); - let inst = ctx.cted.inst(); - let nfo = atom_by_idx(inst.card(), id).expect("Deserializing atom with invalid ID"); - hand.handle(&deser, &nfo.deserialize(ctx.clone(), read, refs)) - }, - orchid_api::HostExtReq::ApplyMacro(am) => { - let tok = hand.will_handle_as(&am); - let sys_ctx = mk_ctx(am.sys, hand.reqnot()); - let ctx = RuleCtx { - args: (am.params.into_iter()) - .map(|(k, v)| ( - Tok::from_api(k), - mtreev_from_api(&v, &mut |_| panic!("No atom in macro prompt!")) - )) - .collect(), - run_id: am.run_id, - sys: sys_ctx.clone(), - }; - hand.handle_as(tok, &match apply_rule(am.id, ctx) { - Err(e) => e.keep_only(|e| *e != err_cascade()).map(|e| Err(e.to_api())), - Ok(t) => Some(Ok(mtreev_to_api(&t, &mut |a| { - api::MacroToken::Atom(a.clone().build(sys_ctx.clone())) - }))), - }) - } - }), + }.boxed_local()), + { + let systems = systems.clone(); + let logger = logger.clone(); + (move|hand,req|async { + let receipt:Receipt = match req { + api::HostExtReq::Ping(ping@api::Ping) => hand.handle(&ping, &()).await, + api::HostExtReq::Sweep(sweep@api::Sweep) => hand.handle(&sweep, &sweep_replica()).await, + api::HostExtReq::SysReq(api::SysReq::NewSystem(new_sys)) => { + let i = decls.iter().enumerate().find(|(_,s)|s.id==new_sys.system).unwrap().0; + let cted = data.systems[i].new_system(&new_sys); + let mut vfses = HashMap::new(); + let lex_filter = cted.inst().dyn_lexers().iter().fold(api::CharFilter(vec![]), |cf,lx|{ + let lxcf = mk_char_filter(lx.char_filter().iter().cloned()); + char_filter_union(&cf, &lxcf) + }); + let mut lazy_mems = HashMap::new(); + let ctx = SysCtx { + cted:cted.clone(),id:new_sys.id,logger:logger.clone(),reqnot:hand.reqnot() + }; + let mut tia_ctx = TIACtxImpl { + lazy: &mut lazy_mems,sys:ctx.clone(),basepath: &[],path:Substack::Bottom, + }; + let const_root = (cted.inst().dyn_env().into_iter()).map(|(k,v)|(k.to_api(),v.into_api(&mut tia_ctx))).collect(); + systems.lock().unwrap().insert(new_sys.id,SystemRecord { + declfs:cted.inst().dyn_vfs().to_api_rec(&mut vfses),vfses,cted,lazy_members:lazy_mems + }); + hand.handle(&new_sys, &api::SystemInst { + lex_filter,const_root,line_types:vec![] + }).await + } + api::HostExtReq::GetMember(get_tree@api::GetMember(sys_id,tree_id)) => { + let mut systems_g = systems.lock().unwrap(); + let sys = systems_g.get_mut(&sys_id).expect("System not found"); + let lazy = &mut sys.lazy_members; + let(path,cb) = match lazy.insert(tree_id,MemberRecord::Res){ + None => panic!("Tree for ID not found"), + Some(MemberRecord::Res) => panic!("This tree has already been transmitted"), + Some(MemberRecord::Gen(path,cb)) => (path,cb), + + }; + let tree = cb.build(path.clone()); + hand.handle(&get_tree, &tree.into_api(&mut TIACtxImpl { + sys:SysCtx::new(sys_id, &sys.cted, &logger,hand.reqnot()),path:Substack::Bottom,basepath: &path,lazy, + })).await + } + api::HostExtReq::VfsReq(api::VfsReq::GetVfs(get_vfs@api::GetVfs(sys_id))) => { + let systems_g = systems.lock().unwrap(); + hand.handle(&get_vfs, &systems_g[&sys_id].declfs).await + } + api::HostExtReq::SysReq(api::SysReq::SysFwded(fwd)) => { + let api::SysFwded(sys_id,payload) = fwd; + let ctx = mk_ctx(sys_id,hand.reqnot()); + let sys = ctx.cted.inst(); + sys.dyn_request(hand,payload) + } + api::HostExtReq::VfsReq(api::VfsReq::VfsRead(vfs_read)) => { + let api::VfsRead(sys_id,vfs_id,path) = &vfs_read; + let systems_g = systems.lock().unwrap(); + let path = path.iter().map(|t|Tok::from_api(*t)).collect_vec(); + hand.handle(&vfs_read, &systems_g[sys_id].vfses[vfs_id].load(PathSlice::new(&path))).await + } + api::HostExtReq::LexExpr(lex@api::LexExpr { + sys,text,pos,id + }) => { + let systems_g = systems.lock().unwrap(); + let lexers = systems_g[&sys].cted.inst().dyn_lexers(); + mem::drop(systems_g); + let text = Tok::from_api(text); + let ctx = LexContext { + sys,id,pos,reqnot:hand.reqnot(),text: &text + }; + let trigger_char = text.await.chars().nth(pos as usize).unwrap(); + for lx in lexers.iter().filter(|l|char_filter_match(l.char_filter(),trigger_char)){ + match lx.lex(&text[pos as usize..], &ctx){ + Err(e)if e.any(|e| *e==err_not_applicable()) => continue, + Err(e) => { + let eopt = e.keep_only(|e| *e!=err_cascade()).map(|e|Err(e.to_api())); + return hand.handle(&lex, &eopt) + }, + Ok((s,expr)) => { + let ctx = mk_ctx(sys,hand.reqnot()); + let expr = expr.to_api(&mut |f,r|do_extra(f,r,ctx.clone())); + let pos = (text.len()-s.len())as u32; + return hand.handle(&lex, &Some(Ok(api::LexedExpr { + pos,expr + }))) + } + + } + }writeln!(logger,"Got notified about n/a character '{trigger_char}'"); + hand.handle(&lex, &None).await + }, + api::HostExtReq::ParseLine(pline) => { + let api::ParseLine { + exported,comments,sys,line + } = &pline; + let mut ctx = mk_ctx(*sys,hand.reqnot()); + let parsers = ctx.cted.inst().dyn_parsers(); + let comments = comments.iter().map(Comment::from_api).collect(); + let line:Vec = ttv_from_api(line, &mut ctx); + let snip = Snippet::new(line.first().expect("Empty line"), &line); + let(head,tail) = snip.pop_front().unwrap(); + let name = if let GenTok::Name(n) = &head.tok { + n + }else { + panic!("No line head") + }; + let parser = parsers.iter().find(|p|p.line_head()== **name).expect("No parser candidate"); + let o_line = match parser.parse(*exported,comments,tail){ + Err(e) => Err(e.to_api()), + Ok(t) => Ok(ttv_to_api(t, &mut |f,range|{ + api::TokenTree { + range,token:api::Token::Atom(f.clone().build(ctx.clone())) + } + })), + + }; + hand.handle(&pline, &o_line).await + } + api::HostExtReq::AtomReq(atom_req) => { + let atom = atom_req.get_atom(); + with_atom_record(&mk_ctx,hand.reqnot(),atom, |nfo,ctx,id,buf|async { + let actx = AtomCtx(buf,atom.drop,ctx.clone()); + match&atom_req { + api::AtomReq::SerializeAtom(ser) => { + let mut buf = enc_vec(&id); + let refs_opt = nfo.serialize(actx, &mut buf); + hand.handle(ser, &refs_opt.map(|refs|(buf,refs))),await + } + api::AtomReq::AtomPrint(print@api::AtomPrint(_)) => hand.handle(print, &nfo.print(actx)).await, + api::AtomReq::Fwded(fwded) => { + let api::Fwded(_,key,payload) = &fwded; + let mut reply = Vec::new(); + let some = nfo.handle_req(actx,Sym::from_api(*key), &mut &payload[..], &mut reply); + hand.handle(fwded, &some.then_some(reply)).await + } + api::AtomReq::CallRef(call@api::CallRef(_,arg)) => { + let ret = nfo.call_ref(actx, *arg); + hand.handle(call, &ret.api_return(ctx.clone(), &mut |h|hand.defer_drop(h))).await + }, + api::AtomReq::FinalCall(call@api::FinalCall(_,arg)) => { + let ret = nfo.call(actx, *arg); + hand.handle(call, &ret.api_return(ctx.clone(), &mut |h|hand.defer_drop(h))).await + } + api::AtomReq::Command(cmd@api::Command(_)) => { + hand.handle(cmd, &match nfo.command(actx){ + Err(e) => Err(e.to_api()), + Ok(opt) => Ok(match opt { + None => api::NextStep::Halt, + Some(cont) => api::NextStep::Continue(cont.api_return(ctx.clone(), &mut |h|hand.defer_drop(h))), + + }) + + }).await + } + + } + }).await + }, + api::HostExtReq::DeserAtom(deser) => { + let api::DeserAtom(sys,buf,refs) = &deser; + let mut read = &mut &buf[..]; + let ctx = mk_ctx(*sys,hand.reqnot()); + let id = api::AtomId::decode(&mut read); + let inst = ctx.cted.inst(); + let nfo = atom_by_idx(inst.card(),id).expect("Deserializing atom with invalid ID"); + hand.handle(&deser, &nfo.deserialize(ctx.clone(),read,refs)).await + }, + orchid_api::HostExtReq::ApplyMacro(am) => { + let tok = hand.will_handle_as(&am); + let sys_ctx = mk_ctx(am.sys,hand.reqnot()); + let ctx = RuleCtx { + args:(am.params.into_iter()).map(|(k,v)|(Tok::from_api(k),mtreev_from_api(&v, &mut |_|panic!("No atom in macro prompt!")))).collect(),run_id:am.run_id,sys:sys_ctx.clone(), + }; + hand.handle_as(tok, &match apply_rule(am.id,ctx){ + Err(e) => e.keep_only(|e| *e!=err_cascade()).map(|e|Err(e.to_api())), + Ok(t) => Some(Ok(mtreev_to_api(&t, &mut |a|{ + api::MacroToken::Atom(a.clone().build(sys_ctx.clone())) + }))), + + }).await + } + + }; + receipt + }.boxed_local()) +}, ); init_replica(rn.clone().map()); while !exiting.load(Ordering::Relaxed) { diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_18_56-277370.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_18_56-277370.txt new file mode 100644 index 0000000..406253c --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_18_56-277370.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x7b98e2f6d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x7b98e14e0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x7b98e065b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x7b98e14f9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x7b98e14f931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x7b98e14f6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x7b98e14f8fdd - rust_begin_unwind + 7: 0x7b98de1a6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x5a2f48927da0 - >::from + 9: 0x5a2f48753db4 - ::fmt + 10: 0x7b98e1c12d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x7b98e14ea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x7b98e14eb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x5a2f4864df33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x5a2f4864c99f - rustfmt[d1e716a5735454ec]::execute + 15: 0x5a2f48647943 - rustfmt[d1e716a5735454ec]::main + 16: 0x5a2f4863be73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x5a2f4863c3f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x7b98e2a77ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x5a2f4864ef98 - main + 20: 0x7b98dce34e08 - + 21: 0x7b98dce34ecc - __libc_start_main + 22: 0x5a2f4862f6c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_19_06-277529.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_19_06-277529.txt new file mode 100644 index 0000000..a27700a --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_19_06-277529.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x7769ba36d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x7769b88e0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x7769b7a5b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x7769b88f9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x7769b88f931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x7769b88f6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x7769b88f8fdd - rust_begin_unwind + 7: 0x7769b55a6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x5c922ea84da0 - >::from + 9: 0x5c922e8b0db4 - ::fmt + 10: 0x7769b9012d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x7769b88ea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x7769b88eb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x5c922e7aaf33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x5c922e7a999f - rustfmt[d1e716a5735454ec]::execute + 15: 0x5c922e7a4943 - rustfmt[d1e716a5735454ec]::main + 16: 0x5c922e798e73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x5c922e7993f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x7769b9e77ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x5c922e7abf98 - main + 20: 0x7769b4145e08 - + 21: 0x7769b4145ecc - __libc_start_main + 22: 0x5c922e78c6c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_19_24-277744.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_19_24-277744.txt new file mode 100644 index 0000000..1fbe23c --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_19_24-277744.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x75c3f976d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x75c3f7ce0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x75c3f6e5b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x75c3f7cf9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x75c3f7cf931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x75c3f7cf6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x75c3f7cf8fdd - rust_begin_unwind + 7: 0x75c3f49a6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x630acd2a0da0 - >::from + 9: 0x630acd0ccdb4 - ::fmt + 10: 0x75c3f8412d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x75c3f7cea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x75c3f7ceb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x630accfc6f33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x630accfc599f - rustfmt[d1e716a5735454ec]::execute + 15: 0x630accfc0943 - rustfmt[d1e716a5735454ec]::main + 16: 0x630accfb4e73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x630accfb53f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x75c3f9277ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x630accfc7f98 - main + 20: 0x75c3f3634e08 - + 21: 0x75c3f3634ecc - __libc_start_main + 22: 0x630accfa86c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_21_19-278933.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_21_19-278933.txt new file mode 100644 index 0000000..b5a7a8e --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_21_19-278933.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x76753116d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x76752f6e0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x76752e85b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x76752f6f9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x76752f6f931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x76752f6f6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x76752f6f8fdd - rust_begin_unwind + 7: 0x76752c3a6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x5750f6273da0 - >::from + 9: 0x5750f609fdb4 - ::fmt + 10: 0x76752fe12d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x76752f6ea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x76752f6eb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x5750f5f99f33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x5750f5f9899f - rustfmt[d1e716a5735454ec]::execute + 15: 0x5750f5f93943 - rustfmt[d1e716a5735454ec]::main + 16: 0x5750f5f87e73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x5750f5f883f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x767530c77ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x5750f5f9af98 - main + 20: 0x76752aef0e08 - + 21: 0x76752aef0ecc - __libc_start_main + 22: 0x5750f5f7b6c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_21_48-279278.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_21_48-279278.txt new file mode 100644 index 0000000..054b874 --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_21_48-279278.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x7fbe8296d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x7fbe80ee0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x7fbe8005b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x7fbe80ef9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x7fbe80ef931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x7fbe80ef6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x7fbe80ef8fdd - rust_begin_unwind + 7: 0x7fbe7dba6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x645d8f426da0 - >::from + 9: 0x645d8f252db4 - ::fmt + 10: 0x7fbe81612d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x7fbe80eea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x7fbe80eeb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x645d8f14cf33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x645d8f14b99f - rustfmt[d1e716a5735454ec]::execute + 15: 0x645d8f146943 - rustfmt[d1e716a5735454ec]::main + 16: 0x645d8f13ae73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x645d8f13b3f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x7fbe82477ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x645d8f14df98 - main + 20: 0x7fbe7c745e08 - + 21: 0x7fbe7c745ecc - __libc_start_main + 22: 0x645d8f12e6c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_22_25-279679.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_22_25-279679.txt new file mode 100644 index 0000000..83b7071 --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_22_25-279679.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x7ae58e56d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x7ae58cae0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x7ae58bc5b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x7ae58caf9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x7ae58caf931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x7ae58caf6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x7ae58caf8fdd - rust_begin_unwind + 7: 0x7ae5897a6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x59f3f1d86da0 - >::from + 9: 0x59f3f1bb2db4 - ::fmt + 10: 0x7ae58d212d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x7ae58caea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x7ae58caeb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x59f3f1aacf33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x59f3f1aab99f - rustfmt[d1e716a5735454ec]::execute + 15: 0x59f3f1aa6943 - rustfmt[d1e716a5735454ec]::main + 16: 0x59f3f1a9ae73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x59f3f1a9b3f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x7ae58e077ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x59f3f1aadf98 - main + 20: 0x7ae588345e08 - + 21: 0x7ae588345ecc - __libc_start_main + 22: 0x59f3f1a8e6c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/orchid-extension/src/rustc-ice-2025-01-19T15_25_47-282159.txt b/orchid-extension/src/rustc-ice-2025-01-19T15_25_47-282159.txt new file mode 100644 index 0000000..fd0d095 --- /dev/null +++ b/orchid-extension/src/rustc-ice-2025-01-19T15_25_47-282159.txt @@ -0,0 +1,31 @@ +thread 'main' panicked at /rust/deps/annotate-snippets-0.9.2/src/display_list/from_snippet.rs:275:9: +SourceAnnotation range `(100, 102)` is bigger than source length `101` +stack backtrace: + 0: 0x7306aa96d725 - std::backtrace::Backtrace::create::hea54461184d28e5c + 1: 0x7306a8ee0cb5 - std::backtrace::Backtrace::force_capture::h50ac56ebac4f2900 + 2: 0x7306a805b0e0 - std[dd93a93a14cc3e06]::panicking::update_hook::>::{closure#0} + 3: 0x7306a8ef9623 - std::panicking::rust_panic_with_hook::hdfd8e9403702a2d1 + 4: 0x7306a8ef931a - std::panicking::begin_panic_handler::{{closure}}::h47998eb7cec3c619 + 5: 0x7306a8ef6ce9 - std::sys::backtrace::__rust_end_short_backtrace::h51610b4899330428 + 6: 0x7306a8ef8fdd - rust_begin_unwind + 7: 0x7306a5ba6b10 - core::panicking::panic_fmt::h76c97b2053f3e171 + 8: 0x646d10ca5da0 - >::from + 9: 0x646d10ad1db4 - ::fmt + 10: 0x7306a9612d66 - core::fmt::write::hbdbaf54d653bfdc0 + 11: 0x7306a8eea90e - <&std::io::stdio::Stderr as std::io::Write>::write_fmt::h297671288300128f + 12: 0x7306a8eeb2d8 - std::io::stdio::_eprint::hc00582a539350b14 + 13: 0x646d109cbf33 - rustfmt[d1e716a5735454ec]::format_and_emit_report:: + 14: 0x646d109ca99f - rustfmt[d1e716a5735454ec]::execute + 15: 0x646d109c5943 - rustfmt[d1e716a5735454ec]::main + 16: 0x646d109b9e73 - std[dd93a93a14cc3e06]::sys::backtrace::__rust_begin_short_backtrace:: + 17: 0x646d109ba3f9 - std[dd93a93a14cc3e06]::rt::lang_start::<()>::{closure#0} + 18: 0x7306aa477ade - std::rt::lang_start_internal::h1d6a430fc18f5497 + 19: 0x646d109ccf98 - main + 20: 0x7306a4745e08 - + 21: 0x7306a4745ecc - __libc_start_main + 22: 0x646d109ad6c9 - + 23: 0x0 - + + +rustc version: 1.86.0-nightly (419b3e2d3 2025-01-15) +platform: x86_64-unknown-linux-gnu \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml index 405ddbd..22936f6 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -7,7 +7,7 @@ style_edition = "2024" tab_spaces = 2 hard_tabs = true max_width = 100 -#error_on_line_overflow = true +error_on_line_overflow = true error_on_unformatted = true format_macro_matchers = true newline_style = "Unix"