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 / omc / om2 / s4 / v-ok.om

72 lines · 1434 bytes Raw Blame History
1note S4 unsized views (spec 6, erratum E2): sized arrays, an unsized name and a text passed to `view T *`
2note and `edit T *` parameters of internal functions, inline ones included; `len` is the run-time count
3note (ulong); constant and run-time indexes in range; a write slice inside the view; six parameter slots
4note mixing scalars and unsized arrays (pointer then count). Exit 0 when every check holds, else the
5note failing check's number.
6om2
7text msg "abcdef"
8fn vsum v view ulong * to ulong
9x = ulong 0
10for i ulong len v
11x = add x get v i
12end
13ret x
14end
15fn pass v view ulong * to ulong
16ret vsum v
17end
18fn isum v view ulong * to ulong inline
19ret add get v 0 get v sub len v 1
20end
21fn fill e edit uchar * c uchar to ulong
22for i ulong len e
23put e i add c uchar i
24end
25ret len e
26end
27fn six a ulong v view ulong * b ulong w edit uchar * to ulong
28put w 0 uchar b
29ret add add mul a 1000 len v add mul b 100 len w
30end
31fn bytes t view uchar * to ulong
32ret add mul ulong get t 0 256 len t
33end
34fn sl a ulong v view uchar * b ulong to ulong
35ret add add mul a 100 mul len v 10 b
36end
37fn main to int
38u = new uchar 7 0
39if ne sl 3 u 4 374
40ret 10
41end
42a = new ulong 5 3
43put a 4 10
44if ne vsum a 22
45ret 1
46end
47if ne pass a 22
48ret 2
49end
50if ne isum a 13
51ret 3
52end
53if ne fill u 40 7
54ret 4
55end
56if ne get u 6 46
57ret 5
58end
59if ne six 2 a 9 u 2912
60ret 6
61end
62if ne get u 0 9
63ret 7
64end
65if ne bytes msg 24838
66ret 8
67end
68if ne bytes view u 2311
69ret 9
70end
71ret 0
72end