Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/src/adapters/python-u64-export.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / src / adapters / python-u64-export.om` 453 lines ยท 6345 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-or-later 2 note Handwritten S1-family upper-to-Python3 exporter (python-explicit-u64-pure-v1, spec/universal/python-u64-v1.md). 3 note Prepended unchanged at build: src/source-aware/vendor/sha256.om and src/source-aware/core.om (decode n). 4 note Input frame: one byte name length L (0 = calc), L name bytes, then one OMSB envelope to EOF. 5 note Output is generated from the OMSA operation records only; the OMSP sidecar is validated by decode, never read. 6 global Yn uchar 1 7 global Ynm uchar 32 8 global Yone uchar 1 9 global Yo uchar 4096 10 global Yl ulong 1 11 global Yni ulong 1 12 global Yln ulong 64 13 global Ydp ulong 64 14 global Ycn ulong 64 15 text Ycalc "calc" 16 text Ywords "def return False None True and as assert async await break class continue del elif else except finally for from global if import in is lambda nonlocal not or pass raise try while with yield match case type" 17 text Ydef "def " 18 text Ymid "):\n return " 19 text Ymask " & 0xFFFFFFFFFFFFFFFF" 20 text YBad "PY_EXPORT_BAD_COMMAND\n" 21 text YMal "PY_EXPORT_MALFORMED\n" 22 text YLim "PY_EXPORT_LIMIT\n" 23 text YProf "PY_EXPORT_PROFILE_MISMATCH\n" 24 text YIO "PY_EXPORT_IO\n" 25 26 fn ydie code ulong to void 27 if eq code 64 28 w = write 2 YBad 0 len YBad 29 end 30 if eq code 65 31 w = write 2 YMal 0 len YMal 32 end 33 if eq code 67 34 w = write 2 YLim 0 len YLim 35 end 36 if eq code 68 37 w = write 2 YProf 0 len YProf 38 end 39 if eq code 77 40 w = write 2 YIO 0 len YIO 41 end 42 exit int code 43 end 44 45 fn ybyte c ulong to void 46 put Yo get Yl 0 uchar c 47 put Yl 0 add get Yl 0 1 48 end 49 50 fn ydigits v ulong to ulong 51 d = ulong 1 52 x = div v 10 53 while gt x 0 54 d = add d 1 55 x = div x 10 56 end 57 ret d 58 end 59 60 fn ydec v ulong to void 61 d = new uchar 20 0 62 i = ulong 0 63 x = v 64 put d 0 uchar add rem x 10 48 65 x = div x 10 66 i = add i 1 67 while gt x 0 68 put d i uchar add rem x 10 48 69 x = div x 10 70 i = add i 1 71 end 72 while gt i 0 73 i = sub i 1 74 ybyte ulong get d i 75 end 76 end 77 78 fn yidc c ulong to bool 79 if and ge c 48 le c 57 80 ret true 81 end 82 if and ge c 65 le c 90 83 ret true 84 end 85 if and ge c 97 le c 122 86 ret true 87 end 88 ret eq c 95 89 end 90 91 fn ywrd p ulong to bool 92 if ge p len Ywords 93 ret false 94 end 95 ret ne get Ywords p 32 96 end 97 98 fn ysame off ulong count ulong to bool 99 if ne count ulong get Yn 0 100 ret false 101 end 102 for i ulong count 103 if ne get Ynm i get Ywords add off i 104 ret false 105 end 106 end 107 ret true 108 end 109 110 fn ykeyword to bool 111 p = ulong 0 112 while lt p len Ywords 113 b = p 114 while ywrd p 115 p = add p 1 116 end 117 if ysame b sub p b 118 ret true 119 end 120 p = add p 1 121 end 122 ret false 123 end 124 125 fn ynameok to bool 126 n = ulong get Yn 0 127 if eq n 0 128 ret true 129 end 130 c = ulong get Ynm 0 131 if or lt c 97 gt c 122 132 ret false 133 end 134 for j ulong n 135 if not yidc ulong get Ynm j 136 ret false 137 end 138 end 139 ret not ykeyword 140 end 141 142 fn ykind i ulong obl ulong to ulong 143 c = get Oc i 144 if or ne get Ot i 1 ne get Oef i 0 145 ret 68 146 end 147 if ne get Oal i 0 148 ret 68 149 end 150 if eq c 9 151 if or ne get Oat i 0 ne get Oob i 1 152 ret 68 153 end 154 put Yni 0 add get Yni 0 1 155 ret 0 156 end 157 if eq c 1 158 if or ne get Oat i 1 ne get Oob i 0 159 ret 68 160 end 161 ret 0 162 end 163 if or lt c 2 gt c 4 164 ret 68 165 end 166 if or ne get Oat i 1 ne get Oob i obl 167 ret 68 168 end 169 ret 0 170 end 171 172 fn yfamily to ulong 173 l = get M 0 174 p = get M 1 175 obl = ulong 0 176 if and eq l 1 eq p 1 177 obl = 1 178 end 179 if and eq l 2 eq p 2 180 obl = 1 181 end 182 if and eq l 3 eq p 4 183 obl = 5 184 end 185 if eq obl 0 186 ret 68 187 end 188 if or ne get M 2 0 ne get M 3 1 189 ret 68 190 end 191 put Yni 0 0 192 for i ulong get M 4 193 if ne ykind i obl 0 194 ret 68 195 end 196 end 197 for j ulong get M 4 198 if eq get Oc j 9 199 if ge get Oi j get Yni 0 200 ret 68 201 end 202 end 203 end 204 ret 0 205 end 206 207 fn ysat v ulong to ulong 208 if gt v `1048576` 209 ret `1048576` 210 end 211 ret v 212 end 213 214 fn ymetric k ulong to void 215 c = get Oc k 216 put Ydp k 0 217 if eq c 9 218 put Yln k 2 219 put Ycn k 0 220 ret 221 end 222 if eq c 1 223 put Yln k ydigits get Oi k 224 put Ycn k 1 225 ret 226 end 227 a = get Oa k 228 b = get Ob k 229 put Yln k ysat add add get Yln a get Yln b 28 230 da = get Ydp a 231 db = get Ydp b 232 if gt da db 233 put Ydp k ysat add da 2 234 else 235 put Ydp k ysat add db 2 236 end 237 put Ycn k ysat add add get Ycn a get Ycn b 1 238 end 239 240 fn yemit k ulong top ulong to void 241 c = get Oc k 242 if eq c 9 243 ybyte 105 244 ybyte add 48 get Oi k 245 ret 246 end 247 if eq c 1 248 ydec get Oi k 249 ret 250 end 251 if eq top 0 252 ybyte 40 253 end 254 ybyte 40 255 yemit get Oa k 0 256 ybyte 32 257 if eq c 2 258 ybyte 43 259 end 260 if eq c 3 261 ybyte 45 262 end 263 if eq c 4 264 ybyte 42 265 end 266 ybyte 32 267 yemit get Ob k 0 268 ybyte 41 269 for i ulong len Ymask 270 ybyte ulong get Ymask i 271 end 272 if eq top 0 273 ybyte 41 274 end 275 end 276 277 fn yroot to ulong 278 n = get M 4 279 if lt n 3 280 ret sub n 1 281 end 282 z = sub n 2 283 y = sub n 1 284 if or ne get Oc z 1 ne get Oi z 0 285 ret y 286 end 287 if or ne get Oc y 2 ne get Ob y z 288 ret y 289 end 290 if ge get Oa y z 291 ret y 292 end 293 ret get Oa y 294 end 295 296 fn yparams to ulong 297 ni = get Yni 0 298 if eq ni 0 299 ret 0 300 end 301 ret sub mul ni 4 2 302 end 303 304 fn ysignature to void 305 for i ulong len Ydef 306 ybyte ulong get Ydef i 307 end 308 if eq ulong get Yn 0 0 309 for j ulong len Ycalc 310 ybyte ulong get Ycalc j 311 end 312 else 313 for j ulong ulong get Yn 0 314 ybyte ulong get Ynm j 315 end 316 end 317 ybyte 40 318 for s ulong get Yni 0 319 if gt s 0 320 ybyte 44 321 ybyte 32 322 end 323 ybyte 105 324 ybyte add 48 s 325 end 326 for u ulong len Ymid 327 ybyte ulong get Ymid u 328 end 329 end 330 331 fn yreadname to void 332 r = read 0 Yn 0 1 333 if lt r 0 334 ydie 77 335 end 336 if eq r 0 337 ydie 64 338 end 339 n = ulong get Yn 0 340 if gt n 32 341 ydie 64 342 end 343 got = ulong 0 344 while lt got n 345 r = read 0 Ynm got sub n got 346 if lt r 0 347 ydie 77 348 end 349 if eq r 0 350 ydie 64 351 end 352 got = add got ulong r 353 end 354 if not ynameok 355 ydie 64 356 end 357 end 358 359 fn yreadunit to ulong 360 n = ulong 0 361 more = ulong 1 362 while and eq more 1 lt n 8192 363 r = read 0 Ib n sub ulong 8192 n 364 if lt r 0 365 ydie 77 366 end 367 if eq r 0 368 more = 0 369 else 370 n = add n ulong r 371 end 372 end 373 if eq n 8192 374 r = read 0 Yone 0 1 375 if lt r 0 376 ydie 77 377 end 378 if gt r 0 379 ydie 65 380 end 381 end 382 ret n 383 end 384 385 fn ytotal root ulong to ulong 386 t = add add len Ydef len Ymid 2 387 t = add t yparams 388 if eq ulong get Yn 0 0 389 t = add t len Ycalc 390 else 391 t = add t ulong get Yn 0 392 end 393 if eq get Oc root 2 394 ret add t sub get Yln root 2 395 end 396 if eq get Oc root 3 397 ret add t sub get Yln root 2 398 end 399 if eq get Oc root 4 400 ret add t sub get Yln root 2 401 end 402 ret add t get Yln root 403 end 404 405 fn main to int 406 constants 407 yreadname 408 n = yreadunit 409 code = decode n 410 if eq code 68 411 ydie 68 412 end 413 if ne code 0 414 ydie 65 415 end 416 if ne yfamily 0 417 ydie 68 418 end 419 for k ulong get M 4 420 ymetric k 421 end 422 root = yroot 423 total = ytotal root 424 if gt total 4096 425 ydie 67 426 end 427 if gt get Ydp root 129 428 ydie 67 429 end 430 if gt add add get Yni 0 get Ycn root 2 64 431 ydie 67 432 end 433 put Yl 0 0 434 ysignature 435 if or or eq get Oc root 2 eq get Oc root 3 eq get Oc root 4 436 yemit root 1 437 else 438 yemit root 0 439 end 440 ybyte 10 441 if ne get Yl 0 total 442 ydie 65 443 end 444 sent = ulong 0 445 while lt sent total 446 r = write 1 Yo sent sub total sent 447 if le r 0 448 ydie 77 449 end 450 sent = add sent ulong r 451 end 452 ret 0 453 end