Skip to main content

Module ast_map

Module ast_map 

Source
Expand description

An exhaustive, rebuilding traversal of the imperative AST.

A pass implements AstMap, overrides the hooks for the nodes it rewrites, and calls the matching walk_* function for everything else; the walks rebuild each node from its mapped children into the pass’s arenas. Every Stmt, Expr and TypeExpr variant is named in its walk — there is no wildcard arm — so adding a variant to the language stops this file compiling until someone decides how it is traversed, and no pass built on it can silently skip one.

A few forms are carried through unchanged, each named: the logic-mode blocks and propositions (Assert, Trust, Theorem, Definition, Axiom, Theory) hold no imperative expressions, and the browser surface (Ui, ComponentDef, a RouteDef body, View) has its own lowering (parser::lgx_lower), which maps a route’s body before it becomes a function; every static backend refuses what is left of that surface before a rewriting pass runs.

Structs§

Arenas
Where a rewriting pass allocates the nodes it builds.

Traits§

AstMap
A rewriting pass over the imperative AST. Each hook’s default rebuilds the node from its mapped children.

Functions§

walk_arm
walk_block
walk_expr
walk_stmt
walk_type