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 / tests / compiler / progs / arena_structs.osc

19 lines · 632 bytes Raw Blame History
1// entry: points
2// OSC-2 arenas: struct literals allocated from an arena; a struct uses its
3// cell count (Pt: 3 cells) of the arena's bound.
4// u8 arithmetic wraps (OSC-1 rule): points 200 -> 96.
5// expect-run: points 4 -> 20
6// expect-run: points 200 -> 96
7struct Pt { x: u8, y: u8, w: [u8; 1] }
8
9fn points(k: u8) -> u8 {
10 let mut s: u8 = 0;
11 arena r bound 7 {
12 let p: own Pt in r = Pt { x: k, y: 1, w: [2; 1] };
13 let q: own Pt in r = Pt { y: k * 2, x: 3, w: [0; 1] };
14 let t: own [u8; 1] in r = alloc(5);
15 p.x = p.x + q.y;
16 s = p.x + p.y + p.w[0] + t[0] + q.x - 3;
17 }
18 return s;
19}