Add logic builtins to Julia and fix some typos

This commit is contained in:
Alex Beregszaszi 2017-11-22 17:25:40 +00:00
parent 2c3f57bec6
commit 63c81bc0d4

View File

@ -313,12 +313,27 @@ The following type conversion functions must be available:
- ``u64tou32(x:u64) -> y:u32``
- etc. (TBD)
.. note::
``u32tobool(x:u32) -> y:bool`` can be implemented as ``y := not(iszerou256(x))`` and
``booltou32(x:bool) -> y:u32`` can be implemented as ``switch x case true:bool { y := 1:u32 } case false:bool { y := 0:u32 }``
Low-level Functions
-------------------
The following functions must be available:
+---------------------------------------------------------------------------------------------------------------+
| *Logic* |
+---------------------------------------------+-----------------------------------------------------------------+
| not(x:bool) -> z:bool | logical not |
+---------------------------------------------+-----------------------------------------------------------------+
| and(x:bool, y:bool) -> z:bool | logical and |
+---------------------------------------------+-----------------------------------------------------------------+
| or(x:bool, y:bool) -> z:bool | logical or |
+---------------------------------------------+-----------------------------------------------------------------+
| xor(x:bool, y:bool) -> z:bool | xor |
+---------------------------------------------+-----------------------------------------------------------------+
| *Arithmetics* |
+---------------------------------------------+-----------------------------------------------------------------+
| addu256(x:u256, y:u256) -> z:u256 | x + y |
@ -343,15 +358,19 @@ The following functions must be available:
+---------------------------------------------+-----------------------------------------------------------------+
| mulmodu256(x:u256, y:u256, m:u256) -> z:u256| (x * y) % m with arbitrary precision arithmetics |
+---------------------------------------------+-----------------------------------------------------------------+
| ltu256(x:u256, y:u256) -> z:bool | 1 if x < y, 0 otherwise |
| ltu256(x:u256, y:u256) -> z:bool | true if x < y, false otherwise |
+---------------------------------------------+-----------------------------------------------------------------+
| gtu256(x:u256, y:u256) -> z:bool | 1 if x > y, 0 otherwise |
| gtu256(x:u256, y:u256) -> z:bool | true if x > y, false otherwise |
+---------------------------------------------+-----------------------------------------------------------------+
| sltu256(x:s256, y:s256) -> z:bool | 1 if x < y, 0 otherwise, for signed numbers in two's complement |
| sltu256(x:s256, y:s256) -> z:bool | true if x < y, false otherwise |
| | (for signed numbers in two's complement) |
+---------------------------------------------+-----------------------------------------------------------------+
| sgtu256(x:s256, y:s256) -> z:bool | 1 if x > y, 0 otherwise, for signed numbers in two's complement |
| sgtu256(x:s256, y:s256) -> z:bool | true if x > y, false otherwise |
| | (for signed numbers in two's complement) |
+---------------------------------------------+-----------------------------------------------------------------+
| equ256(x:u256, y:u256) -> z:bool | 1 if x == y, 0 otherwise |
| equ256(x:u256, y:u256) -> z:bool | true if x == y, false otherwise |
+---------------------------------------------+-----------------------------------------------------------------+
| iszerou256(x:u256) -> z:bool | true if x == 0, false otherwise |
+---------------------------------------------+-----------------------------------------------------------------+
| notu256(x:u256) -> z:u256 | ~x, every bit of x is negated |
+---------------------------------------------+-----------------------------------------------------------------+
@ -473,6 +492,8 @@ The following functions must be available:
+---------------------------------------------+-----------------------------------------------------------------+
| *Others* |
+---------------------------------------------+-----------------------------------------------------------------+
| discard(unused:bool) | discard value |
+---------------------------------------------+-----------------------------------------------------------------+
| discardu256(unused:u256) | discard value |
+---------------------------------------------+-----------------------------------------------------------------+
| splitu256tou64(x:u256) -> (x1:u64, x2:u64, | split u256 to four u64's |
@ -481,7 +502,7 @@ The following functions must be available:
| combineu64tou256(x1:u64, x2:u64, x3:u64, | combine four u64's into a single u256 |
| x4:u64) -> (x:u256) | |
+---------------------------------------------+-----------------------------------------------------------------+
| sha3(p:u256, s:u256) -> v:u256 | keccak(mem[p...(p+s))) |
| keccak256(p:u256, s:u256) -> v:u256 | keccak(mem[p...(p+s))) |
+---------------------------------------------+-----------------------------------------------------------------+
Backends