Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/qualification/om2/sec/s3s4/ce-view.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / qualification / om2 / sec / s3s4 / ce-view.om` 68 lines ยท 1883 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note Contract section 4 lines 105-108 and section 6 line 170, errata E2: every index into an UNSIZED view 3 note keeps its run-time check (trap 3), also when it is a constant after unrolling or inlining. b holds 4 note 1 10 100 ... 10^7; the callee sees a part of b (or the 4-element a4 = b[0..4), E2) and reads one 5 note element past its length, which in b is a defined neighbour: a compiler that drops the check prints 6 note it and exits 0 instead of trapping. One stdin byte selects: 7 note A sumv part b 0 4 (unrolled 5 reads): 1 11 111 1111, trap 3 exit 103 8 note B sumv a4 (sized array to view ulong *, E2): 1 11 111 1111, trap 3 exit 103 9 note C sumi part b 0 4 (sumv inlined): 1 11 111 1111, trap 3 exit 103 10 note D getc part b 0 4 (constant get v 6, no unroll): trap 3 exit 103 11 note E sumv part b 0 5 (in range): 1 11 111 1111 11111, then 11111 exit 0 12 note F sumv part b 3 4: 1000 11000 111000 `1111000`, trap 3 exit 103 13 note Twin ce-view-plain.om (unroll and inline removed) has the same expectations; OM-1 approximation 14 note ce-view-om1.om uses sized views. Expected: oracle/s3s4/exp/ce-view-*.out (python3). 15 om2 16 fn sumv v view ulong * to ulong 17 s = ulong 0 18 for i ulong 5 unroll 19 s = add s get v i 20 pu s 21 end 22 ret s 23 end 24 fn sumi v view ulong * to ulong inline 25 s = ulong 0 26 for i ulong 5 unroll 27 s = add s get v i 28 pu s 29 end 30 ret s 31 end 32 fn getc v view ulong * to ulong 33 ret get v 6 34 end 35 fn main to int 36 sb = new uchar 1 0 37 r = read 0 sb 0 1 38 k = get sb 0 39 b = new ulong 8 0 40 a4 = new ulong 4 0 41 p = ulong 1 42 for j ulong 8 43 put b j p 44 p = mul p 10 45 end 46 for j ulong 4 47 put a4 j get b j 48 end 49 if eq k 65 50 pu sumv part b 0 4 51 end 52 if eq k 66 53 pu sumv a4 54 end 55 if eq k 67 56 pu sumi part b 0 4 57 end 58 if eq k 68 59 pu getc part b 0 4 60 end 61 if eq k 69 62 pu sumv part b 0 5 63 end 64 if eq k 70 65 pu sumv part b 3 4 66 end 67 ret 0 68 end