code wiki / _hdl_build / nx_lang_struct.nx
nx_lang_struct.nx
buildroot/runtime/_hdl_build/nx_lang_struct.nx
about
nx_lang_struct.nx -- LANG-EXPORT FRONTEND, atom 1 (the SSA structurizer foundation). Takes a REAL NishiLang
.nx source, runs it through nxc2's OWN frontend (lex_source -> parse_module -> SSA Module), then WALKS the
SSA of function 0 and RECOVERS the structured export IR (the "AST etc" nxc2 lacks): SSA value-numbering maps
each value-id to a single-letter var, constants materialize as `V <var> <int>`, binops become `BIN <lhs> <a>
<op> <b>` / `IDIV`, and the function's RETURN becomes `PRINT <var>`. The body is wrapped in `LOOP <free> 1`
so the existing nx_lang_export_grow interp+emitter consumes it -> 6 languages, all from REAL Nishi source.
ATOM 1 SCOPE: straight-line arithmetic (const + + - * / % + return). Control flow (if/loop recovery from the
CFG) + params/locals are the next structurizer atoms. license_tier: ORIGINAL
dependencies 6 imports · 0 importers
imports: nx_syscalls.nxnx_types.nxnx_lex_kinds.nxnx_ir.nxnx_tokenizer.nxnx_parse.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
| 15 | const K_MAGIC_8192: i64 = 8192 |
| 16 | const K_MAGIC_4096: i64 = 4096 |
functions
| 18 | func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: sp |
| 19 | func sp(s: *u8) -> i64 { sys_write(1, s, slen(s)); return 0 } |
| 20 | func bcat(buf: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var i: i64 = 0; while s[i] != (0 as u8) { buf[o] = s[i]; o = o + 1; i = i + 1 } return o } |
| 21 | func bch(buf: *u8, off: i64, c: i64) -> i64 { buf[off] = c as u8; return off + 1 } |
| 22 | func bnum(buf: *u8, off: i64, v: i64) -> i64 |
| 34 | func readfile(path: *u8, buf: *u8, cap: i64) -> i64 |
| 43 | 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 } |
| 47 | func letter_of(f: *Function, rid: i64, vmap: *i64, body: *u8, st: *i64) -> i64 |
| 62 | func main() -> i64 |