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
omega-mv / bridge / omega-bridge / tests / freest-fixtures / scalar.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Arbitrary names, constants, nested calls, branch locals, signed comparisons and wrap. |
| 3 | const STEP ulong 1 |
| 4 | fn upper x uint to ulong |
| 5 | ret ulong add x uint 1 |
| 6 | end |
| 7 | fn choose x long to long |
| 8 | if lt x long 0 |
| 9 | ret long -1 |
| 10 | else |
| 11 | ret long 1 |
| 12 | end |
| 13 | end |
| 14 | fn portable_scalar value uint signedv long to ulong |
| 15 | v = upper value |
| 16 | if lt choose signedv long 0 |
| 17 | narrow = uchar 7 |
| 18 | v = add v ulong narrow |
| 19 | else |
| 20 | v = add v STEP |
| 21 | end |
| 22 | ret v |
| 23 | end |