forked from Orchid/orchid
Fixed a very nasty deadlock
This commit is contained in:
@@ -15,7 +15,7 @@ pub async fn gen_macro_lib() -> Vec<GenMember> {
|
||||
prefix("macros", [
|
||||
fun(true, "resolve", async |tpl: TAtom<MacTree>| resolve(own(&tpl).await).await),
|
||||
prefix("common", [
|
||||
build_macro(None, ["..", "_"]).finish(),
|
||||
build_macro(None, ["..", "_", "="]).finish(),
|
||||
build_macro(Some(1), ["+"])
|
||||
.rule(mactreev!("...$" lhs 1 macros::common::+ "...$" rhs 0), [async |[lhs, rhs]| {
|
||||
call(sym_ref(sym!(std::ops::add::resolve)), [resolve(lhs).await, resolve(rhs).await])
|
||||
@@ -41,7 +41,7 @@ pub async fn gen_macro_lib() -> Vec<GenMember> {
|
||||
call(sym_ref(sym!(std::ops::mod::resolve)), [resolve(lhs).await, resolve(rhs).await])
|
||||
}])
|
||||
.finish(),
|
||||
build_macro(Some(10), ["."])
|
||||
build_macro(Some(3), ["."])
|
||||
.rule(mactreev!("...$" lhs 1 macros::common::. "...$" rhs 0), [async |[lhs, rhs]| {
|
||||
call(sym_ref(sym!(std::ops::get::resolve)), [resolve(lhs).await, resolve(rhs).await])
|
||||
}])
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::macros::macro_value::Macro;
|
||||
use crate::macros::mactree_lexer::MacTreeLexer;
|
||||
use crate::macros::match_macros::{MatcherAtom, gen_match_macro_lib};
|
||||
use crate::macros::ph_lexer::{PhAtom, PhLexer};
|
||||
use crate::macros::std_macros::gen_std_macro_lib;
|
||||
use crate::macros::stdlib::gen_std_macro_lib;
|
||||
use crate::macros::utils::MacroBodyArgCollector;
|
||||
use crate::{MacTree, StdSystem};
|
||||
|
||||
@@ -55,10 +55,14 @@ impl System for MacroSystem {
|
||||
sym!(macros::common::;),
|
||||
sym!(macros::common::..),
|
||||
sym!(macros::common::_),
|
||||
sym!(macros::common::=),
|
||||
sym!(macros::common::.),
|
||||
sym!(std::tuple::t),
|
||||
sym!(std::record::r),
|
||||
sym!(pattern::match),
|
||||
sym!(pattern::ref),
|
||||
sym!(pattern::=>),
|
||||
Sym::literal("std::fn::|>").await,
|
||||
]
|
||||
}
|
||||
fn lexers() -> Vec<LexerObj> { vec![&MacTreeLexer, &PhLexer] }
|
||||
|
||||
@@ -21,7 +21,6 @@ use orchid_extension::tree::{GenMember, fun, prefix};
|
||||
use crate::macros::resolve::resolve;
|
||||
use crate::macros::utils::{build_macro, mactree, mactreev};
|
||||
use crate::std::reflection::sym_atom::SymAtom;
|
||||
use crate::std::tuple::Tuple;
|
||||
use crate::{HomoTpl, MacTok, MacTree, OrcOpt, Tpl, UntypedTuple, api};
|
||||
|
||||
#[derive(Clone, Coding)]
|
||||
@@ -92,20 +91,15 @@ pub async fn gen_match_macro_lib() -> Vec<GenMember> {
|
||||
async |[value, rules]| {
|
||||
exec(async move |mut h| {
|
||||
let rule_lines = h
|
||||
.exec::<TAtom<Tuple>>(call(sym_ref(sym!(macros::resolve)), [
|
||||
.exec::<HomoTpl<TAtom<MacTree>>>(call(sym_ref(sym!(macros::resolve)), [
|
||||
mactree!(macros::common::semi_list "push" rules.clone();).to_gen().await,
|
||||
]))
|
||||
.await?;
|
||||
let mut rule_atoms = Vec::<(TAtom<MatcherAtom>, Expr)>::new();
|
||||
for line_exprh in rule_lines.iter() {
|
||||
let line_mac = h
|
||||
.exec::<TAtom<MacTree>>(Expr::from_handle(
|
||||
ExprHandle::from_ticket(*line_exprh).await,
|
||||
))
|
||||
.await?;
|
||||
for line_mac in rule_lines.0.iter() {
|
||||
let Tpl((matcher, body)) = h
|
||||
.exec(call(sym_ref(sym!(macros::resolve)), [
|
||||
mactree!(pattern::_row "push" own(&line_mac).await ;).to_gen().await,
|
||||
mactree!(pattern::_row "push" own(line_mac).await ;).to_gen().await,
|
||||
]))
|
||||
.await?;
|
||||
rule_atoms.push((matcher, body));
|
||||
|
||||
@@ -10,7 +10,7 @@ pub mod match_macros;
|
||||
mod ph_lexer;
|
||||
mod resolve;
|
||||
mod rule;
|
||||
pub mod std_macros;
|
||||
pub mod stdlib;
|
||||
mod utils;
|
||||
|
||||
use mactree::{MacTok, MacTree};
|
||||
|
||||
12
orchid-std/src/macros/stdlib/funnctional.rs
Normal file
12
orchid-std/src/macros/stdlib/funnctional.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use orchid_extension::tree::{GenMember, prefix};
|
||||
|
||||
use crate::macros::resolve::resolve;
|
||||
use crate::macros::utils::{build_macro, mactree, mactreev};
|
||||
|
||||
pub async fn gen_functional_macro_lib() -> Vec<GenMember> {
|
||||
prefix("std::fn", [build_macro(Some(4), ["|>"])
|
||||
.rule(mactreev!("...$" lhs 0 "std::fn::|>" "$" fun "...$" rhs 0), [async |[lhs, fun, rhs]| {
|
||||
resolve(mactree!(("push" fun ; "push" lhs ;) "pushv" rhs ;)).await
|
||||
}])
|
||||
.finish()])
|
||||
}
|
||||
20
orchid-std/src/macros/stdlib/mod.rs
Normal file
20
orchid-std/src/macros/stdlib/mod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
pub mod funnctional;
|
||||
pub mod option;
|
||||
pub mod record;
|
||||
pub mod tuple;
|
||||
|
||||
use orchid_extension::tree::{GenMember, merge_trivial};
|
||||
|
||||
use crate::macros::stdlib::funnctional::gen_functional_macro_lib;
|
||||
use crate::macros::stdlib::option::gen_option_macro_lib;
|
||||
use crate::macros::stdlib::record::gen_record_macro_lib;
|
||||
use crate::macros::stdlib::tuple::gen_tuple_macro_lib;
|
||||
|
||||
pub async fn gen_std_macro_lib() -> Vec<GenMember> {
|
||||
merge_trivial([
|
||||
gen_functional_macro_lib().await,
|
||||
gen_option_macro_lib().await,
|
||||
gen_tuple_macro_lib().await,
|
||||
gen_record_macro_lib().await,
|
||||
])
|
||||
}
|
||||
56
orchid-std/src/macros/stdlib/option.rs
Normal file
56
orchid-std/src/macros/stdlib/option.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
use futures::StreamExt;
|
||||
use orchid_base::sym;
|
||||
use orchid_extension::atom::TAtom;
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::coroutine_exec::exec;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::gen_expr::{call, sym_ref};
|
||||
use orchid_extension::tree::{GenMember, fun, prefix};
|
||||
|
||||
use crate::macros::match_macros::MatcherAtom;
|
||||
use crate::macros::resolve::resolve;
|
||||
use crate::macros::utils::{build_macro, mactree, mactreev};
|
||||
use crate::{OrcOpt, Tpl};
|
||||
|
||||
pub async fn gen_option_macro_lib() -> Vec<GenMember> {
|
||||
prefix("std::option", [
|
||||
fun(false, "is_some_body", |sub: TAtom<MatcherAtom>, val: OrcOpt<Expr>| {
|
||||
exec(async move |mut h| {
|
||||
let Some(sub_val) = val.0 else { return Ok(OrcOpt(None)) };
|
||||
sub.run_matcher(&mut h, sub_val).await
|
||||
})
|
||||
}),
|
||||
fun(
|
||||
false,
|
||||
"is_none_body",
|
||||
async |val: OrcOpt<Expr>| {
|
||||
if val.0.is_none() { OrcOpt(Some(Tpl(()))) } else { OrcOpt(None) }
|
||||
},
|
||||
),
|
||||
build_macro(None, ["some", "none"])
|
||||
.rule(mactreev!(pattern::match_rule ( std::option::some "...$" sub_pattern 0)), [
|
||||
|[sub]: [_; _]| {
|
||||
exec(async move |mut h| {
|
||||
let sub = h
|
||||
.exec::<TAtom<MatcherAtom>>(resolve(mactree!(pattern::match_rule "push" sub;)).await)
|
||||
.await?;
|
||||
Ok(MatcherAtom {
|
||||
keys: sub.keys().collect().await,
|
||||
matcher: h
|
||||
.register(call(sym_ref(sym!(std::option::is_some_body)), [sub.to_gen().await]))
|
||||
.await,
|
||||
})
|
||||
})
|
||||
},
|
||||
])
|
||||
.rule(mactreev!(pattern::match_rule(std::option::none)), [|[]: [_; _]| {
|
||||
exec(async |mut h| {
|
||||
Ok(MatcherAtom {
|
||||
keys: vec![],
|
||||
matcher: h.register(sym_ref(sym!(std::option::is_none_body))).await,
|
||||
})
|
||||
})
|
||||
}])
|
||||
.finish(),
|
||||
])
|
||||
}
|
||||
45
orchid-std/src/macros/stdlib/record.rs
Normal file
45
orchid-std/src/macros/stdlib/record.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use orchid_base::sym;
|
||||
use orchid_extension::atom::TAtom;
|
||||
use orchid_extension::atom_owned::own;
|
||||
use orchid_extension::conv::ToExpr;
|
||||
use orchid_extension::coroutine_exec::exec;
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::gen_expr::{call, sym_ref};
|
||||
use orchid_extension::tree::{GenMember, prefix};
|
||||
|
||||
use crate::macros::resolve::resolve;
|
||||
use crate::macros::utils::{build_macro, mactree, mactreev};
|
||||
use crate::std::string::str_atom::IntStrAtom;
|
||||
use crate::{HomoTpl, MacTree, Tpl};
|
||||
|
||||
pub async fn gen_record_macro_lib() -> Vec<GenMember> {
|
||||
prefix("std::record", [build_macro(None, ["r", "_row"])
|
||||
.rule(mactreev!(std::record::r[ "...$" elements 0 ]), [async |[elements]: [_; _]| {
|
||||
exec(async move |mut h| {
|
||||
let tup = h
|
||||
.exec::<HomoTpl<TAtom<MacTree>>>(call(sym_ref(sym!(macros::resolve)), [
|
||||
mactree!((macros::common::comma_list "push" elements ;)).to_gen().await,
|
||||
]))
|
||||
.await?;
|
||||
let mut record = sym_ref(sym!(std::record::empty));
|
||||
for item_exprh in tup.0 {
|
||||
let Tpl((key, value)) = h
|
||||
.exec::<Tpl<(TAtom<IntStrAtom>, Expr)>>(
|
||||
resolve(mactree!(std::record::_row "push" own(&item_exprh).await ;)).await,
|
||||
)
|
||||
.await?;
|
||||
record = call(sym_ref(sym!(std::record::set)), [
|
||||
record.to_gen().await,
|
||||
key.to_gen().await,
|
||||
value.to_gen().await,
|
||||
]);
|
||||
}
|
||||
Ok(record)
|
||||
})
|
||||
.await
|
||||
}])
|
||||
.rule(mactreev!(std::record::_row ( "$" name "...$" value 1 )), [async |[name, value]| {
|
||||
Ok(Tpl((resolve(name).await, resolve(value).await)))
|
||||
}])
|
||||
.finish()])
|
||||
}
|
||||
@@ -10,53 +10,11 @@ use orchid_extension::gen_expr::{GExpr, call, sym_ref};
|
||||
use orchid_extension::tree::{GenMember, fun, prefix};
|
||||
|
||||
use crate::macros::match_macros::MatcherAtom;
|
||||
use crate::macros::resolve::resolve;
|
||||
use crate::macros::utils::{build_macro, mactree, mactreev};
|
||||
use crate::{HomoTpl, MacTree, OrcOpt, Tpl};
|
||||
use crate::{HomoTpl, MacTree, OrcOpt};
|
||||
|
||||
pub async fn gen_std_macro_lib() -> Vec<GenMember> {
|
||||
prefix("std", [
|
||||
prefix("option", [
|
||||
fun(false, "is_some_body", |sub: TAtom<MatcherAtom>, val: OrcOpt<Expr>| {
|
||||
exec(async move |mut h| {
|
||||
let Some(sub_val) = val.0 else { return Ok(OrcOpt(None)) };
|
||||
sub.run_matcher(&mut h, sub_val).await
|
||||
})
|
||||
}),
|
||||
fun(false, "is_none_body", async |val: OrcOpt<Expr>| {
|
||||
if val.0.is_none() { OrcOpt(Some(Tpl(()))) } else { OrcOpt(None) }
|
||||
}),
|
||||
build_macro(None, ["some", "none"])
|
||||
.rule(mactreev!(pattern::match_rule ( std::option::some "...$" sub_pattern 0)), [
|
||||
|[sub]: [_; _]| {
|
||||
exec(async move |mut h| {
|
||||
let sub = h
|
||||
.exec::<TAtom<MatcherAtom>>(
|
||||
resolve(mactree!(pattern::match_rule "push" sub;)).await,
|
||||
)
|
||||
.await?;
|
||||
Ok(MatcherAtom {
|
||||
keys: sub.keys().collect().await,
|
||||
matcher: h
|
||||
.register(call(sym_ref(sym!(std::option::is_some_body)), [sub
|
||||
.to_gen()
|
||||
.await]))
|
||||
.await,
|
||||
})
|
||||
})
|
||||
},
|
||||
])
|
||||
.rule(mactreev!(pattern::match_rule(std::option::none)), [|[]: [_; _]| {
|
||||
exec(async |mut h| {
|
||||
Ok(MatcherAtom {
|
||||
keys: vec![],
|
||||
matcher: h.register(sym_ref(sym!(std::option::is_none_body))).await,
|
||||
})
|
||||
})
|
||||
}])
|
||||
.finish(),
|
||||
]),
|
||||
prefix("tuple", [
|
||||
pub async fn gen_tuple_macro_lib() -> Vec<GenMember> {
|
||||
prefix("std::tuple", [
|
||||
build_macro(None, ["t"])
|
||||
.rule(mactreev!(std::tuple::t [ "...$" elements 0 ]), [|[elements]: [_; _]| {
|
||||
exec(async move |mut h| {
|
||||
@@ -94,32 +52,7 @@ pub async fn gen_std_macro_lib() -> Vec<GenMember> {
|
||||
])
|
||||
.finish(),
|
||||
fun(false, "matcher_body", tuple_matcher_body),
|
||||
]),
|
||||
prefix("record", [
|
||||
build_macro(None, ["r"])
|
||||
.rule(mactreev!(std::record::r[ "...$" elements 0 ]), [async |[elements]: [_;_]| {
|
||||
exec(async move |mut h| {
|
||||
let tup = h
|
||||
.exec::<HomoTpl<TAtom<MacTree>>>(call(sym_ref(sym!(macros::resolve)), [
|
||||
mactree!((macros::common::comma_list "push" elements ;)).to_gen().await,
|
||||
]))
|
||||
.await?;
|
||||
let val = stream::iter(&tup.0[..])
|
||||
.fold(sym_ref(sym!(std::tuple::empty)), async |head, new| {
|
||||
call(sym_ref(sym!(std::tuple::cat)), [
|
||||
head,
|
||||
call(sym_ref(sym!(std::tuple::one)), [call(
|
||||
sym_ref(sym!(macros::resolve)),
|
||||
[new.clone().to_gen().await],
|
||||
)]),
|
||||
])
|
||||
})
|
||||
.await;
|
||||
Ok(val)
|
||||
}).await
|
||||
}]).finish(),
|
||||
])
|
||||
])
|
||||
}
|
||||
|
||||
fn parse_tpl(elements: MacTree, tail_matcher: Option<MacTree>) -> impl Future<Output = GExpr> {
|
||||
@@ -188,6 +188,15 @@ macro_rules! mactreev_impl {
|
||||
$ret.push($arg);
|
||||
$crate::macros::utils::mactreev_impl!(@RECUR $ret $($tail)*);
|
||||
};
|
||||
(@RECUR $ret:ident "pushv" $arg:expr ; $($tail:tt)*) => {
|
||||
let $crate::macros::mactree::MacTok::S(_, body) = $arg.tok() else {
|
||||
panic!("pushv used with non-vec value")
|
||||
};
|
||||
for item in body.items.iter() {
|
||||
$ret.push(item.clone());
|
||||
}
|
||||
$crate::macros::utils::mactreev_impl!(@RECUR $ret $($tail)*);
|
||||
};
|
||||
(@RECUR $ret:ident "l_" $arg:expr ; ($($body:tt)*) $($tail:tt)*) => {
|
||||
$ret.push(MacTok::Lambda(
|
||||
MacTok::Name($arg).at(orchid_base::location::Pos::Inherit),
|
||||
|
||||
@@ -5,11 +5,12 @@ use std::rc::Rc;
|
||||
use futures::AsyncWrite;
|
||||
use futures::future::join_all;
|
||||
use hashbrown::HashMap;
|
||||
use orchid_api_derive::Coding;
|
||||
use orchid_api_traits::{Encode, Request};
|
||||
use orchid_base::interner::{IStr, es};
|
||||
use orchid_base::name::Sym;
|
||||
use orchid_base::sym;
|
||||
use orchid_extension::atom::{Atomic, Supports};
|
||||
use orchid_extension::atom::{Atomic, MethodSetBuilder, Supports};
|
||||
use orchid_extension::atom_owned::{DeserializeCtx, OwnedAtom, OwnedVariant};
|
||||
use orchid_extension::expr::Expr;
|
||||
use orchid_extension::gen_expr::sym_ref;
|
||||
@@ -18,12 +19,15 @@ use crate::api;
|
||||
use crate::std::protocol::types::{GetImplMethod, GetTagIdMethod};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Record(pub Rc<HashMap<IStr, Expr>>);
|
||||
impl Atomic for Record {
|
||||
pub struct RecordAtom(pub Rc<HashMap<IStr, Expr>>);
|
||||
impl Atomic for RecordAtom {
|
||||
type Data = ();
|
||||
type Variant = OwnedVariant;
|
||||
fn reg_reqs() -> MethodSetBuilder<Self> {
|
||||
MethodSetBuilder::new().handle::<GetTagIdMethod>().handle::<GetImplMethod>()
|
||||
}
|
||||
}
|
||||
impl OwnedAtom for Record {
|
||||
impl OwnedAtom for RecordAtom {
|
||||
type Refs = Vec<Expr>;
|
||||
async fn serialize(&self, write: Pin<&mut (impl AsyncWrite + ?Sized)>) -> Self::Refs {
|
||||
let (keys, values) =
|
||||
@@ -34,17 +38,17 @@ impl OwnedAtom for Record {
|
||||
async fn deserialize(mut dctx: impl DeserializeCtx, refs: Self::Refs) -> Self {
|
||||
let keys =
|
||||
join_all(dctx.decode::<Vec<api::TStr>>().await.iter().map(|t| async { es(*t).await })).await;
|
||||
Record(Rc::new(keys.into_iter().zip(refs).collect()))
|
||||
RecordAtom(Rc::new(keys.into_iter().zip(refs).collect()))
|
||||
}
|
||||
|
||||
async fn val(&self) -> Cow<'_, Self::Data> { Cow::Owned(()) }
|
||||
}
|
||||
impl Supports<GetTagIdMethod> for Record {
|
||||
impl Supports<GetTagIdMethod> for RecordAtom {
|
||||
async fn handle(&self, _: GetTagIdMethod) -> <GetTagIdMethod as Request>::Response {
|
||||
Sym::literal("std::record::Record").await.to_api()
|
||||
}
|
||||
}
|
||||
impl Supports<GetImplMethod> for Record {
|
||||
impl Supports<GetImplMethod> for RecordAtom {
|
||||
async fn handle(&self, req: GetImplMethod) -> <GetImplMethod as Request>::Response {
|
||||
let name = Sym::from_api(req.0).await;
|
||||
let val = if name == sym!(std::ops::get) {
|
||||
@@ -57,3 +61,9 @@ impl Supports<GetImplMethod> for Record {
|
||||
Some(val.create().await.serialize().await)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Coding)]
|
||||
pub struct CreateRecord(pub std::collections::HashMap<api::TStr, api::ExprTicket>);
|
||||
impl Request for CreateRecord {
|
||||
type Response = api::ExprTicket;
|
||||
}
|
||||
|
||||
@@ -7,24 +7,24 @@ use orchid_extension::expr::Expr;
|
||||
use orchid_extension::tree::{GenMember, cnst, fun, prefix};
|
||||
|
||||
use crate::std::option::OrcOpt;
|
||||
use crate::std::record::record_atom::Record;
|
||||
use crate::std::record::record_atom::RecordAtom;
|
||||
use crate::std::string::str_atom::IntStrAtom;
|
||||
|
||||
pub fn gen_record_lib() -> Vec<GenMember> {
|
||||
prefix("std::record", [
|
||||
cnst(true, "empty", Record(Rc::new(HashMap::new()))),
|
||||
fun(true, "set", async |map: TAtom<Record>, key: IntStrAtom, val: Expr| {
|
||||
cnst(true, "empty", RecordAtom(Rc::new(HashMap::new()))),
|
||||
fun(true, "set", async |map: TAtom<RecordAtom>, key: IntStrAtom, val: Expr| {
|
||||
let mut map = own(&map).await.0.as_ref().clone();
|
||||
map.insert(key.0.clone(), val);
|
||||
Record(Rc::new(map))
|
||||
RecordAtom(Rc::new(map))
|
||||
}),
|
||||
fun(true, "get", async |map: TAtom<Record>, key: IntStrAtom| {
|
||||
fun(true, "get", async |map: TAtom<RecordAtom>, key: IntStrAtom| {
|
||||
OrcOpt(own(&map).await.0.get(&key.0).cloned())
|
||||
}),
|
||||
fun(true, "delete", async |map: TAtom<Record>, key: IntStrAtom| {
|
||||
fun(true, "delete", async |map: TAtom<RecordAtom>, key: IntStrAtom| {
|
||||
let mut map = own(&map).await.0.as_ref().clone();
|
||||
map.remove(&key.0);
|
||||
Record(Rc::new(map))
|
||||
RecordAtom(Rc::new(map))
|
||||
}),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::rc::Rc;
|
||||
|
||||
use futures::future::join_all;
|
||||
use orchid_api_derive::{Coding, Hierarchy};
|
||||
use orchid_base::interner::es;
|
||||
use orchid_base::name::Sym;
|
||||
use orchid_base::reqnot::{Receipt, ReqHandle, ReqHandleExt};
|
||||
use orchid_base::sym;
|
||||
@@ -23,7 +24,7 @@ use crate::std::option::{OptAtom, gen_option_lib};
|
||||
use crate::std::protocol::proto_parser::{AsProtoParser, ProtoParser};
|
||||
use crate::std::protocol::type_parser::{AsTypeParser, TypeParser};
|
||||
use crate::std::protocol::types::{CreateTag, Tag, Tagged, gen_protocol_lib};
|
||||
use crate::std::record::record_atom::Record;
|
||||
use crate::std::record::record_atom::{CreateRecord, RecordAtom};
|
||||
use crate::std::record::record_lib::gen_record_lib;
|
||||
use crate::std::reflection::sym_atom::{CreateSymAtom, SymAtom, gen_sym_lib};
|
||||
use crate::std::string::str_lexer::StringLexer;
|
||||
@@ -36,6 +37,7 @@ use crate::{Float, Int};
|
||||
pub enum StdReq {
|
||||
CreateTag(CreateTag),
|
||||
CreateTuple(CreateTuple),
|
||||
CreateRecord(CreateRecord),
|
||||
CreateSymAtom(CreateSymAtom),
|
||||
}
|
||||
|
||||
@@ -58,7 +60,7 @@ impl SystemCard for StdSystem {
|
||||
Some(StrAtom::dynfo()),
|
||||
Some(IntStrAtom::dynfo()),
|
||||
Some(OptAtom::dynfo()),
|
||||
Some(Record::dynfo()),
|
||||
Some(RecordAtom::dynfo()),
|
||||
Some(Tuple::dynfo()),
|
||||
Some(TupleBuilder::dynfo()),
|
||||
Some(Tag::dynfo()),
|
||||
@@ -74,6 +76,14 @@ impl System for StdSystem {
|
||||
let tk = tpl.to_expr().await.serialize().await;
|
||||
xreq.reply(req, &tk).await.unwrap()
|
||||
},
|
||||
StdReq::CreateRecord(ref req @ CreateRecord(ref items)) => {
|
||||
let values =
|
||||
join_all(items.iter().map(async |(k, v)| (es(*k).await, Expr::deserialize(*v).await)))
|
||||
.await;
|
||||
let rec = RecordAtom(Rc::new(values.into_iter().collect()));
|
||||
let tk = rec.to_expr().await.serialize().await;
|
||||
xreq.reply(req, &tk).await.unwrap()
|
||||
},
|
||||
StdReq::CreateSymAtom(ref req @ CreateSymAtom(sym_tok)) => {
|
||||
let sym_atom = SymAtom(Sym::from_api(sym_tok).await);
|
||||
xreq.reply(req, &sym_atom.to_expr().await.serialize().await).await.unwrap()
|
||||
@@ -109,5 +119,7 @@ impl System for StdSystem {
|
||||
gen_ops_lib(),
|
||||
])
|
||||
}
|
||||
async fn prelude() -> Vec<Sym> { vec![sym!(std), sym!(std::tuple), sym!(std::option)] }
|
||||
async fn prelude() -> Vec<Sym> {
|
||||
vec![sym!(std), sym!(std::tuple), sym!(std::option), sym!(std::record)]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user