Skip to main content

count_dispatch

Function count_dispatch 

pub fn count_dispatch(source: &str) -> usize
Expand description

The Jones-optimality oracle: count the units of interpreter dispatch remaining in a residual program.

A residual that is genuinely Jones-optimal has dissolved the interpreter entirely and returns zero. One unit is counted for each of:

  • an Inspect arm dispatching on a Core IR variant (CInt, CIf, …);
  • an environment/function-map lookup item <literal> of env / ... of funcs;
  • a Core IR constructor (new CInt, a CInt(...) call, a VInt variant, …);
  • a call to a known dispatch function ([DISPATCH_FN_NAMES]).

Unlike verify_no_overhead_source, this walks the whole tree and accumulates a count rather than short-circuiting on the first violation.