code wiki / _hdl_build / nx_eoe_branch.nx

nx_eoe_branch.nx

buildroot/runtime/_hdl_build/nx_eoe_branch.nx

6127 B115 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic eoe
docsdependenciesstructsconstsfunctions

about

nx_eoe_branch.nx -- EMITTER-OF-EMITTERS, GENERALITY RUNG 3: BRANCHES-from-spec. The ladder so far: nx_eoe (006e) synthesizes control-flow DEPTH (N unconditional nested loops); nx_eoe_oplist (006g) synthesizes a LINEAR COMPUTATION (op-list, no branching). Neither can take a DIFFERENT PATH based on data. This rung synthesizes a CONDITIONAL: an if/else whose PREDICATE comes from the spec, so the emitted program takes a DIFFERENT BRANCH for different inputs -- real data-driven control-flow divergence, which a linear op-list and an unconditional loop nest provably cannot produce. nx_eoe_branch <basename> <start> <pred> <then-op> <else-op> pred = g<t> | l<t> | e<t> (acc > t | acc < t | acc == t) then-op = a<n> | m<n> | s<n> (applied iff pred true) else-op = a<n> | m<n> | s<n> (applied iff pred false) -> writes runtime/_hdl_build/<basename>.nx whose main() sets acc=start, applies then-op OR else-op per the predicate, and prints "RESULT=<acc>\n". nx_cc compiles it (the if/else MACHINE CODE is delegated to the compiler the team owns -- the emitter only synthesizes the STRUCTURE from data). no-false-green plan (X-AUT-006d): same ops but a START that flips the predicate -> the OTHER branch runs -> a DIFFERENT correct result (proves the branch is really evaluated, not constant-folded to one side); tamper the threshold -> flips. Sovereign, no gcc/.sh. HONEST SCOPE: a single 2-way branch over one comparison; NOT yet nested/op-list branches or loops-with-conditions -- ONE rung. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_eoe_branch.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main eob_p sys_write eob_atoi_from sys_mmap eob_cat eob_catn eob_catn ↻ sys_mmap ↻ eob_emit_op eob_cat ↻ eob_catn ↻ sys_openat_wr sys_write ↻ sys_close

structs

none

consts

27const K_MAGIC_65536: i64 = 65536

functions

29func eob_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
called by 2: eob_emit_opmain
30func eob_catn(dst: *u8, off: i64, v: i64) -> i64
42func eob_p(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 calls 1: sys_write
43func eob_atoi_from(s: *u8, from: i64) -> i64
called by 1: main
49func eob_emit_op(buf: *u8, off: i64, indent: *u8, c: i64, n: i64) -> i64
called by 1: main calls 2: eob_cateob_catn
61func main(argc: i64, argv: *i64) -> i64