use super::VastTreeWalkPlan;
use vyre_foundation::ir::Program;
use vyre_primitives::graph::vast_tree_walk::{
try_ast_walk_plan, try_ast_walk_postorder, try_ast_walk_preorder, POSTORDER_OP_ID,
PREORDER_OP_ID,
};
pub fn build_vast_tree_walk_plan(
nodes: &str,
preorder_out: &str,
postorder_out: &str,
node_count: u32,
traversal_capacity: u32,
) -> Result<VastTreeWalkPlan, String> {
use crate::observability::{bump, vast_tree_walk_calls};
bump(&vast_tree_walk_calls);
bump(&vast_tree_walk_calls);
try_ast_walk_plan(
nodes,
preorder_out,
postorder_out,
node_count,
traversal_capacity,
)
}
pub fn build_checked_preorder_walk(
nodes: &str,
out: &str,
node_count: u32,
traversal_capacity: u32,
) -> Result<Program, String> {
use crate::observability::{bump, vast_tree_walk_calls};
bump(&vast_tree_walk_calls);
try_ast_walk_preorder(nodes, out, node_count, traversal_capacity)
}
pub fn build_checked_postorder_walk(
nodes: &str,
out: &str,
node_count: u32,
traversal_capacity: u32,
) -> Result<Program, String> {
use crate::observability::{bump, vast_tree_walk_calls};
bump(&vast_tree_walk_calls);
try_ast_walk_postorder(nodes, out, node_count, traversal_capacity)
}
#[must_use]
pub fn build_trusted_preorder_walk(
nodes: &str,
out: &str,
node_count: u32,
traversal_capacity: u32,
) -> Program {
use crate::observability::{bump, vast_tree_walk_calls};
bump(&vast_tree_walk_calls);
try_ast_walk_preorder(nodes, out, node_count, traversal_capacity).unwrap_or_else(|error| {
panic!("trusted VAST preorder walk shape was not prevalidated: {error}")
})
}
#[must_use]
pub fn build_trusted_postorder_walk(
nodes: &str,
out: &str,
node_count: u32,
traversal_capacity: u32,
) -> Program {
use crate::observability::{bump, vast_tree_walk_calls};
bump(&vast_tree_walk_calls);
try_ast_walk_postorder(nodes, out, node_count, traversal_capacity).unwrap_or_else(|error| {
panic!("trusted VAST postorder walk shape was not prevalidated: {error}")
})
}
#[must_use]
pub const fn primitive_op_ids() -> [&'static str; 2] {
[PREORDER_OP_ID, POSTORDER_OP_ID]
}