nx_func_extract.nx
buildroot/runtime/nx_func_extract.nx
about
nx_extract.nx -- function-body extraction + normalization + hashing.
Substrate-native primitive for semantic-equivalence verification.
Foundation for the dedup-then-consolidate workflow: extract a
named function from a file, normalize away comments and whitespace,
compute a deterministic hash, compare across files.
Capabilities provided:
- nx_extract_func_body : locate `func NAME(...)` and return its
body byte range [body_start, body_end)
- nx_extract_normalize : copy a buffer slice with line comments
removed and runs of whitespace collapsed
to single spaces; strings preserved verbatim
- nx_extract_hash : FNV-1a 64-bit hash of a byte range
- nx_extract_func_hash : convenience -- extract + normalize + hash
All pure-NishiLang. No reliance on external grep/awk/sed. This is
the substrate's answer to "diff two functions for equivalence"
without leaving NishiLang.
genealogy_id: fowler_noll_vo_1991_fnv1a + baker_1995_clone_detection
lineage_id: syntax_directed_function_extraction + content_hash
axioms: NX_AX_REL_REFLEXIVITY (hash(a) = hash(a))
+ NX_AX_REL_SYMMETRY (hash(a)=hash(b) <-> hash(b)=hash(a))
+ NX_AX_REL_TRANSITIVITY (a~b, b~c -> a~c)
together: hash-equality is an equivalence relation;
collisions are theoretically possible (Pigeonhole) but
FNV-1a 64-bit collision probability is negligible at
our function-population scale (thousands, not billions).
dependencies 4 imports · 0 importers
imports: syscalls.nxruntime.nxnx_axioms.nxnx_lex.nx
imported by: nobody (leaf or entry point)
structs
| none |
consts
| 42 | const NX_EXTRACT_FNV64_OFFSET: i64 = 0xcbf29ce484222325 |
| 43 | const NX_EXTRACT_FNV64_PRIME: i64 = 1099511628211 // 0x100000001b3 |
functions
| 49 | func nx_extract_is_alnum_us(c: i64) -> i64 |
| 66 | func nx_extract_func_body(buf: *u8, len: i64, fname: *u8, |
| 219 | func nx_extract_normalize(buf: *u8, start: i64, end: i64, out: *u8) -> i64 |
| 311 | func nx_extract_hash(buf: *u8, len: i64) -> i64 called by 1: nx_extract_func_hash |
| 324 | func nx_extract_func_hash(buf: *u8, len: i64, fname: *u8, |