omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / ng / tests / nocaps / gate.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note seed/ng/tests/nocaps/gate.om: the no-caps gate of ng (NgNoCaps, 2026-11-11; Drake: "no hard caps on our own |
| 3 | note software ... put a TEST that will alarm"). Handwritten seeded Omega, program mode, Linux AArch64. The child and |
| 4 | note file helpers follow seed/ng/front/gate-front-ir.om; seed/ng/sha256.om supplies sh_dat, sh_all and sh_dig. |
| 5 | note Build: cat seed/ng/sha256.om seed/ng/tests/nocaps/gate.om | seed/out/omc > nocaps-gate |
| 6 | note Run from the repository root: nocaps-gate OMC OMC_SHA256 SCRATCH [NG] |
| 7 | note OMC the oracle compiler; its sha256 must be OMC_SHA256 (64 lowercase hex) or nothing runs (INVALID) |
| 8 | note SCRATCH a new directory (created 0700; an existing one is INVALID) |
| 9 | note NG an ng binary to judge in place of the one this gate builds from seed/ng/ng.units (the negative |
| 10 | note control: ng from before the no-caps arena must FAIL here); with NG no mutant is built |
| 11 | note 1. Units far past every fixed table ng's front, its ΩIR builder, reader and writer, and its a64 back end had |
| 12 | note until the no-caps arena (src/ir.om ar_*): each is generated into SCRATCH (u.om, and the same bytes after |
| 13 | note the mode lines `@ng front-check` and `@ng front-ir`) from the case table g_cs below, never stored. |
| 14 | note 2. Per case NAME WANT OMC KIND: OMC compiles the unit and must exit OMC (0, or a code-generator limit of omc's |
| 15 | note own, D6: 12); when 0 its binary must exit WANT. ng `@ng front-check` must exit 0, or exactly omc's code |
| 16 | note with omc's stderr bytes when KIND is d (an om2 diag unit: the stderr records are compared in full). KIND |
| 17 | note r: ng `@ng front-ir` exits 0, `@ng a64` of its ΩIR exits 0, and that ELF, run, exits WANT. KIND c and d stop |
| 18 | note after the check. A line per case: ok NAME, the exits, ng's milliseconds per stage and the bytes of the unit. |
| 19 | note 3. Mutants (with no NG): each re-imposes one of the old fixed tables or loop bounds, or breaks the arena's growth, in the |
| 20 | note composed units of seed/ng/ng.units (pattern FROM present exactly once, replaced by TO); each must make a case |
| 21 | note fail (KILLED; its own case is tried first). A control: case 1 judged with WANT + 1 must fail. |
| 22 | note 4. The usage alarm (OmcNoCaps's gate-usage, for ng): ng `@ng front-check` of the largest real units in this |
| 23 | note repository, each after a `usage` line (seed/node/journal-gate.om and ng's own units joined), writes its ng-use |
| 24 | note record (unit 0 was seed/omc/omc.om until omc declared a run-time pool: ng refuses that as scope, exit 64); |
| 25 | note the arena top must stay at or below 10% of the arena and every group at or below 5%, and one check at or |
| 26 | note below 2 s; past a threshold the gate FAILs with ALARM, the number and the threshold. Its control: ng with |
| 27 | note the arena shrunk to 1048576 words must trip the alarm (with no NG). |
| 28 | note Deadline: every child is killed after 600 s (NOT_RUN, never PASS). |
| 29 | note Output: lines per case, mutant, control and unit, then |
| 30 | note NOCAPSGATE PASS|FAIL|NOT_RUN cases=N fail=F mutants=M killed=K controls=C tripped=T notrun=U |
| 31 | note Exit 0 PASS, 1 FAIL, 2 INVALID, 3 a tool did not build, 4 NOT_RUN. Globals g_*, functions gn_*. |
| 32 | text g_w "seed/ng/ ng.units ng ngm src.om u.om fc.in fi.in ir ai elf bin e0 e1 e2 e3 nul o0 o1 berr us.in seed/node/journal-gate.om uo " |
| 33 | text g_m "FAIL |ok |: omc exit |: omc binary exit |: ng front-check exit |: ng front-ir exit |: ng a64 exit |: program exit |, want |: front-check stderr differs from omc's|NOCAPSGATE PASS|NOCAPSGATE FAIL|NOCAPSGATE INVALID: | cases=| fail=| mutants=| killed=|usage: nocaps-gate OMC OMC_SHA256 SCRATCH [NG]|oracle sha256 differs from OMC_SHA256|scratch exists or cannot be made|build failed: |mutant |: survived every case|: killed by |: pattern not present exactly once|control |: not tripped|: tripped by | ms: check |, ir |, a64 |, elf | (unused)| (unused)| omc=| ng=|NOT_RUN |: a child passed the 600 s deadline| notrun=|: cannot write scratch| bytes=|usage |ALARM |: no ng-use record|: arena top | words, | controls=| tripped=|: front-check took | ms (threshold 2000 ms)|% of the arena (threshold 10%)|NOCAPSGATE NOT_RUN|: group |% of the arena (threshold 5%)| top=| largest=| ms|control usage: arena of 1048576 words|" |
| 34 | text g_pfc "@ng front-check\n" |
| 35 | text g_pfr "@ng front-ir\n" |
| 36 | text g_pa64 "@ng a64\n" |
| 37 | text g_use "usage\n" |
| 38 | note the pieces of the generated units (g_t, separated by |, numbered from 0) |
| 39 | text g_t "|global n| ulong 1\n|fn main to int\nput n0 0 3\nput n99999 0 4\nret int add get n0 0 get n99999 0\nend\n|text t| \"ab\"\n|fn main to int\nx = len t0\ny = len t99999\nret int add x y\nend\n|global long_global_name_| uint 1\n|fn main to int\nput long_global_name_0 0 uint 5\nput long_global_name_99999 0 uint 7\nret int add get long_global_name_0 0 get long_global_name_99999 0\nend\n|fn q| to ulong\nret |\nend\n|fn main to int\na = q0\nb = q59999\nret int rem add a b 256\nend\n|fn inc x ulong to ulong\nret add x 1\nend\nfn main to int\nx = ulong 0\n|x = inc x\n|ret int rem x 256\nend\n|note pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\n|fn main to int\nx = int 41\nx = add x 1\nret x\nend\n|fn main to int\nx = ulong 1\n|if eq x 1\n|ret 9\n|end\n|ret 0\nend\n|fn main to int\nx = ulong 0\n|while true\nx = add x 1\nbreak\nend\n|y = ulong 0\nwhile lt y 1\ny = add y 1\nx = add x 1\ncontinue\nend\n|fn main to int\nx = |add |ulong 0| ulong 1|\nret int rem x 256\nend\n|fn inc x ulong to ulong\nret add x 1\nend\nfn main to int\nx = |inc |ulong 0\nret int rem x 256\nend\n|fn main to int\n|a| = new ulong 1 |\n|x = get a9999 0\nret int rem x 256\nend\n|om2\n|fn ia| x int to int inline\nret add x 1\nend\n|om2 diag\nfn main to int\nx = long 0\n|x = add x long 1\n|ret int rem x long 256\nend\n|| \"|aaaaaaaaaaaaaaaa|\"\n|fn main to int\nx = len t0\ny = len t16\nret int rem add x y 256\nend\n|abc| x int to int\n|x = ia| x\n|ret x\nend\n|fn main to int\nx = int 0\n|x = fg|ret rem x 256\nend\n|fn inc x ulong to ulong\nret add x 1\nend\n| x ulong to ulong\ny = x\n|y = inc y\n|ret y\nend\n|x = q|neg |long 1\nret int rem x long 256\nend\n|not ||add ulong 1 |fn fg|fn f6 a ulong b ulong c ulong d ulong e ulong g ulong to ulong\nret add a 1\nend\nfn main to int\nx = |f6 | ulong 1 ulong 1 ulong 1 ulong 1 ulong 1|fn f x long to long\n|x = add x 1\n|ret x\nend\nfn main to int\nret int rem f long 1 256\nend\n|ret x\nend\nfn main to int\nret int rem f long 9223372036854506807 256\nend\n|om2\nfn ia x int to int inline\n|if eq x 1\nret 9\nend\n|ret x\nend\nfn main to int\nx = ia int 41\nret x\nend\n|\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|fn main to int\nret int rem len t 256\nend\n|" |
| 40 | note the cases: NAME WANT OMC KIND SPEC..., SPEC tokens Lk (piece k), Rk:N (piece k, N times), Nk:m:p:N (for i in |
| 41 | note 0 .. N-1: piece k, i, then piece m and i again when m is not 0, then piece p), I:A:B (the inline-edges unit), |
| 42 | note C:F:K (F functions of K calls each, main calling them all), T:K (K texts of 1 MiB, the last 3 bytes longer). |
| 43 | note KIND r: check, front-ir, a64, the ELF; i: check and front-ir (ng's a64 stage refuses these for a reason named |
| 44 | note below, never a table of the front or the ΩIR); c and d: the check only (d an om2 diag unit, stderr compared). |
| 45 | note Each is past an old fixed table: names100k (front names 8192, front-ir 8192, ΩIR reader 65536 globals, a64 |
| 46 | note 65537 addresses), texts100k, long100k (long names 4096), fns60k (functions 4096), calls1m (calls 524288; its |
| 47 | note ΩIR is 21 MB, past the 16 MiB payload and output buffers; one function of 2,000,009 wires is past what a64's |
| 48 | note per-wire tables, 10 words a wire, take in the arena: i), calls1100k (1,100,000 calls in all: a64's 1048576 |
| 49 | note call sites), calls524289 (the formerly ngcap row: a64's 262144 wires a function), in64m (input 8 MiB), |
| 50 | note nest5000 (blocks 512, front-ir stack 1024; a64's liveness, blocks x wires / 64 words, is 7,035,471 words a |
| 51 | note bitset, past the arena: i), nest3000 (a64 liveness 2.5 M words, past its 2097152), nest1100 (a function of |
| 52 | note over 1000 blocks: a64 read block 1000 and up as a trap label), breaks3000 / conts3000 (1024 each; a64 |
| 53 | note liveness: i), value5000 (value nesting 1024; omc 12), callnest5000, call6nest12000 (front-ir call arguments |
| 54 | note 65536: 72000 here), snap2m (front-ir name snapshots 1048576), arrays10k (front-ir local arrays 8192; omc 12, a64's frame: |
| 55 | note `unsupported`, i), inline22k (inline edges 16384; omc c52e986e and 1e628c80 trapped 3 past 64 inline edges, fixed |
| 56 | note in omc 2495bc25, omega-mv 83507124: omc compiles it and its binary exits 228), diag1m (om2 diag site records 8 MiB), texts17m (ΩIR global |
| 57 | note data 16 MiB, a64 code image 16 MiB), and the deepest value shapes at 32767 levels (d*32767: the stack-derived |
| 58 | note bound of 32768; daddr's right-nested adds need a frame past a64's 4095 bytes: i). |
| 59 | note Old loop bounds of the front and a64 (trap 4 or a64's `unsupported` before the no-caps review): inlrets1m (an |
| 60 | note inline frame's rets walked by fe_inl_pat, 1,000,000 passes: 1,000,001 reachable rets in one inline body called |
| 61 | note once, one inline edge; its front-ir is refused, class 23, by the ΩIR format's 65536 blocks a function, IR.md |
| 62 | note s12: c), text16m (fe_ltxb, a front-ir pass a text byte, 16777216: one literal of 16,777,219 bytes), lalc16m |
| 63 | note (fe_lalc's read-ahead, a pass a blank line and two a statement line, 16777216: 16,777,232 blank lines in main's |
| 64 | note outermost block), fix270k (a64's 262144 branch fixups a function: one overflow branch each), fixtrap270k (the |
| 65 | note same function overflowing: a trap branch patched past the old table, exit 101). |
| 66 | text g_cs "names100k 7 0 r N1:0:2:100000 L3\ntexts100k 4 0 r N4:0:5:100000 L6\nlong100k 12 0 r N7:0:8:100000 L9\nfns60k 95 0 r N10:11:12:60000 L13\ncalls1m 64 0 i L14 R15:1000000 L16\ncalls1100k 224 0 r C:1100:1000\ncalls524289 1 0 r L14 R15:524289 L16\nin64m 42 0 r R17:671088 L18\nnest5000 9 0 i L19 R20:5000 L21 R22:5000 L23\nnest3000 9 0 r L19 R20:3000 L21 R22:3000 L23\nnest1100 9 0 r L19 R20:1100 L21 R22:1100 L23\nbreaks3000 184 0 i L24 R25:3000 L16\nconts3000 184 0 i L24 R26:3000 L16\nvalue5000 136 12 r L27 R28:5000 L29 R30:5000 L31\ncallnest5000 136 0 r L32 R33:5000 L34\ncall6nest12000 224 0 r L70 R71:12000 L29 R72:12000 L31\nsnap2m 9 0 r N1:0:2:1000 L19 R20:2000 L21 R22:2000 L23\narrays10k 15 12 i L35 N36:37:38:10000 L39\ninline22k 228 0 c L40 I:150:150\ndiag1m 0 0 d L43 R44:1000000 L45\ntexts17m 3 0 r T:17\ndneg32767 255 12 r L27 R64:32767 L65\ndadd32767 255 12 r L27 R28:32767 L29 R30:32767 L31\ndcall32767 255 24 r L32 R33:32767 L34\ndnot32767 255 12 r L27 R66:32767 L34\ndaddr32767 255 12 i L27 R68:32767 L34\ninlrets1m 41 0 c L77 R78:1000001 L79\ntext16m 3 0 r L4 L47 R48:1048576 L51 L49 L81\nlalc16m 1 0 r L19 R80:1048577 L16\nfix270k 177 0 r L73 R74:270000 L75\nfixtrap270k 101 0 r L73 R74:270000 L76\n" |
| 67 | global g_wo uint 64 |
| 68 | global g_wl uint 64 |
| 69 | global g_mo uint 128 |
| 70 | global g_ml uint 128 |
| 71 | global g_to uint 128 |
| 72 | global g_tl uint 128 |
| 73 | global g_omc uchar 4096 |
| 74 | global g_scr uchar 4096 |
| 75 | global g_pa uchar 8192 |
| 76 | global g_av uchar 16384 |
| 77 | global g_b1 uchar 16777216 |
| 78 | global g_b2 uchar 16777216 |
| 79 | global g_gb uchar 1048576 |
| 80 | global g_gf int 3 |
| 81 | global g_o uchar 4096 |
| 82 | global g_stb uchar 4 |
| 83 | global g_hx uchar 128 |
| 84 | global g_ng uchar 4096 |
| 85 | global g_mf uchar 256 |
| 86 | global g_mt uchar 512 |
| 87 | global g_n ulong 48 |
| 88 | note g_n: 0 path length, 1 omc length, 2 scratch length (with '/'), 3 argv bytes, 4 argc, 5 b1 length, 6 b2 length, |
| 89 | note 7 generator buffer fill, 8 case cursor in g_cs, 9 out length, 10 cases, 11 failed cases, 12 quiet, 13 current |
| 90 | note case failed (1) or NOT_RUN (2), 14 name start, 15 name end, 16 a child passed the deadline, 17 mutants, 18 killed, |
| 91 | note 19 controls, 20 tripped, 21 NOT_RUN cases, 22 NG given, 23 WANT adjustment (control), 24 spec cursor, 25 spec |
| 92 | note end, 26 unit bytes, 27 mutant FROM length, 28 mutant TO length, 29 ng binary word (2 or 3), 30 alarms, |
| 93 | note 31 last front-check ms, 32 ng-use top, 33 ng-use arena, 34 largest group words, 35 its label start, 36 its end |
| 94 | |
| 95 | note ---- words and output ------------------------------------------------------------------------------- |
| 96 | fn gn_split t ulong to void |
| 97 | w = ulong 0 |
| 98 | s = ulong 0 |
| 99 | if eq t 0 |
| 100 | for i ulong len g_w bound 4096 |
| 101 | if eq get g_w i 32 |
| 102 | put g_wo w uint s |
| 103 | put g_wl w uint sub i s |
| 104 | w = add w 1 |
| 105 | s = add i 1 |
| 106 | end |
| 107 | end |
| 108 | end |
| 109 | if eq t 1 |
| 110 | for i ulong len g_m bound 8192 |
| 111 | if eq get g_m i 124 |
| 112 | put g_mo w uint s |
| 113 | put g_ml w uint sub i s |
| 114 | w = add w 1 |
| 115 | s = add i 1 |
| 116 | end |
| 117 | end |
| 118 | end |
| 119 | if eq t 2 |
| 120 | for i ulong len g_t bound 65536 |
| 121 | if eq get g_t i 124 |
| 122 | put g_to w uint s |
| 123 | put g_tl w uint sub i s |
| 124 | w = add w 1 |
| 125 | s = add i 1 |
| 126 | end |
| 127 | end |
| 128 | end |
| 129 | end |
| 130 | fn gn_init to void |
| 131 | gn_split 0 |
| 132 | gn_split 1 |
| 133 | gn_split 2 |
| 134 | put g_n 29 2 |
| 135 | end |
| 136 | fn gn_c b ulong to void |
| 137 | n = get g_n 9 |
| 138 | if lt n len g_o |
| 139 | put g_o n uchar b |
| 140 | put g_n 9 add n 1 |
| 141 | end |
| 142 | end |
| 143 | fn gn_nl to void |
| 144 | gn_c 10 |
| 145 | r = write 1 g_o 0 get g_n 9 |
| 146 | put g_n 9 0 |
| 147 | end |
| 148 | fn gn_say i ulong to void |
| 149 | s = ulong get g_mo i |
| 150 | for j ulong ulong get g_ml i bound 256 |
| 151 | gn_c ulong get g_m add s j |
| 152 | end |
| 153 | end |
| 154 | fn gn_num v ulong to void |
| 155 | if ge v 10 |
| 156 | gn_num div v 10 |
| 157 | end |
| 158 | gn_c add 48 rem v 10 |
| 159 | end |
| 160 | fn gn_name to void |
| 161 | for p ulong sub get g_n 15 get g_n 14 bound 256 |
| 162 | gn_c ulong get g_cs add get g_n 14 p |
| 163 | end |
| 164 | end |
| 165 | note a failure of the current case (FAIL NAME<message i>), unless quiet |
| 166 | fn gn_fail i ulong to void |
| 167 | put g_n 13 1 |
| 168 | if eq get g_n 12 0 |
| 169 | gn_say 0 |
| 170 | gn_name |
| 171 | gn_say i |
| 172 | end |
| 173 | end |
| 174 | fn gn_failv i ulong v ulong w ulong to void |
| 175 | gn_fail i |
| 176 | if eq get g_n 12 0 |
| 177 | gn_num v |
| 178 | gn_say 8 |
| 179 | gn_num w |
| 180 | gn_nl |
| 181 | end |
| 182 | end |
| 183 | |
| 184 | note ---- paths and files ---------------------------------------------------------------------------------- |
| 185 | fn gn_pclr to void |
| 186 | put g_n 0 0 |
| 187 | end |
| 188 | fn gn_pc c ulong to void |
| 189 | n = get g_n 0 |
| 190 | if lt n len g_pa |
| 191 | put g_pa n uchar c |
| 192 | put g_n 0 add n 1 |
| 193 | end |
| 194 | end |
| 195 | fn gn_pw i ulong to void |
| 196 | s = ulong get g_wo i |
| 197 | for j ulong ulong get g_wl i bound 64 |
| 198 | gn_pc ulong get g_w add s j |
| 199 | end |
| 200 | end |
| 201 | note scratch file word i |
| 202 | fn gn_ps i ulong to void |
| 203 | gn_pclr |
| 204 | for j ulong get g_n 2 bound 4096 |
| 205 | gn_pc ulong get g_scr j |
| 206 | end |
| 207 | gn_pw i |
| 208 | end |
| 209 | fn gn_open fl ulong to int |
| 210 | r = fopen g_pa 0 get g_n 0 int fl 420 |
| 211 | if lt r 0 |
| 212 | ret -1 |
| 213 | end |
| 214 | ret int r |
| 215 | end |
| 216 | fn gn_rdonly to int |
| 217 | ret gn_open 524288 |
| 218 | end |
| 219 | fn gn_wronly to int |
| 220 | ret gn_open 524865 |
| 221 | end |
| 222 | fn gn_exe to int |
| 223 | r = unlink g_pa 0 get g_n 0 |
| 224 | x = fopen g_pa 0 get g_n 0 524865 493 |
| 225 | if lt x 0 |
| 226 | ret -1 |
| 227 | end |
| 228 | ret int x |
| 229 | end |
| 230 | fn gn_fclo fd int to void |
| 231 | if ge fd 0 |
| 232 | r = fclose fd |
| 233 | end |
| 234 | end |
| 235 | note write b1[0, n) to fd; false on a short write |
| 236 | fn gn_wr fd int n ulong to bool |
| 237 | o = ulong 0 |
| 238 | while lt o n bound 16777217 |
| 239 | x = write fd g_b1 o sub n o |
| 240 | if le x 0 |
| 241 | ret false |
| 242 | end |
| 243 | o = add o ulong x |
| 244 | end |
| 245 | ret true |
| 246 | end |
| 247 | note read the file at g_pa into b1 at offset o; its length, or 2^63 when unreadable or too big |
| 248 | fn gn_slurp o ulong to ulong |
| 249 | fd = gn_rdonly |
| 250 | if lt fd 0 |
| 251 | ret shl ulong 1 63 |
| 252 | end |
| 253 | n = o |
| 254 | ok = true |
| 255 | while true bound 16777218 |
| 256 | x = read fd g_b1 n sub len g_b1 n |
| 257 | if lt x 0 |
| 258 | ok = false |
| 259 | break |
| 260 | end |
| 261 | if eq x 0 |
| 262 | break |
| 263 | end |
| 264 | n = add n ulong x |
| 265 | if ge n len g_b1 |
| 266 | ok = false |
| 267 | break |
| 268 | end |
| 269 | end |
| 270 | gn_fclo fd |
| 271 | if not ok |
| 272 | ret shl ulong 1 63 |
| 273 | end |
| 274 | ret sub n o |
| 275 | end |
| 276 | note read up to m bytes of fd into b1 (k 1) or b2 (k 2); the count (0 at the end) |
| 277 | fn gn_rdn fd int k ulong m ulong to ulong |
| 278 | n = ulong 0 |
| 279 | while lt n m bound 1048577 |
| 280 | x = long 0 |
| 281 | if eq k 1 |
| 282 | x = read fd g_b1 n sub m n |
| 283 | else |
| 284 | x = read fd g_b2 n sub m n |
| 285 | end |
| 286 | if le x 0 |
| 287 | ret n |
| 288 | end |
| 289 | n = add n ulong x |
| 290 | end |
| 291 | ret n |
| 292 | end |
| 293 | fn gn_eqn n ulong to bool |
| 294 | for j ulong n bound 1048576 |
| 295 | if ne get g_b1 j get g_b2 j |
| 296 | ret false |
| 297 | end |
| 298 | end |
| 299 | ret true |
| 300 | end |
| 301 | note the scratch files w1 and w2 hold the same bytes |
| 302 | fn gn_fcmp w1 ulong w2 ulong to bool |
| 303 | gn_ps w1 |
| 304 | f1 = gn_rdonly |
| 305 | gn_ps w2 |
| 306 | f2 = gn_rdonly |
| 307 | ok = and ge f1 0 ge f2 0 |
| 308 | dn = false |
| 309 | while and ok not dn bound 65536 |
| 310 | a = gn_rdn f1 1 1048576 |
| 311 | b = gn_rdn f2 2 1048576 |
| 312 | if ne a b |
| 313 | ok = false |
| 314 | else |
| 315 | if eq a 0 |
| 316 | dn = true |
| 317 | end |
| 318 | ok = gn_eqn a |
| 319 | end |
| 320 | end |
| 321 | gn_fclo f1 |
| 322 | gn_fclo f2 |
| 323 | ret ok |
| 324 | end |
| 325 | note scratch file d = the mode line text m (0 a64, 1 front-check) then the bytes of scratch file s |
| 326 | fn gn_pref m ulong s ulong d ulong to bool |
| 327 | n = ulong 0 |
| 328 | if eq m 0 |
| 329 | n = len g_pa64 |
| 330 | for j ulong n bound 64 |
| 331 | put g_b1 j get g_pa64 j |
| 332 | end |
| 333 | else |
| 334 | n = len g_use |
| 335 | for j ulong n bound 64 |
| 336 | put g_b1 j get g_use j |
| 337 | end |
| 338 | end |
| 339 | gn_ps d |
| 340 | fo = gn_wronly |
| 341 | if lt fo 0 |
| 342 | ret false |
| 343 | end |
| 344 | ok = gn_wr fo n |
| 345 | if eq m 2 |
| 346 | ok = and ok gn_wr fo 0 |
| 347 | end |
| 348 | gn_ps s |
| 349 | fi = gn_rdonly |
| 350 | dn = false |
| 351 | while and ok not dn bound 65536 |
| 352 | if lt fi 0 |
| 353 | ok = false |
| 354 | else |
| 355 | k = gn_rdn fi 1 1048576 |
| 356 | if eq k 0 |
| 357 | dn = true |
| 358 | else |
| 359 | ok = gn_wr fo k |
| 360 | end |
| 361 | end |
| 362 | end |
| 363 | gn_fclo fi |
| 364 | gn_fclo fo |
| 365 | ret ok |
| 366 | end |
| 367 | |
| 368 | note ---- children ------------------------------------------------------------------------------------ |
| 369 | fn gn_aclr to void |
| 370 | put g_n 3 2 |
| 371 | put g_n 4 0 |
| 372 | end |
| 373 | fn gn_apa to void |
| 374 | p = get g_n 3 |
| 375 | n = get g_n 0 |
| 376 | for j ulong n bound 8192 |
| 377 | put g_av add add p 2 j get g_pa j |
| 378 | end |
| 379 | put g_av p uchar and n 255 |
| 380 | put g_av add p 1 uchar shr n 8 |
| 381 | put g_n 3 add p add n 2 |
| 382 | c = add get g_n 4 1 |
| 383 | put g_n 4 c |
| 384 | put g_av 0 uchar and c 255 |
| 385 | put g_av 1 uchar shr c 8 |
| 386 | end |
| 387 | fn gn_redir s int d int to void |
| 388 | if ne dupfd s d 0 long d |
| 389 | exit 127 |
| 390 | end |
| 391 | end |
| 392 | note run the argument list with stdin, stdout, stderr fds (closed here); the exit code, 256 + the signal, 1000 |
| 393 | note when the child passed the 600 s deadline (killed; g_n 16 = 1) |
| 394 | fn gn_spawn fi int fo int fe int to ulong |
| 395 | if or lt fi 0 or lt fo 0 lt fe 0 |
| 396 | gn_fclo fi |
| 397 | gn_fclo fo |
| 398 | gn_fclo fe |
| 399 | ret 512 |
| 400 | end |
| 401 | pid = fork |
| 402 | if lt pid 0 |
| 403 | exit 2 |
| 404 | end |
| 405 | if eq pid 0 |
| 406 | gn_redir fi 0 |
| 407 | gn_redir fo 1 |
| 408 | gn_redir fe 2 |
| 409 | r = execprog g_av 0 get g_n 3 |
| 410 | exit 127 |
| 411 | end |
| 412 | gn_fclo fi |
| 413 | gn_fclo fo |
| 414 | gn_fclo fe |
| 415 | t0 = monons |
| 416 | while true bound 1000000000 |
| 417 | r = waitpid int pid g_stb 0 len g_stb 1 |
| 418 | if eq r pid |
| 419 | x = ulong get g_stb 0 |
| 420 | if ne x 0 |
| 421 | ret add 256 x |
| 422 | end |
| 423 | ret ulong get g_stb 1 |
| 424 | end |
| 425 | if lt r 0 |
| 426 | exit 2 |
| 427 | end |
| 428 | if gt sub monons t0 600000000000 |
| 429 | r = killpid int pid 9 |
| 430 | r = waitpid int pid g_stb 0 len g_stb 0 |
| 431 | put g_n 16 1 |
| 432 | ret 1000 |
| 433 | end |
| 434 | q = sleepns 200000 |
| 435 | end |
| 436 | exit 2 |
| 437 | end |
| 438 | note run scratch program p with stdin scratch i, stdout scratch o (an executable when ex), stderr scratch e |
| 439 | fn gn_run p ulong i ulong o ulong ex bool e ulong to ulong |
| 440 | gn_ps i |
| 441 | fi = gn_rdonly |
| 442 | gn_aclr |
| 443 | gn_ps p |
| 444 | gn_apa |
| 445 | gn_ps o |
| 446 | fo = int -1 |
| 447 | if ex |
| 448 | fo = gn_exe |
| 449 | else |
| 450 | fo = gn_wronly |
| 451 | end |
| 452 | gn_ps e |
| 453 | fe = gn_wronly |
| 454 | ret gn_spawn fi fo fe |
| 455 | end |
| 456 | note OMC with stdin scratch i, stdout scratch o (an executable), stderr scratch e |
| 457 | fn gn_omc i ulong o ulong e ulong to ulong |
| 458 | gn_ps i |
| 459 | fi = gn_rdonly |
| 460 | gn_aclr |
| 461 | gn_pclr |
| 462 | for j ulong get g_n 1 bound 4096 |
| 463 | gn_pc ulong get g_omc j |
| 464 | end |
| 465 | gn_apa |
| 466 | gn_ps o |
| 467 | fo = gn_exe |
| 468 | gn_ps e |
| 469 | fe = gn_wronly |
| 470 | ret gn_spawn fi fo fe |
| 471 | end |
| 472 | note milliseconds since t0 |
| 473 | fn gn_ms t0 long to ulong |
| 474 | ret ulong div sub monons t0 1000000 |
| 475 | end |
| 476 | |
| 477 | note ---- the generator ------------------------------------------------------------------------------ |
| 478 | note g_gb is flushed to the g_gf files (u.om, fc.in, fi.in) when full and at the end |
| 479 | fn gn_gflush to bool |
| 480 | n = get g_n 7 |
| 481 | ok = true |
| 482 | for f ulong 3 |
| 483 | fd = get g_gf f |
| 484 | o = ulong 0 |
| 485 | while and ok lt o n bound 1048577 |
| 486 | x = write fd g_gb o sub n o |
| 487 | if le x 0 |
| 488 | ok = false |
| 489 | else |
| 490 | o = add o ulong x |
| 491 | end |
| 492 | end |
| 493 | end |
| 494 | put g_n 26 add get g_n 26 n |
| 495 | put g_n 7 0 |
| 496 | ret ok |
| 497 | end |
| 498 | fn gn_gc c ulong to void |
| 499 | n = get g_n 7 |
| 500 | if ge n len g_gb |
| 501 | z = gn_gflush |
| 502 | n = ulong 0 |
| 503 | end |
| 504 | put g_gb n uchar c |
| 505 | put g_n 7 add n 1 |
| 506 | end |
| 507 | fn gn_gt k ulong to void |
| 508 | s = ulong get g_to k |
| 509 | for j ulong ulong get g_tl k bound 4096 |
| 510 | gn_gc ulong get g_t add s j |
| 511 | end |
| 512 | end |
| 513 | fn gn_gn v ulong to void |
| 514 | if ge v 10 |
| 515 | gn_gn div v 10 |
| 516 | end |
| 517 | gn_gc add 48 rem v 10 |
| 518 | end |
| 519 | note the next decimal number of the spec at g_n 24 (stops at ':', ' ' or the end of the line) |
| 520 | fn gn_snum to ulong |
| 521 | v = ulong 0 |
| 522 | p = get g_n 24 |
| 523 | while lt p get g_n 25 bound 32 |
| 524 | c = ulong get g_cs p |
| 525 | if or lt c 48 gt c 57 |
| 526 | put g_n 24 add p 1 |
| 527 | ret v |
| 528 | end |
| 529 | v = add mul v 10 sub c 48 |
| 530 | p = add p 1 |
| 531 | end |
| 532 | put g_n 24 p |
| 533 | ret v |
| 534 | end |
| 535 | note the inline-edges unit (I:A:B): A inline functions ia0.., B functions f0.. each calling every inline function on |
| 536 | note x, main calling every f on x: B * A edges from a function to an inline function, each recorded once |
| 537 | fn gn_ginl a ulong b ulong to void |
| 538 | for k ulong a bound 100000 |
| 539 | gn_gt 41 |
| 540 | gn_gn k |
| 541 | gn_gt 42 |
| 542 | end |
| 543 | for j ulong b bound 100000 |
| 544 | gn_gt 69 |
| 545 | gn_gn j |
| 546 | gn_gt 52 |
| 547 | for k ulong a bound 100000 |
| 548 | gn_gt 53 |
| 549 | gn_gn k |
| 550 | gn_gt 54 |
| 551 | end |
| 552 | gn_gt 55 |
| 553 | end |
| 554 | gn_gt 56 |
| 555 | for j ulong b bound 100000 |
| 556 | gn_gt 57 |
| 557 | gn_gn j |
| 558 | gn_gt 54 |
| 559 | end |
| 560 | gn_gt 58 |
| 561 | end |
| 562 | note the spread-calls unit (C:F:K): F functions q0.. of K calls each, main calling every q on x |
| 563 | fn gn_gcall f ulong k ulong to void |
| 564 | gn_gt 59 |
| 565 | for j ulong f bound 100000 |
| 566 | gn_gt 10 |
| 567 | gn_gn j |
| 568 | gn_gt 60 |
| 569 | for i ulong k bound 100000 |
| 570 | gn_gt 61 |
| 571 | end |
| 572 | gn_gt 62 |
| 573 | end |
| 574 | gn_gt 24 |
| 575 | for j ulong f bound 100000 |
| 576 | gn_gt 63 |
| 577 | gn_gn j |
| 578 | gn_gt 54 |
| 579 | end |
| 580 | gn_gt 16 |
| 581 | end |
| 582 | note the texts unit (T:K): K texts t0.. of 1048576 bytes (the last 3 more), then main reading t0 and the last |
| 583 | fn gn_gtxt k ulong to void |
| 584 | for i ulong k bound 4096 |
| 585 | gn_gt 4 |
| 586 | gn_gn i |
| 587 | gn_gt 47 |
| 588 | for j ulong 65536 |
| 589 | gn_gt 48 |
| 590 | end |
| 591 | if eq add i 1 k |
| 592 | gn_gt 51 |
| 593 | end |
| 594 | gn_gt 49 |
| 595 | end |
| 596 | gn_gt 50 |
| 597 | end |
| 598 | note generate the case's unit (spec tokens from g_n 24 to g_n 25) into u.om, fc.in and fi.in; false when a |
| 599 | note file cannot be written |
| 600 | fn gn_gen to bool |
| 601 | put g_n 26 0 |
| 602 | put g_n 7 0 |
| 603 | gn_ps 5 |
| 604 | put g_gf 0 gn_wronly |
| 605 | gn_ps 6 |
| 606 | put g_gf 1 gn_wronly |
| 607 | gn_ps 7 |
| 608 | put g_gf 2 gn_wronly |
| 609 | ok = and ge get g_gf 0 0 and ge get g_gf 1 0 ge get g_gf 2 0 |
| 610 | if ok |
| 611 | for j ulong len g_pfc bound 64 |
| 612 | put g_gb j get g_pfc j |
| 613 | end |
| 614 | o = ulong 0 |
| 615 | x = write get g_gf 1 g_gb 0 len g_pfc |
| 616 | for j ulong len g_pfr bound 64 |
| 617 | put g_gb j get g_pfr j |
| 618 | end |
| 619 | x = write get g_gf 2 g_gb 0 len g_pfr |
| 620 | while lt get g_n 24 get g_n 25 bound 64 |
| 621 | p = get g_n 24 |
| 622 | c = ulong get g_cs p |
| 623 | put g_n 24 add p 1 |
| 624 | if eq c 76 |
| 625 | gn_gt gn_snum |
| 626 | end |
| 627 | if eq c 82 |
| 628 | k = gn_snum |
| 629 | n = gn_snum |
| 630 | for i ulong n bound 16777216 |
| 631 | gn_gt k |
| 632 | end |
| 633 | end |
| 634 | if eq c 78 |
| 635 | k = gn_snum |
| 636 | m = gn_snum |
| 637 | q = gn_snum |
| 638 | n = gn_snum |
| 639 | for i ulong n bound 16777216 |
| 640 | gn_gt k |
| 641 | gn_gn i |
| 642 | if ne m 0 |
| 643 | gn_gt m |
| 644 | gn_gn i |
| 645 | end |
| 646 | gn_gt q |
| 647 | end |
| 648 | end |
| 649 | if eq c 73 |
| 650 | put g_n 24 add get g_n 24 1 |
| 651 | a = gn_snum |
| 652 | b = gn_snum |
| 653 | gn_ginl a b |
| 654 | end |
| 655 | if eq c 67 |
| 656 | put g_n 24 add get g_n 24 1 |
| 657 | a = gn_snum |
| 658 | b = gn_snum |
| 659 | gn_gcall a b |
| 660 | end |
| 661 | if eq c 84 |
| 662 | put g_n 24 add get g_n 24 1 |
| 663 | gn_gtxt gn_snum |
| 664 | end |
| 665 | end |
| 666 | ok = gn_gflush |
| 667 | end |
| 668 | gn_fclo get g_gf 0 |
| 669 | gn_fclo get g_gf 1 |
| 670 | gn_fclo get g_gf 2 |
| 671 | ret ok |
| 672 | end |
| 673 | |
| 674 | note ---- one case ----------------------------------------------------------------------------------------- |
| 675 | note fields of the case line at g_n 8: name, WANT, OMC, KIND; the spec's span into g_n 24 and 25; the KIND letter |
| 676 | note (0 at the end of the table, 1 for a malformed line) |
| 677 | fn gn_line to ulong |
| 678 | p = get g_n 8 |
| 679 | e = len g_cs |
| 680 | if ge p e |
| 681 | ret 0 |
| 682 | end |
| 683 | q = p |
| 684 | while and lt q e ne get g_cs q 10 bound 4096 |
| 685 | q = add q 1 |
| 686 | end |
| 687 | put g_n 8 add q 1 |
| 688 | s = p |
| 689 | while and lt p q ne get g_cs p 32 bound 256 |
| 690 | p = add p 1 |
| 691 | end |
| 692 | put g_n 14 s |
| 693 | put g_n 15 p |
| 694 | put g_n 24 add p 1 |
| 695 | put g_n 25 q |
| 696 | ret 2 |
| 697 | end |
| 698 | note the current case: the unit generated, then judged by OMC and its binary (gn_omcp), ng's check (gn_chk) and, |
| 699 | note for KIND r, ng's front-ir, a64 and the ELF (gn_ngrun); a line per case. g_n 37..44: check, ir, a64 and elf |
| 700 | note milliseconds, omc's exit, its binary's, ng's check exit, the ELF's |
| 701 | fn gn_case kind ulong want ulong oc ulong to void |
| 702 | put g_n 13 0 |
| 703 | put g_n 16 0 |
| 704 | if eq get g_n 12 0 |
| 705 | put g_n 10 add get g_n 10 1 |
| 706 | end |
| 707 | for i ulong 8 |
| 708 | put g_n add 37 i 0 |
| 709 | end |
| 710 | if not gn_gen |
| 711 | gn_fail 39 |
| 712 | gn_nl |
| 713 | ret |
| 714 | end |
| 715 | if not gn_omcp kind want oc |
| 716 | ret |
| 717 | end |
| 718 | if not gn_chk kind |
| 719 | ret |
| 720 | end |
| 721 | if or eq kind 114 eq kind 105 |
| 722 | if not gn_ngrun want eq kind 114 |
| 723 | ret |
| 724 | end |
| 725 | end |
| 726 | if eq get g_n 12 0 |
| 727 | gn_say 1 |
| 728 | gn_name |
| 729 | gn_say 34 |
| 730 | gn_num get g_n 41 |
| 731 | gn_c 47 |
| 732 | gn_num get g_n 42 |
| 733 | gn_say 35 |
| 734 | gn_num get g_n 43 |
| 735 | gn_c 47 |
| 736 | gn_num get g_n 44 |
| 737 | gn_say 40 |
| 738 | gn_num get g_n 26 |
| 739 | gn_say 28 |
| 740 | gn_num get g_n 37 |
| 741 | gn_say 29 |
| 742 | gn_num get g_n 38 |
| 743 | gn_say 30 |
| 744 | gn_num get g_n 39 |
| 745 | gn_say 31 |
| 746 | gn_num get g_n 40 |
| 747 | gn_nl |
| 748 | end |
| 749 | end |
| 750 | note OMC on u.om must exit oc; when 0 (and KIND is not d) its binary must exit WANT (+ g_n 23) |
| 751 | fn gn_omcp kind ulong want ulong oc ulong to bool |
| 752 | x = gn_omc 5 11 12 |
| 753 | put g_n 41 x |
| 754 | if gn_dl |
| 755 | ret false |
| 756 | end |
| 757 | if ne x oc |
| 758 | gn_failv 2 x oc |
| 759 | ret false |
| 760 | end |
| 761 | if or ne oc 0 eq kind 100 |
| 762 | ret true |
| 763 | end |
| 764 | a = gn_run 11 16 17 false 19 |
| 765 | put g_n 42 a |
| 766 | if gn_dl |
| 767 | ret false |
| 768 | end |
| 769 | w = add want get g_n 23 |
| 770 | if ne a w |
| 771 | gn_failv 3 a w |
| 772 | ret false |
| 773 | end |
| 774 | ret true |
| 775 | end |
| 776 | note ng @ng front-check: exit 0, or for KIND d omc's exit and omc's stderr bytes |
| 777 | fn gn_chk kind ulong to bool |
| 778 | t0 = monons |
| 779 | y = gn_run get g_n 29 6 17 false 13 |
| 780 | put g_n 37 gn_ms t0 |
| 781 | put g_n 43 y |
| 782 | if gn_dl |
| 783 | ret false |
| 784 | end |
| 785 | if ne kind 100 |
| 786 | if ne y 0 |
| 787 | gn_failv 4 y 0 |
| 788 | ret false |
| 789 | end |
| 790 | ret true |
| 791 | end |
| 792 | x = get g_n 41 |
| 793 | if ne y x |
| 794 | gn_failv 4 y x |
| 795 | ret false |
| 796 | end |
| 797 | if not gn_fcmp 12 13 |
| 798 | gn_fail 9 |
| 799 | if eq get g_n 12 0 |
| 800 | gn_nl |
| 801 | end |
| 802 | ret false |
| 803 | end |
| 804 | ret true |
| 805 | end |
| 806 | note ng @ng front-ir, then (full) @ng a64 of its ΩIR, then the ELF: exits 0, 0 and WANT (+ g_n 23) |
| 807 | fn gn_ngrun want ulong full bool to bool |
| 808 | t0 = monons |
| 809 | z = gn_run get g_n 29 7 8 false 14 |
| 810 | put g_n 38 gn_ms t0 |
| 811 | if gn_dl |
| 812 | ret false |
| 813 | end |
| 814 | if ne z 0 |
| 815 | gn_failv 5 z 0 |
| 816 | ret false |
| 817 | end |
| 818 | if not full |
| 819 | ret true |
| 820 | end |
| 821 | if not gn_pref 0 8 9 |
| 822 | gn_fail 39 |
| 823 | gn_nl |
| 824 | ret false |
| 825 | end |
| 826 | t0 = monons |
| 827 | z = gn_run get g_n 29 9 10 true 15 |
| 828 | put g_n 39 gn_ms t0 |
| 829 | if gn_dl |
| 830 | ret false |
| 831 | end |
| 832 | if ne z 0 |
| 833 | gn_failv 6 z 0 |
| 834 | ret false |
| 835 | end |
| 836 | t0 = monons |
| 837 | b = gn_run 10 16 17 false 19 |
| 838 | put g_n 40 gn_ms t0 |
| 839 | put g_n 44 b |
| 840 | if gn_dl |
| 841 | ret false |
| 842 | end |
| 843 | w = add want get g_n 23 |
| 844 | if ne b w |
| 845 | gn_failv 7 b w |
| 846 | ret false |
| 847 | end |
| 848 | ret true |
| 849 | end |
| 850 | note a child of the current case passed the deadline: NOT_RUN (g_n 13 = 2) |
| 851 | fn gn_dl to bool |
| 852 | if eq get g_n 16 0 |
| 853 | ret false |
| 854 | end |
| 855 | put g_n 13 2 |
| 856 | if eq get g_n 12 0 |
| 857 | gn_say 36 |
| 858 | gn_name |
| 859 | gn_say 37 |
| 860 | gn_nl |
| 861 | end |
| 862 | ret true |
| 863 | end |
| 864 | note the next field of the case line (a number) at g_n 24 |
| 865 | fn gn_fnum to ulong |
| 866 | ret gn_snum |
| 867 | end |
| 868 | note every case (when only is not 0, the case with that number first and, when stop, only until one fails); |
| 869 | note true when some case failed |
| 870 | fn gn_all only ulong stop bool to bool |
| 871 | hit = false |
| 872 | put g_n 8 0 |
| 873 | k = ulong 0 |
| 874 | while true bound 4096 |
| 875 | r = gn_line |
| 876 | if eq r 0 |
| 877 | break |
| 878 | end |
| 879 | k = add k 1 |
| 880 | want = gn_fnum |
| 881 | oc = gn_fnum |
| 882 | kind = ulong get g_cs get g_n 24 |
| 883 | put g_n 24 add get g_n 24 2 |
| 884 | if or eq only 0 eq only k |
| 885 | gn_case kind want oc |
| 886 | if eq get g_n 13 1 |
| 887 | hit = true |
| 888 | if eq get g_n 12 0 |
| 889 | put g_n 11 add get g_n 11 1 |
| 890 | end |
| 891 | if stop |
| 892 | ret true |
| 893 | end |
| 894 | end |
| 895 | if eq get g_n 13 2 |
| 896 | if eq get g_n 12 0 |
| 897 | put g_n 21 add get g_n 21 1 |
| 898 | end |
| 899 | end |
| 900 | end |
| 901 | end |
| 902 | ret hit |
| 903 | end |
| 904 | |
| 905 | note ---- building ng ---------------------------------------------------------------------------------- |
| 906 | note append the file at g_pa to b1 at its length (g_n 5); false when unreadable |
| 907 | fn gn_cat to bool |
| 908 | n = gn_slurp get g_n 5 |
| 909 | if ge n shl ulong 1 63 |
| 910 | ret false |
| 911 | end |
| 912 | put g_n 5 add get g_n 5 n |
| 913 | ret true |
| 914 | end |
| 915 | note the units of seed/ng/ng.units (lines SHA256 PATH, in order) into b1 |
| 916 | fn gn_units to bool |
| 917 | put g_n 5 0 |
| 918 | gn_pclr |
| 919 | gn_pw 0 |
| 920 | gn_pw 1 |
| 921 | fd = gn_rdonly |
| 922 | if lt fd 0 |
| 923 | ret false |
| 924 | end |
| 925 | k = gn_rdn fd 2 1048576 |
| 926 | gn_fclo fd |
| 927 | s = ulong 0 |
| 928 | for i ulong k bound 1048576 |
| 929 | if eq get g_b2 i 10 |
| 930 | if gt i add s 65 |
| 931 | gn_pclr |
| 932 | for j ulong sub i add s 65 bound 4096 |
| 933 | gn_pc ulong get g_b2 add add s 65 j |
| 934 | end |
| 935 | if not gn_cat |
| 936 | ret false |
| 937 | end |
| 938 | end |
| 939 | s = add i 1 |
| 940 | end |
| 941 | end |
| 942 | ret true |
| 943 | end |
| 944 | note write b1[0, g_n 5) to scratch src.om (the usage step reads it as ng's own units, with or without NG) |
| 945 | fn gn_wsrc to bool |
| 946 | gn_ps 4 |
| 947 | fd = gn_wronly |
| 948 | if lt fd 0 |
| 949 | ret false |
| 950 | end |
| 951 | ok = gn_wr fd get g_n 5 |
| 952 | gn_fclo fd |
| 953 | ret ok |
| 954 | end |
| 955 | note compile b1[0, g_n 5) with OMC into scratch word o |
| 956 | fn gn_bld o ulong to bool |
| 957 | if not gn_wsrc |
| 958 | ret false |
| 959 | end |
| 960 | x = gn_omc 4 o 19 |
| 961 | ret eq x 0 |
| 962 | end |
| 963 | note copy the file named by argument 4 to scratch ng (an executable) |
| 964 | fn gn_cpng to bool |
| 965 | r = argread 4 g_pa 0 4095 |
| 966 | if lt r 1 |
| 967 | ret false |
| 968 | end |
| 969 | put g_n 0 ulong r |
| 970 | put g_n 5 0 |
| 971 | if not gn_cat |
| 972 | ret false |
| 973 | end |
| 974 | gn_ps 2 |
| 975 | fd = gn_exe |
| 976 | if lt fd 0 |
| 977 | ret false |
| 978 | end |
| 979 | ok = gn_wr fd get g_n 5 |
| 980 | gn_fclo fd |
| 981 | ret ok |
| 982 | end |
| 983 | |
| 984 | note ---- mutants and controls -------------------------------------------------------------------------- |
| 985 | note the mutants: FROM|TO pairs of g_mx (each FROM present exactly once in the composed units), with the number of |
| 986 | note the case that should kill it |
| 987 | text g_mx "\nfe_need 4 n\nput ar_m add get ar_rb 4 n w\n|\nif ge n 8192\nfe_fail 14\nend\nfe_need 4 n\nput ar_m add get ar_rb 4 n w\n|\nfe_need 6 k\n|\nif ge k 4096\nfe_fail 14\nend\nfe_need 6 k\n|\nfe_need 8 f\n|\nif ge f 4096\nfe_fail 14\nend\nfe_need 8 f\n|\nfe_need 10 n\n|\nif ge n 524288\nfe_fail 14\nend\nfe_need 10 n\n|\nfe_need 11 n\n|\nif ge n 512\nfe_fail 14\nend\nfe_need 11 n\n|\nfe_need 12 n\n|\nif ge n 1024\nfe_fail 14\nend\nfe_need 12 n\n|\nfe_need 13 n\n|\nif ge n 1024\nfe_fail 14\nend\nfe_need 13 n\n|\nfe_need 14 n\n|\nif ge n 16384\nfe_fail 14\nend\nfe_need 14 n\n|\nif gt get f_depth 0 32768\n|\nif gt get f_depth 0 1024\n|\nfe_need 3 n\n|\nif ge n 8388608\nfe_fail 14\nend\nfe_need 3 n\n|\nret fe_check get ar_inl 0\n|\nif ge get ar_inl 0 8388608\nfe_fail 14\nend\nret fe_check get ar_inl 0\n|\nfe_need 18 n\n|\nif ge n 8192\nfe_lno\nend\nfe_need 18 n\n|\nfe_need 20 d\n|\nif ge d 1024\nfe_lno\nend\nfe_need 20 d\n|\nfe_need 21 add p n0\n|\nif gt add p n0 1048576\nfe_lno\nend\nfe_need 21 add p n0\n|\nfe_need 22 a\n|\nif ge a 8192\nfe_lno\nend\nfe_need 22 a\n|\nfe_need 23 add bs np\n|\nif gt add bs np 65536\nfe_lno\nend\nfe_need 23 add bs np\n|\nif ne ar_need 1 add p k 0\nar_die\nend\n|\nif gt add p k 16777216\nar_die\nend\nif ne ar_need 1 add p k 0\nar_die\nend\n|\nif eq ng_rd 2\nng_bad 23 get ar_inl 0\nend\n|\nif eq ng_rd 2\nng_bad 23 get ar_inl 0\nend\nif gt get ar_inl 0 16777216\nng_bad 23 16777216\nend\n|\nif ne ar_need 2 x 0\nar_die\nend\n|\nif ge x 16777216\nar_die\nend\nif ne ar_need 2 x 0\nar_die\nend\n|\nif ne ar_need 24 add get i_n 2 1 0\n|\nif ge get i_n 2 65536\nir_bad 23 get i_rd 0\nret\nend\nif ne ar_need 24 add get i_n 2 1 0\n|\nif ne ar_need 25 n 0\n|\nif gt n 65536\na6_unsup n\nend\nif ne ar_need 25 n 0\n|\nif ne ar_need 26 add nv 1 0\n|\nif gt nv 262144\na6_unsup nv\nend\nif ne ar_need 26 add nv 1 0\n|\nif ne ar_need 27 mul get a_fs 1 lw 0\n|\nif gt mul get a_fs 1 lw 2097152\na6_unsup lw\nend\nif ne ar_need 27 mul get a_fs 1 lw 0\n|\na6_pmove\nc = get a_ncl 0\nif ne ar_need 28 c 0\n|\na6_pmove\nc = get a_ncl 0\nif ge c 1048576\na6_unsup c\nend\nif ne ar_need 28 c 0\n|\nif gt add o 4 134217728\n|\nif gt add o 4 16777216\n|\nconst a_tlab ulong 4294967296\n|\nconst a_tlab ulong 1000\n|\nar_copy t b o\n|\nar_copy t b 0\n|\nfn fe_inl_pat p0 ulong to void\nput f_nilp 0 p0\n|\nfn fe_inl_pat p0 ulong to void\nn = get f_nilp 0\nj = p0\nwhile lt j n\nj = add j 1\nend\nput f_nilp 0 p0\n|\nwhile lt p e bound 134217729\n|\nwhile lt p e bound 16777216\n|\ndp = ulong 0\ngo = true\nwhile go bound 134217729\n|\ndp = ulong 0\ngo = true\nwhile go bound 16777216\n|\nn = get a_fs 12\nif ne ar_need 30 n 0\n|\nn = get a_fs 12\nif ge n 262144\na6_unsup n\nend\nif ne ar_need 30 n 0\n|\nwhile lt i get a_fs 12 bound 33554433\n|\nwhile lt i get a_fs 12 bound 262144\n|" |
| 988 | note g_mkt: the case number (1-based) that should kill each mutant, in order |
| 989 | text g_mkt "1 3 4 5 9 12 13 19 14 20 8 1 9 17 18 16 5 21 21 1 1 7 10 6 21 11 1 27 28 29 30 30 " |
| 990 | global g_mk ulong 64 |
| 991 | note gn_mkinit: g_mkt into g_mk |
| 992 | fn gn_mkinit to void |
| 993 | v = ulong 0 |
| 994 | k = ulong 0 |
| 995 | for j ulong len g_mkt bound 1024 |
| 996 | c = ulong get g_mkt j |
| 997 | if eq c 32 |
| 998 | put g_mk k v |
| 999 | k = add k 1 |
| 1000 | v = ulong 0 |
| 1001 | else |
| 1002 | v = add mul v 10 sub c 48 |
| 1003 | end |
| 1004 | end |
| 1005 | end |
| 1006 | note mutant i (0-based): FROM into g_mf, TO into g_mt; false when there is no mutant i |
| 1007 | fn gn_msel i ulong to bool |
| 1008 | w = ulong 0 |
| 1009 | s = ulong 0 |
| 1010 | fs = ulong 0 |
| 1011 | fl = ulong 0 |
| 1012 | for j ulong len g_mx bound 1048576 |
| 1013 | if eq get g_mx j 124 |
| 1014 | if eq w mul i 2 |
| 1015 | fs = s |
| 1016 | fl = sub j s |
| 1017 | end |
| 1018 | if eq w add mul i 2 1 |
| 1019 | if gt fl len g_mf |
| 1020 | ret false |
| 1021 | end |
| 1022 | for q ulong fl bound 256 |
| 1023 | put g_mf q get g_mx add fs q |
| 1024 | end |
| 1025 | put g_n 27 fl |
| 1026 | tl = sub j s |
| 1027 | if gt tl len g_mt |
| 1028 | ret false |
| 1029 | end |
| 1030 | for q ulong tl bound 512 |
| 1031 | put g_mt q get g_mx add s q |
| 1032 | end |
| 1033 | put g_n 28 tl |
| 1034 | ret true |
| 1035 | end |
| 1036 | w = add w 1 |
| 1037 | s = add j 1 |
| 1038 | end |
| 1039 | end |
| 1040 | ret false |
| 1041 | end |
| 1042 | note the places of FROM in b1[0, g_n 5) |
| 1043 | fn gn_mcount to ulong |
| 1044 | k = get g_n 27 |
| 1045 | n = get g_n 5 |
| 1046 | c = ulong 0 |
| 1047 | if lt n k |
| 1048 | ret 0 |
| 1049 | end |
| 1050 | p = ulong 0 |
| 1051 | while le add p k n bound 16777217 |
| 1052 | if gn_mat p k |
| 1053 | c = add c 1 |
| 1054 | p = add p k |
| 1055 | else |
| 1056 | p = add p 1 |
| 1057 | end |
| 1058 | end |
| 1059 | ret c |
| 1060 | end |
| 1061 | fn gn_mat p ulong k ulong to bool |
| 1062 | if ne get g_b1 p get g_mf 0 |
| 1063 | ret false |
| 1064 | end |
| 1065 | for j ulong k bound 256 |
| 1066 | if ne get g_b1 add p j get g_mf j |
| 1067 | ret false |
| 1068 | end |
| 1069 | end |
| 1070 | ret true |
| 1071 | end |
| 1072 | note the place of the first FROM in b1[0, g_n 5), or g_n 5 when there is none |
| 1073 | fn gn_mpos to ulong |
| 1074 | k = get g_n 27 |
| 1075 | n = get g_n 5 |
| 1076 | if lt n k |
| 1077 | ret n |
| 1078 | end |
| 1079 | e = sub n k |
| 1080 | p = ulong 0 |
| 1081 | while le p e bound 16777217 |
| 1082 | if gn_mat p k |
| 1083 | ret p |
| 1084 | end |
| 1085 | p = add p 1 |
| 1086 | end |
| 1087 | ret n |
| 1088 | end |
| 1089 | note b1 with its one FROM replaced by TO (b2 holds the copy) |
| 1090 | fn gn_msub to void |
| 1091 | p = gn_mpos |
| 1092 | n = get g_n 5 |
| 1093 | for j ulong n bound 16777216 |
| 1094 | put g_b2 j get g_b1 j |
| 1095 | end |
| 1096 | t = get g_n 28 |
| 1097 | for j ulong t bound 512 |
| 1098 | put g_b1 add p j get g_mt j |
| 1099 | end |
| 1100 | r = add p get g_n 27 |
| 1101 | d = add p t |
| 1102 | m = sub n r |
| 1103 | for j ulong m bound 16777216 |
| 1104 | x = get g_b2 add r j |
| 1105 | put g_b1 add d j x |
| 1106 | end |
| 1107 | put g_n 5 add d m |
| 1108 | end |
| 1109 | note mutant i: built to scratch ngm and judged quietly on its own case first, then every case until one fails |
| 1110 | fn gn_mut i ulong to void |
| 1111 | put g_n 17 add get g_n 17 1 |
| 1112 | gn_say 21 |
| 1113 | gn_num i |
| 1114 | if not gn_units |
| 1115 | gn_say 20 |
| 1116 | gn_nl |
| 1117 | put g_n 11 add get g_n 11 1 |
| 1118 | ret |
| 1119 | end |
| 1120 | if ne gn_mcount 1 |
| 1121 | gn_say 24 |
| 1122 | gn_nl |
| 1123 | put g_n 11 add get g_n 11 1 |
| 1124 | ret |
| 1125 | end |
| 1126 | gn_msub |
| 1127 | if not gn_bld 3 |
| 1128 | gn_say 20 |
| 1129 | gn_nl |
| 1130 | put g_n 11 add get g_n 11 1 |
| 1131 | ret |
| 1132 | end |
| 1133 | put g_n 29 3 |
| 1134 | put g_n 12 1 |
| 1135 | k = get g_mk i |
| 1136 | hit = gn_all k true |
| 1137 | if not hit |
| 1138 | hit = gn_all 0 true |
| 1139 | end |
| 1140 | put g_n 12 0 |
| 1141 | put g_n 29 2 |
| 1142 | if hit |
| 1143 | put g_n 18 add get g_n 18 1 |
| 1144 | gn_say 23 |
| 1145 | gn_name |
| 1146 | else |
| 1147 | gn_say 22 |
| 1148 | put g_n 11 add get g_n 11 1 |
| 1149 | end |
| 1150 | gn_nl |
| 1151 | end |
| 1152 | note control: case 1 judged with WANT + 1 must fail |
| 1153 | fn gn_ctl to void |
| 1154 | put g_n 19 add get g_n 19 1 |
| 1155 | put g_n 23 1 |
| 1156 | put g_n 12 1 |
| 1157 | hit = gn_all 1 true |
| 1158 | put g_n 12 0 |
| 1159 | put g_n 23 0 |
| 1160 | gn_say 25 |
| 1161 | gn_num 1 |
| 1162 | if hit |
| 1163 | put g_n 20 add get g_n 20 1 |
| 1164 | gn_say 27 |
| 1165 | gn_name |
| 1166 | else |
| 1167 | gn_say 26 |
| 1168 | put g_n 11 add get g_n 11 1 |
| 1169 | end |
| 1170 | gn_nl |
| 1171 | end |
| 1172 | |
| 1173 | note the largest group's token of the last record (b1[g_n 35, g_n 36)) |
| 1174 | fn gn_ulab to void |
| 1175 | s = get g_n 35 |
| 1176 | for j ulong sub get g_n 36 s bound 4096 |
| 1177 | gn_c ulong get g_b1 add s j |
| 1178 | end |
| 1179 | end |
| 1180 | note ---- the usage alarm --------------------------------------------------------------------------------- |
| 1181 | note gn_uin k: scratch us.in = "@ng front-check\nusage\n", then unit k (0 seed/node/journal-gate.om, 1 ng's own units joined, |
| 1182 | note the scratch src.om the build wrote); false when it cannot be written |
| 1183 | fn gn_uin k ulong to bool |
| 1184 | n = len g_pfc |
| 1185 | for j ulong n bound 64 |
| 1186 | put g_b1 j get g_pfc j |
| 1187 | end |
| 1188 | u = len g_use |
| 1189 | for j ulong u bound 64 |
| 1190 | put g_b1 add n j get g_use j |
| 1191 | end |
| 1192 | n = add n u |
| 1193 | if eq k 0 |
| 1194 | gn_pclr |
| 1195 | gn_pw 21 |
| 1196 | else |
| 1197 | gn_ps 4 |
| 1198 | end |
| 1199 | m = gn_slurp n |
| 1200 | if ge m shl ulong 1 63 |
| 1201 | ret false |
| 1202 | end |
| 1203 | gn_ps 20 |
| 1204 | fd = gn_wronly |
| 1205 | if lt fd 0 |
| 1206 | ret false |
| 1207 | end |
| 1208 | ok = gn_wr fd add n m |
| 1209 | gn_fclo fd |
| 1210 | ret ok |
| 1211 | end |
| 1212 | note the decimal number in b1 after the first byte c of [s, e) |
| 1213 | fn gn_tnum s ulong e ulong c ulong to ulong |
| 1214 | p = s |
| 1215 | while and lt p e ne ulong get g_b1 p c bound 256 |
| 1216 | p = add p 1 |
| 1217 | end |
| 1218 | p = add p 1 |
| 1219 | v = ulong 0 |
| 1220 | while lt p e bound 32 |
| 1221 | d = ulong get g_b1 p |
| 1222 | if or lt d 48 gt d 57 |
| 1223 | ret v |
| 1224 | end |
| 1225 | v = add mul v 10 sub d 48 |
| 1226 | p = add p 1 |
| 1227 | end |
| 1228 | ret v |
| 1229 | end |
| 1230 | note the ng-use record in b1[0, n): g_n 33 the arena words, 32 the top, 34 the largest group's words, 35 / 36 that |
| 1231 | note group's token; false when it is not a record |
| 1232 | fn gn_upar n ulong to bool |
| 1233 | put g_n 34 0 |
| 1234 | if lt n 8 |
| 1235 | ret false |
| 1236 | end |
| 1237 | if or ne get g_b1 0 110 or ne get g_b1 1 103 ne get g_b1 2 45 |
| 1238 | ret false |
| 1239 | end |
| 1240 | t = ulong 0 |
| 1241 | p = ulong 0 |
| 1242 | while lt p n bound 1048576 |
| 1243 | s = p |
| 1244 | while and lt p n gt get g_b1 p 32 bound 4096 |
| 1245 | p = add p 1 |
| 1246 | end |
| 1247 | if gt p s |
| 1248 | if eq t 2 |
| 1249 | put g_n 33 gn_tnum s p 61 |
| 1250 | end |
| 1251 | if eq t 3 |
| 1252 | put g_n 32 gn_tnum s p 61 |
| 1253 | end |
| 1254 | if ge t 6 |
| 1255 | h = gn_tnum s p 47 |
| 1256 | if gt h get g_n 34 |
| 1257 | put g_n 34 h |
| 1258 | put g_n 35 s |
| 1259 | put g_n 36 p |
| 1260 | end |
| 1261 | end |
| 1262 | t = add t 1 |
| 1263 | end |
| 1264 | p = add p 1 |
| 1265 | end |
| 1266 | ret ge t 6 |
| 1267 | end |
| 1268 | note the name of usage unit k |
| 1269 | fn gn_uname k ulong to void |
| 1270 | if eq k 0 |
| 1271 | s = ulong get g_wo 21 |
| 1272 | for j ulong ulong get g_wl 21 bound 64 |
| 1273 | gn_c ulong get g_w add s j |
| 1274 | end |
| 1275 | else |
| 1276 | s = ulong get g_wo 0 |
| 1277 | for j ulong ulong get g_wl 0 bound 64 |
| 1278 | gn_c ulong get g_w add s j |
| 1279 | end |
| 1280 | s = ulong get g_wo 1 |
| 1281 | for j ulong ulong get g_wl 1 bound 64 |
| 1282 | gn_c ulong get g_w add s j |
| 1283 | end |
| 1284 | end |
| 1285 | end |
| 1286 | note unit k through ng (scratch word g_n 29) with a usage line: its record judged against the thresholds; a line |
| 1287 | note per unit (usage NAME top=.. largest=GROUP=N/H .. ms) and one per alarm unless quiet; the alarms, counted |
| 1288 | fn gn_uchk k ulong to ulong |
| 1289 | if not gn_uin k |
| 1290 | if eq get g_n 12 0 |
| 1291 | gn_say 42 |
| 1292 | gn_uname k |
| 1293 | gn_say 39 |
| 1294 | gn_nl |
| 1295 | end |
| 1296 | ret 1 |
| 1297 | end |
| 1298 | t0 = monons |
| 1299 | x = gn_run get g_n 29 20 22 false 15 |
| 1300 | ms = gn_ms t0 |
| 1301 | gn_ps 22 |
| 1302 | n = gn_slurp 0 |
| 1303 | if or ne x 0 or ge n shl ulong 1 63 not gn_upar n |
| 1304 | if eq get g_n 12 0 |
| 1305 | gn_say 42 |
| 1306 | gn_uname k |
| 1307 | gn_say 43 |
| 1308 | gn_nl |
| 1309 | end |
| 1310 | ret 1 |
| 1311 | end |
| 1312 | a = get g_n 33 |
| 1313 | tp = get g_n 32 |
| 1314 | h = get g_n 34 |
| 1315 | al = ulong 0 |
| 1316 | if gt mul tp 100 mul a 10 |
| 1317 | al = add al 1 |
| 1318 | gn_ual k 44 tp a 50 |
| 1319 | end |
| 1320 | if gt mul h 100 mul a 5 |
| 1321 | al = add al 1 |
| 1322 | gn_ual k 52 h a 53 |
| 1323 | end |
| 1324 | if gt ms 2000 |
| 1325 | al = add al 1 |
| 1326 | if eq get g_n 12 0 |
| 1327 | gn_say 42 |
| 1328 | gn_uname k |
| 1329 | gn_say 48 |
| 1330 | gn_num ms |
| 1331 | gn_say 49 |
| 1332 | gn_nl |
| 1333 | end |
| 1334 | end |
| 1335 | if eq get g_n 12 0 |
| 1336 | gn_say 41 |
| 1337 | gn_uname k |
| 1338 | gn_say 54 |
| 1339 | gn_num tp |
| 1340 | gn_say 55 |
| 1341 | gn_ulab |
| 1342 | gn_c 32 |
| 1343 | gn_num ms |
| 1344 | gn_say 56 |
| 1345 | gn_nl |
| 1346 | end |
| 1347 | ret al |
| 1348 | end |
| 1349 | note one alarm line: ALARM NAME<message m> v words, P<message t> |
| 1350 | fn gn_ual k ulong m ulong v ulong a ulong t ulong to void |
| 1351 | if ne get g_n 12 0 |
| 1352 | ret |
| 1353 | end |
| 1354 | gn_say 42 |
| 1355 | gn_uname k |
| 1356 | gn_say m |
| 1357 | gn_num v |
| 1358 | gn_say 45 |
| 1359 | gn_num div mul v 100 a |
| 1360 | gn_say t |
| 1361 | gn_nl |
| 1362 | end |
| 1363 | note the usage alarm over both units (counted as failed cases when it alarms); control (with no NG): ng built |
| 1364 | note with the arena shrunk to 1048576 words must alarm on some unit |
| 1365 | fn gn_usage to void |
| 1366 | for k ulong 2 |
| 1367 | if ne gn_uchk k 0 |
| 1368 | put g_n 11 add get g_n 11 1 |
| 1369 | end |
| 1370 | end |
| 1371 | end |
| 1372 | text g_ux "\nglobal ar_m ulong 16777216\n|\nglobal ar_m ulong 1048576\n|" |
| 1373 | fn gn_uctl to void |
| 1374 | put g_n 19 add get g_n 19 1 |
| 1375 | gn_say 57 |
| 1376 | put g_n 27 0 |
| 1377 | put g_n 28 0 |
| 1378 | k = ulong 0 |
| 1379 | fs = ulong 0 |
| 1380 | for j ulong len g_ux bound 256 |
| 1381 | if eq get g_ux j 124 |
| 1382 | if eq k 0 |
| 1383 | put g_n 27 j |
| 1384 | for q ulong j bound 256 |
| 1385 | put g_mf q get g_ux q |
| 1386 | end |
| 1387 | fs = add j 1 |
| 1388 | else |
| 1389 | put g_n 28 sub j fs |
| 1390 | for q ulong sub j fs bound 256 |
| 1391 | put g_mt q get g_ux add fs q |
| 1392 | end |
| 1393 | end |
| 1394 | k = add k 1 |
| 1395 | end |
| 1396 | end |
| 1397 | ok = gn_units |
| 1398 | if ok |
| 1399 | ok = eq gn_mcount 1 |
| 1400 | end |
| 1401 | if ok |
| 1402 | gn_msub |
| 1403 | ok = gn_bld 3 |
| 1404 | end |
| 1405 | if not ok |
| 1406 | gn_say 20 |
| 1407 | gn_nl |
| 1408 | put g_n 11 add get g_n 11 1 |
| 1409 | ret |
| 1410 | end |
| 1411 | put g_n 29 3 |
| 1412 | put g_n 12 1 |
| 1413 | al = add gn_uchk 0 gn_uchk 1 |
| 1414 | put g_n 12 0 |
| 1415 | put g_n 29 2 |
| 1416 | if gt al 0 |
| 1417 | put g_n 20 add get g_n 20 1 |
| 1418 | gn_say 27 |
| 1419 | gn_num al |
| 1420 | else |
| 1421 | gn_say 26 |
| 1422 | put g_n 11 add get g_n 11 1 |
| 1423 | end |
| 1424 | gn_nl |
| 1425 | end |
| 1426 | |
| 1427 | note ---- main --------------------------------------------------------------------------------------------- |
| 1428 | fn gn_inval i ulong to int |
| 1429 | gn_say 12 |
| 1430 | gn_say i |
| 1431 | gn_nl |
| 1432 | ret 2 |
| 1433 | end |
| 1434 | note OMC hashes to the hex of argument 2 |
| 1435 | fn gn_oracle to bool |
| 1436 | gn_pclr |
| 1437 | for j ulong get g_n 1 bound 4096 |
| 1438 | gn_pc ulong get g_omc j |
| 1439 | end |
| 1440 | fd = gn_rdonly |
| 1441 | if lt fd 0 |
| 1442 | ret false |
| 1443 | end |
| 1444 | n = ulong 0 |
| 1445 | while true bound 16777218 |
| 1446 | x = read fd sh_dat n sub len sh_dat n |
| 1447 | if le x 0 |
| 1448 | break |
| 1449 | end |
| 1450 | n = add n ulong x |
| 1451 | if ge n len sh_dat |
| 1452 | gn_fclo fd |
| 1453 | ret false |
| 1454 | end |
| 1455 | end |
| 1456 | gn_fclo fd |
| 1457 | sh_all n |
| 1458 | r = argread 2 g_hx 0 128 |
| 1459 | if ne r 64 |
| 1460 | ret false |
| 1461 | end |
| 1462 | for j ulong 32 |
| 1463 | b = get sh_dig j |
| 1464 | if ne get g_hx mul j 2 sh_hexd uint shr b 4 |
| 1465 | ret false |
| 1466 | end |
| 1467 | if ne get g_hx add mul j 2 1 sh_hexd uint and b 15 |
| 1468 | ret false |
| 1469 | end |
| 1470 | end |
| 1471 | ret true |
| 1472 | end |
| 1473 | fn main to int |
| 1474 | gn_init |
| 1475 | gn_mkinit |
| 1476 | c = argcnt |
| 1477 | if and ne c 4 ne c 5 |
| 1478 | ret gn_inval 17 |
| 1479 | end |
| 1480 | r = argread 1 g_omc 0 4095 |
| 1481 | if lt r 1 |
| 1482 | ret gn_inval 17 |
| 1483 | end |
| 1484 | put g_n 1 ulong r |
| 1485 | if not gn_oracle |
| 1486 | ret gn_inval 18 |
| 1487 | end |
| 1488 | r = argread 3 g_scr 0 4094 |
| 1489 | if lt r 1 |
| 1490 | ret gn_inval 17 |
| 1491 | end |
| 1492 | n = ulong r |
| 1493 | x = makedir g_scr 0 n 448 |
| 1494 | if ne x 0 |
| 1495 | ret gn_inval 19 |
| 1496 | end |
| 1497 | put g_scr n 47 |
| 1498 | put g_n 2 add n 1 |
| 1499 | gn_ps 16 |
| 1500 | fd = gn_wronly |
| 1501 | gn_fclo fd |
| 1502 | if eq c 5 |
| 1503 | put g_n 22 1 |
| 1504 | if not gn_cpng |
| 1505 | ret gn_inval 17 |
| 1506 | end |
| 1507 | note the usage step reads ng's own units from src.om: compose and write it, without building |
| 1508 | if not gn_units |
| 1509 | gn_say 20 |
| 1510 | gn_nl |
| 1511 | ret 3 |
| 1512 | end |
| 1513 | if not gn_wsrc |
| 1514 | gn_say 20 |
| 1515 | gn_nl |
| 1516 | ret 3 |
| 1517 | end |
| 1518 | else |
| 1519 | if not gn_units |
| 1520 | gn_say 20 |
| 1521 | gn_nl |
| 1522 | ret 3 |
| 1523 | end |
| 1524 | if not gn_bld 2 |
| 1525 | gn_say 20 |
| 1526 | gn_ps 19 |
| 1527 | r = write 1 g_pa 0 get g_n 0 |
| 1528 | gn_nl |
| 1529 | ret 3 |
| 1530 | end |
| 1531 | end |
| 1532 | z = gn_all 0 false |
| 1533 | gn_usage |
| 1534 | if eq get g_n 22 0 |
| 1535 | for i ulong 64 |
| 1536 | if gn_msel i |
| 1537 | gn_mut i |
| 1538 | end |
| 1539 | end |
| 1540 | gn_ctl |
| 1541 | gn_uctl |
| 1542 | end |
| 1543 | f = get g_n 11 |
| 1544 | nr = get g_n 21 |
| 1545 | if ne f 0 |
| 1546 | gn_say 11 |
| 1547 | else |
| 1548 | if ne nr 0 |
| 1549 | gn_say 51 |
| 1550 | else |
| 1551 | gn_say 10 |
| 1552 | end |
| 1553 | end |
| 1554 | gn_say 13 |
| 1555 | gn_num get g_n 10 |
| 1556 | gn_say 14 |
| 1557 | gn_num f |
| 1558 | gn_say 15 |
| 1559 | gn_num get g_n 17 |
| 1560 | gn_say 16 |
| 1561 | gn_num get g_n 18 |
| 1562 | gn_say 46 |
| 1563 | gn_num get g_n 19 |
| 1564 | gn_say 47 |
| 1565 | gn_num get g_n 20 |
| 1566 | gn_say 38 |
| 1567 | gn_num nr |
| 1568 | gn_nl |
| 1569 | if ne f 0 |
| 1570 | ret 1 |
| 1571 | end |
| 1572 | if ne nr 0 |
| 1573 | ret 4 |
| 1574 | end |
| 1575 | ret 0 |
| 1576 | end |