Commit 2adf260
committed
refactor(tw): extract Tw_section.Encode.ownership; delete orphan tw_ownership_section.ml
Establishes lib/tw_section.{ml,mli} as the canonical home for typed-wasm
custom-section wire encoders, sized to absorb proposal 0001's two new
sections (typedwasm.regions, typedwasm.capabilities) when they land.
Changes:
- lib/tw_section.ml{,i} created. Encode.ownership operates on
pre-byte-encoded triples ((int * int list * int) list) — avoids
a Codegen→Tw_section→Codegen type cycle while keeping the byte
layout intact.
- lib/codegen.ml:159-177 — build_ownership_section body replaced
with a 6-line wrapper that maps ownership_kind→byte and delegates
to Tw_section.Encode.ownership. Same signature, byte-equal output.
- lib/dune — tw_section module added.
- lib/tw_ownership_section.ml DELETED. Was orphan: not in lib/dune
modules list, no callers, only string-mentioned in tw_verify.ml's
stale doc comment (which is also fixed here).
- lib/tw_verify.ml:213 — stale doc comment updated:
Tw_ownership_section.build_section → Tw_section.Encode.ownership.
Rationale: #444 — prevent the
3-sections × 2-copies = 6-encoder fan-out when proposal 0001
(hyperpolymath/typed-wasm#34, hyperpolymath/typed-wasm#76) lands.
Sharing the internal LE writers (write_u32_le / write_u8) inside
Tw_section.Encode means future Encode.regions / Encode.capabilities
land in one place rather than duplicating the buffer plumbing.
ADR-021 v2-emit flip is OUT OF SCOPE. Tw_section.Encode.ownership
ships v1. When the cross-repo coordination unblocks, the flip is
a localised change to this one module.
Tea_* hand-rolled fixture encoders (lib/tea_bridge.ml,
lib/tea_cs_bridge.ml, lib/tea_router.ml) are intentionally NOT
migrated in this PR — they hard-code demo bytes for tea
demonstrations, which is a separate concern from the live
producer-side dedup.
Verification: dune build clean; dune runtest 352/352 passing
(round-trip tests would catch any byte divergence).
Refs #444
Refs hyperpolymath/typed-wasm#34
Refs hyperpolymath/typed-wasm#761 parent 9b9b321 commit 2adf260
6 files changed
Lines changed: 69 additions & 115 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
178 | 166 | | |
179 | 167 | | |
180 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
0 commit comments