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 / qualification / om2 / sec / s3s4 / ce-view-plain.om

70 lines · 1997 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note TWIN of ce-view.om with every unroll and inline removed (section 4 lines 91, 97): OM-2 unit,
3note same expectations per selector.
4note Contract section 4 lines 105-108 and section 6 line 170, errata E2: every index into an UNSIZED view
5note keeps its run-time check (trap 3), also when it is a constant after unrolling or inlining. b holds
6note 1 10 100 ... 10^7; the callee sees a part of b (or the 4-element a4 = b[0..4), E2) and reads one
7note element past its length, which in b is a defined neighbour: a compiler that drops the check prints
8note it and exits 0 instead of trapping. One stdin byte selects:
9note A sumv part b 0 4 (unrolled 5 reads): 1 11 111 1111, trap 3 exit 103
10note B sumv a4 (sized array to view ulong *, E2): 1 11 111 1111, trap 3 exit 103
11note C sumi part b 0 4 (sumv inlined): 1 11 111 1111, trap 3 exit 103
12note D getc part b 0 4 (constant get v 6, no unroll): trap 3 exit 103
13note E sumv part b 0 5 (in range): 1 11 111 1111 11111, then 11111 exit 0
14note F sumv part b 3 4: 1000 11000 111000 1111000, trap 3 exit 103
15note Twin ce-view-plain.om (unroll and inline removed) has the same expectations; OM-1 approximation
16note ce-view-om1.om uses sized views. Expected: oracle/s3s4/exp/ce-view-*.out (python3).
17om2
18fn sumv v view ulong * to ulong
19s = ulong 0
20for i ulong 5
21s = add s get v i
22pu s
23end
24ret s
25end
26fn sumi v view ulong * to ulong
27s = ulong 0
28for i ulong 5
29s = add s get v i
30pu s
31end
32ret s
33end
34fn getc v view ulong * to ulong
35ret get v 6
36end
37fn main to int
38sb = new uchar 1 0
39r = read 0 sb 0 1
40k = get sb 0
41b = new ulong 8 0
42a4 = new ulong 4 0
43p = ulong 1
44for j ulong 8
45put b j p
46p = mul p 10
47end
48for j ulong 4
49put a4 j get b j
50end
51if eq k 65
52pu sumv part b 0 4
53end
54if eq k 66
55pu sumv a4
56end
57if eq k 67
58pu sumi part b 0 4
59end
60if eq k 68
61pu getc part b 0 4
62end
63if eq k 69
64pu sumv part b 0 5
65end
66if eq k 70
67pu sumv part b 3 4
68end
69ret 0
70end