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/df_struct.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 / df_struct.osc` 40 lines ยท 1061 bytes Raw Blame History 1 // entry: f h 2 // OSC-3 item 3 (drop flags): struct owners, an own parameter moved on one 3 // path, and an owner declared inside a loop body and moved on one path (its 4 // flag is set again by each iteration's declaration). 5 struct P { x: u32, v: [u32; 2] } 6 7 fn eat(p: own P) -> u32 { return p.x + p.v[1]; } 8 9 fn eat2(a: own [u32; 2]) -> u32 { return a[0] + a[1]; } 10 11 fn pass(p: own P, k: u32) -> u32 { 12 if k > 3 { return eat(p) + 1; } 13 let mut r: u32 = p.x; 14 if k == 1 { r = r + eat(p); } 15 return r; 16 } 17 18 fn f(k: u32) -> u32 { 19 let p: own P = P { x: k & 7, v: [1; 2] }; 20 let q: own P = P { x: 2, v: [k & 3; 2] }; 21 let mut r: u32 = pass(q, k); 22 if k > 8 { r = r + eat(p); } 23 return r; 24 } 25 26 fn h(n: u32) -> u32 { 27 let mut s: u32 = 0; 28 for i in 0 .. 6 { 29 let a: own [u32; 2] = alloc(i as u32); 30 if (i as u32) < n { s = s + eat2(a); } 31 } 32 return s; 33 } 34 // expect-run: f 0 -> 2 35 // expect-run: f 1 -> 5 36 // expect-run: f 5 -> 4 37 // expect-run: f 9 -> 6 38 // expect-run: h 3 -> 6 39 // expect-run: h 0 -> 0 40 // expect-run: h 10 -> 30