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.om

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