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 / ng / front / cases / nom_layout_bounds.om
| 1 | note Layout boundaries: the last field ends exactly at the layout size, a big-endian field and a little-endian |
| 2 | note field keep their own byte order, the last array element is writable without touching its neighbour, and |
| 3 | note a run-time index one past the array traps 3 (exit 103). |
| 4 | om2 |
| 5 | layout lo 12 |
| 6 | field lead uchar at 0 little |
| 7 | field w ushort 2 at 1 big |
| 8 | field d uint at 5 little |
| 9 | field last uchar 3 at 9 little |
| 10 | end |
| 11 | fn five to ulong |
| 12 | ret 3 |
| 13 | end |
| 14 | fn fill c edit lo to void |
| 15 | put c lead 255 |
| 16 | put c w 1 0x0102 |
| 17 | put c d 0x0a0b0c0d |
| 18 | put c last 2 0x77 |
| 19 | end |
| 20 | fn check c view lo to int |
| 21 | if ne get c lead 255 |
| 22 | ret 1 |
| 23 | end |
| 24 | if ne get c w 1 0x0102 |
| 25 | ret 2 |
| 26 | end |
| 27 | if ne get c d 0x0a0b0c0d |
| 28 | ret 3 |
| 29 | end |
| 30 | if ne get c last 2 0x77 |
| 31 | ret 4 |
| 32 | end |
| 33 | if ne get c last 0 0 |
| 34 | ret 5 |
| 35 | end |
| 36 | if ne get c w 0 0 |
| 37 | ret 6 |
| 38 | end |
| 39 | ret 0 |
| 40 | end |
| 41 | fn over c edit lo to void |
| 42 | put c last five 1 |
| 43 | end |
| 44 | fn main to int |
| 45 | c = new uchar 12 0 |
| 46 | fill c |
| 47 | r = check c |
| 48 | if ne r 0 |
| 49 | ret r |
| 50 | end |
| 51 | if ne get c 3 1 |
| 52 | ret 11 |
| 53 | end |
| 54 | if ne get c 4 2 |
| 55 | ret 12 |
| 56 | end |
| 57 | if ne get c 5 0x0d |
| 58 | ret 13 |
| 59 | end |
| 60 | if ne get c 8 0x0a |
| 61 | ret 14 |
| 62 | end |
| 63 | if ne get c 11 0x77 |
| 64 | ret 15 |
| 65 | end |
| 66 | if ne get c 9 0 |
| 67 | ret 16 |
| 68 | end |
| 69 | over c |
| 70 | ret 0 |
| 71 | end |