code wiki / _hdl_build / nx_canoncat.nx
nx_canoncat.nx
buildroot/runtime/_hdl_build/nx_canoncat.nx
about
nx_canoncat -- concatenate N canon files into one, renumbering feature part references.
★THE ENTIRE "PERFECT ONE UNIT, THEN AGGREGATE" MECHANISM IS THIS ORGAN (plan rung S4). A skull, a
hand, a torso are each authored and gated as their OWN canon; composition into a body is a cat.
That is only true because of one discipline enforced here:
P and R rows pass through BYTE-VERBATIM. This organ does not parse them beyond the leading
letter, so when the canon grows fields (P grew mat, then rotZ, then rotY) concatenation keeps
working without an edit here -- an organ that re-emitted parsed fields would silently STRIP any
field added after it was written, which is exactly how format evolution corrupts a pipeline.
F rows are the one exception, because they carry the ONLY cross-row reference in the format: a
part INDEX, where parts are numbered by order of P appearance. File k's F rows are shifted by
the P count of files 0..k-1. Everything after the index is passed through verbatim for the same
reason as above.
Fail-closed on purpose:
- an F row referencing a part its OWN file never declared is a corrupt canon -> refuse (exit 5),
because shifting a dangling index would turn one file's corruption into another file's feature.
- an unknown row type -> refuse (exit 6). A row this organ cannot classify is a row whose
renumbering rule is UNKNOWN; passing it through silently would be a guess with a file format.
usage: nx_canoncat <out.canon> <in1.canon> [in2.canon ...]
nx_canoncat selftest
dependencies 1 imports · 0 importers
imports: nx_gate_verdict.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
| 27 | const CC_MAXIN: i64 = 8388608 // 8MB per input canon -- far above any real canon, refuses beyond |
| 28 | const CC_MAXOUT: i64 = 67108864 |
functions
| 30 | func cc_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } called by 1: main |
| 31 | func cc_pn(v: i64) -> i64 called by 1: main |
| 40 | func cc_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 46 | func cc_wnum(out: *u8, pos: *i64, v: i64) -> i64 called by 1: cc_one |
| 58 | func cc_one(inb: *u8, n: i64, out: *u8, opos: *i64, pbase: i64) -> i64 |
| 122 | func cc_cat(outpath: *u8, files: *i64, nf: i64) -> i64 |
| 144 | func cc_gate() -> i64 |
| 228 | func main(argc: i64, argv: *i64) -> i64 |