omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / fixtures / bytecopy.om
| 1 | note byte copy: read up to 65536 bytes, copy them byte by byte into a second pool reversed, write it |
| 2 | global src uchar 65536 |
| 3 | global dst uchar 65536 |
| 4 | fn fill to ulong |
| 5 | t = ulong 0 |
| 6 | k = read 0 src 0 len src |
| 7 | while gt k 0 |
| 8 | t = add t ulong k |
| 9 | k = long 0 |
| 10 | if lt t len src |
| 11 | k = read 0 src t sub len src t |
| 12 | end |
| 13 | end |
| 14 | ret t |
| 15 | end |
| 16 | fn main to int |
| 17 | n = fill |
| 18 | for i ulong n |
| 19 | put dst sub sub n i 1 get src i |
| 20 | end |
| 21 | w = write 1 dst 0 n |
| 22 | ret 0 |
| 23 | end |