code wiki / _hdl_build / nx_viz_partition_gate.nx
nx_viz_partition_gate.nx source
↩ module page · 61 lines · 2790 B
1// nx_viz_partition_gate.nx -- REFEREE for the partition layer. Tree: 0=root; 1,2 children of 0; 3,4 children of
2// 1 (value 1 each); 5 child of 2 (value 2). Subtree vals: 1->2, 2->2, root->4. Expected spans (of [0,4]):
3// 0:[0,4] 1:[0,2] 2:[2,4] 3:[0,1] 4:[1,2] 5:[2,4] depths: 0,1,1,2,2,2
4// GREEN iff total + spans + depths + sibling-tiling. Sovereign: nx_viz_partition. license_tier: ORIGINAL
5import "nx_viz_partition.nx"
6import "nx_syscalls.nx"
7import "nx_gate_verdict.nx"
8
9func 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 }
10func g_row(name: *u8, ok: i64) -> i64 {
11 if ok == 1 { g_w(" PASS " as *u8) }
12 if ok != 1 { g_w(" FAIL " as *u8) }
13 g_w(name); g_w("\n" as *u8)
14 return ok
15}
16
17func main() -> i64 {
18 g_w("viz-partition gate (d3-hierarchy partition: subtree-proportional spans)\n" as *u8)
19 let parent: *i64 = sys_mmap(128) as *i64
20 let value: *i64 = sys_mmap(128) as *i64
21 let span: *i64 = sys_mmap(256) as *i64
22 let depth: *i64 = sys_mmap(128) as *i64
23 parent[0] = 0 - 1; value[0] = 0
24 parent[1] = 0; value[1] = 0
25 parent[2] = 0; value[2] = 0
26 parent[3] = 1; value[3] = 1
27 parent[4] = 1; value[4] = 1
28 parent[5] = 2; value[5] = 2
29 var pass: i64 = 0
30
31 let total: i64 = vp_partition(6, parent, value, span, depth)
32 var t1: i64 = 0
33 if total == 4 { t1 = 1 }
34 pass = pass + g_row("T1 total = 4\x00" as *u8, t1)
35
36 var t2: i64 = 0
37 if span[0] == 0 { if span[1] == 4 { if span[2] == 0 { if span[3] == 2 { if span[4] == 2 { if span[5] == 4 { t2 = 1 } } } } } }
38 pass = pass + g_row("T2 root[0,4] node1[0,2] node2[2,4]\x00" as *u8, t2)
39
40 var t3: i64 = 0
41 if span[6] == 0 { if span[7] == 1 { if span[8] == 1 { if span[9] == 2 { if span[10] == 2 { if span[11] == 4 { t3 = 1 } } } } } }
42 pass = pass + g_row("T3 leaves node3[0,1] node4[1,2] node5[2,4]\x00" as *u8, t3)
43
44 var t4: i64 = 0
45 if depth[0] == 0 { if depth[1] == 1 { if depth[3] == 2 { if depth[5] == 2 { t4 = 1 } } } }
46 pass = pass + g_row("T4 depths 0/1/2 correct\x00" as *u8, t4)
47
48 var t5: i64 = 0
49 if span[3] == span[4] { if span[9] == span[10] { t5 = 1 } }
50 pass = pass + g_row("T5 siblings tile parent (no gaps/overlap)\x00" as *u8, t5)
51
52 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
53 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
54 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
55 let ctr__dry: *i64 = gv_ctr()
56 ctr__dry[0] = pass
57 ctr__dry[1] = 5
58 let rc__dry: i64 = gv_verdict("VIZ-PARTITION-GATE" as *u8, ctr__dry, "5/5 (hierarchical spans, area-conserving)" as *u8)
59 sys_exit(rc__dry)
60 return rc__dry
61}