code wiki / (root) / nx_compile_wat.nx

nx_compile_wat.nx

buildroot/runtime/nx_compile_wat.nx

3899 B108 linesdepth 6pulls 16 transitivereach 0 importersview sourcekind tooltopic compile
docsdependenciesstructsconstsfunctions

about

nx_compile_wat.nx -- SOVEREIGN source-file driver for the NishiLang WAT (WebAssembly) backend. The NishiLang counterpart of nxc2.exe's --target wat path: reads a .nx (import-expanded), runs lex_source -> parse_module -> opt_run -> wat_emit_module (nx_wasm.nx, now f32-capable), writes WAT to stdout. This WIRES the sovereign wat emitter into a usable driver so the wat path is no longer C-only. The wat is then fed to nx_wat_compiler (.wat -> .wasm, sovereign) for the browser. usage: nx_compile_wat <src.nx> > out.wat license_tier: ORIGINAL

dependencies 12 imports · 0 importers

nx_syscalls.nx nx_types.nx nx_lex_kinds.nx nx_outbuf.nx nx_ir.nx nx_tokenizer.nx nx_parse.nx nx_opt.nx nx_ir_dump.nx nx_ir_validate.nx nx_compile_wat.nx

diagram shows first 10 each side; +2 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_types.nxnx_lex_kinds.nxnx_outbuf.nxnx_ir.nxnx_tokenizer.nxnx_parse.nxnx_opt.nxnx_ir_dump.nxnx_ir_validate.nxnx_import.nxnx_wasm.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 expand_ctx_new sys_mmap ↻ expand_imports expand_imports_inner watd_log sys_write 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 ↻ lexm_body_at ↻

structs

none

consts

19const WAT_MAGIC_4096: i64 = 4096
20const WAT_MAGIC_262144: i64 = 262144
22const WAT_SRC_CAP: i64 = 2097152
23const WAT_OUT_CAP: i64 = 16777216
24const WAT_EXPAND_CAP: i64 = 4194304

functions

26func watd_log(msg: *u8, n: i64) -> i64 { return sys_write(2, msg, n) }
called by 1: main calls 1: sys_write
27func watd_read_stdin(buf: *u8, cap: i64) -> i64
calls 1: sys_read
49func main(argc: i64, argv: *i64) -> i64