Commit ce324fa
feat(codegen): export
The AST has carried `fd_vis : visibility` since forever; the parser has
accepted `pub fn` since forever; the `PUB` token has been wired through
lexer + parser_driver. Only the two WASM backends (codegen.ml:1724 and
codegen_gc.ml:1110) were ignoring `fd_vis` and instead consulting a
hardcoded name allowlist:
["main"; "init_state"; "step_state"; "get_state"; "mission_active"]
This commit makes both backends honour `fd_vis = Public` as well. The
game-hook allowlist is retained verbatim for backward compat with
pre-`pub` programs (IDApTIK CharacterSelect bridge et al.), so:
- `pub fn foo() -> Bool` — exported (new)
- `fn main() -> ()` — exported (backward compat)
- `fn helper() -> Int` — not exported (unchanged)
Verified via `/tmp/multi_pub_test.affine`: three `pub fn test_*` all
appear in the WASM export list; a non-`pub` helper does not.
Unblocks the `affinescript-deno-test` MVP's one-test-per-file
constraint — the harness can now discover multiple `test_*` exports
per file via `module.functionExports.filter(n => n.startsWith('test_'))`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>pub fn to WASM (both codegen.ml + codegen_gc.ml)1 parent 1f7006e commit ce324fa
2 files changed
Lines changed: 14 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1721 | 1721 | | |
1722 | 1722 | | |
1723 | 1723 | | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
1727 | 1731 | | |
1728 | 1732 | | |
1729 | 1733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1111 | 1111 | | |
1112 | 1112 | | |
1113 | 1113 | | |
1114 | | - | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1115 | 1118 | | |
1116 | 1119 | | |
| 1120 | + | |
| 1121 | + | |
1117 | 1122 | | |
1118 | | - | |
| 1123 | + | |
1119 | 1124 | | |
1120 | 1125 | | |
1121 | 1126 | | |
| |||
0 commit comments