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 / seed / equiv / clamp.unit.om
| 1 | note irequiv fixture (issue 826): saturating byte add, two parameters (u16 domain). |
| 2 | note clamp_add is copied verbatim from tests/one_layer/omegese/dev/dev01.omegese |
| 3 | note (omega-mv 62d1d0d6). clamp_wrap is a refactor that adds in uchar and |
| 4 | note detects the wrap instead of widening to ushort. |
| 5 | fn clamp_add a uchar b uchar to uchar |
| 6 | x = ushort a |
| 7 | y = ushort b |
| 8 | s = add x y |
| 9 | if gt s 255 |
| 10 | ret 255 |
| 11 | end |
| 12 | ret uchar s |
| 13 | end |
| 14 | fn clamp_wrap a uchar b uchar to uchar |
| 15 | s = add a b |
| 16 | if lt s a |
| 17 | ret 255 |
| 18 | end |
| 19 | ret s |
| 20 | end |