Lines
0 %
Functions
Branches
100 %
//! Hand-written recursive accessor on the `$report_node` entity.
//!
//! Lives outside the tangled `typed_entity.rs` because the
//! `children` field's `PairRef(Entity(ReportNode))` return type
//! doesn't fit the simple-ident shape the tangler emits. The
//! compile path follows the same template every other accessor
//! uses: validate arity, push the entity arg via
//! `compile_for_stack`, kind-check, `struct.get`. Field 4 is the
//! children pair per the layout in `entity_registry.org`.
use super::super::context::CompileContext;
use super::super::emit::FunctionEmitter;
use super::NativeSpec;
use crate::ast::{EntityKind, Expr, PairElement, WasmType};
use crate::error::{Error, Result};
use crate::runtime::SymbolTable;
fn node_children_eval(_symbols: &mut SymbolTable, args: &[Expr]) -> Result<Expr> {
if args.len() != 1 {
return Err(Error::Arity {
name: "NODE-CHILDREN".to_string(),
expected: 1,
actual: args.len(),
});
}
Ok(Expr::WasmRuntime(WasmType::PairRef(PairElement::Entity(
EntityKind::ReportNode,
))))
fn node_children_stack(
ctx: &mut CompileContext,
emit: &mut FunctionEmitter,
symbols: &mut SymbolTable,
args: &[Expr],
) -> Result<WasmType> {
let ty = crate::compiler::expr::compile_for_stack(ctx, emit, symbols, &args[0])?;
let expected = WasmType::EntityRef(EntityKind::ReportNode);
if ty != expected {
return Err(Error::Type {
expected: format!("{expected} for NODE-CHILDREN"),
actual: ty.to_string(),
emit.struct_get(ctx.ids.ty_report_node, 4);
Ok(WasmType::PairRef(PairElement::Entity(
)))
pub(in crate::compiler::native) const NATIVES: &[NativeSpec] = &[NativeSpec {
name: "NODE-CHILDREN",
eval: node_children_eval,
stack: Some(node_children_stack),
effect: None,
}];