Skip to main content

Module traverse

Module traverse 

Source
Expand description

Tree traversal utilities for AIRL IR nodes.

Since nodes are inline trees (not graph-referenced), these utilities provide the building blocks for finding, replacing, and transforming nodes by their NodeId.

Functionsยง

collect_node_ids
Collect all NodeIds in a tree.
find_containing_function
Find which function contains a node with the given ID.
find_node
Find a node by ID in a tree, returning a reference to it.
functions_containing_node
Collect all function IDs that contain a given node ID.
node_contains_id
Check if a node tree contains a node with the given ID.
rename_in_tree
Rename all occurrences of a symbol in a node tree. Renames: variable names in Param/Let, call targets in Call.
replace_node_in_tree
Replace a node by ID in a tree, returning a new tree with the replacement. Returns None if the target was not found.