v5 Linker

  • validate module graph first
  • enforce unique names, main-last, imports-first
  • then merge artifacts

Function rebasing

  • offset = total functions emitted so far
  • for each module function: id += offset
  • rewrite every MAKE_CLOSURE immediate in function bodies and MAIN
  • offset += module function count

Dependency order

  • import can only target earlier module
  • map name -> module index
  • reject unknown/future imports deterministically

Init semantics

  • concatenate MAIN blocks in module order
  • main runs last
  • deterministic initialization side effects

Failure checks

  • duplicate module names
  • duplicate function IDs after rewrite
  • closure id out of merged function range
  • malformed module graph

Reliability checklist

  • clone instruction slices before in-place rewrite
  • rewrite pass is deterministic and single-shot
  • first-error output for reproducibility
1 / 1
Use arrow keys or click edges to navigate. Press H to toggle help, F for fullscreen.