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/rust-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 / rust-u64-export.om` 322 lines ยท 4766 bytes Raw Blame History 1 note SPDX-License-Identifier: AGPL-3.0-or-later 2 note Handwritten S1-family upper-to-Rust 2021 exporter (spec/universal/rust-u64-v1.md section 5). 3 note Prepended unchanged at build: src/source-aware/vendor/sha256.om and src/source-aware/core.om (decode n). 4 note Input: one OMSB envelope to EOF. Output is generated from the OMSA operation records only; the 5 note OMSP sidecar is validated by the #621 decoder, never read for output. 6 global Yone uchar 1 7 global Yo uchar 4096 8 global Yl ulong 1 9 global Yni ulong 1 10 global Yob ulong 1 11 global Yln ulong 64 12 global Ydp ulong 64 13 global Ycn ulong 64 14 text Yhead "pub fn calc(" 15 text Ypar ": u64" 16 text Yret ") -> u64 { " 17 text Ytail " }\n" 18 text Ymeth ".wrapping_add(.wrapping_sub(.wrapping_mul(" 19 text YMal "RUST_EXPORT_MALFORMED\n" 20 text YLim "RUST_EXPORT_LIMIT\n" 21 text YProf "RUST_EXPORT_PROFILE_MISMATCH\n" 22 text YIO "RUST_EXPORT_IO\n" 23 24 fn ydie code ulong to void 25 if eq code 65 26 w = write 2 YMal 0 len YMal 27 end 28 if eq code 67 29 w = write 2 YLim 0 len YLim 30 end 31 if eq code 68 32 w = write 2 YProf 0 len YProf 33 end 34 if eq code 77 35 w = write 2 YIO 0 len YIO 36 end 37 exit int code 38 end 39 40 fn ybyte c ulong to void 41 put Yo get Yl 0 uchar c 42 put Yl 0 add get Yl 0 1 43 end 44 45 fn ydigits v ulong to ulong 46 d = ulong 1 47 x = div v 10 48 while gt x 0 49 d = add d 1 50 x = div x 10 51 end 52 ret d 53 end 54 55 fn ydec v ulong to void 56 d = new uchar 20 0 57 i = ulong 0 58 x = v 59 put d 0 uchar add rem x 10 48 60 x = div x 10 61 i = add i 1 62 while gt x 0 63 put d i uchar add rem x 10 48 64 x = div x 10 65 i = add i 1 66 end 67 while gt i 0 68 i = sub i 1 69 ybyte ulong get d i 70 end 71 end 72 73 note Family membership per translation-compose-v1 section 1, on fields already validated by decode. 74 fn ykind i ulong to ulong 75 c = get Oc i 76 if or ne get Ot i 1 ne get Oef i 0 77 ret 68 78 end 79 if ne get Oal i 0 80 ret 68 81 end 82 if eq c 9 83 if or ne get Oat i 0 ne get Oob i 1 84 ret 68 85 end 86 put Yni 0 add get Yni 0 1 87 ret 0 88 end 89 if eq c 1 90 if or ne get Oat i 1 ne get Oob i 0 91 ret 68 92 end 93 ret 0 94 end 95 if or lt c 2 gt c 4 96 ret 68 97 end 98 if or ne get Oat i 1 ne get Oob i get Yob 0 99 ret 68 100 end 101 ret 0 102 end 103 104 fn ymember to ulong 105 l = get M 0 106 p = get M 1 107 if and eq l 1 eq p 1 108 ret 1 109 end 110 if and eq l 2 eq p 2 111 ret 1 112 end 113 if and eq l 3 eq p 4 114 ret 5 115 end 116 ret 0 117 end 118 119 fn ys1 to ulong 120 ob = ymember 121 if eq ob 0 122 ret 68 123 end 124 put Yob 0 ob 125 if or ne get M 2 0 ne get M 3 1 126 ret 68 127 end 128 put Yni 0 0 129 for i ulong get M 4 130 if ne ykind i 0 131 ret 68 132 end 133 end 134 for j ulong get M 4 135 if eq get Oc j 9 136 if ge get Oi j get Yni 0 137 ret 68 138 end 139 end 140 end 141 ret 0 142 end 143 144 fn ysat v ulong to ulong 145 if gt v `1048576` 146 ret `1048576` 147 end 148 ret v 149 end 150 151 note Length, call-parenthesis depth and re-import operation count of each result's expression. 152 fn ymetric k ulong to void 153 c = get Oc k 154 put Ydp k 0 155 if eq c 9 156 put Yln k 2 157 put Ycn k 0 158 ret 159 end 160 if eq c 1 161 put Yln k add ydigits get Oi k 3 162 put Ycn k 1 163 ret 164 end 165 a = get Oa k 166 b = get Ob k 167 put Yln k ysat add add get Yln a get Yln b 15 168 da = get Ydp a 169 db = add get Ydp b 1 170 if gt da db 171 put Ydp k da 172 else 173 put Ydp k db 174 end 175 put Ycn k ysat add add get Ycn a get Ycn b 1 176 end 177 178 fn yemit k ulong to void 179 c = get Oc k 180 if eq c 9 181 ybyte 105 182 ybyte add 48 get Oi k 183 ret 184 end 185 if eq c 1 186 ydec get Oi k 187 ybyte 117 188 ybyte 54 189 ybyte 52 190 ret 191 end 192 yemit get Oa k 193 off = mul sub c 2 14 194 for i ulong 14 195 ybyte ulong get Ymeth add off i 196 end 197 yemit get Ob k 198 ybyte 41 199 end 200 201 note translation-v1 section 4: the pre-normalization root of a NORMALIZED unit, else the last result. 202 fn yroot to ulong 203 n = get M 4 204 if lt n 3 205 ret sub n 1 206 end 207 z = sub n 2 208 y = sub n 1 209 if or ne get Oc z 1 ne get Oi z 0 210 ret y 211 end 212 if or ne get Oc y 2 ne get Ob y z 213 ret y 214 end 215 if ge get Oa y z 216 ret y 217 end 218 ret get Oa y 219 end 220 221 fn yparams to ulong 222 ni = get Yni 0 223 if eq ni 0 224 ret 0 225 end 226 ret sub mul ni 9 2 227 end 228 229 fn ysignature to void 230 for i ulong len Yhead 231 ybyte ulong get Yhead i 232 end 233 for s ulong get Yni 0 234 if gt s 0 235 ybyte 44 236 ybyte 32 237 end 238 ybyte 105 239 ybyte add 48 s 240 for t ulong len Ypar 241 ybyte ulong get Ypar t 242 end 243 end 244 for u ulong len Yret 245 ybyte ulong get Yret u 246 end 247 end 248 249 fn yreadunit to ulong 250 n = ulong 0 251 more = ulong 1 252 while and eq more 1 lt n 8192 253 r = read 0 Ib n sub ulong 8192 n 254 if lt r 0 255 ydie 77 256 end 257 if eq r 0 258 more = 0 259 else 260 n = add n ulong r 261 end 262 end 263 if eq n 8192 264 r = read 0 Yone 0 1 265 if lt r 0 266 ydie 77 267 end 268 if gt r 0 269 ydie 65 270 end 271 end 272 ret n 273 end 274 275 fn main to int 276 constants 277 n = yreadunit 278 code = decode n 279 if eq code 68 280 ydie 68 281 end 282 if ne code 0 283 ydie 65 284 end 285 if ne ys1 0 286 ydie 68 287 end 288 for k ulong get M 4 289 ymetric k 290 end 291 root = yroot 292 total = add add len Yhead len Yret len Ytail 293 total = add total yparams 294 total = add total get Yln root 295 if gt total 4096 296 ydie 67 297 end 298 if gt get Ydp root 16 299 ydie 67 300 end 301 if gt add add get Yni 0 get Ycn root 2 64 302 ydie 67 303 end 304 put Yl 0 0 305 ysignature 306 yemit root 307 for i ulong len Ytail 308 ybyte ulong get Ytail i 309 end 310 if ne get Yl 0 total 311 ydie 65 312 end 313 sent = ulong 0 314 while lt sent total 315 r = write 1 Yo sent sub total sent 316 if le r 0 317 ydie 77 318 end 319 sent = add sent ulong r 320 end 321 ret 0 322 end