code wiki / _hdl_build / nx_pattern_emit8.nx
nx_pattern_emit8.nx
buildroot/runtime/_hdl_build/nx_pattern_emit8.nx
about
nx_pattern_emit8.nx -- PATTERN EMITTER: STRUCT_WALK (shape 13 -- race-1's first named growth
rung: the assignment-DECOMPOSITION step Claude still had to hand-write). Authors a fixed+var
field-sequence walker from a FIELD TABLE (the spec is the config, rule 11):
kind 0 = FIXED(w) skip w bytes (w from widths[i])
kind 1 = VAR8 1-byte length prefix + body
kind 2 = VAR16 2-byte BE length prefix + body
kind 3 = TAIL16 2-byte BE length prefix; the walker RETURNS this final block
Authored fn: <name>_locate(b, n, out) -> 0 ok (out[0]=block off, out[1]=block len) / -1 = any
truncation REFUSED (never a clipped read). The ClientHello layout (hdr/ver/random/sid/suites/
comp/extensions) is exactly this table -- so are the B5 container headers. Per-field bounds
checks + offsets are BAKED at emit time field-by-field; the core has no table interpreter at
runtime (composition of straight-line checks, rule 22). Test KATs are COMPUTED BY THE EMITTER
from a synthetic image it constructs to the same table (exact off/len + truncation refusal).
REFUSAL RAILS: unknown kind, TAIL16 not last, last not TAIL16, FIXED width < 1, nfields < 1
-> spec REFUSED, never authored. Extends emit chain ..emit7(WIRE_TLV).
LAWS: struct-free, integer-only, flat ifs, no &&/||, <=6 args per func. license_tier: ORIGINAL
dependencies 1 imports · 7 importers
imports: nx_syscalls.nx
imported by: _race5_team_author2.nx_race6_team_author.nx_seed_ncf_kinds67.nxnx_auto_builder.nxnx_auto_builder_s20.nxnx_pattern_emit89_demo.nxnx_warden_build.nx
structs
| none |
consts
| none |
functions
| 19 | func p8_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 } |
| 20 | func p8_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 } |
| 23 | func p8_spec_ok(kinds: *i64, widths: *i64, nfields: i64) -> i64 called by 1: pe8_author_struct_walk |
| 39 | func p8_emit_field(fd: i64, kind: i64, width: i64) -> i64 |
| 64 | func pe8_emit_struct_walk(fd: i64, name: *u8, kinds: *i64, widths: *i64, nfields: i64) -> i64 |
| 80 | func p8_build_image(img: *u8, kinds: *i64, widths: *i64, nfields: i64, exp: *i64) -> i64 |
| 114 | func pe8_emit_struct_walk_test(fd: i64, name: *u8, kinds: *i64, widths: *i64, nfields: i64) -> i64 |
| 137 | func pe8_author_struct_walk(name: *u8, modpath: *u8, testpath: *u8, kinds: *i64, widths: *i64, nfields: i64) -> i64 |
| 182 | func p8_spec2_ok(kinds: *i64, widths: *i64, nfields: i64) -> i64 |
| 210 | func p8_emit_field2(fd: i64, kind: i64, width: i64) -> i64 |
| 272 | func pe8_emit_struct_walk2(fd: i64, name: *u8, kinds: *i64, widths: *i64, nfields: i64) -> i64 |
| 288 | func p8_crc32(img: *u8, s: i64, e: i64) -> i64 |
| 307 | func p8_build_image2(img: *u8, kinds: *i64, widths: *i64, nfields: i64, exp: *i64) -> i64 |
| 367 | func pe8_emit_struct_walk_test2(fd: i64, name: *u8, kinds: *i64, widths: *i64, nfields: i64) -> i64 |
| 414 | func pe8_author_struct_walk2(name: *u8, modpath: *u8, testpath: *u8, kinds: *i64, widths: *i64, nfields: i64) -> i64 |