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_nested.osc

31 lines · 851 bytes Raw Blame History
1// entry: nested sibling
2// OSC-2 arenas: nested arenas; the inner arena is destroyed first, then the
3// outer one. Sibling arenas reuse the runtime slot of a destroyed arena.
4// expect-run: nested 3 -> 15
5// expect-run: sibling 2 -> 9
6fn nested(k: u16) -> u16 {
7 let mut s: u16 = 0;
8 arena outer bound 4 {
9 let a: own [u16; 2] in outer = alloc(k);
10 arena inner bound 4 {
11 let b: own [u16; 4] in inner = alloc(k * 2);
12 let c: own [u16; 2] in outer = alloc(3);
13 s = a[0] + b[3] + c[1] * 2;
14 }
15 s = s + 0;
16 }
17 return s;
18}
19
20fn sibling(k: u8) -> u8 {
21 let mut s: u8 = 0;
22 arena r1 bound 2 {
23 let a: own [u8; 2] in r1 = alloc(k);
24 s = a[1];
25 }
26 arena r2 bound 2 {
27 let b: own [u8; 2] in r2 = alloc(k + 5);
28 s = s + b[0];
29 }
30 return s;
31}