Commit 017a2f7
feat(stdlib): Argv — extern "env" pattern for wasm-host argv access (#86)
## Summary
- Adds `stdlib/Argv.eph` declaring three host imports (`argv_count`,
`argv_arg_len`, `argv_arg_get`) any wasm host embedding an ephapax
module must implement.
- Follows the WASI `args_get` / `args_sizes_get` buffer shape — hosts
can either bridge to WASI directly or implement the symbols natively.
- No compiler change. Existing `extern "env" { ... }` infrastructure in
`src/ephapax-wasm/src/lib.rs` (`collect_extern_imports`) handles it.
## Why
Phase 14a.1 of porting the gossamer CLI (`gossamer/cli/`) from native
Zig to typed-wasm Ephapax. The CLI needs argv access for subcommand
dispatch (`gossamer dev` vs `gossamer build` etc.). Doing it as a stdlib
`extern "env"` pattern rather than a new compiler intrinsic keeps the
compiler footprint zero while unblocking any wasm-host launcher.
Higher-level helpers (slice→String, full `Array<String>`
materialisation) are deferred until region-scoped String allocation and
a List/Array story stabilise in the v2 stdlib. Documented in the module
header.
## Test plan
Verified end-to-end on this branch:
- [x] \`ephapax parse stdlib/Argv.eph\` — 3 extern fns recognised
- [x] \`ephapax compile stdlib/Argv.eph -o /tmp/argv.wasm\` — 727-byte
.wasm
- [x] Wasm Import section inspection shows \`env::argv_count\`,
\`env::argv_arg_len\`, \`env::argv_arg_get\` emitted as proper host
imports alongside the baseline \`env::print_i32\` /
\`env::print_string\`.
- [ ] Reviewer: confirm naming aligns with future WASI-compat plan (if
any).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f60bd53 commit 017a2f7
1 file changed
Lines changed: 37 additions & 0 deletions
| 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 | + | |
0 commit comments