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/slices/copy_cells.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 / slices / copy_cells.osc` 46 lines ยท 1371 bytes Raw Blame History 1 // slice-entry: copy fill sum_cells poke 2 // cells is the writable side: a caller-supplied u64 output slice; c[i] = e stores, c[i] loads, both checked. 3 // slice-run: copy bytes:010203 cells:3 -> 3 cells=1,2,3 4 // slice-run: copy bytes:010203 cells:5=9,9,9,9,9 -> 3 cells=1,2,3,9,9 5 // slice-run: copy bytes:`0102030405` cells:2 -> 2 cells=1,2 6 // slice-run: copy bytes: cells:4 -> 0 cells=0,0,0,0 7 // slice-run: copy bytes:NULL cells:NULL -> 0 8 // slice-run: fill cells:3 7 -> 3 cells=7,7,7 9 // slice-run: fill cells:NULL 7 -> 0 10 // slice-run: sum_cells cells:3=4,5,6 -> 15 11 // slice-run: poke cells:4 3 99 -> 99 cells=0,0,0,99 12 // slice-run: poke cells:4 4 99 -> trap=BOUNDS 13 // slice-run: poke cells:NULL 0 1 -> trap=BOUNDS 14 // slice-run: poke cells:4 `18446744073709551615` 1 -> trap=BOUNDS 15 fn copy(src: bytes, dst: cells) -> u64 { 16 let mut i: u64 = 0; 17 while i < src.len && i < dst.len bound 4096 { 18 dst[i] = src[i]; 19 i = i + 1; 20 } 21 return i; 22 } 23 24 fn fill(dst: cells, v: u64) -> u64 { 25 let mut i: u64 = 0; 26 while i < dst.len bound 4096 { 27 dst[i] = v; 28 i = i + 1; 29 } 30 return i; 31 } 32 33 fn sum_cells(c: cells) -> u64 { 34 let mut s: u64 = 0; 35 let mut i: u64 = 0; 36 while i < c.len bound 4096 { 37 s = s + c[i]; 38 i = i + 1; 39 } 40 return s; 41 } 42 43 fn poke(c: cells, i: u64, v: u64) -> u64 { 44 c[i] = v; 45 return c[i]; 46 }