code wiki / _hdl_build / nx_lang_struct.nx

nx_lang_struct.nx

buildroot/runtime/_hdl_build/nx_lang_struct.nx

7416 B143 linesdepth 5pulls 9 transitivereach 0 importersview sourcekind tooltopic lang
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_types.nx nx_lex_kinds.nx nx_ir.nx nx_tokenizer.nx nx_parse.nx nx_lang_struct.nx

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

main sys_mmap readfile sys_openat_rd sys_read sys_close sp sys_write slen lex_source sys_mmap ↻ lexm_expand lexm_prescan lexm_isid is_alnum is_alpha is_digit lexm_body_end lexm_define lexm_init sys_mmap ↻ lexm_warn_body_too_long lexm_diag_cell lexm_emit_str lexm_emit_dec sys_write ↻ lexm_name_at lexm_body_at sys_mmap ↻ lexm_isid ↻ lexm_body_end ↻ lexm_for_expand lexm_isid ↻ lexm_body_end ↻ lexm_for_emit lexm_isid ↻ sys_mmap ↻ lexm_for_bound lexm_lookup lexm_name_at ↻

structs

none

consts

15const K_MAGIC_8192: i64 = 8192
16const K_MAGIC_4096: i64 = 4096

functions

18func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: sp
19func sp(s: *u8) -> i64 { sys_write(1, s, slen(s)); return 0 }
called by 1: main calls 2: sys_writeslen
20func 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 }
called by 2: letter_ofmain
21func bch(buf: *u8, off: i64, c: i64) -> i64 { buf[off] = c as u8; return off + 1 }
called by 2: letter_ofmain
22func bnum(buf: *u8, off: i64, v: i64) -> i64
called by 2: letter_ofmain calls 1: sys_mmap
34func readfile(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
43func 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 }
47func letter_of(f: *Function, rid: i64, vmap: *i64, body: *u8, st: *i64) -> i64
called by 1: main calls 3: bcatbchbnum
62func main() -> i64