pub fn prune_unreachable_prelude(source: &str) -> StringExpand description
Drop ONLY the auto-imported stdlib PRELUDE functions that are never reachable, keeping EVERY
user-defined function untouched. This is the chip-encoder analog of keep_reachable_functions, but
safe for LOGOS’s non-name( call forms: apply_prelude splices a WHOLE module when the program mentions
any of its names, so an UNCALLED prelude helper that reaches a host builtin (parseFloat, format, …)
would make the flat chip image reject even though it never runs. This prunes those dead prelude helpers
so the encoder lowers only what the program executes — with two safety differences from the C tree-shake:
• it NEVER drops a user function (the prune set is exactly the prelude vocabulary), so a user procedure
invoked by a LOGOS call form the call-only scan misses (Launch a task to worker, higher-order
apply(f, …)) is always kept;
• reachability uses the PERMISSIVE references (any use position — the same predicate apply_prelude
splices on), so a prelude function reached via to <fn> / of <fn> / a value position is retained.
The output is byte-identical to the input when nothing is pruned (no prelude, or all reachable), so the
AOT/other hot paths are untouched. Over-pruning can only ever surface as a LOUD undefined reference.