code wiki / _hdl_build / nx_fnptr_min_probe.nx

nx_fnptr_min_probe.nx source

↩ module page · 21 lines · 964 B

1// nx_fnptr_min_probe.nx -- minimal seq715 discriminator (see nx_fnptr_call_gate). 2// Compiles ONLY on a parser that implements the postfix indirect-call branch. 3// license_tier: ORIGINAL No hw writes (Rule 26). 4import "nx_syscalls.nx" 5func addk(a: i64, b: i64, c: i64) -> i64 { return a*100 + b*10 + c } 6struct FP { 7 f: func(i64, i64, i64) -> i64, 8} 9// NOTE the call sits in an `if` CONDITION, not a `let` binding. That is 10// deliberate and load-bearing: a defective parser mis-compiles the `let` form 11// SILENTLY (binds the function's address) and still exits 0, so a `let`-shaped 12// probe compiles clean on a broken compiler and proves nothing. In condition 13// position the same defect desyncs the parser and the build fails outright, so 14// a successful BUILD is by itself evidence the postfix branch exists. 15func main() -> i64 { 16 let p: *FP = sys_mmap(16) as *FP 17 p.f = addk 18 if p.f(1, 2, 3) == 123 { sys_exit(0) } 19 sys_exit(1) 20 return 0 21}