code wiki / _hdl_build / nx_lang_export_grow.nx
nx_lang_export_grow.nx
buildroot/runtime/_hdl_build/nx_lang_export_grow.nx
about
nx_lang_export_grow.nx -- LANG-EXPORT-GROW: IR-driven multi-language codegen.
Advance over 002: the PROGRAM is now a NEUTRAL IR (knowledge/registry/lang_export_program.tsv, a
statement list) and each LANGUAGE is a set of per-CONSTRUCT templates (lang_export_constructs.tsv).
The engine WALKS the IR emitting each statement via the target language's construct-templates (with
depth-indent), so BOTH program and language are DATA -- the whole-organ architecture in miniature.
HONEST TRUTH: the organ also INTERPRETS the same IR (tiny evaluator) for the native value, so the
Nishi truth is literally the IR evaluated (the wheeler flip: Nishi = oracle). GATE = gcc/node/python
on the emitted source must each reproduce that truth. GROW = more constructs + nesting + wiring nxc2's
frontend to PRODUCE this IR so whole real organs export. license_tier: ORIGINAL
dependencies 1 imports · 0 importers
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
structs
| none |
consts
| 11 | const K_MAGIC_8192: i64 = 8192 |
functions
| 13 | func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 14 | func puts(s: *u8) -> i64 { sys_write(1, s, slen(s)); return 0 } |
| 15 | func catn(dst: *u8, off: i64, v: i64) -> i64 |
| 27 | func putn(v: i64) -> i64 { let b: *u8 = sys_mmap(28); let o: i64 = catn(b, 0, v); sys_write(1, b, o); return 0 } |
| 28 | func cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { dst[o] = s[i]; o = o + 1; i = i + 1 } return o } |
| 29 | func copyslice(out: *u8, o: i64, src: *u8, start: i64, len: i64) -> i64 { var oo: i64 = o; var j: i64 = 0; while j < len { out[oo] = src[start + j]; oo = oo + 1; j = j + 1 } return oo } called by 1: render |
| 30 | func scant(buf: *u8, start: i64, end: i64) -> i64 { var p: i64 = start; var g: i64 = 1; while g == 1 { if p >= end { g = 0 } else { if buf[p] == (9 as u8) { g = 0 } else { p = p + 1 } } } return p } |
| 31 | func parseint(buf: *u8, start: i64, len: i64) -> i64 { var v: i64 = 0; var i: i64 = 0; while i < len { v = v * 10 + ((buf[start + i] as i64) - 48); i = i + 1 } return v } |
| 32 | func readfile(path: *u8, buf: *u8, cap: i64) -> i64 |
| 41 | func wfile(path: *u8, buf: *u8, n: i64) -> i64 { let fd: i64 = sys_openat_wr(path, 420); if fd < 0 { return 0 - 1 } sys_write(fd, buf, n); sys_close(fd); return 0 } |
| 44 | func tok(buf: *u8, pos: i64, end: i64, res: *i64) -> i64 called by 1: parse_ir |
| 67 | func op_of(buf: *u8, start: i64) -> i64 called by 1: parse_ir |
| 85 | func parse_ir(ir: *u8, irn: i64, sop: *i64, opd: *i64) -> i64 |
| 114 | func slice_eq(ir: *u8, s1: i64, l1: i64, s2: i64, l2: i64) -> i64 called by 1: exec_body |
| 126 | func exec_body(ir: *u8, sop: *i64, opd: *i64, val: *i64, bs: i64, be: i64, ftab: *i64, nf: i64, arrs: *i64) -> i64 |
| 181 | func interp(ir: *u8, sop: *i64, opd: *i64, ns: i64) -> i64 |
| 242 | func lookup(cons: *u8, consn: i64, key: *u8, res: *i64) -> i64 |
| 267 | func render(out: *u8, o: i64, tpl: *u8, tlen: i64, ir: *u8, ops: *i64) -> i64 |
| 292 | func emit_line(out: *u8, o: i64, key: *u8, depth: i64, ind: *u8, indlen: i64, cons: *u8, consn: i64, ir: *u8, ops: *i64) -> i64 |
| 303 | func mkkey(kb: *u8, lang: *u8, construct: *u8) -> i64 { var o: i64 = cat(kb, 0, lang); kb[o] = (46 as u8); o = o + 1; o = cat(kb, o, construct); kb[o] = (0 as u8); return 0 } |
| 304 | func mkpath(pathb: *u8, name: *u8, ext: *u8) -> i64 { var o: i64 = cat(pathb, 0, "_offc/lg_" as *u8); o = cat(pathb, o, name); pathb[o] = (46 as u8); o = o + 1; o = cat(pathb, o, ext); pathb[o] = (0 as u8); return 0 } |
| 305 | func emitlog(name: *u8, bytes: i64) -> i64 { puts("EMIT lang=" as *u8); puts(name); puts(" file=_offc/lg_" as *u8); puts(name); puts(" bytes=" as *u8); putn(bytes); puts("\n" as *u8); return 0 } |
| 307 | func emit_sep(out: *u8, o: i64, lang: *u8, cons: *u8, consn: i64) -> i64 |
| 318 | func emit_localsig_funco(out: *u8, o: i64, lang: *u8, ir: *u8, sop: *i64, opd: *i64, fk: i64, ns: i64, fops: *i64, cons: *u8, consn: i64) -> i64 |
| 340 | func gen_lang(lang: *u8, ir: *u8, sop: *i64, opd: *i64, ns: i64, cons: *u8, consn: i64, out: *u8) -> i64 |
| 434 | func streq_slice(buf: *u8, off: i64, src: *u8, start: i64, len: i64) -> i64 called by 1: enum_langs |
| 441 | func enum_langs(cons: *u8, consn: i64, langbuf: *u8, langoff: *i64, maxl: i64) -> i64 |
| 473 | func main() -> i64 |