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/crumbline/cl_core.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 / crumbline / cl_core.om` 67 lines ยท 1363 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Pure seeded OM-2 helpers backing src/crumbline/cl_common.c: 3 note little-endian encode/decode, lowercase hex encoding, and byte substring search. 4 om2 5 6 fn cl_hex_nib v ulong to uchar 7 if lt v 10 8 ret uchar add 48 v 9 end 10 ret uchar add 87 v 11 end 12 13 export fn cl_om_put_le val ulong nbytes ulong out_buf out uchar 8 to void 14 for i ulong 8 15 put out_buf i 0 16 end 17 n = nbytes 18 if gt n 8 19 n = 8 20 end 21 for i ulong n 22 put out_buf i uchar and shr val mul i 8 255 23 end 24 end 25 26 export fn cl_om_get_le in_buf view uchar 8 nbytes ulong to ulong 27 n = nbytes 28 if gt n 8 29 n = 8 30 end 31 v = ulong 0 32 for i ulong n 33 v = or v shl ulong get in_buf i mul i 8 34 end 35 ret v 36 end 37 38 export fn cl_om_hex src view uchar * out_hex edit uchar * to void 39 requires eq len out_hex mul len src 2 40 for i ulong len src 41 b = ulong get src i 42 put out_hex mul i 2 cl_hex_nib shr b 4 43 put out_hex add mul i 2 1 cl_hex_nib and b 15 44 end 45 end 46 47 export fn cl_om_contains hay view uchar * needle view uchar * to ulong 48 hl = len hay 49 nl = len needle 50 if or eq nl 0 gt nl hl 51 ret 0 52 end 53 limit = add sub hl nl 1 54 for i ulong limit 55 matched = ulong 1 56 for j ulong nl 57 if ne get hay add i j get needle j 58 matched = 0 59 break 60 end 61 end 62 if eq matched 1 63 ret 1 64 end 65 end 66 ret 0 67 end