1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00

[Tolk] Get rid of ~tilda with mutate and self methods

This is a very big change.
If FunC has `.methods()` and `~methods()`, Tolk has only dot,
one and only way to call a `.method()`.
A method may mutate an object, or may not.
It's a behavioral and semantic difference from FunC.

- `cs.loadInt(32)` modifies a slice and returns an integer
- `b.storeInt(x, 32)` modifies a builder
- `b = b.storeInt()` also works, since it not only modifies, but returns
- chained methods also work, they return `self`
- everything works exactly as expected, similar to JS
- no runtime overhead, exactly same Fift instructions
- custom methods are created with ease
- tilda `~` does not exist in Tolk at all
This commit is contained in:
tolk-vm 2024-10-31 11:18:54 +04:00
parent 12ff28ac94
commit d9dba320cc
No known key found for this signature in database
GPG key ID: 7905DD7FE0324B12
85 changed files with 2710 additions and 1965 deletions

View file

@ -17,11 +17,7 @@ fun createEmptyTuple(): tuple
/// Appends a value to tuple, resulting in `Tuple t' = (x1, ..., xn, value)`.
/// If its size exceeds 255, throws a type check exception.
@pure
fun tuplePush<X>(t: tuple, value: X): tuple
asm "TPUSH";
@pure
fun ~tuplePush<X>(t: tuple, value: X): (tuple, ())
fun tuplePush<X>(mutate self: tuple, value: X): void
asm "TPUSH";
/// Returns the first element of a non-empty tuple.
@ -336,118 +332,109 @@ fun beginParse(c: cell): slice
asm "CTOS";
/// Checks if slice is empty. If not, throws an exception.
fun assertEndOfSlice(s: slice): void
fun assertEndOfSlice(self: slice): void
asm "ENDS";
/// Loads the next reference from the slice.
@pure
fun loadRef(s: slice): (slice, cell)
fun loadRef(mutate self: slice): cell
asm( -> 1 0) "LDREF";
/// Preloads the next reference from the slice.
@pure
fun preloadRef(s: slice): cell
fun preloadRef(self: slice): cell
asm "PLDREF";
/// Loads a signed [len]-bit integer from a slice.
@pure
fun loadInt(s: slice, len: int): (slice, int)
fun loadInt(mutate self: slice, len: int): int
builtin;
/// Loads an unsigned [len]-bit integer from a slice.
@pure
fun loadUint(s: slice, len: int): (slice, int)
fun loadUint(mutate self: slice, len: int): int
builtin;
/// Loads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate slice `s''`.
@pure
fun loadBits(s: slice, len: int): (slice, slice)
fun loadBits(mutate self: slice, len: int): slice
builtin;
/// Preloads a signed [len]-bit integer from a slice.
@pure
fun preloadInt(s: slice, len: int): int
fun preloadInt(self: slice, len: int): int
builtin;
/// Preloads an unsigned [len]-bit integer from a slice.
@pure
fun preloadUint(s: slice, len: int): int
fun preloadUint(self: slice, len: int): int
builtin;
/// Preloads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate slice.
@pure
fun preloadBits(s: slice, len: int): slice
fun preloadBits(self: slice, len: int): slice
builtin;
/// Loads serialized amount of Toncoins (any unsigned integer up to `2^120 - 1`).
@pure
fun loadCoins(s: slice): (slice, int)
fun loadCoins(mutate self: slice): int
asm( -> 1 0) "LDGRAMS";
/// Loads bool (-1 or 0) from a slice
@pure
fun loadBool(s: slice): (slice, int)
fun loadBool(mutate self: slice): int
asm( -> 1 0) "1 LDI";
/// Shifts a slice pointer to [len] bits forward, mutating the slice.
@pure
fun skipBits(s: slice, len: int): slice
asm "SDSKIPFIRST"; // todo make mutating
@pure
fun ~skipBits(s: slice, len: int): (slice, ())
fun skipBits(mutate self: slice, len: int): self
asm "SDSKIPFIRST";
/// Returns the first `0 ≤ len ≤ 1023` bits of a slice.
@pure
fun getFirstBits(s: slice, len: int): slice
fun getFirstBits(self: slice, len: int): slice
asm "SDCUTFIRST";
/// Returns all but the last `0 ≤ len ≤ 1023` bits of a slice.
@pure
fun removeLastBits(s: slice, len: int): slice
asm "SDSKIPLAST"; // todo make mutating
@pure
fun ~removeLastBits(s: slice, len: int): (slice, ())
fun removeLastBits(mutate self: slice, len: int): self
asm "SDSKIPLAST";
/// Returns the last `0 ≤ len ≤ 1023` bits of a slice.
@pure
fun getLastBits(s: slice, len: int): slice
fun getLastBits(self: slice, len: int): slice
asm "SDCUTLAST";
/// Loads a dictionary (TL HashMapE structure, represented as TVM cell) from a slice.
/// Returns `null` if `nothing` constructor is used.
@pure
fun loadDict(s: slice): (slice, cell)
fun loadDict(mutate self: slice): cell
asm( -> 1 0) "LDDICT";
/// Preloads a dictionary (cell) from a slice.
@pure
fun preloadDict(s: slice): cell
fun preloadDict(self: slice): cell
asm "PLDDICT";
/// Loads a dictionary as [loadDict], but returns only the remainder of the slice.
@pure
fun skipDict(s: slice): slice
asm "SKIPDICT"; // todo make mutating
@pure
fun ~skipDict(s: slice): (slice, ())
fun skipDict(mutate self: slice): self
asm "SKIPDICT";
/// Loads (Maybe ^Cell) from a slice.
/// In other words, loads 1 bit: if it's true, loads the first ref, otherwise returns `null`.
@pure
fun loadMaybeRef(s: slice): (slice, cell)
fun loadMaybeRef(mutate self: slice): cell
asm( -> 1 0) "LDOPTREF";
/// Preloads (Maybe ^Cell) from a slice.
@pure
fun preloadMaybeRef(s: slice): cell
fun preloadMaybeRef(self: slice): cell
asm "PLDOPTREF";
/// Loads (Maybe ^Cell), but returns only the remainder of the slice.
@pure
fun ~skipMaybeRef(s: slice): (slice, ())
fun skipMaybeRef(mutate self: slice): self
asm "SKIPOPTREF";
/**
@ -464,62 +451,60 @@ fun beginCell(): builder
/// Converts a builder into an ordinary `cell`.
@pure
fun endCell(b: builder): cell
fun endCell(self: builder): cell
asm "ENDC";
/// Stores a reference to a cell into a builder.
@pure
fun storeRef(b: builder, c: cell): builder
asm(c b) "STREF";
fun storeRef(mutate self: builder, c: cell): self
asm(c self) "STREF";
/// Stores a signed [len]-bit integer into a builder (`0 ≤ len ≤ 257`).
@pure
fun storeInt(b: builder, x: int, len: int): builder
fun storeInt(mutate self: builder, x: int, len: int): self
builtin;
/// Stores an unsigned [len]-bit integer into a builder (`0 ≤ len ≤ 256`).
@pure
fun storeUint(b: builder, x: int, len: int): builder
fun storeUint(mutate self: builder, x: int, len: int): self
builtin;
/// Stores a slice into a builder.
@pure
fun storeSlice(b: builder, s: slice): builder
fun storeSlice(mutate self: builder, s: slice): self
asm "STSLICER";
/// Stores amount of Toncoins into a builder.
@pure
fun storeCoins(b: builder, x: int): builder
fun storeCoins(mutate self: builder, x: int): self
asm "STGRAMS";
/// Stores bool (-1 or 0) into a builder.
/// Attention: true value is `-1`, not 1! If you pass `1` here, TVM will throw an exception.
@pure
fun storeBool(b: builder, x: int): builder
asm(x b) "1 STI";
fun storeBool(mutate self: builder, x: int): self
asm(x self) "1 STI";
/// Stores dictionary (represented by TVM `cell` or `null`) into a builder.
/// In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise.
@pure
fun storeDict(b: builder, c: cell): builder
asm(c b) "STDICT";
fun storeDict(mutate self: builder, c: cell): self
asm(c self) "STDICT";
/// Stores (Maybe ^Cell) into a builder.
/// In other words, if cell is `null`, store '0' bit; otherwise, store '1' and a ref to [c].
@pure
fun storeMaybeRef(b: builder, c: cell): builder
asm(c b) "STOPTREF";
fun storeMaybeRef(mutate self: builder, c: cell): self
asm(c self) "STOPTREF";
/// Concatenates two builders.
@pure
fun storeBuilder(to: builder, from: builder): builder
fun storeBuilder(mutate self: builder, from: builder): self
asm "STBR";
/// Stores a slice representing TL addr_none$00 (two `0` bits).
@pure
fun storeAddressNone(b: builder): builder
asm "0 PUSHINT" "SWAP" "2 STU";
@pure
fun ~storeAddressNone(b: builder): (builder, ())
fun storeAddressNone(mutate self: builder): self
asm "b{00} STSLICECONST";
@ -529,47 +514,47 @@ fun ~storeAddressNone(b: builder): (builder, ())
/// Returns the number of references in a slice.
@pure
fun getRemainingRefsCount(s: slice): int
fun getRemainingRefsCount(self: slice): int
asm "SREFS";
/// Returns the number of data bits in a slice.
@pure
fun getRemainingBitsCount(s: slice): int
fun getRemainingBitsCount(self: slice): int
asm "SBITS";
/// Returns both the number of data bits and the number of references in a slice.
@pure
fun getRemainingBitsAndRefsCount(s: slice): (int, int)
fun getRemainingBitsAndRefsCount(self: slice): (int, int)
asm "SBITREFS";
/// Checks whether a slice is empty (i.e., contains no bits of data and no cell references).
@pure
fun isEndOfSlice(s: slice): int
fun isEndOfSlice(self: slice): int
asm "SEMPTY";
/// Checks whether a slice has no bits of data.
@pure
fun isEndOfSliceBits(s: slice): int
fun isEndOfSliceBits(self: slice): int
asm "SDEMPTY";
/// Checks whether a slice has no references.
@pure
fun isEndOfSliceRefs(s: slice): int
fun isEndOfSliceRefs(self: slice): int
asm "SREMPTY";
/// Checks whether data parts of two slices coinside.
@pure
fun isSliceBitsEqual(a: slice, b: slice): int
fun isSliceBitsEqual(self: slice, b: slice): int
asm "SDEQ";
/// Returns the number of cell references already stored in a builder.
@pure
fun getBuilderRefsCount(b: builder): int
fun getBuilderRefsCount(self: builder): int
asm "BREFS";
/// Returns the number of data bits already stored in a builder.
@pure
fun getBuilderBitsCount(b: builder): int
fun getBuilderBitsCount(self: builder): int
asm "BBITS";
@ -613,8 +598,8 @@ fun getBuilderBitsCount(b: builder): int
/// Loads from slice [s] the only prefix that is a valid `MsgAddress`,
/// and returns both this prefix `s'` and the remainder `s''` of [s] as slices.
@pure
fun loadAddress(s: slice): (slice, slice)
asm( -> 1 0) "LDMSGADDR"; // todo make mutating
fun loadAddress(mutate self: slice): slice
asm( -> 1 0) "LDMSGADDR";
/// Decomposes slice [s] containing a valid `MsgAddress` into a `tuple t` with separate fields of this `MsgAddress`.
/// If [s] is not a valid `MsgAddress`, a cell deserialization exception is thrown.
@ -686,7 +671,7 @@ const NON_BOUNCEABLE = 0x10;
/// Load msgFlags from incoming message body (4 bits).
@pure
fun loadMessageFlags(s: slice): (slice, int)
fun loadMessageFlags(mutate self: slice): int
asm( -> 1 0) "4 LDU";
/// Having msgFlags (4 bits), check that a message is bounced.
@ -697,38 +682,34 @@ fun isMessageBounced(msgFlags: int): int
/// Skip 0xFFFFFFFF prefix (when a message is bounced).
@pure
fun ~skipBouncedPrefix(s: slice): (slice, ())
fun skipBouncedPrefix(mutate self: slice): self
asm "32 PUSHINT" "SDSKIPFIRST";
/// The guideline recommends to start the body of an internal message with uint32 `op` and uint64 `queryId`.
@pure
fun loadMessageOp(s: slice): (slice, int)
fun loadMessageOp(mutate self: slice): int
asm( -> 1 0) "32 LDU";
@pure
fun ~skipMessageOp(s: slice): (slice, ())
fun skipMessageOp(mutate self: slice): self
asm "32 PUSHINT" "SDSKIPFIRST";
@pure
fun storeMessageOp(b: builder, op: int): builder
asm(op b) "32 STU";
fun ~storeMessageOp(b: builder, op: int): (builder, ())
asm(op b) "32 STU";
fun storeMessageOp(mutate self: builder, op: int): self
asm(op self) "32 STU";
/// The guideline recommends that uint64 `queryId` should follow uint32 `op`.
@pure
fun loadMessageQueryId(s: slice): (slice, int)
fun loadMessageQueryId(mutate self: slice): int
asm( -> 1 0) "64 LDU";
@pure
fun ~skipMessageQueryId(s: slice): (slice, ())
fun skipMessageQueryId(mutate self: slice): self
asm "64 PUSHINT" "SDSKIPFIRST";
@pure
fun storeMessageQueryId(b: builder, queryId: int): builder
asm(queryId b) "64 STU";
fun ~storeMessageQueryId(b: builder, queryId: int): (builder, ())
asm(queryId b) "64 STU";
fun storeMessageQueryId(mutate self: builder, queryId: int): self
asm(queryId self) "64 STU";
/// SEND MODES - https://docs.ton.org/tvm.pdf page 137, SENDRAWMSG

View file

@ -24,7 +24,7 @@ fun listSplit<X>(list: tuple): (X, tuple)
/// Extracts the tail and the head of lisp-style list.
@pure
fun ~listNext<X>(list: tuple): (tuple, X)
fun listNext<X>(mutate self: tuple): X
asm( -> 1 0) "UNCONS";
/// Returns the head of lisp-style list.

View file

@ -19,415 +19,279 @@ fun createEmptyDict(): cell
/// Checks whether a dictionary is empty.
@pure
fun dictIsEmpty(c: cell): int
fun dictIsEmpty(self: cell): int
asm "DICTEMPTY";
@pure
fun iDictGet(dict: cell, keyLen: int, key: int): (slice, int)
asm(key dict keyLen) "DICTIGET" "NULLSWAPIFNOT";
fun iDictGet(self: cell, keyLen: int, key: int): (slice, int)
asm(key self keyLen) "DICTIGET" "NULLSWAPIFNOT";
@pure
fun uDictGet(dict: cell, keyLen: int, key: int): (slice, int)
asm(key dict keyLen) "DICTUGET" "NULLSWAPIFNOT";
fun uDictGet(self: cell, keyLen: int, key: int): (slice, int)
asm(key self keyLen) "DICTUGET" "NULLSWAPIFNOT";
@pure
fun sDictGet(dict: cell, keyLen: int, key: slice): (slice, int)
asm(key dict keyLen) "DICTGET" "NULLSWAPIFNOT";
fun sDictGet(self: cell, keyLen: int, key: slice): (slice, int)
asm(key self keyLen) "DICTGET" "NULLSWAPIFNOT";
@pure
fun iDictSet(dict: cell, keyLen: int, key: int, value: slice): cell
asm(value key dict keyLen) "DICTISET";
fun iDictSet(mutate self: cell, keyLen: int, key: int, value: slice): void
asm(value key self keyLen) "DICTISET";
@pure
fun ~iDictSet(dict: cell, keyLen: int, key: int, value: slice): (cell, ())
asm(value key dict keyLen) "DICTISET";
fun uDictSet(mutate self: cell, keyLen: int, key: int, value: slice): void
asm(value key self keyLen) "DICTUSET";
@pure
fun uDictSet(dict: cell, keyLen: int, key: int, value: slice): cell
asm(value key dict keyLen) "DICTUSET";
@pure
fun ~uDictSet(dict: cell, keyLen: int, key: int, value: slice): (cell, ())
asm(value key dict keyLen) "DICTUSET";
@pure
fun sDictSet(dict: cell, keyLen: int, key: slice, value: slice): cell
asm(value key dict keyLen) "DICTSET";
@pure
fun ~sDictSet(dict: cell, keyLen: int, key: slice, value: slice): (cell, ())
asm(value key dict keyLen) "DICTSET";
@pure
fun iDictSetRef(dict: cell, keyLen: int, key: int, value: cell): cell
asm(value key dict keyLen) "DICTISETREF";
@pure
fun ~iDictSetRef(dict: cell, keyLen: int, key: int, value: cell): (cell, ())
asm(value key dict keyLen) "DICTISETREF";
@pure
fun uDictSetRef(dict: cell, keyLen: int, key: int, value: cell): cell
asm(value key dict keyLen) "DICTUSETREF";
@pure
fun ~uDictSetRef(dict: cell, keyLen: int, key: int, value: cell): (cell, ())
asm(value key dict keyLen) "DICTUSETREF";
@pure
fun sDictSetRef(dict: cell, keyLen: int, key: slice, value: cell): cell
asm(value key dict keyLen) "DICTSETREF";
@pure
fun ~sDictSetRef(dict: cell, keyLen: int, key: slice, value: cell): (cell, ())
asm(value key dict keyLen) "DICTSETREF";
@pure
fun iDictSetIfNotExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTIADD";
@pure
fun ~iDictSetIfNotExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTIADD";
@pure
fun uDictSetIfNotExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTUADD";
@pure
fun ~uDictSetIfNotExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTUADD";
fun sDictSet(mutate self: cell, keyLen: int, key: slice, value: slice): void
asm(value key self keyLen) "DICTSET";
@pure
fun iDictSetIfExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTIREPLACE";
fun iDictSetRef(mutate self: cell, keyLen: int, key: int, value: cell): void
asm(value key self keyLen) "DICTISETREF";
@pure
fun ~iDictSetIfExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTIREPLACE";
fun uDictSetRef(mutate self: cell, keyLen: int, key: int, value: cell): void
asm(value key self keyLen) "DICTUSETREF";
@pure
fun uDictSetIfExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTUREPLACE";
@pure
fun ~uDictSetIfExists(dict: cell, keyLen: int, key: int, value: slice): (cell, int)
asm(value key dict keyLen) "DICTUREPLACE";
@pure
fun iDictGetRef(dict: cell, keyLen: int, key: int): (cell, int)
asm(key dict keyLen) "DICTIGETREF" "NULLSWAPIFNOT";
@pure
fun uDictGetRef(dict: cell, keyLen: int, key: int): (cell, int)
asm(key dict keyLen) "DICTUGETREF" "NULLSWAPIFNOT";
@pure
fun sDictGetRef(dict: cell, keyLen: int, key: slice): (cell, int)
asm(key dict keyLen) "DICTGETREF" "NULLSWAPIFNOT";
@pure
fun iDictGetRefOrNull(dict: cell, keyLen: int, key: int): cell
asm(key dict keyLen) "DICTIGETOPTREF";
@pure
fun uDictGetRefOrNull(dict: cell, keyLen: int, key: int): cell
asm(key dict keyLen) "DICTUGETOPTREF";
@pure
fun sDictGetRefOrNull(dict: cell, keyLen: int, key: slice): cell
asm(key dict keyLen) "DICTGETOPTREF";
fun sDictSetRef(mutate self: cell, keyLen: int, key: slice, value: cell): void
asm(value key self keyLen) "DICTSETREF";
@pure
fun iDictDelete(dict: cell, keyLen: int, key: int): (cell, int)
asm(key dict keyLen) "DICTIDEL";
fun iDictSetIfNotExists(mutate self: cell, keyLen: int, key: int, value: slice): int
asm(value key self keyLen) "DICTIADD";
@pure
fun ~iDictDelete(dict: cell, keyLen: int, key: int): (cell, int)
asm(key dict keyLen) "DICTIDEL";
fun uDictSetIfNotExists(mutate self: cell, keyLen: int, key: int, value: slice): int
asm(value key self keyLen) "DICTUADD";
@pure
fun uDictDelete(dict: cell, keyLen: int, key: int): (cell, int)
asm(key dict keyLen) "DICTUDEL";
@pure
fun ~uDictDelete(dict: cell, keyLen: int, key: int): (cell, int)
asm(key dict keyLen) "DICTUDEL";
fun iDictSetIfExists(mutate self: cell, keyLen: int, key: int, value: slice): int
asm(value key self keyLen) "DICTIREPLACE";
@pure
fun sDictDelete(dict: cell, keyLen: int, key: slice): (cell, int)
asm(key dict keyLen) "DICTDEL";
fun uDictSetIfExists(mutate self: cell, keyLen: int, key: int, value: slice): int
asm(value key self keyLen) "DICTUREPLACE";
@pure
fun ~sDictDelete(dict: cell, keyLen: int, key: slice): (cell, int)
asm(key dict keyLen) "DICTDEL";
@pure
fun iDictSetAndGet(dict: cell, keyLen: int, key: int, value: slice): (cell, slice, int)
asm(value key dict keyLen) "DICTISETGET" "NULLSWAPIFNOT";
@pure
fun ~iDictSetAndGet(dict: cell, keyLen: int, key: int, value: slice): (cell, (slice, int))
asm(value key dict keyLen) "DICTISETGET" "NULLSWAPIFNOT";
fun iDictGetRef(self: cell, keyLen: int, key: int): (cell, int)
asm(key self keyLen) "DICTIGETREF" "NULLSWAPIFNOT";
@pure
fun uDictSetAndGet(dict: cell, keyLen: int, key: int, value: slice): (cell, slice, int)
asm(value key dict keyLen) "DICTUSETGET" "NULLSWAPIFNOT";
fun uDictGetRef(self: cell, keyLen: int, key: int): (cell, int)
asm(key self keyLen) "DICTUGETREF" "NULLSWAPIFNOT";
@pure
fun ~uDictSetAndGet(dict: cell, keyLen: int, key: int, value: slice): (cell, (slice, int))
asm(value key dict keyLen) "DICTUSETGET" "NULLSWAPIFNOT";
fun sDictGetRef(self: cell, keyLen: int, key: slice): (cell, int)
asm(key self keyLen) "DICTGETREF" "NULLSWAPIFNOT";
@pure
fun sDictSetAndGet(dict: cell, keyLen: int, key: slice, value: slice): (cell, slice, int)
asm(value key dict keyLen) "DICTSETGET" "NULLSWAPIFNOT";
@pure
fun ~sDictSetAndGet(dict: cell, keyLen: int, key: slice, value: slice): (cell, (slice, int))
asm(value key dict keyLen) "DICTSETGET" "NULLSWAPIFNOT";
fun iDictGetRefOrNull(self: cell, keyLen: int, key: int): cell
asm(key self keyLen) "DICTIGETOPTREF";
@pure
fun iDictSetAndGetPreviousRefOrNull(dict: cell, keyLen: int, key: int, value: cell): (cell, cell)
asm(value key dict keyLen) "DICTISETGETOPTREF";
fun uDictGetRefOrNull(self: cell, keyLen: int, key: int): cell
asm(key self keyLen) "DICTUGETOPTREF";
@pure
fun ~iDictSetAndGetPreviousRefOrNull(dict: cell, keyLen: int, key: int, value: cell): (cell, cell)
asm(value key dict keyLen) "DICTISETGETOPTREF";
fun sDictGetRefOrNull(self: cell, keyLen: int, key: slice): cell
asm(key self keyLen) "DICTGETOPTREF";
@pure
fun uDictSetAndGetPreviousRefOrNull(dict: cell, keyLen: int, key: int, value: cell): (cell, cell)
asm(value key dict keyLen) "DICTUSETGETOPTREF";
@pure
fun ~uDictSetAndGetPreviousRefOrNull(dict: cell, keyLen: int, key: int, value: cell): (cell, cell)
asm(value key dict keyLen) "DICTUSETGETOPTREF";
fun iDictDelete(mutate self: cell, keyLen: int, key: int): int
asm(key self keyLen) "DICTIDEL";
@pure
fun iDictDeleteAndGet(dict: cell, keyLen: int, key: int): (cell, slice, int)
asm(key dict keyLen) "DICTIDELGET" "NULLSWAPIFNOT";
fun uDictDelete(mutate self: cell, keyLen: int, key: int): int
asm(key self keyLen) "DICTUDEL";
@pure
fun ~iDictDeleteAndGet(dict: cell, keyLen: int, key: int): (cell, (slice, int))
asm(key dict keyLen) "DICTIDELGET" "NULLSWAPIFNOT";
fun sDictDelete(mutate self: cell, keyLen: int, key: slice): int
asm(key self keyLen) "DICTDEL";
@pure
fun uDictDeleteAndGet(dict: cell, keyLen: int, key: int): (cell, slice, int)
asm(key dict keyLen) "DICTUDELGET" "NULLSWAPIFNOT";
@pure
fun ~uDictDeleteAndGet(dict: cell, keyLen: int, key: int): (cell, (slice, int))
asm(key dict keyLen) "DICTUDELGET" "NULLSWAPIFNOT";
fun iDictSetAndGet(mutate self: cell, keyLen: int, key: int, value: slice): (slice, int)
asm(value key self keyLen) "DICTISETGET" "NULLSWAPIFNOT";
@pure
fun sDictDeleteAndGet(dict: cell, keyLen: int, key: slice): (cell, slice, int)
asm(key dict keyLen) "DICTDELGET" "NULLSWAPIFNOT";
fun uDictSetAndGet(mutate self: cell, keyLen: int, key: int, value: slice): (slice, int)
asm(value key self keyLen) "DICTUSETGET" "NULLSWAPIFNOT";
@pure
fun ~sDictDeleteAndGet(dict: cell, keyLen: int, key: slice): (cell, (slice, int))
asm(key dict keyLen) "DICTDELGET" "NULLSWAPIFNOT";
fun sDictSetAndGet(mutate self: cell, keyLen: int, key: slice, value: slice): (slice, int)
asm(value key self keyLen) "DICTSETGET" "NULLSWAPIFNOT";
@pure
fun iDictSetBuilder(dict: cell, keyLen: int, key: int, value: builder): cell
asm(value key dict keyLen) "DICTISETB";
fun iDictSetAndGetRefOrNull(mutate self: cell, keyLen: int, key: int, value: cell): cell
asm(value key self keyLen) "DICTISETGETOPTREF";
@pure
fun ~iDictSetBuilder(dict: cell, keyLen: int, key: int, value: builder): (cell, ())
asm(value key dict keyLen) "DICTISETB";
fun uDictSetAndGetRefOrNull(mutate self: cell, keyLen: int, key: int, value: cell): cell
asm(value key self keyLen) "DICTUSETGETOPTREF";
@pure
fun uDictSetBuilder(dict: cell, keyLen: int, key: int, value: builder): cell
asm(value key dict keyLen) "DICTUSETB";
@pure
fun ~uDictSetBuilder(dict: cell, keyLen: int, key: int, value: builder): (cell, ())
asm(value key dict keyLen) "DICTUSETB";
fun iDictDeleteAndGet(mutate self: cell, keyLen: int, key: int): (slice, int)
asm(key self keyLen) "DICTIDELGET" "NULLSWAPIFNOT";
@pure
fun sDictSetBuilder(dict: cell, keyLen: int, key: slice, value: builder): cell
asm(value key dict keyLen) "DICTSETB";
fun uDictDeleteAndGet(mutate self: cell, keyLen: int, key: int): (slice, int)
asm(key self keyLen) "DICTUDELGET" "NULLSWAPIFNOT";
@pure
fun ~sDictSetBuilder(dict: cell, keyLen: int, key: slice, value: builder): (cell, ())
asm(value key dict keyLen) "DICTSETB";
fun sDictDeleteAndGet(mutate self: cell, keyLen: int, key: slice): (slice, int)
asm(key self keyLen) "DICTDELGET" "NULLSWAPIFNOT";
@pure
fun iDictSetBuilderIfNotExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTIADDB";
fun iDictSetBuilder(mutate self: cell, keyLen: int, key: int, value: builder): void
asm(value key self keyLen) "DICTISETB";
@pure
fun ~iDictSetBuilderIfNotExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTIADDB";
fun uDictSetBuilder(mutate self: cell, keyLen: int, key: int, value: builder): void
asm(value key self keyLen) "DICTUSETB";
@pure
fun uDictSetBuilderIfNotExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTUADDB";
fun sDictSetBuilder(mutate self: cell, keyLen: int, key: slice, value: builder): void
asm(value key self keyLen) "DICTSETB";
@pure
fun ~uDictSetBuilderIfNotExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTUADDB";
@pure
fun iDictSetBuilderIfExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTIREPLACEB";
fun iDictSetBuilderIfNotExists(mutate self: cell, keyLen: int, key: int, value: builder): int
asm(value key self keyLen) "DICTIADDB";
@pure
fun ~iDictSetBuilderIfExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTIREPLACEB";
fun uDictSetBuilderIfNotExists(mutate self: cell, keyLen: int, key: int, value: builder): int
asm(value key self keyLen) "DICTUADDB";
@pure
fun uDictSetBuilderIfExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTUREPLACEB";
fun iDictSetBuilderIfExists(mutate self: cell, keyLen: int, key: int, value: builder): int
asm(value key self keyLen) "DICTIREPLACEB";
@pure
fun ~uDictSetBuilderIfExists(dict: cell, keyLen: int, key: int, value: builder): (cell, int)
asm(value key dict keyLen) "DICTUREPLACEB";
fun uDictSetBuilderIfExists(mutate self: cell, keyLen: int, key: int, value: builder): int
asm(value key self keyLen) "DICTUREPLACEB";
@pure
fun iDictDeleteFirstAndGet(dict: cell, keyLen: int): (cell, int, slice, int)
fun iDictDeleteFirstAndGet(mutate self: cell, keyLen: int): (int, slice, int)
asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2";
@pure
fun ~iDictDeleteFirstAndGet(dict: cell, keyLen: int): (cell, (int, slice, int))
asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2";
@pure
fun uDictDeleteFirstAndGet(dict: cell, keyLen: int): (cell, int, slice, int)
fun uDictDeleteFirstAndGet(mutate self: cell, keyLen: int): (int, slice, int)
asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2";
@pure
fun ~uDictDeleteFirstAndGet(dict: cell, keyLen: int): (cell, (int, slice, int))
asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2";
@pure
fun sDictDeleteFirstAndGet(dict: cell, keyLen: int): (cell, slice, slice, int)
asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2";
@pure
fun ~sDictDeleteFirstAndGet(dict: cell, keyLen: int): (cell, (slice, slice, int))
fun sDictDeleteFirstAndGet(mutate self: cell, keyLen: int): (slice, slice, int)
asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2";
@pure
fun iDictDeleteLastAndGet(dict: cell, keyLen: int): (cell, int, slice, int)
fun iDictDeleteLastAndGet(mutate self: cell, keyLen: int): (int, slice, int)
asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2";
@pure
fun ~iDictDeleteLastAndGet(dict: cell, keyLen: int): (cell, (int, slice, int))
asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2";
@pure
fun uDictDeleteLastAndGet(dict: cell, keyLen: int): (cell, int, slice, int)
fun uDictDeleteLastAndGet(mutate self: cell, keyLen: int): (int, slice, int)
asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2";
@pure
fun ~uDictDeleteLastAndGet(dict: cell, keyLen: int): (cell, (int, slice, int))
asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2";
@pure
fun sDictDeleteLastAndGet(dict: cell, keyLen: int): (cell, slice, slice, int)
asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2";
@pure
fun ~sDictDeleteLastAndGet(dict: cell, keyLen: int): (cell, (slice, slice, int))
fun sDictDeleteLastAndGet(mutate self: cell, keyLen: int): (slice, slice, int)
asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2";
@pure
fun iDictGetFirst(dict: cell, keyLen: int): (int, slice, int)
fun iDictGetFirst(self: cell, keyLen: int): (int, slice, int)
asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2";
@pure
fun uDictGetFirst(dict: cell, keyLen: int): (int, slice, int)
fun uDictGetFirst(self: cell, keyLen: int): (int, slice, int)
asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2";
@pure
fun sDictGetFirst(dict: cell, keyLen: int): (slice, slice, int)
fun sDictGetFirst(self: cell, keyLen: int): (slice, slice, int)
asm (-> 1 0 2) "DICTMIN" "NULLSWAPIFNOT2";
@pure
fun iDictGetFirstAsRef(dict: cell, keyLen: int): (int, cell, int)
fun iDictGetFirstAsRef(self: cell, keyLen: int): (int, cell, int)
asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2";
@pure
fun uDictGetFirstAsRef(dict: cell, keyLen: int): (int, cell, int)
fun uDictGetFirstAsRef(self: cell, keyLen: int): (int, cell, int)
asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2";
@pure
fun sDictGetFirstAsRef(dict: cell, keyLen: int): (slice, cell, int)
fun sDictGetFirstAsRef(self: cell, keyLen: int): (slice, cell, int)
asm (-> 1 0 2) "DICTMINREF" "NULLSWAPIFNOT2";
@pure
fun iDictGetLast(dict: cell, keyLen: int): (int, slice, int)
fun iDictGetLast(self: cell, keyLen: int): (int, slice, int)
asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2";
@pure
fun uDictGetLast(dict: cell, keyLen: int): (int, slice, int)
fun uDictGetLast(self: cell, keyLen: int): (int, slice, int)
asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2";
@pure
fun sDictGetLast(dict: cell, keyLen: int): (slice, slice, int)
fun sDictGetLast(self: cell, keyLen: int): (slice, slice, int)
asm (-> 1 0 2) "DICTMAX" "NULLSWAPIFNOT2";
@pure
fun iDictGetLastAsRef(dict: cell, keyLen: int): (int, cell, int)
fun iDictGetLastAsRef(self: cell, keyLen: int): (int, cell, int)
asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2";
@pure
fun uDictGetLastAsRef(dict: cell, keyLen: int): (int, cell, int)
fun uDictGetLastAsRef(self: cell, keyLen: int): (int, cell, int)
asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2";
@pure
fun sDictGetLastAsRef(dict: cell, keyLen: int): (slice, cell, int)
fun sDictGetLastAsRef(self: cell, keyLen: int): (slice, cell, int)
asm (-> 1 0 2) "DICTMAXREF" "NULLSWAPIFNOT2";
@pure
fun iDictGetNext(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2";
fun iDictGetNext(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2";
@pure
fun uDictGetNext(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2";
fun uDictGetNext(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2";
@pure
fun iDictGetNextOrEqual(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2";
fun iDictGetNextOrEqual(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2";
@pure
fun uDictGetNextOrEqual(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2";
fun uDictGetNextOrEqual(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2";
@pure
fun iDictGetPrev(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2";
fun iDictGetPrev(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2";
@pure
fun uDictGetPrev(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2";
fun uDictGetPrev(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2";
@pure
fun iDictGetPrevOrEqual(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2";
fun iDictGetPrevOrEqual(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2";
@pure
fun uDictGetPrevOrEqual(dict: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot dict keyLen -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2";
fun uDictGetPrevOrEqual(self: cell, keyLen: int, pivot: int): (int, slice, int)
asm(pivot self keyLen -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2";
/**
@ -435,13 +299,13 @@ fun uDictGetPrevOrEqual(dict: cell, keyLen: int, pivot: int): (int, slice, int)
*/
@pure
fun prefixDictGet(dict: cell, keyLen: int, key: slice): (slice, slice, slice, int)
asm(key dict keyLen) "PFXDICTGETQ" "NULLSWAPIFNOT2";
fun prefixDictGet(self: cell, keyLen: int, key: slice): (slice, slice, slice, int)
asm(key self keyLen) "PFXDICTGETQ" "NULLSWAPIFNOT2";
@pure
fun prefixDictSet(dict: cell, keyLen: int, key: slice, value: slice): (cell, int)
asm(value key dict keyLen) "PFXDICTSET";
fun prefixDictSet(mutate self: cell, keyLen: int, key: slice, value: slice): int
asm(value key self keyLen) "PFXDICTSET";
@pure
fun prefixDictDelete(dict: cell, keyLen: int, key: slice): (cell, int)
asm(key dict keyLen) "PFXDICTDEL";
fun prefixDictDelete(mutate self: cell, keyLen: int, key: slice): int
asm(key self keyLen) "PFXDICTDEL";

View file

@ -21,9 +21,5 @@ fun transformSliceToContinuation(s: slice): continuation
/// Moves a variable or a value [x] to the top of the stack.
@pure
fun stackMoveToTop<X>(x: X): X
fun stackMoveToTop<X>(mutate self: X): void
asm "NOP";
/// Mark a variable as used, such that the code which produced it won't be deleted even if it is not impure.
fun stackMoveToTopImpure<X>(x: X): void // todo needs to be deleted, check verified contracts
asm "DROP";