You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: renew SPEC §8 as real spec; expand codegen-environment to full realisation (#106)
* docs: thin SPEC.adoc §8 to forward-reference codegen-environment.adoc
PR #94 landed the full codegen environment reference as
docs/specs/codegen-environment.adoc. §8 in SPEC.adoc is now redundant;
replace its body with a one-paragraph forward-reference to avoid
maintaining two copies.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs: promote SPEC §8 to real spec; expand codegen-environment to full realisation
Reverses direction from the prior commit on this branch (which thinned
§8 to a one-paragraph forward-reference).
SPEC.adoc §8 — "Top-Level Binding Environment"
- Renamed from "Codegen Module Environment" (which was wrong layer — it
described implementation, not language).
- Now a proper, target-agnostic specification:
- 8.1 Top-Level Kinds — table of all eight constructors of `top_level`,
what each binds, whether it has a runtime artefact.
- 8.2 Declaration Order and Visibility — source-order processing,
no forward references, recommended ordering.
- 8.3 Identifier Resolution — local → variant tag → top-level lookup
order with positional rules.
- 8.4 Cross-Module Bindings — fn/extern fn flow, const restriction
documented as known gap.
- 8.5 Conformance Criteria — six MUST clauses (C1–C6) that any
code generator has to satisfy.
- Voice matches §1–§7 (judgement-form clauses, target-agnostic).
codegen-environment.adoc — full WebAssembly realisation reference
- Reframed as "WebAssembly Realisation of SPEC §8".
- Added `ctx` record reproduction with field-by-field semantics.
- Promoted `func_indices` encoding to its own §3 with a decode table.
- §4 walks every `gen_decl` arm (TopFn, FnExtern legacy, TopExternFn,
TopConst, TopType, TopExternType, TopEffect/Trait/Impl) in
implementation order, naming concrete steps and side-effects.
- §5 documents `gen_imports` end-to-end (load, find, intern, import,
register) plus glob expansion.
- §6 documents the actual ExprVar/ExprApp resolution paths.
- §7 cross-walks the SPEC §8.5 criteria C1–C6 against codegen.ml sites.
- §8 per-target matrix covers js/rust/ocaml/codegen_gc/codegen_node
plus the loud-fail policy for the remaining backends.
- §9 worked example traces a const-then-fn program through codegen.
- §10 records #73 as CLOSED, since the negative-sentinel ExprVar arm
at lib/codegen.ml:442–445 resolves it.
Net effect: SPEC.adoc gains a real §8 instead of a placeholder pointer;
codegen-environment.adoc becomes a usable implementation manual for
contributors landing new back-ends.
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments