Commit 21988c5
committed
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.1 parent 6669acb commit 21988c5
2 files changed
Lines changed: 472 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
| 653 | + | |
654 | 654 | | |
655 | | - | |
656 | | - | |
657 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
658 | 795 | | |
659 | 796 | | |
660 | 797 | | |
| |||
0 commit comments