Commit d2f563d
committed
refactor(codegen): extract affinescript.ownership emission to lib/tw_ownership_section.ml
Tranche A3 of docs/specs/TYPED-WASM-ROADMAP.adoc. Behaviour-preserving
move; downstream callers (lib/tw_verify.ml, lib/tw_interface.ml,
test/test_e2e.ml) are unaffected.
Why now: A3 was specified as a prerequisite for B1 (ADR-020 v2-parse
support, now ACCEPTED + RATIFIED 2026-05-24). Putting the on-wire
format in a dedicated module is cheap now and saves us editing
codegen.ml inline when v2-parse + v2-emit land.
Changes:
- NEW lib/tw_ownership_section.ml — the dedicated home for:
* type ownership_kind (Unrestricted/Linear/SharedBorrow/ExclBorrow)
* ownership_kind_of_param (extracts from p_ownership or type shape)
* ownership_kind_of_ret
* ownership_kind_byte (0..3 encoding)
* build_section (v1 binary serialiser)
- MOD lib/codegen.ml — re-exports preserve the [Codegen.X] surface:
* type ownership_kind = Tw_ownership_section.ownership_kind = | ...
(type equation keeps Codegen.Linear etc. resolving as
constructors so `open Codegen` in Tw_verify / Tw_interface /
Test_e2e continues to work)
* `let ownership_kind_of_param = Tw_ownership_section.…` and
friends — pure aliases.
* `let build_ownership_section = Tw_ownership_section.build_section`
— alias preserving the prior public name.
No semantic change. The v1 binary format and all enforcement (L7
aliasing + L10 linearity + L13 isolation) are unchanged. The 260+
test baseline should pass byte-for-byte; in particular the
ownership-section round-trip cases
(test_ownership_section_present / _roundtrip / _entry_count) test
the exact same serialisation path.
Not yet verified locally — no OCaml toolchain in this remote
execution environment. CI is the verification surface; the change
is mechanical and the type-equation re-export pattern is a
standard OCaml idiom.
Refs ADR-020, docs/specs/TYPED-WASM-ROADMAP.adoc §"Tranche A — A3"1 parent d4522e4 commit d2f563d
2 files changed
Lines changed: 122 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
111 | 116 | | |
112 | 117 | | |
113 | 118 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
127 | 122 | | |
128 | 123 | | |
129 | 124 | | |
| |||
136 | 131 | | |
137 | 132 | | |
138 | 133 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
146 | 137 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
150 | 141 | | |
151 | 142 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
178 | 149 | | |
179 | 150 | | |
180 | 151 | | |
| |||
| 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 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
0 commit comments