Cut down on macro nonsense
- InertAtomic replaced atomic_inert! for improved tooling support - atomic_defaults! is easier to type out than to explain in a docstring - Changed rustfmt config to better support tiny functions such as as_any
This commit is contained in:
@@ -12,19 +12,19 @@ use crate::{ast, define_fn, ConstTree, Interner, Primitive};
|
||||
define_fn! {
|
||||
ReadString = |x| Ok(init_cps(3, IOCmdHandlePack{
|
||||
cmd: ReadCmd::RStr(SRead::All),
|
||||
handle: x.try_into()?
|
||||
handle: x.downcast()?
|
||||
}))
|
||||
}
|
||||
define_fn! {
|
||||
ReadLine = |x| Ok(init_cps(3, IOCmdHandlePack{
|
||||
cmd: ReadCmd::RStr(SRead::Line),
|
||||
handle: x.try_into()?
|
||||
handle: x.downcast()?
|
||||
}))
|
||||
}
|
||||
define_fn! {
|
||||
ReadBin = |x| Ok(init_cps(3, IOCmdHandlePack{
|
||||
cmd: ReadCmd::RBytes(BRead::All),
|
||||
handle: x.try_into()?
|
||||
handle: x.downcast()?
|
||||
}))
|
||||
}
|
||||
define_fn! {
|
||||
@@ -72,7 +72,7 @@ define_fn! {
|
||||
define_fn! {
|
||||
Flush = |x| Ok(init_cps(3, IOCmdHandlePack {
|
||||
cmd: WriteCmd::Flush,
|
||||
handle: x.try_into()?
|
||||
handle: x.downcast()?
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -81,23 +81,23 @@ pub enum ReadResult {
|
||||
impl ReadResult {
|
||||
pub fn dispatch(self, succ: ExprInst, fail: ExprInst) -> Vec<ExprInst> {
|
||||
match self {
|
||||
ReadResult::RBin(_, Err(e)) | ReadResult::RStr(_, Err(e)) =>
|
||||
vec![call(fail, vec![wrap_io_error(e)]).wrap()],
|
||||
ReadResult::RBin(_, Err(e)) | ReadResult::RStr(_, Err(e)) => {
|
||||
vec![call(fail, vec![wrap_io_error(e)]).wrap()]
|
||||
},
|
||||
ReadResult::RBin(_, Ok(bytes)) => {
|
||||
let arg = Binary(Arc::new(bytes)).atom_cls().wrap();
|
||||
vec![call(succ, vec![arg]).wrap()]
|
||||
},
|
||||
ReadResult::RStr(_, Ok(text)) =>
|
||||
vec![call(succ, vec![Literal::Str(text.into()).into()]).wrap()],
|
||||
ReadResult::RStr(_, Ok(text)) => {
|
||||
vec![call(succ, vec![Literal::Str(text.into()).into()]).wrap()]
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Placeholder function for an eventual conversion from [io::Error] to Orchid
|
||||
/// data
|
||||
fn wrap_io_error(_e: io::Error) -> ExprInst {
|
||||
Literal::Uint(0u64).into()
|
||||
}
|
||||
fn wrap_io_error(_e: io::Error) -> ExprInst { Literal::Uint(0u64).into() }
|
||||
|
||||
/// Writing command (string or binary)
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
||||
Reference in New Issue
Block a user