2023-10-29 17:29:16 -04:00
|
|
|
/// Write the implementation for the intermediate ast node for a type that is a noop or is not yet implemented.
|
|
|
|
|
///
|
|
|
|
|
/// This exists to make changing the type signature easier.
|
|
|
|
|
macro_rules! inoop {
|
|
|
|
|
($istruct:ident, $pstruct:ident) => {
|
|
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
|
pub(crate) struct $istruct {}
|
|
|
|
|
|
|
|
|
|
impl $istruct {
|
|
|
|
|
pub(crate) async fn new<'reg, 'orig, 'parse>(
|
2023-10-29 22:31:29 -04:00
|
|
|
_registry: crate::intermediate::RefRegistry<'orig, 'parse>,
|
|
|
|
|
_original: &'orig organic::types::$pstruct<'parse>,
|
2023-10-29 17:29:16 -04:00
|
|
|
) -> Result<$istruct, CustomError> {
|
|
|
|
|
Ok($istruct {})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use inoop;
|
|
|
|
|
|
|
|
|
|
/// Write the implementation for the intermediate ast node.
|
|
|
|
|
///
|
|
|
|
|
/// This exists to make changing the type signature easier.
|
|
|
|
|
macro_rules! intermediate {
|
2023-10-29 18:35:42 -04:00
|
|
|
($istruct:ident, $pstruct:ident, $original:ident, $registry:ident, $fnbody:tt) => {
|
2023-10-29 17:29:16 -04:00
|
|
|
impl $istruct {
|
2023-10-29 21:19:30 -04:00
|
|
|
pub(crate) async fn new<'orig, 'parse>(
|
|
|
|
|
registry: crate::intermediate::RefRegistry<'orig, 'parse>,
|
2023-10-29 17:29:16 -04:00
|
|
|
original: &'orig organic::types::$pstruct<'parse>,
|
|
|
|
|
) -> Result<$istruct, CustomError> {
|
2023-10-29 18:35:42 -04:00
|
|
|
let $original = original;
|
|
|
|
|
let $registry = registry;
|
|
|
|
|
$fnbody
|
2023-10-29 17:29:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use intermediate;
|
|
|
|
|
|
|
|
|
|
/// Write the implementation for the intermediate ast node.
|
|
|
|
|
///
|
|
|
|
|
/// This exists to make changing the type signature easier.
|
|
|
|
|
macro_rules! iselector {
|
2023-10-29 18:54:50 -04:00
|
|
|
($istruct:ident, $pstruct:ident, $original:ident, $registry:ident, $fnbody:tt) => {
|
2023-10-29 17:29:16 -04:00
|
|
|
impl $istruct {
|
2023-10-29 21:19:30 -04:00
|
|
|
pub(crate) fn new<'orig, 'parse>(
|
|
|
|
|
registry: crate::intermediate::RefRegistry<'orig, 'parse>,
|
2023-10-29 17:29:16 -04:00
|
|
|
original: &'orig organic::types::$pstruct<'parse>,
|
2023-10-29 21:19:30 -04:00
|
|
|
) -> BoxFuture<'orig, Result<$istruct, CustomError>> {
|
2023-10-29 20:01:44 -04:00
|
|
|
let $registry = registry;
|
|
|
|
|
let $original = original;
|
|
|
|
|
async move { $fnbody }.boxed()
|
2023-10-29 17:29:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use iselector;
|
2023-10-29 18:26:52 -04:00
|
|
|
|
|
|
|
|
macro_rules! iitem {
|
|
|
|
|
($registry:expr, $original:expr, $(($penum:path, $ienum:path, $istruct:ident),)*) => {
|
|
|
|
|
match $original {
|
|
|
|
|
$(
|
2023-10-29 18:54:50 -04:00
|
|
|
$penum(inner) => Ok($ienum(
|
2023-10-29 21:19:30 -04:00
|
|
|
$istruct::new($registry.clone(), inner).await?,
|
2023-10-29 18:26:52 -04:00
|
|
|
)),
|
|
|
|
|
)*
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) use iitem;
|