code wiki / _hdl_build / nx_pattern_emit13.nx
nx_pattern_emit13.nx
buildroot/runtime/_hdl_build/nx_pattern_emit13.nx
about
nx_pattern_emit13.nx -- PATTERN EMITTER: STATE_MACHINE (shape 18 -- the first rung of the
ADVANCED-STACK ladders spec 2026-06-10: the shape DirectX-class pipeline validation, CUDA-class
queue lifecycles, Klipper-class G-code modal interpreters, and TLS/session handshakes are all
made of). The Builder authors a deterministic finite state machine from a TRANSITION TABLE:
spec[0]=nstates spec[1]=nevents spec[2]=s0 (initial state)
spec[3 + s*nevents + e] = next state, or -1 = UNDEFINED (refused, never silently absorbed)
Authored fns (transitions BAKED as straight-line ifs -- no runtime table interpreter, rule 22):
<name>_step(s, e) -> next state; -1 on out-of-range s/e or undefined transition
<name>_run(ev, n, s0) -> final state after folding ev[0..n); -1 the moment any step refuses
EMIT-TIME RAILS (the PID/PREDICTOR_CODER discipline): nstates/nevents outside 1..16, s0 out of
range, any table value outside -1..nstates-1 -> spec REFUSED, nothing written. Test KATs are
COMPUTED BY THE EMITTER from the same table: a greedy defined-transition walk from s0 with the
expected final state, an undefined-transition refusal (or out-of-range when the table is total),
an out-of-range-event refusal, and a determinism re-run. Extends the emit1-12 family.
LAWS: struct-free, integer-only, flat ifs, no &&/||, <=6 args per func. license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: _gjob_author.nxnx_auto_builder.nxnx_auto_builder_s20.nxnx_pattern_emit13_demo.nx
structs
| none |
consts
| none |
functions
| 18 | func p13_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd, s, n); return 0 } |
| 19 | func p13_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 22 | func p13_spec_ok(spec: *i64) -> i64 called by 1: pe13_author_state_machine |
| 42 | func pe13_emit_state_machine(fd: i64, name: *u8, spec: *i64) -> i64 |
| 78 | func p13_walk(spec: *i64, wev: *i64, wfinal: *i64) -> i64 |
| 106 | func p13_find_undef(spec: *i64) -> i64 |
| 122 | func pe13_emit_state_machine_test(fd: i64, name: *u8, spec: *i64) -> i64 |
| 157 | func pe13_author_state_machine(name: *u8, modpath: *u8, testpath: *u8, spec: *i64) -> i64 |