organic/src/wasm/subscript.rs

43 lines
1000 B
Rust
Raw Normal View History

use serde::Deserialize;
use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use crate::types::Subscript;
2024-01-01 18:34:10 -05:00
use crate::util::elisp_fact::ElispFact;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
2023-12-29 12:49:43 -05:00
pub struct WasmSubscript {
2023-12-29 23:46:47 -05:00
#[serde(rename = "use-brackets-p")]
pub(crate) use_brackets: bool,
}
to_wasm!(
2023-12-29 12:49:43 -05:00
WasmSubscript,
2023-12-25 11:51:39 -05:00
Subscript<'s>,
2023-12-25 12:32:35 -05:00
original,
wasm_context,
{ WasmAstNode::Subscript(original) },
2023-12-29 23:46:47 -05:00
{ "subscript".into() },
{
let children = original
.children
.iter()
.map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode>::into)
})
.collect::<Result<Vec<_>, _>>()?;
Ok((
children,
WasmSubscript {
2023-12-29 23:46:47 -05:00
use_brackets: original.use_brackets,
},
))
}
);