MCPcopy Create free account
hub / github.com/ControlCplusControlV/Scribe / walk_ast

Function walk_ast

crates/papyrus/src/ast_optimization.rs:21–29  ·  view source on GitHub ↗

Walks through each expression in the abstract syntax tree, optimizing the AST where possible. A new, optimized AST is returned Which is then passed into the Miden generation logic.

(ast: Vec<Expr>, visitor: &mut V)

Source from the content-addressed store, hash-verified

19// Walks through each expression in the abstract syntax tree, optimizing the AST where possible. A new, optimized AST is returned
20//Which is then passed into the Miden generation logic.
21fn walk_ast<V: ExpressionVisitor>(ast: Vec<Expr>, visitor: &mut V) -> Vec<Expr> {
22 let mut new_ast = vec![];
23 for expr in ast {
24 if let Some(expr) = walk_expr(expr, visitor) {
25 new_ast.push(expr);
26 }
27 }
28 new_ast
29}
30
31trait ExpressionVisitor {
32 fn visit_expr(&mut self, expr: Expr) -> Option<Expr>;

Callers 1

walk_exprFunction · 0.85

Calls 2

walk_exprFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected