omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / hsum.om
| 1 | note hsum: a unit with private helpers. The compiler enters a function-mode unit at its last function |
| 2 | note (word 0 branches there), so only that function is bound; sq and cap are internal calls. |
| 3 | fn sq x ulong to ulong |
| 4 | ret mul x x |
| 5 | end |
| 6 | |
| 7 | fn cap x ulong to ulong |
| 8 | if gt x 1000000 |
| 9 | trap 9 |
| 10 | end |
| 11 | ret x |
| 12 | end |
| 13 | |
| 14 | fn hsum a view uchar 4 b ulong to ulong |
| 15 | s = b |
| 16 | for i ulong 4 |
| 17 | s = add s sq ulong get a i |
| 18 | end |
| 19 | ret cap s |
| 20 | end |