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-bridge/blob/main/tests/native/v2/vec.om # omega-bridge Omega-first language interoperability: checked conversion backends and native language bindings Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-bridge / tests / native / v2 / vec.om` 58 lines ยท 1117 bytes Raw Blame History 1 note vec.om: an OM-2 unit for the native ABI v2 tests (tests/native/v2/run.sh): six exports over 2 note unsized views and one private helper. A loop runs at most `1000000` passes (trap 4 beyond, as in 3 note OM-1), so the sums go in parts of at most `1000000` elements. 4 om2 5 fn psum p view uchar * to ulong 6 s = ulong 0 7 for i ulong len p 8 s = add s ulong get p i 9 end 10 ret s 11 end 12 export fn bsum d view uchar * to ulong 13 s = ulong 0 14 n = len d 15 for c ulong add div n `1000000` 1 16 o = mul c `1000000` 17 k = sub n o 18 if gt k `1000000` 19 k = `1000000` 20 end 21 s = add s psum part d o k 22 end 23 ret s 24 end 25 export fn wsum d view uint * to ulong 26 s = ulong 0 27 n = len d 28 for c ulong add div n `1000000` 1 29 o = mul c `1000000` 30 k = sub n o 31 if gt k `1000000` 32 k = `1000000` 33 end 34 for i ulong k 35 s = add s ulong get d add o i 36 end 37 end 38 ret s 39 end 40 export fn vlen d view ulong * to ulong 41 ret len d 42 end 43 export fn vcopy s view ushort * d edit ushort * to ulong 44 for i ulong len s 45 put d i get s i 46 end 47 ret len s 48 end 49 export fn vpart d view uchar * o ulong k ulong to ulong 50 ret psum part d o k 51 end 52 export fn lsum d view long * to long 53 s = long 0 54 for i ulong len d 55 s = add s get d i 56 end 57 ret s 58 end