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/tests/compiler/progs/arena_basic.osc # 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 / tests / compiler / progs / arena_basic.osc` 39 lines ยท 1144 bytes Raw Blame History 1 // entry: basic ret_inside mixed 2 // OSC-2 arenas: allocations from a bounded arena; objects are never released 3 // one by one, the whole arena is destroyed at the end of its block (also on a 4 // return from inside the block). Unique owners and arena objects mix. 5 // expect-run: basic 5 -> 17 6 // expect-run: ret_inside 3 -> 13 7 // expect-run: ret_inside 0 -> 7 8 // expect-run: mixed 4 -> 30 9 fn basic(k: u32) -> u32 { 10 let mut s: u32 = 0; 11 arena r bound 8 { 12 let a: own [u32; 3] in r = alloc(k); 13 let b: own [u32; 5] in r = alloc(2); 14 a[1] = a[0] + b[4] * 5; 15 s = a[1] + b[0]; 16 } 17 return s; 18 } 19 20 fn ret_inside(k: u8) -> u32 { 21 arena r bound 64 { 22 let a: own [u32; 60] in r = alloc(k as u32); 23 if k > 0 { return a[59] + 10; } 24 let b: own [u32; 4] in r = alloc(7); 25 return b[3]; 26 } 27 } 28 29 fn mixed(k: u32) -> u32 { 30 let u: own [u32; 2] = alloc(k); 31 let mut s: u32 = 0; 32 arena r bound 6 { 33 let a: own [u32; 6] in r = alloc(k * 2); 34 let v: own [u32; 1] = alloc(10); 35 s = a[5] + u[1] + v[0]; 36 } 37 let w: own [u32; 2] = alloc(8); 38 return s + w[0]; 39 }