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 / train / aien-train / native / omegese45 / translate / otmsg.om
| 1 | note SPDX-License-Identifier: AGPL-3.0-only |
| 2 | note otmsg: glue from the translator to the contract lane's codec and |
| 3 | note validator (native/omegese45/vocab.om and msg.om, concatenated before |
| 4 | note this file). The translator never re-implements the R45 grammar: every |
| 5 | note G and P line is validated by ocsetgl / ocvline. |
| 6 | |
| 7 | note Copy otin[o, o+n) into the contract input buffer ocin. False when the |
| 8 | note line does not fit. |
| 9 | fn otcopy o ulong n ulong to bool |
| 10 | if gt n len ocin |
| 11 | ret false |
| 12 | end |
| 13 | for i ulong n |
| 14 | put ocin i get otin add o i |
| 15 | end |
| 16 | ret true |
| 17 | end |
| 18 | |
| 19 | note Append the contract reason word for -v (v < 0 from ocvline/ocsetgl). |
| 20 | fn otprs v long to void |
| 21 | r = ulong neg v |
| 22 | if or lt r 1 gt r 20 |
| 23 | otpdec r |
| 24 | ret |
| 25 | end |
| 26 | o = mul sub r 1 8 |
| 27 | for j ulong 8 |
| 28 | c = get ocrtx add o j |
| 29 | if ne c 32 |
| 30 | otpb c |
| 31 | end |
| 32 | end |
| 33 | end |
| 34 | |
| 35 | note Append the surface word of vocabulary id. |
| 36 | fn otpword id ulong to void |
| 37 | ocvinit |
| 38 | o = get ocwo id |
| 39 | for j ulong get ocwl id |
| 40 | otpb get ocvtsv add o j |
| 41 | end |
| 42 | end |