Module staging

Module staging 

Source
Expand description

Pink bridge layer: Exp ↔ Val cons-list conversion and the trans pass.

Three passes connect expression trees to source-as-data:

  • trans is base.scm’s trans: it rewrites an s-expression value into the nameless source encoding — symbols become (var n) lists by position in a name environment, binders lose their names — leaving everything else as tagged lists.
  • val_cons_to_exp finishes what trans starts, converting the nameless encoding into an actual Exp tree the machine can run.
  • exp_to_val_cons goes the other way, rendering an Exp back into the nameless list encoding; trans uses it to splice already-compiled code (a (name . code) env entry) into its output.

All three are iterative (explicit heap work stacks): arbitrarily deep Pink source trees cannot overflow the native stack.