nx_template_instantiate.nx
buildroot/runtime/nx_template_instantiate.nx
about
nx_template_instantiate.nx -- substrate-native template engine.
For each registry entry that declares a "shape" field, read the
corresponding template under specs/algo_shapes/<shape>/, substitute
{{PLACEHOLDER}} tokens with values from the meta.json's
"template_params" object, write the result to impl.nx + test.nx.
This is the SELF-SUFFICIENCY dependency: new algorithms in a known
shape need ONLY metadata (no body) -- substrate emits the impl.
Recognized placeholder tokens (any name in {{UPPER_CASE}} is replaced
from template_params). {{NX_MODULE}} is always replaced with the
meta's "nx_module" value.
genealogy_id: substrate_template_engine_2026_05_13
lineage_id: codegen_via_substitution
license: public_domain
dependencies 5 imports · 0 importers
imports: nx_syscalls.nxnx_runtime.nxnx_tier.nxnx_dirent.nxnx_fcntl.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 30 | const NX_MAGIC_16384: i64 = 16384 |
| 32 | const STDOUT: i64 = 1 |
| 33 | const NX_TPL_PATH_BUF: nx_size = 512 |
| 34 | const NX_TPL_VAL_CAP: nx_size = 512 |
| 35 | const NX_TPL_BUF_CAP: nx_size = 16384 |
functions
| 39 | func write_str_to_fd(fd: i64, s: *u8) -> nx_int |
| 45 | func write_all2(fd: i64, buf: *u8, n: nx_size) -> nx_size |
| 57 | func find_substr2(buf: *u8, start: nx_idx, n: nx_size, needle: *u8, nlen: nx_size) -> nx_idx |
| 77 | func read_meta_field(buf: *u8, n: nx_size, key: *u8, out: *u8, out_cap: nx_size) -> nx_size |
| 127 | func substitute_template(src: *u8, src_n: nx_size, |
| 235 | func extract_params_slice(meta: *u8, meta_n: nx_size, out_start: *i64) -> nx_size |
| 284 | func instantiate_shape_entry(entry_name: *u8) -> nx_int called by 1: main calls 8: sys_mmapsys_read_fileread_meta_fieldextract_params_slicesubstitute_templatenx_open_wr+2 |
| 412 | func main() -> i64 |