code wiki / _hdl_build / nx_viz_treemap_gate.nx
nx_viz_treemap_gate.nx source
↩ module page · 55 lines · 2478 B
1// nx_viz_treemap_gate.nx -- REFEREE for the treemap layer (slice-and-dice partition).
2// T1 vertical : values[1,1,2] in (0,0,400x100) -> [0,0,100,100] [100,0,100,100] [200,0,200,100]
3// T2 horizontal: values[1,1] in (10,20,100x400) -> [10,20,100,200] [10,220,100,200]
4// T3 conservation: sum of rect areas == total area (even-dividing case, no truncation)
5// GREEN iff T1+T2+T3. Sovereign: nx_viz_treemap + nx_syscalls. license_tier: ORIGINAL
6import "nx_viz_treemap.nx"
7import "nx_syscalls.nx"
8import "nx_gate_verdict.nx"
9
10func g_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
11func g_row(name: *u8, ok: i64) -> i64 {
12 if ok == 1 { g_w(" PASS " as *u8) }
13 if ok != 1 { g_w(" FAIL " as *u8) }
14 g_w(name); g_w("\n" as *u8)
15 return ok
16}
17
18func main() -> i64 {
19 g_w("viz-treemap gate (slice-and-dice partition, integer)\n" as *u8)
20 let vals: *i64 = sys_mmap(64) as *i64
21 let r: *i64 = sys_mmap(256) as *i64
22 var pass: i64 = 0
23
24 vals[0] = 1; vals[1] = 1; vals[2] = 2
25 vt_treemap(vals, 3, 0, 0, 400, 100, r)
26 var t1: i64 = 0
27 if r[0] == 0 { if r[1] == 0 { if r[2] == 100 { if r[3] == 100 {
28 if r[4] == 100 { if r[6] == 100 {
29 if r[8] == 200 { if r[10] == 200 { t1 = 1 } } } } } } } }
30 pass = pass + g_row("T1 vertical 1:1:2 in 400x100\x00" as *u8, t1)
31
32 vals[0] = 1; vals[1] = 1
33 vt_treemap(vals, 2, 10, 20, 100, 400, r)
34 var t2: i64 = 0
35 if r[0] == 10 { if r[1] == 20 { if r[2] == 100 { if r[3] == 200 {
36 if r[4] == 10 { if r[5] == 220 { if r[7] == 200 { t2 = 1 } } } } } } }
37 pass = pass + g_row("T2 horizontal 1:1 in 100x400\x00" as *u8, t2)
38
39 vals[0] = 1; vals[1] = 1; vals[2] = 2
40 vt_treemap(vals, 3, 0, 0, 400, 100, r)
41 var area: i64 = r[2] * r[3] + r[6] * r[7] + r[10] * r[11]
42 var t3: i64 = 0
43 if area == 40000 { t3 = 1 }
44 pass = pass + g_row("T3 area conservation == 400x100\x00" as *u8, t3)
45
46 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
47 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
48 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
49 let ctr__dry: *i64 = gv_ctr()
50 ctr__dry[0] = pass
51 ctr__dry[1] = 3
52 let rc__dry: i64 = gv_verdict("VIZ-TREEMAP-GATE" as *u8, ctr__dry, "3/3 (weighted rect partition, area-conserving)" as *u8)
53 sys_exit(rc__dry)
54 return rc__dry
55}