Skip to content

Commit dfda879

Browse files
authored
Merge pull request #1741 from ton-blockchain/tolk-v1.0
Tolk v1.0: lazy loading, AST inlining, peephole optimizations, TVM 11
2 parents 8f99af7 + 43d2bfd commit dfda879

File tree

181 files changed

+10928
-1301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+10928
-1301
lines changed

crypto/smartcont/tolk-stdlib/common.tolk

Lines changed: 328 additions & 252 deletions
Large diffs are not rendered by default.
Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,70 @@
11
// A part of standard library for Tolk
2-
tolk 0.99
2+
tolk 1.0
33

44
/**
55
Gas and payment related primitives.
66
*/
77

88
/// Returns amount of gas (in gas units) consumed in current Computation Phase.
99
fun getGasConsumedAtTheMoment(): int
10-
asm "GASCONSUMED";
10+
asm "GASCONSUMED"
1111

1212
/// This function is required to be called when you process an external message (from an outer world)
1313
/// and "accept" it to blockchain.
1414
/// Without calling this function, an external message would be discarded.
1515
/// As an effect, the current smart contract agrees to buy some gas to finish the current transaction.
1616
/// For more details, check [accept_message effects](https://ton.org/docs/#/smart-contracts/accept).
1717
fun acceptExternalMessage(): void
18-
asm "ACCEPT";
18+
asm "ACCEPT"
1919

2020
/// When processing an internal message, by default, the limit of gas consumption is determined by incoming message.
2121
/// Functions [setGasLimit] and [setGasLimitToMaximum] allow you to change this behavior.
2222
/// Sets current gas limit `gl` to its maximal allowed value `gm`, and resets the gas credit `gc` to zero,
2323
/// decreasing the value of `gr` by `gc` in the process.
2424
fun setGasLimitToMaximum(): void
25-
asm "ACCEPT";
25+
asm "ACCEPT"
2626

2727
/// When processing an internal message, by default, the limit of gas consumption is determined by incoming message.
2828
/// Functions [setGasLimit] and [setGasLimitToMaximum] allow you to change this behavior.
2929
/// Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero.
3030
/// If the gas consumed so far (including the present instruction) exceeds the resulting value of `gl`,
3131
/// an (unhandled) out of gas exception is thrown before setting new gas limits.
3232
fun setGasLimit(limit: int): void
33-
asm "SETGASLIMIT";
33+
asm "SETGASLIMIT"
3434

3535
/// Calculates fee (amount in nanotoncoins to be paid) for a transaction which consumed [gasUsed] gas units.
3636
fun calculateGasFee(workchain: int8, gasUsed: int): coins
37-
asm(gasUsed workchain) "GETGASFEE";
37+
asm(gasUsed workchain) "GETGASFEE"
3838

3939
/// Same as [calculateGasFee], but without flat price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level)
4040
fun calculateGasFeeWithoutFlatPrice(workchain: int8, gasUsed: coins): coins
41-
asm(gasUsed workchain) "GETGASFEESIMPLE";
41+
asm(gasUsed workchain) "GETGASFEESIMPLE"
4242

4343
/// Calculates amount of nanotoncoins you should pay for storing a contract of provided size for [seconds].
4444
/// [bits] and [cells] represent contract state (code + data).
4545
fun calculateStorageFee(workchain: int8, seconds: int, bits: int, cells: int): coins
46-
asm(cells bits seconds workchain) "GETSTORAGEFEE";
46+
asm(cells bits seconds workchain) "GETSTORAGEFEE"
4747

48-
/// Calculates amount of nanotoncoins you should pay to send a message of specified size.
49-
fun calculateMessageFee(workchain: int8, bits: int, cells: int): coins
50-
asm(cells bits workchain) "GETFORWARDFEE";
48+
/// Calculates amount of nanotoncoins you should pay to send a message of a specified size.
49+
fun calculateForwardFee(workchain: int8, bits: int, cells: int): coins
50+
asm(cells bits workchain) "GETFORWARDFEE"
5151

52-
/// Same as [calculateMessageFee], but without lump price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level)
53-
fun calculateMessageFeeWithoutLumpPrice(workchain: int8, bits: int, cells: int): coins
54-
asm(cells bits workchain) "GETFORWARDFEESIMPLE";
52+
/// Same as [calculateForwardFee], but without lump price (you have supposed to read https://docs.ton.org/develop/howto/fees-low-level)
53+
fun calculateForwardFeeWithoutLumpPrice(workchain: int8, bits: int, cells: int): coins
54+
asm(cells bits workchain) "GETFORWARDFEESIMPLE"
5555

5656
/// Calculates fee that was paid by the sender of an incoming internal message.
57-
fun calculateOriginalMessageFee(workchain: int8, incomingFwdFee: coins): coins
58-
asm(incomingFwdFee workchain) "GETORIGINALFWDFEE";
57+
@deprecated("use modern `onInternalMessage` and access `in.originalForwardFee` directly")
58+
fun calculateOriginalForwardFee(workchain: int8, incomingFwdFee: coins): coins
59+
asm(incomingFwdFee workchain) "GETORIGINALFWDFEE"
5960

6061
/// Returns the amount of nanotoncoins current contract debts for storage. ("due" and "debt" are synonyms)
6162
/// If it has no debt, `0` is returned.
6263
fun contract.getStorageDuePayment(): coins
63-
asm "DUEPAYMENT";
64+
asm "DUEPAYMENT"
6465

6566
/// Returns the amount of nanotoncoins charged for storage.
6667
/// (during storage phase preceeding to current computation phase)
6768
@pure
6869
fun contract.getStoragePaidPayment(): coins
69-
asm "STORAGEFEES";
70+
asm "STORAGEFEES"
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 0.99
2+
tolk 1.0
33

44
/**
55
Lisp-style lists are nested 2-elements tuples: `[1, [2, [3, null]]]` represents list `[1, 2, 3]`.
@@ -9,25 +9,25 @@ tolk 0.99
99

1010
@pure
1111
fun createEmptyList(): tuple
12-
asm "PUSHNULL";
12+
asm "PUSHNULL"
1313

1414
/// Adds an element to the beginning of lisp-style list.
1515
/// Note, that it does not mutate the list: instead, it returns a new one (it's a lisp pattern).
1616
@pure
1717
fun listPrepend<X>(head: X, tail: tuple?): tuple
18-
asm "CONS";
18+
asm "CONS"
1919

2020
/// Extracts the head and the tail of lisp-style list.
2121
@pure
2222
fun listSplit<X>(list: tuple): (X, tuple?)
23-
asm "UNCONS";
23+
asm "UNCONS"
2424

2525
/// Returns the head of lisp-style list.
2626
@pure
2727
fun listGetHead<X>(list: tuple): X
28-
asm "CAR";
28+
asm "CAR"
2929

3030
/// Returns the tail of lisp-style list.
3131
@pure
3232
fun listGetTail(list: tuple): tuple?
33-
asm "CDR";
33+
asm "CDR"

0 commit comments

Comments
 (0)