count_nodes

Function count_nodes 

Source
pub fn count_nodes(e: &Exp) -> usize
Expand description

Count Exp tree nodes — used by Val::Display for #<code N nodes>, and by tests that need to bound compiled-ANF size.

Iterative (Vec-worklist) rather than recursive, so it can handle the deeply-nested Exp trees produced by Futamura-3 self-compilation without overflowing the native stack. Each pop adds one to the count and pushes the node’s children for later visitation; the final count is the total number of pops.