// Moved from apps/selfhost-compiler/builder/mod.hako
// builder/mod.hako — Aggregator for compiler-track passes (scaffold)

using lang.compiler.builder.ssa.localvar as LocalSSA
using lang.compiler.builder.ssa.loopssa as LoopSSA
using lang.compiler.builder.rewrite.special as RewriteSpecial
using lang.compiler.builder.rewrite.known as RewriteKnown

static box CompilerBuilder {
  // Apply passes in safe order; currently no-ops (behavior-neutral).
  apply_all(stage1_json) {
    local j = stage1_json
    j = RewriteSpecial.apply(j)
    j = RewriteKnown.try_apply(j)
    j = LocalSSA.ensure_recv(j)
    j = LocalSSA.ensure_args(j)
    j = LocalSSA.ensure_cond(j)
    j = LocalSSA.ensure_cmp(j)
    j = LoopSSA.stabilize_merges(j)
    return j
  }
}

