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 / inline-order-om1.om

65 lines · 2025 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note OM-1 TWIN of inline-order.om (inline removed, om2 line made a note) for the pinned compiler
3note 734f0a39: same expectations, so OM-1 semantics cross-check the oracle now.
4note Contract section 4 lines 93-98 (inline) and 102-104 (folding): arguments are evaluated left to
5note right before the body, exactly as for a call; traps, their order and codes are unchanged; removing
6note inline changes nothing (twin inline-order-plain.om). One stdin byte selects a case:
7note A f (mk 10 1) (mk 3 2): markers 1 then 2, then 11/3 = 3 exit 0
8note B f (div 1 0) (add 2147483647 1): first argument traps 2 exit 102
9note C f (add 2147483647 1) (div 1 0): first argument traps 1 exit 101
10note D f 2147483647 0: body add traps 1 before body div traps 2 exit 101 (constant args: no fold)
11note E f 5 0: body div by 0 traps 2 exit 102 (constant args: no fold)
12note F f (mk 1 1) (div 1 0): marker 1 printed, then trap 2 exit 102
13note G f (div 1 0) (mk 1 2): trap 2 before the marker exit 102
14note H g -5, g 7: early ret inside an inlined body: 0 then 14 exit 0
15note I g (mk 7 3): an argument used twice in the body is evaluated once: marker 3, then 14
16note Expected stdout: oracle/s3s4/exp/inline-order-*.out (python3, oracle/s3s4/oracle.py).
17note OM-1 unit: this line replaces the om2 line
18fn f a int b int to int
19x = add a 1
20ret div x b
21end
22fn g a int to int
23if lt a 0
24ret 0
25end
26ret mul a 2
27end
28fn mk v int t ulong to int
29pu t
30ret v
31end
32fn main to int
33s = new uchar 1 0
34r = read 0 s 0 1
35k = get s 0
36if eq k 65
37pu ulong f mk 10 1 mk 3 2
38end
39if eq k 66
40pu ulong f div int 1 0 add int 2147483647 1
41end
42if eq k 67
43pu ulong f add int 2147483647 1 div int 1 0
44end
45if eq k 68
46pu ulong f 2147483647 0
47end
48if eq k 69
49pu ulong f 5 0
50end
51if eq k 70
52pu ulong f mk 1 1 div int 1 0
53end
54if eq k 71
55pu ulong f div int 1 0 mk 1 2
56end
57if eq k 72
58pu ulong g -5
59pu ulong g 7
60end
61if eq k 73
62pu ulong g mk 7 3
63end
64ret 0
65end