code wiki / _hdl_build / c0_authz_step.nx
c0_authz_step.nx source
↩ module page · 30 lines · 995 B
1// AUTHORED BY THE NISHI BUILDER (pattern: STATE_MACHINE) -- baked transition walk, no Claude logic
2import "nx_syscalls.nx"
3func c0_authz_step_step(s: i64, e: i64) -> i64 {
4 if s < 0 { return 0 - 1 }
5 if s >= 4 { return 0 - 1 }
6 if e < 0 { return 0 - 1 }
7 if e >= 6 { return 0 - 1 }
8 if s == 0 { if e == 0 { return 0 } }
9 if s == 1 { if e == 0 { return 0 } }
10 if s == 1 { if e == 1 { return 1 } }
11 if s == 2 { if e == 0 { return 0 } }
12 if s == 2 { if e == 2 { return 2 } }
13 if s == 3 { if e == 0 { return 0 } }
14 if s == 3 { if e == 1 { return 3 } }
15 if s == 3 { if e == 2 { return 3 } }
16 if s == 3 { if e == 3 { return 3 } }
17 if s == 3 { if e == 4 { return 3 } }
18 if s == 3 { if e == 5 { return 3 } }
19 return 0 - 1
20}
21func c0_authz_step_run(ev: *i64, n: i64, s0: i64) -> i64 {
22 var s: i64 = s0
23 var i: i64 = 0
24 while i < n {
25 s = c0_authz_step_step(s, ev[i])
26 if s < 0 { return 0 - 1 }
27 i = i + 1
28 }
29 return s
30}