nx_bundle_gen.nx
buildroot/runtime/nx_bundle_gen.nx
about
nx_bundle_gen.nx -- pure-NishiLang shard-bundle generator.
Walks specs/algo_registry/ to collect shape-driven primitives, then
emits runtime/_bundle_shard_<i>.nx files where each shard inlines
renamed copies of multiple primitives' test.nx, plus a master main()
that invokes every test_<nx>() and emits PASS/FAIL via sys_write.
Replaces sed-per-primitive in bash (which cost ~139s wall for 1192
primitives via 1192 subshells). Pure NishiLang means substrate self-
generates its own bundles -- aligns with the "no host tools for own
bookkeeping" directive.
Rewriting rules per inlined test.nx:
1. Strip lines starting with `import ` (bundle re-emits the shared
imports at the top once)
2. Rename `func main() -> nx_int` -> `func test_<nx>() -> nx_int`
and `func main() -> i64` -> `func test_<nx>() -> nx_int`
3. Replace `__syscall(93, N, 0, 0, 0, 0, 0)` (process exit syscall)
with plain `N` so failure propagates to the bundle's master main
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_runtime.nxnx_dirent.nxnx_fcntl.nxnx_tier.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 33 | const NX_BG_PATH_BUF: nx_size = 512 |
| 34 | const NX_BG_FIELD_CAP: nx_size = 4096 |
| 35 | const NX_BG_SHARD_SIZE: nx_int = 200 |
| 36 | const NX_BG_MAX_PRIMS: nx_size = 1048576 // 1M slots; mmap is lazy |
| 37 | const NX_BG_NAME_LEN: nx_size = 64 // bytes per name slot |
| 38 | const NX_BG_SCRATCH: nx_size = 65536 // per-prim scratch for test.nx |
functions
| 42 | func bg_str_cat(dst: *u8, off: nx_idx, src: *u8) -> nx_idx |
| 52 | func bg_write_all(fd: nx_fd, buf: *u8, n: nx_size) -> nx_size |
| 63 | func bg_wrs(fd: nx_fd, s: *u8) -> nx_int |
| 69 | func bg_find(buf: *u8, start: nx_idx, end: nx_idx, needle: *u8, nlen: nx_size) -> nx_idx |
| 88 | func bg_read_field(buf: *u8, n: nx_size, key: *u8, out: *u8) -> nx_size |
| 121 | func bg_file_exists(path: *u8) -> nx_int |
| 133 | func bg_collect_prims(prims_buf: *u8) -> nx_size called by 1: main calls 11: nx_openatsys_mmapnx_dirent_readnx_dirent_iternx_dirent_name_lenbg_str_cat+5 |
| 209 | func bg_line_end(buf: *u8, pos: nx_idx, n: nx_size) -> nx_idx called by 1: bg_emit_rewritten_test |
| 220 | func bg_is_import_line(buf: *u8, pos: nx_idx, le: nx_idx) -> nx_int called by 1: bg_emit_rewritten_test |
| 244 | func bg_emit_line(fd: nx_fd, src: *u8, pos: nx_idx, le: nx_idx, nx_mod: *u8) -> nx_int |
| 333 | func bg_emit_rewritten_test(fd: nx_fd, src: *u8, src_n: nx_size, nx_mod: *u8) -> nx_int |
| 347 | func bg_emit_shard(shard_idx: nx_int, prims_buf: *u8, lo: nx_size, hi: nx_size) -> nx_int |
| 448 | func main() -> nx_exit |