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_struct_bounds.om
| 1 | note Struct field boundaries: the last array element is writable and leaves the neighbouring cells alone, |
| 2 | note every scalar width round-trips its extreme values through an 8-byte cell, and the index is checked |
| 3 | note only against the field's own length (the first element of the next field is not reachable). |
| 4 | struct W a byte s short i int u uchar w ushort ui uint f uchar arr uchar 3 z ulong end |
| 5 | fn main to int |
| 6 | w = new W 0 0 0 0 0 0 0 0 0 |
| 7 | put w a -128 |
| 8 | put w s -32768 |
| 9 | put w i -2147483648 |
| 10 | put w u 255 |
| 11 | put w w 65535 |
| 12 | put w ui 4294967295 |
| 13 | put w f 1 |
| 14 | put w arr 2 9 |
| 15 | put w z 1234605616436508552 |
| 16 | if ne get w a -128 |
| 17 | ret 1 |
| 18 | end |
| 19 | if ne get w s -32768 |
| 20 | ret 2 |
| 21 | end |
| 22 | if ne get w i -2147483648 |
| 23 | ret 3 |
| 24 | end |
| 25 | if ne get w u 255 |
| 26 | ret 4 |
| 27 | end |
| 28 | if ne get w w 65535 |
| 29 | ret 5 |
| 30 | end |
| 31 | if ne get w ui 4294967295 |
| 32 | ret 6 |
| 33 | end |
| 34 | if ne get w f 1 |
| 35 | ret 7 |
| 36 | end |
| 37 | if ne get w arr 2 9 |
| 38 | ret 8 |
| 39 | end |
| 40 | if ne get w arr 0 0 |
| 41 | ret 9 |
| 42 | end |
| 43 | if ne get w z 1234605616436508552 |
| 44 | ret 10 |
| 45 | end |
| 46 | put w a 127 |
| 47 | put w arr 0 255 |
| 48 | if ne get w s -32768 |
| 49 | ret 11 |
| 50 | end |
| 51 | if ne get w arr 1 0 |
| 52 | ret 12 |
| 53 | end |
| 54 | k = ulong 0 |
| 55 | for j ulong 3 |
| 56 | put w arr j uchar add j 1 |
| 57 | k = add k ulong get w arr j |
| 58 | end |
| 59 | if ne k 6 |
| 60 | ret 13 |
| 61 | end |
| 62 | ret 0 |
| 63 | end |