code wiki / _hdl_build / nx_dupfunc_test.nx

nx_dupfunc_test.nx

buildroot/runtime/_hdl_build/nx_dupfunc_test.nx

6681 B130 linesdepth 6pulls 8 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_dupfunc_test.nx -- gate for the function-body duplication detector. THE PROPERTY THAT MATTERS is T1: two identical bodies behind DIFFERENT NAMES must hash the same. Every duplicate this tool found in the real tree has a different name in each copy -- the integer-printing helper appears 198 times as vn, t_putn, gn, dn, wn and tn -- so a detector keyed on names would report a clean tree. Ignoring the name is the whole design. T4 is a regression test for a bug that made the tool useless while reporting success: NishiLang has no break, the body scan escaped by assigning its loop variable, and that destroyed the position it had just found. Every body came out empty, so the scan measured 0 functions across 17000 files and printed verdict=GREEN. ★A detector that reports nothing looks exactly like a clean tree. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gatelib.nx nx_gate.nx nx_dupfunc_test.nx

imports: nx_syscalls.nxnx_gatelib.nxnx_gate.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap x_norm sys_mmap ↻ gl_strip_comments slen tw sys_write x_hash

structs

none

consts

none

functions

20func tw(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
21func tn(v: i64) -> i64 { let b: *u8 = sys_mmap(24); var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } let t: *u8 = sys_mmap(24); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; 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 { b[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, b, k); return 0 }
22func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: main
24func x_hash(buf: *u8, n: i64) -> i64
called by 1: main
33func x_norm(src: *u8, n: i64, out: *u8) -> i64
called by 1: main calls 2: sys_mmapgl_strip_comments
60func main() -> i64