omega-helix
This project has not described itself yet.
Brought by drakestapleton
omega-helix / native / pillars_cli.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note Unified 8-Pillar Pure-Omega CLI (OMG pack/decode/samp + Arboris 3-layer guide). |
| 3 | note Concatenated after cli.om on hosted targets (gb10, aarch64, macos, x86linux); stubbed on UEFI. |
| 4 | |
| 5 | fn omg_pick_neural st ulong tm ulong to ulong |
| 6 | off = get og 27 |
| 7 | best = OMG_EOF |
| 8 | bv = bitcast f64 ulong 18442240474082181120 |
| 9 | for c ulong 256 |
| 10 | if eq get omg_mask c 1 |
| 11 | v = get oa add off c |
| 12 | if or eq best OMG_EOF gt v bv |
| 13 | bv = v |
| 14 | best = c |
| 15 | end |
| 16 | end |
| 17 | end |
| 18 | if or eq best OMG_EOF eq tm 0 |
| 19 | ret best |
| 20 | end |
| 21 | tau = div f64 tm 1000.0 |
| 22 | m = bitcast f64 ulong 18442240474082181120 |
| 23 | for c2 ulong 256 |
| 24 | if eq get omg_mask c2 1 |
| 25 | x = div get oa add off c2 tau |
| 26 | put oa add off c2 x |
| 27 | m = fmax m x |
| 28 | end |
| 29 | end |
| 30 | sm = 0.0f64 |
| 31 | for c3 ulong 256 |
| 32 | if eq get omg_mask c3 1 |
| 33 | e = fexp sub get oa add off c3 m |
| 34 | put oa add off c3 e |
| 35 | sm = add sm e |
| 36 | else |
| 37 | put oa add off c3 0.0f64 |
| 38 | end |
| 39 | end |
| 40 | if le sm 0.0f64 |
| 41 | ret best |
| 42 | end |
| 43 | u = mul mul f64 shr smx st 11 1.1102230246251565e-16 sm |
| 44 | acc = 0.0f64 |
| 45 | la = best |
| 46 | for k ulong 256 |
| 47 | if eq get omg_mask k 1 |
| 48 | pk = get oa add off k |
| 49 | acc = add acc pk |
| 50 | if lt u acc |
| 51 | ret k |
| 52 | end |
| 53 | if gt pk 0.0f64 |
| 54 | la = k |
| 55 | end |
| 56 | end |
| 57 | end |
| 58 | ret la |
| 59 | end |
| 60 | |
| 61 | fn omg_write_dec ai ulong to ulong |
| 62 | rc = omg_decode_om |
| 63 | if ne rc 0 |
| 64 | exit 33 |
| 65 | end |
| 66 | nd = get omg_ndec 0 |
| 67 | if gt nd 524288 |
| 68 | exit 70 |
| 69 | end |
| 70 | ocwopen ai |
| 71 | for i ulong nd |
| 72 | put ock i get omg_dec i |
| 73 | end |
| 74 | ocwput 0 nd |
| 75 | ocwend ai |
| 76 | ret nd |
| 77 | end |
| 78 | |
| 79 | text omg_p_pack "OMGPACK " |
| 80 | text omg_p_dec "OMGDEC " |
| 81 | text omg_p_samp "OMGSAMP " |
| 82 | text arb_p_guide "ARBGUIDE " |
| 83 | |
| 84 | fn omg_pack_cli to void |
| 85 | if ne oargc 5 |
| 86 | exit 2 |
| 87 | end |
| 88 | n = odread 3 |
| 89 | if or eq n 0 gt n OMG_MAX_SRC |
| 90 | exit 2 |
| 91 | end |
| 92 | for i ulong n |
| 93 | put omg_src i get od0 i |
| 94 | end |
| 95 | put omg_nsrc 0 n |
| 96 | if ne omg_parse_om 0 |
| 97 | exit 30 |
| 98 | end |
| 99 | nt = get omg_ntok 0 |
| 100 | if or eq nt 0 gt nt 524288 |
| 101 | exit 70 |
| 102 | end |
| 103 | sid = omg_semantic_id |
| 104 | ocwopen 4 |
| 105 | for j ulong nt |
| 106 | put ock j uchar and ulong get omg_toks j 255 |
| 107 | end |
| 108 | ocwput 0 nt |
| 109 | ocwend 4 |
| 110 | omg_put_str omg_p_pack |
| 111 | oputu n |
| 112 | oputc 32 |
| 113 | oputu nt |
| 114 | oputc 32 |
| 115 | oputx sid |
| 116 | oputc 10 |
| 117 | oflush |
| 118 | end |
| 119 | |
| 120 | fn omg_dec_cli to void |
| 121 | if ne oargc 5 |
| 122 | exit 2 |
| 123 | end |
| 124 | nt = odread 3 |
| 125 | if or eq nt 0 gt nt OMG_MAX_TOKS |
| 126 | exit 2 |
| 127 | end |
| 128 | for i ulong nt |
| 129 | put omg_toks i ushort get od0 i |
| 130 | end |
| 131 | put omg_ntok 0 nt |
| 132 | nd = omg_write_dec 4 |
| 133 | omg_put_str omg_p_dec |
| 134 | oputu nt |
| 135 | oputc 32 |
| 136 | oputu nd |
| 137 | oputc 10 |
| 138 | oflush |
| 139 | end |
| 140 | |
| 141 | fn omg_samp_cli to void |
| 142 | if ne oargc 8 |
| 143 | exit 2 |
| 144 | end |
| 145 | ockloop 3 |
| 146 | if ne get og 0 256 |
| 147 | exit 2 |
| 148 | end |
| 149 | st = oargu 4 |
| 150 | budget = oargu 5 |
| 151 | tm = oargu 6 |
| 152 | if or eq budget 0 gt budget 512 |
| 153 | exit 2 |
| 154 | end |
| 155 | ochipup |
| 156 | omg_init_gen |
| 157 | put omg_ntok 0 0 |
| 158 | put og 9 0 |
| 159 | ocpush 0 |
| 160 | for step ulong budget |
| 161 | omg_valid_mask sub budget step |
| 162 | olastf |
| 163 | tok = omg_pick_neural st tm |
| 164 | if ne tm 0 |
| 165 | st = add st 11400714819323198485 |
| 166 | end |
| 167 | if eq tok OMG_EOF |
| 168 | break |
| 169 | end |
| 170 | omg_emit tok |
| 171 | if ne omg_step tok 0 |
| 172 | exit 32 |
| 173 | end |
| 174 | ocpush tok |
| 175 | if and eq get omg_st 0 0 eq get omg_st 1 0 |
| 176 | break |
| 177 | end |
| 178 | end |
| 179 | nd = omg_write_dec 7 |
| 180 | sid = omg_semantic_id |
| 181 | omg_put_str omg_p_samp |
| 182 | oputu get omg_ntok 0 |
| 183 | oputc 32 |
| 184 | oputu nd |
| 185 | oputc 32 |
| 186 | oputx sid |
| 187 | oputc 10 |
| 188 | oflush |
| 189 | end |
| 190 | |
| 191 | fn cmdomg_cli to void |
| 192 | if lt oargc 3 |
| 193 | cmdomg |
| 194 | ret |
| 195 | end |
| 196 | r = oargr 2 |
| 197 | if eq r 8 |
| 198 | if and eq get oarg 0 115 eq get oarg 1 101 |
| 199 | cmdomg |
| 200 | ret |
| 201 | end |
| 202 | end |
| 203 | if and eq r 4 eq get oarg 0 112 |
| 204 | omg_pack_cli |
| 205 | ret |
| 206 | end |
| 207 | if and eq r 6 eq get oarg 0 100 |
| 208 | omg_dec_cli |
| 209 | ret |
| 210 | end |
| 211 | if and eq r 4 and eq get oarg 0 115 eq get oarg 1 97 |
| 212 | omg_samp_cli |
| 213 | ret |
| 214 | end |
| 215 | exit 2 |
| 216 | end |
| 217 | |
| 218 | fn arb_ingest_toks cn ulong to void |
| 219 | arboris_clear |
| 220 | if lt cn 2 |
| 221 | ret |
| 222 | end |
| 223 | w1 = new ulong 1 0 |
| 224 | lim1 = sub cn 1 |
| 225 | for i1 ulong lim1 |
| 226 | put w1 0 ulong get od0 i1 |
| 227 | ok1 = arboris_put w1 0 1 ulong get od0 add i1 1 910000 |
| 228 | end |
| 229 | if lt cn 3 |
| 230 | ret |
| 231 | end |
| 232 | w2 = new ulong 2 0 |
| 233 | lim2 = sub cn 2 |
| 234 | for i2 ulong lim2 |
| 235 | put w2 0 ulong get od0 i2 |
| 236 | put w2 1 ulong get od0 add i2 1 |
| 237 | ok2 = arboris_put w2 0 2 ulong get od0 add i2 2 930000 |
| 238 | end |
| 239 | if lt cn 4 |
| 240 | ret |
| 241 | end |
| 242 | w3 = new ulong 3 0 |
| 243 | lim3 = sub cn 3 |
| 244 | for i3 ulong lim3 |
| 245 | put w3 0 ulong get od0 i3 |
| 246 | put w3 1 ulong get od0 add i3 1 |
| 247 | put w3 2 ulong get od0 add i3 2 |
| 248 | ok3 = arboris_put w3 0 3 ulong get od0 add i3 3 960000 |
| 249 | end |
| 250 | end |
| 251 | |
| 252 | fn arb_try_bypass step ulong to ulong |
| 253 | ctx = new ulong 3 0 |
| 254 | res = new ulong 2 0 |
| 255 | if ge step 3 |
| 256 | put ctx 0 ulong get omg_toks sub step 3 |
| 257 | put ctx 1 ulong get omg_toks sub step 2 |
| 258 | put ctx 2 ulong get omg_toks sub step 1 |
| 259 | if arboris_probe ctx 0 3 res |
| 260 | cand3 = get res 0 |
| 261 | if and lt cand3 256 and ge get res 1 900000 eq get omg_mask cand3 1 |
| 262 | ret cand3 |
| 263 | end |
| 264 | end |
| 265 | end |
| 266 | if ge step 2 |
| 267 | put ctx 0 ulong get omg_toks sub step 2 |
| 268 | put ctx 1 ulong get omg_toks sub step 1 |
| 269 | if arboris_probe ctx 0 2 res |
| 270 | cand2 = get res 0 |
| 271 | if and lt cand2 256 and ge get res 1 900000 eq get omg_mask cand2 1 |
| 272 | ret cand2 |
| 273 | end |
| 274 | end |
| 275 | end |
| 276 | if ge step 1 |
| 277 | put ctx 0 ulong get omg_toks sub step 1 |
| 278 | if arboris_probe ctx 0 1 res |
| 279 | cand1 = get res 0 |
| 280 | if and lt cand1 256 and ge get res 1 900000 eq get omg_mask cand1 1 |
| 281 | ret cand1 |
| 282 | end |
| 283 | end |
| 284 | end |
| 285 | ret OMG_EOF |
| 286 | end |
| 287 | |
| 288 | fn arb_guide_cli to void |
| 289 | if ne oargc 9 |
| 290 | exit 2 |
| 291 | end |
| 292 | cn = odread 4 |
| 293 | arb_ingest_toks cn |
| 294 | ockloop 3 |
| 295 | if ne get og 0 256 |
| 296 | exit 2 |
| 297 | end |
| 298 | st = oargu 5 |
| 299 | budget = oargu 6 |
| 300 | tm = oargu 7 |
| 301 | if or eq budget 0 gt budget 512 |
| 302 | exit 2 |
| 303 | end |
| 304 | ochipup |
| 305 | omg_init_gen |
| 306 | put omg_ntok 0 0 |
| 307 | put og 9 0 |
| 308 | ocpush 0 |
| 309 | bp = ulong 0 |
| 310 | ltp = ulong 0 |
| 311 | for step ulong budget |
| 312 | omg_valid_mask sub budget step |
| 313 | tok = arb_try_bypass step |
| 314 | if ne tok OMG_EOF |
| 315 | bp = add bp 1 |
| 316 | else |
| 317 | ltp = add ltp 1 |
| 318 | olastf |
| 319 | tok = omg_pick_neural st tm |
| 320 | if ne tm 0 |
| 321 | st = add st 11400714819323198485 |
| 322 | end |
| 323 | end |
| 324 | if eq tok OMG_EOF |
| 325 | break |
| 326 | end |
| 327 | omg_emit tok |
| 328 | if ne omg_step tok 0 |
| 329 | exit 32 |
| 330 | end |
| 331 | ocpush tok |
| 332 | if and eq get omg_st 0 0 eq get omg_st 1 0 |
| 333 | break |
| 334 | end |
| 335 | end |
| 336 | nd = omg_write_dec 8 |
| 337 | sid = omg_semantic_id |
| 338 | omg_put_str arb_p_guide |
| 339 | oputu get omg_ntok 0 |
| 340 | oputc 32 |
| 341 | oputu bp |
| 342 | oputc 32 |
| 343 | oputu ltp |
| 344 | oputc 32 |
| 345 | oputu nd |
| 346 | oputc 32 |
| 347 | oputx sid |
| 348 | oputc 10 |
| 349 | oflush |
| 350 | end |
| 351 | |
| 352 | fn cmdarboris_cli to void |
| 353 | if lt oargc 3 |
| 354 | cmdarboris |
| 355 | ret |
| 356 | end |
| 357 | r = oargr 2 |
| 358 | if eq r 8 |
| 359 | if and eq get oarg 0 115 eq get oarg 1 101 |
| 360 | cmdarboris |
| 361 | ret |
| 362 | end |
| 363 | end |
| 364 | if and eq r 5 eq get oarg 0 103 |
| 365 | arb_guide_cli |
| 366 | ret |
| 367 | end |
| 368 | exit 2 |
| 369 | end |