code wiki / _hdl_build / nx_flip_lib.nx
nx_flip_lib.nx
buildroot/runtime/_hdl_build/nx_flip_lib.nx
about
nx_flip_lib.nx -- THE BASE for the FlipOrgan family (rule #6 OO base, rule #15 DRY, rule #22).
NishiLang has no classes, so the base-class contract is expressed as a shared library every organ
in the family imports and specialises. Before this, nx_flip_score / _real / _defl / _worklist /
_gate each carried their OWN copy of the SAME ~17 primitives under a private prefix (fl_ fr_ fd_
fw_ fg_) -- five copies of column parsing, five of integer printing, five of the line-scan idiom.
A fix to any one of them fixed only one organ. That does not scale and it is how the family drifts.
THE FAMILY CONTRACT every FlipOrgan honours (enforced by nx_flip_gate, 16 cases):
1. summary + `verdict=` FIRST, detail buffered and flushed last (nx_plan_run caps snippets at 200B)
2. FAIL-CLOSED on absent input -- an absent finding/component/observation is a FINDING, not a neutral
3. every threshold read from a plane, never a literal in code (rule #11)
4. integer-only arithmetic, basis points for ratios (no-float substrate)
5. a `verdict=` anchor so the ecosystem judge can read the result (D001)
TAB-separated, newline-terminated plane rows are the ONE wire format (rule: planes > tsv).
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 3 imports · 5 importers
imports: nx_store_seed_lib.nxnx_seg_store.nxnx_syscalls.nx
imported by: nx_flip_defl.nxnx_flip_gate.nxnx_flip_real.nxnx_flip_score.nxnx_flip_worklist.nx
structs
| none |
consts
| 22 | const FX_TAB: i64 = 9 |
| 23 | const FX_NL: i64 = 10 |
| 24 | const FX_MINUS: i64 = 45 |
| 25 | const FX_D0: i64 = 48 |
| 26 | const FX_D9: i64 = 57 |
| 27 | const FX_BPS: i64 = 10000 |
| 28 | const FX_BUF: i64 = 262144 |
| 29 | const FX_OUT: i64 = 1 |
| 30 | const FX_SCRATCH: i64 = 32 |
| 31 | const FX_PFXCAP: i64 = 256 |
| 32 | const FX_NUMCAP: i64 = 40 |
| 33 | const FX_TMPCAP: i64 = 32 |
| 34 | const FX_BASE10: i64 = 10 |
| 35 | const FX_EXIT_USAGE: i64 = 2 |
| 36 | const FX_EXIT_REFUSED: i64 = 4 |
functions
| 39 | func fx_puts(s: *u8) -> i64 |
| 44 | func fx_putn(n: i64) -> i64 |
| 59 | func fx_kv(k: *u8, v: i64) -> i64 |
| 66 | func fx_putslice(b: *u8, a: i64, e: i64) -> i64 calls 1: sys_write |
| 72 | func fx_bcat(b: *u8, o: i64, s: *u8) -> i64 |
| 78 | func fx_bcatn(b: *u8, o: i64, n: i64) -> i64 |
| 90 | func fx_bcatsl(b: *u8, o: i64, src: *u8, a: i64, e: i64) -> i64 |
| 98 | func fx_atoi(s: *u8) -> i64 |
| 114 | func fx_line_end(b: *u8, n: i64, i: i64) -> i64 |
| 122 | func fx_col(b: *u8, ls: i64, le: i64, idx: i64, out: *i64) -> i64 |
| 140 | func fx_slice_atoi(b: *u8, a: i64, e: i64) -> i64 |
| 158 | func fx_col_atoi(b: *u8, ls: i64, le: i64, idx: i64, sp: *i64) -> i64 |
| 162 | func fx_slice_eqs(b: *u8, a: i64, e: i64, s: *u8) -> i64 |
| 170 | func fx_slice_eq(a: *u8, a0: i64, a1: i64, b: *u8, b0: i64, b1: i64) -> i64 |
| 179 | func fx_row_by_id(b: *u8, n: i64, key: *u8, out: *i64, sp: *i64) -> i64 |
| 193 | func fx_row_by_slice(b: *u8, n: i64, kb: *u8, k0: i64, k1: i64, out: *i64, sp: *i64) -> i64 |
| 209 | func fx_has_finding(bf: *u8, nf: i64, deal: *u8, dealcol: i64, compcol: i64, kb: *u8, k0: i64, k1: i64, sp: *i64) -> i64 |
| 229 | func fx_cat2(root: *u8, tail: *u8) -> *u8 |
| 240 | func fx_plane(root: *u8, tail: *u8, nout: *i64) -> *u8 |