code wiki / _hdl_build / nx_wasm_emit2.nx

nx_wasm_emit2.nx

buildroot/runtime/_hdl_build/nx_wasm_emit2.nx

3651 B84 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind tooltopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_emit2.nx -- G-WASM-001 milestone 2: emit a REAL function module byte-by-byte (memory section + param + local + local.get/set + i64.const + i64.add + multi-export), the encoding actual game code needs. Reuses leb128.nx. Verified byte-exact vs WABT used ONCE as an alignment oracle, then WABT leaves the path. NO node/python/WABT in this organ. Target module: (module (memory (export "memory") 1) (func (export "f") (param i64) (result i64) (local i64) local.get 0 i64.const 5 i64.add local.set 1 local.get 1)) license_tier: ORIGINAL

dependencies 2 imports · 0 importers

leb128.nx nx_syscalls.nx nx_wasm_emit2.nx

imports: leb128.nxnx_syscalls.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 w8 emit_section w8 ↻ uleb128_encode wcopy uleb128_encode ↻ sleb128_encode wcopy ↻ sys_openat_wr sys_exit sys_write sys_close

structs

none

consts

12const K_MAGIC_1024: i64 = 1024

functions

14func w8(b: *u8, p: i64, v: i64) -> i64 { b[p] = v as u8; return p + 1 }
called by 2: emit_sectionmain
15func wcopy(dst: *u8, dp: i64, src: *u8, n: i64) -> i64
called by 2: emit_sectionmain
20func emit_section(out: *u8, p: i64, id: i64, sc: *u8, sclen: i64) -> i64
called by 1: main calls 3: w8uleb128_encodewcopy
27func main() -> i64