interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / seed / ng / front / cases / nom_struct_bounds.om

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