code wiki / (root) / nx_bundle_gen.nx

nx_bundle_gen.nx

buildroot/runtime/nx_bundle_gen.nx

17890 B473 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_runtime.nx nx_dirent.nx nx_fcntl.nx nx_tier.nx nx_bundle_gen.nx

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

main sys_mmap bg_collect_prims nx_openat sys_mmap ↻ nx_dirent_read nx_dirent_iter nx_dirent_name_len bg_str_cat sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close bg_find bg_read_field sys_mmap ↻ bg_find ↻ bg_file_exists nx_openat ↻ sys_close ↻ sys_close ↻ sys_write strlen bg_emit_shard sys_mmap ↻ bg_str_cat ↻ nx_open_wr nx_openat ↻ bg_wrs bg_write_all sys_write ↻ strlen ↻ sys_read_file ↻ bg_emit_rewritten_test bg_line_end bg_is_import_line bg_emit_line bg_find ↻

structs

none

consts

33const NX_BG_PATH_BUF: nx_size = 512
34const NX_BG_FIELD_CAP: nx_size = 4096
35const NX_BG_SHARD_SIZE: nx_int = 200
36const NX_BG_MAX_PRIMS: nx_size = 1048576 // 1M slots; mmap is lazy
37const NX_BG_NAME_LEN: nx_size = 64 // bytes per name slot
38const NX_BG_SCRATCH: nx_size = 65536 // per-prim scratch for test.nx

functions

42func bg_str_cat(dst: *u8, off: nx_idx, src: *u8) -> nx_idx
52func bg_write_all(fd: nx_fd, buf: *u8, n: nx_size) -> nx_size
called by 2: bg_wrsbg_emit_line calls 1: sys_write
63func bg_wrs(fd: nx_fd, s: *u8) -> nx_int
69func bg_find(buf: *u8, start: nx_idx, end: nx_idx, needle: *u8, nlen: nx_size) -> nx_idx
88func bg_read_field(buf: *u8, n: nx_size, key: *u8, out: *u8) -> nx_size
called by 1: bg_collect_prims calls 2: sys_mmapbg_find
121func bg_file_exists(path: *u8) -> nx_int
called by 1: bg_collect_prims calls 2: nx_openatsys_close
133func bg_collect_prims(prims_buf: *u8) -> nx_size
209func bg_line_end(buf: *u8, pos: nx_idx, n: nx_size) -> nx_idx
220func bg_is_import_line(buf: *u8, pos: nx_idx, le: nx_idx) -> nx_int
244func bg_emit_line(fd: nx_fd, src: *u8, pos: nx_idx, le: nx_idx, nx_mod: *u8) -> nx_int
333func bg_emit_rewritten_test(fd: nx_fd, src: *u8, src_n: nx_size, nx_mod: *u8) -> nx_int
347func bg_emit_shard(shard_idx: nx_int, prims_buf: *u8, lo: nx_size, hi: nx_size) -> nx_int
448func main() -> nx_exit