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 / gpu / nvidia / om / core / idparse.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Copyright 2026 Drake Stapleton |
| 3 | fn chex c ulong to ulong |
| 4 | if and ge c 48 le c 57 |
| 5 | ret sub c 48 |
| 6 | end |
| 7 | if and ge c 65 le c 70 |
| 8 | ret sub c 55 |
| 9 | end |
| 10 | if and ge c 97 le c 102 |
| 11 | ret sub c 87 |
| 12 | end |
| 13 | ret 256 |
| 14 | end |
| 15 | fn cidparse s view uchar 65 d edit uchar 32 to ulong |
| 16 | if ne ulong get s 64 0 |
| 17 | ret 1 |
| 18 | end |
| 19 | for i ulong 32 |
| 20 | a = ulong get s mul i 2 |
| 21 | b = chex ulong get s add mul i 2 1 |
| 22 | if eq b 256 |
| 23 | ret 1 |
| 24 | end |
| 25 | x = chex a |
| 26 | if ne x 256 |
| 27 | put d i uchar add mul x 16 b |
| 28 | else |
| 29 | if eq a 45 |
| 30 | put d i uchar and sub 0 b 255 |
| 31 | else |
| 32 | if or eq a 43 or eq a 32 and ge a 9 le a 13 |
| 33 | put d i uchar b |
| 34 | else |
| 35 | ret 1 |
| 36 | end |
| 37 | end |
| 38 | end |
| 39 | end |
| 40 | ret 0 |
| 41 | end |
| 42 | fn cversion kind ulong ver ulong to ulong |
| 43 | want = ulong 1 |
| 44 | if eq kind 8 |
| 45 | want = 2 |
| 46 | if eq ver 1 |
| 47 | ret 2 |
| 48 | end |
| 49 | end |
| 50 | if ne ver want |
| 51 | ret 1 |
| 52 | end |
| 53 | ret 0 |
| 54 | end |
| 55 | fn cver kind ulong to ulong |
| 56 | if eq kind 8 |
| 57 | ret 2 |
| 58 | end |
| 59 | ret 1 |
| 60 | end |