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/path/rx_path_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 / path / rx_path_core.om` 165 lines ยท 3539 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Pure seeded OM-2 PATH-1 validation, comparison, and canonical big-endian 3 note header/step wire codecs backing src/path/rx_path.c. 4 om2 5 6 const rxp_err_step_limit long -80 7 const rxp_err_input_limit long -81 8 const rxp_err_output_limit long -82 9 const rxp_err_param_limit long -83 10 const rxp_err_attr_limit long -84 11 const rxp_err_malformed long -87 12 13 fn rxp_role_cap family ulong to ulong 14 if eq family 1 15 ret 4 16 end 17 if eq family 2 18 ret 4 19 end 20 if eq family 3 21 ret 7 22 end 23 if eq family 4 24 ret 7 25 end 26 if eq family 5 27 ret 6 28 end 29 ret 0 30 end 31 32 export fn rxp_valid_role family ulong role ulong to ulong 33 cap = rxp_role_cap family 34 if eq cap 0 35 ret 0 36 end 37 if ne shr role 8 family 38 ret 0 39 end 40 lo = and role 255 41 if or lt lo 1 gt lo cap 42 ret 0 43 end 44 ret 1 45 end 46 47 export fn rxp_check_step family ulong role ulong n_in ulong n_out ulong plen ulong to long 48 if eq rxp_valid_role family role 0 49 ret rxp_err_malformed 50 end 51 if gt n_in 8 52 ret rxp_err_input_limit 53 end 54 if gt n_out 8 55 ret rxp_err_output_limit 56 end 57 if gt plen 1024 58 ret rxp_err_param_limit 59 end 60 ret 0 61 end 62 63 export fn rxp_step_size n_in ulong n_out ulong plen ulong to ulong 64 ret add add add 46 mul 32 n_in mul 32 n_out plen 65 end 66 67 export fn rxp_bytes_cmp a view uchar * b view uchar * to long 68 n = len a 69 if lt len b n 70 n = len b 71 end 72 for i ulong n 73 xa = ulong get a i 74 xb = ulong get b i 75 if lt xa xb 76 ret -1 77 end 78 if gt xa xb 79 ret 1 80 end 81 end 82 if lt len a len b 83 ret -1 84 end 85 if gt len a len b 86 ret 1 87 end 88 ret 0 89 end 90 91 fn rxp_put16_be buf edit uchar * off ulong v ulong to void 92 put buf off uchar and shr v 8 255 93 put buf add off 1 uchar and v 255 94 end 95 96 fn rxp_get16_be buf view uchar * off ulong to ulong 97 ret or shl ulong get buf off 8 ulong get buf add off 1 98 end 99 100 export fn rxp_encode_header count ulong attr_count ulong ids view uchar 96 out_hdr out uchar 106 to void 101 put out_hdr 0 79 102 put out_hdr 1 77 103 put out_hdr 2 71 104 put out_hdr 3 48 105 put out_hdr 4 1 106 put out_hdr 5 12 107 rxp_put16_be out_hdr 6 count 108 for i ulong 96 109 put out_hdr add 8 i get ids i 110 end 111 rxp_put16_be out_hdr 104 attr_count 112 end 113 114 export fn rxp_decode_header in_hdr view uchar 106 counts edit ulong 2 ids out uchar 96 to long 115 if or ne get in_hdr 0 79 ne get in_hdr 1 77 116 ret rxp_err_malformed 117 end 118 if or ne get in_hdr 2 71 ne get in_hdr 3 48 119 ret rxp_err_malformed 120 end 121 if or ne get in_hdr 4 1 ne get in_hdr 5 12 122 ret rxp_err_malformed 123 end 124 count = rxp_get16_be in_hdr 6 125 if gt count 512 126 ret rxp_err_step_limit 127 end 128 for i ulong 96 129 put ids i get in_hdr add 8 i 130 end 131 acount = rxp_get16_be in_hdr 104 132 if gt acount 32 133 ret rxp_err_attr_limit 134 end 135 put counts 0 count 136 put counts 1 acount 137 ret 0 138 end 139 140 export fn rxp_encode_step_head idx ulong family ulong role ulong in_cnt ulong out_buf out uchar 8 to void 141 rxp_put16_be out_buf 0 idx 142 rxp_put16_be out_buf 2 family 143 rxp_put16_be out_buf 4 role 144 rxp_put16_be out_buf 6 in_cnt 145 end 146 147 export fn rxp_decode_step_head in_buf view uchar 8 expect_idx ulong fields edit ulong 3 to long 148 idx = rxp_get16_be in_buf 0 149 if ne idx expect_idx 150 ret rxp_err_malformed 151 end 152 family = rxp_get16_be in_buf 2 153 role = rxp_get16_be in_buf 4 154 if eq rxp_valid_role family role 0 155 ret rxp_err_malformed 156 end 157 in_cnt = rxp_get16_be in_buf 6 158 if gt in_cnt 8 159 ret rxp_err_input_limit 160 end 161 put fields 0 family 162 put fields 1 role 163 put fields 2 in_cnt 164 ret 0 165 end