Tuple, List, and Null primitives
TVM Instructions Content List
- Overview
- Stack Manipulation
- Tuple, List and Null
- Constants and Literals
- Arithmetic Operations
- Data Comparison
- Cell Manipulation
- Continuation and Control Flow
- Exception Generation and Handling
- Dictionary Manipulation
- Application-specific Primitives
- Miscellaneous
| Opcode | Fift syntax | Stack | Description | Gas |
|---|---|---|---|---|
| Please enter a search query | ||||
| No results found | ||||
Tuple, List, and Null primitives
| xxxxxxx Opcode | xxxxxxxxxxxxxxxxxxxxxxxxxxxx Fift syntax | xxxxxxxxxxxxxxxxx Stack | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Description | xxxx Gas |
|---|---|---|---|---|
6D | NULLPUSHNULL | - null | Pushes the only value of type Null. | 18 |
6E | ISNULL | x - ? | Checks whether x is a Null, and returns -1 or 0 accordingly. | 18 |
6F0n | [n] TUPLE | x_1 ... x_n - t | Creates a new Tuple t=(x_1, … ,x_n) containing n values x_1,..., x_n.0 <= n <= 15 | 26+n |
6F00 | NIL | - t | Pushes the only Tuple t=() of length zero. | 26 |
6F01 | SINGLE | x - t | Creates a singleton t:=(x), i.e., a Tuple of length one. | 27 |
6F02 | PAIRCONS | x y - t | Creates pair t:=(x,y). | 28 |
6F03 | TRIPLE | x y z - t | Creates triple t:=(x,y,z). | 29 |
6F1k | [k] INDEX | t - x | Returns the k-th element of a Tuple t.0 <= k <= 15. | 26 |
6F10 | FIRSTCAR | t - x | Returns the first element of a Tuple. | 26 |
6F11 | SECONDCDR | t - y | Returns the second element of a Tuple. | 26 |
6F12 | THIRD | t - z | Returns the third element of a Tuple. | 26 |
6F2n | [n] UNTUPLE | t - x_1 ... x_n | Unpacks a Tuple t=(x_1,...,x_n) of length equal to 0 <= n <= 15.If t is not a Tuple, or if \|t\| != n, a type check exception is thrown. | 26+n |
6F21 | UNSINGLE | t - x | Unpacks a singleton t=(x). | 27 |
6F22 | UNPAIRUNCONS | t - x y | Unpacks a pair t=(x,y). | 28 |
6F23 | UNTRIPLE | t - x y z | Unpacks a triple t=(x,y,z). | 29 |
6F3k | [k] UNPACKFIRST | t - x_1 ... x_k | Unpacks first 0 <= k <= 15 elements of a Tuple t.If \|t\|<k, throws a type check exception. | 26+k |
6F30 | CHKTUPLE | t - | Checks whether t is a Tuple. If not, throws a type check exception. | 26 |
6F4n | [n] EXPLODE | t - x_1 ... x_m m | Unpacks a Tuple t=(x_1,...,x_m) and returns its length m, but only if m <= n <= 15. Otherwise throws a type check exception. | 26+m |
6F5k | [k] SETINDEX | t x - t' | Computes Tuple t' that differs from t only at position t'_{k+1}, which is set to x.0 <= k <= 15If k >= \|t\|, throws a range check exception. | 26+\|t\| |
6F50 | SETFIRST | t x - t' | Sets the first component of Tuple t to x and returns the resulting Tuple t'. | 26+\|t\| |
6F51 | SETSECOND | t x - t' | Sets the second component of Tuple t to x and returns the resulting Tuple t'. | 26+\|t\| |
6F52 | SETTHIRD | t x - t' | Sets the third component of Tuple t to x and returns the resulting Tuple t'. | 26+\|t\| |
6F6k | [k] INDEXQ | t - x | Returns the k-th element of a Tuple t, where 0 <= k <= 15. In other words, returns x_{k+1} if t=(x_1,...,x_n). If k>=n, or if t is Null, returns a Null instead of x. | 26 |
6F60 | FIRSTQCARQ | t - x | Returns the first element of a Tuple. | 26 |
6F61 | SECONDQCDRQ | t - y | Returns the second element of a Tuple. | 26 |
6F62 | THIRDQ | t - z | Returns the third element of a Tuple. | 26 |
6F7k | [k] SETINDEXQ | t x - t' | Sets the k-th component of Tuple t to x, where 0 <= k < 16, and returns the resulting Tuple t'.If \|t\| <= k, first extends the original Tuple to length n’=k+1 by setting all new components to Null. If the original value of t is Null, treats it as an empty Tuple. If t is not Null or Tuple, throws an exception. If x is Null and either \|t\| <= k or t is Null, then always returns t'=t (and does not consume tuple creation gas). | 26+\|t’\| |
6F70 | SETFIRSTQ | t x - t' | Sets the first component of Tuple t to x and returns the resulting Tuple t'. | 26+\|t’\| |
6F71 | SETSECONDQ | t x - t' | Sets the second component of Tuple t to x and returns the resulting Tuple t'. | 26+\|t’\| |
6F72 | SETTHIRDQ | t x - t' | Sets the third component of Tuple t to x and returns the resulting Tuple t'. | 26+\|t’\| |
6F80 | TUPLEVAR | x_1 ... x_n n - t | Creates a new Tuple t of length n similarly to TUPLE, but with 0 <= n <= 255 taken from the stack. | 26+n |
6F81 | INDEXVAR | t k - x | Similar to k INDEX, but with 0 <= k <= 254 taken from the stack. | 26 |
6F82 | UNTUPLEVAR | t n - x_1 ... x_n | Similar to n UNTUPLE, but with 0 <= n <= 255 taken from the stack. | 26+n |
6F83 | UNPACKFIRSTVAR | t n - x_1 ... x_n | Similar to n UNPACKFIRST, but with 0 <= n <= 255 taken from the stack. | 26+n |
6F84 | EXPLODEVAR | t n - x_1 ... x_m m | Similar to n EXPLODE, but with 0 <= n <= 255 taken from the stack. | 26+m |
6F85 | SETINDEXVAR | t x k - t' | Similar to k SETINDEX, but with 0 <= k <= 254 taken from the stack. | 26+\|t’\| |
6F86 | INDEXVARQ | t k - x | Similar to n INDEXQ, but with 0 <= k <= 254 taken from the stack. | 26 |
6F87 | SETINDEXVARQ | t x k - t' | Similar to k SETINDEXQ, but with 0 <= k <= 254 taken from the stack. | 26+\|t’\| |
6F88 | TLEN | t - n | Returns the length of a Tuple. | 26 |
6F89 | QTLEN | t - n or -1 | Similar to TLEN, but returns -1 if t is not a Tuple. | 26 |
6F8A | ISTUPLE | t - ? | Returns -1 or 0 depending on whether t is a Tuple. | 26 |
6F8B | LAST | t - x | Returns the last element of a non-empty Tuple t. | 26 |
6F8C | TPUSHCOMMA | t x - t' | Appends a value x to a Tuple t=(x_1,...,x_n), but only if the resulting Tuple t'=(x_1,...,x_n,x) is of length at most 255. Otherwise throws a type check exception. | 26+\|t’\| |
6F8D | TPOP | t - t' x | Detaches the last element x=x_n from a non-empty Tuple t=(x_1,...,x_n), and returns both the resulting Tuple t'=(x_1,...,x_{n-1}) and the original last element x. | 26+\|t’\| |
6FA0 | NULLSWAPIF | x - x or null x | Pushes a Null under the topmost Integer x, but only if x!=0. | 26 |
6FA1 | NULLSWAPIFNOT | x - x or null x | Pushes a Null under the topmost Integer x, but only if x=0. May be used for stack alignment after quiet primitives such as PLDUXQ. | 26 |
6FA2 | NULLROTRIF | x y - x y or null x y | Pushes a Null under the second stack entry from the top, but only if the topmost Integer y is non-zero. | 26 |
6FA3 | NULLROTRIFNOT | x y - x y or null x y | Pushes a Null under the second stack entry from the top, but only if the topmost Integer y is zero. May be used for stack alignment after quiet primitives such as LDUXQ. | 26 |
6FA4 | NULLSWAPIF2 | x - x or null null x | Pushes two nulls under the topmost Integer x, but only if x!=0.Equivalent to NULLSWAPIF NULLSWAPIF. | 26 |
6FA5 | NULLSWAPIFNOT2 | x - x or null null x | Pushes two nulls under the topmost Integer x, but only if x=0.Equivalent to NULLSWAPIFNOT NULLSWAPIFNOT. | 26 |
6FA6 | NULLROTRIF2 | x y - x y or null null x y | Pushes two nulls under the second stack entry from the top, but only if the topmost Integer y is non-zero.Equivalent to NULLROTRIF NULLROTRIF. | 26 |
6FA7 | NULLROTRIFNOT2 | x y - x y or null null x y | Pushes two nulls under the second stack entry from the top, but only if the topmost Integer y is zero.Equivalent to NULLROTRIFNOT NULLROTRIFNOT. | 26 |
6FBij | [i] [j] INDEX2 | t - x | Recovers x=(t_{i+1})_{j+1} for 0 <= i,j <= 3.Equivalent to [i] INDEX [j] INDEX. | 26 |
6FB4 | CADR | t - x | Recovers x=(t_2)_1. | 26 |
6FB5 | CDDR | t - x | Recovers x=(t_2)_2. | 26 |
6FE_ijk | [i] [j] [k] INDEX3 | t - x | Recovers x=t_{i+1}_{j+1}_{k+1}.0 <= i,j,k <= 3Equivalent to [i] [j] INDEX2 [k] INDEX. | 26 |
6FD4 | CADDR | t - x | Recovers x=t_2_2_1. | 26 |
6FD5 | CDDDR | t - x | Recovers x=t_2_2_2. | 26 |