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