From 8f7eebb23d62d017e5c77e2b249ea72032ac9c56 Mon Sep 17 00:00:00 2001 From: SpyCheese Date: Tue, 28 Nov 2023 17:51:31 +0300 Subject: [PATCH] Make all functions impure by default, add "pure" specifier Change specifiers in stdlib.fc, adjust legacy tests, remove pragma strict-purity-check --- crypto/func/abscode.cpp | 6 - crypto/func/auto-tests/legacy_tester.py | 10 +- crypto/func/auto-tests/legacy_tests.json | 22 +- .../legacy_tests/gg-marketplace/stdlib.fc | 424 +++++++++--------- .../legacy_tests/nominator-pool/stdlib.fc | 416 ++++++++--------- .../auto-tests/legacy_tests/storage/stdlib.fc | 380 ++++++++-------- .../legacy_tests/tele-nft-item/stdlib.fc | 410 ++++++++--------- .../whales-nominators/modules/utils.fc | 2 +- .../whales-nominators/nominators.fc | 2 +- .../legacy_tests/whales-nominators/stdlib.fc | 418 ++++++++--------- .../func/auto-tests/tests/default-impure.fc | 25 ++ crypto/func/auto-tests/tests/explicit-pure.fc | 33 ++ crypto/func/func.cpp | 2 - crypto/func/func.h | 6 +- crypto/func/gen-abscode.cpp | 6 +- crypto/func/keywords.cpp | 1 + crypto/func/parse-func.cpp | 22 +- crypto/smartcont/stdlib.fc | 380 ++++++++-------- 18 files changed, 1320 insertions(+), 1245 deletions(-) create mode 100644 crypto/func/auto-tests/tests/default-impure.fc create mode 100644 crypto/func/auto-tests/tests/explicit-pure.fc diff --git a/crypto/func/abscode.cpp b/crypto/func/abscode.cpp index 56fe48127..f1ffcfa49 100644 --- a/crypto/func/abscode.cpp +++ b/crypto/func/abscode.cpp @@ -223,12 +223,6 @@ void VarDescrList::show(std::ostream& os) const { os << " ]\n"; } -void Op::set_impure(const CodeBlob& code) { - if (code.flags & CodeBlob::_ForbidImpure) { - throw src::ParseError{where, "impure operation in pure function"}; - } - flags |= _Impure; -} void Op::flags_set_clear(int set, int clear) { flags = (flags | set) & ~clear; for (auto& op : block0) { diff --git a/crypto/func/auto-tests/legacy_tester.py b/crypto/func/auto-tests/legacy_tester.py index 9a9905012..c4db40334 100644 --- a/crypto/func/auto-tests/legacy_tester.py +++ b/crypto/func/auto-tests/legacy_tester.py @@ -32,13 +32,13 @@ ["jetton-minter/jetton-minter.fc", 9028309926287301331466371999814928201427184114165428257502393474125007156494], ["gg-marketplace/nft-marketplace-v2.fc", 92199806964112524639740773542356508485601908152150843819273107618799016205930], ["jetton-wallet/jetton-wallet.fc", 86251125787443633057458168028617933212663498001665054651523310772884328206542], - ["whales-nominators/nominators.fc", 8941364499854379927692172316865293429893094891593442801401542636695127885153], + ["whales-nominators/nominators.fc", 64989185004203073400683226767264384908045055609681310145961012819587514238303], - ["tact-examples/treasure_Treasure.code.fc", 13962538639825790677138656603323869918938565499584297120566680287245364723897], - ["tact-examples/jetton_SampleJetton.code.fc", 94076762218493729104783735200107713211245710256802265203823917715299139499110], - ["tact-examples/jetton_JettonDefaultWallet.code.fc", 29421313492520031238091587108198906058157443241743283101866538036369069620563], - ["tact-examples/maps_MapTestContract.code.fc", 22556550222249123835909180266811414538971143565993192846012583552876721649744], + ["tact-examples/treasure_Treasure.code.fc", 60348994682690664630455354672413353326734169633005380820521037982881341539662], + ["tact-examples/jetton_SampleJetton.code.fc", 70075170397574779402104489003369966746142305378310979462742589461276337980270], + ["tact-examples/jetton_JettonDefaultWallet.code.fc", 12710666798574325848563501630728896968396634924087634181325633274893128358499], + ["tact-examples/maps_MapTestContract.code.fc", 86004071444084135394990759334664637743689750108042267324839281046456545168857], ] def getenv(name, default=None): diff --git a/crypto/func/auto-tests/legacy_tests.json b/crypto/func/auto-tests/legacy_tests.json index 61a433bb7..29c6a2ab3 100644 --- a/crypto/func/auto-tests/legacy_tests.json +++ b/crypto/func/auto-tests/legacy_tests.json @@ -1 +1,21 @@ -[["elector/elector-code.fc", "115226404411715505328583639896096915745686314074575650766750648324043316883483"], ["config/config-code.fc", "10913070768607625342121305745084703121685937915388357634624451844356456145601"], ["eth-bridge-multisig/multisig-code.fc", "101509909129354488841890823627011033360100627957439967918234053299675481277954"], ["bsc-bridge-collector/votes-collector.fc", "62190447221288642706570413295807615918589884489514159926097051017036969900417"], ["uni-lock-wallet/uni-lockup-wallet.fc", "61959738324779104851267145467044677651344601417998258530238254441977103654381"], ["nft-collection/nft-collection-editable.fc", "45561997735512210616567774035540357815786262097548276229169737015839077731274"], ["dns-collection/nft-collection.fc", "107999822699841936063083742021519765435859194241091312445235370766165379261859"], ["tele-nft-item/nft-item.fc", "69777543125381987786450436977742010705076866061362104025338034583422166453344"], ["storage/storage-contract.fc", "91377830060355733016937375216020277778264560226873154627574229667513068328151"], ["storage/storage-provider.fc", "13618336676213331164384407184540461509022654507176709588621016553953760588122"], ["nominator-pool/pool.fc", "69767057279163099864792356875696330339149706521019810113334238732928422055375"], ["jetton-minter/jetton-minter.fc", "9028309926287301331466371999814928201427184114165428257502393474125007156494"], ["gg-marketplace/nft-marketplace-v2.fc", "92199806964112524639740773542356508485601908152150843819273107618799016205930"], ["jetton-wallet/jetton-wallet.fc", "86251125787443633057458168028617933212663498001665054651523310772884328206542"], ["whales-nominators/nominators.fc", "8941364499854379927692172316865293429893094891593442801401542636695127885153"], ["tact-examples/treasure_Treasure.code.fc", "13962538639825790677138656603323869918938565499584297120566680287245364723897"], ["tact-examples/jetton_SampleJetton.code.fc", "94076762218493729104783735200107713211245710256802265203823917715299139499110"], ["tact-examples/jetton_JettonDefaultWallet.code.fc", "29421313492520031238091587108198906058157443241743283101866538036369069620563"], ["tact-examples/maps_MapTestContract.code.fc", "22556550222249123835909180266811414538971143565993192846012583552876721649744"]] \ No newline at end of file +[ + ["elector/elector-code.fc", "115226404411715505328583639896096915745686314074575650766750648324043316883483"], + ["config/config-code.fc", "10913070768607625342121305745084703121685937915388357634624451844356456145601"], + ["eth-bridge-multisig/multisig-code.fc", "101509909129354488841890823627011033360100627957439967918234053299675481277954"], + ["bsc-bridge-collector/votes-collector.fc", "62190447221288642706570413295807615918589884489514159926097051017036969900417"], + ["uni-lock-wallet/uni-lockup-wallet.fc", "61959738324779104851267145467044677651344601417998258530238254441977103654381"], + ["nft-collection/nft-collection-editable.fc", "45561997735512210616567774035540357815786262097548276229169737015839077731274"], + ["dns-collection/nft-collection.fc", "107999822699841936063083742021519765435859194241091312445235370766165379261859"], + ["tele-nft-item/nft-item.fc", "69777543125381987786450436977742010705076866061362104025338034583422166453344"], + ["storage/storage-contract.fc", "91377830060355733016937375216020277778264560226873154627574229667513068328151"], + ["storage/storage-provider.fc", "13618336676213331164384407184540461509022654507176709588621016553953760588122"], + ["nominator-pool/pool.fc", "69767057279163099864792356875696330339149706521019810113334238732928422055375"], + ["jetton-minter/jetton-minter.fc", "9028309926287301331466371999814928201427184114165428257502393474125007156494"], + ["gg-marketplace/nft-marketplace-v2.fc", "92199806964112524639740773542356508485601908152150843819273107618799016205930"], + ["jetton-wallet/jetton-wallet.fc", "86251125787443633057458168028617933212663498001665054651523310772884328206542"], + ["whales-nominators/nominators.fc", "64989185004203073400683226767264384908045055609681310145961012819587514238303"], + ["tact-examples/treasure_Treasure.code.fc", "60348994682690664630455354672413353326734169633005380820521037982881341539662"], + ["tact-examples/jetton_SampleJetton.code.fc", "70075170397574779402104489003369966746142305378310979462742589461276337980270"], + ["tact-examples/jetton_JettonDefaultWallet.code.fc", "12710666798574325848563501630728896968396634924087634181325633274893128358499"], + ["tact-examples/maps_MapTestContract.code.fc", "86004071444084135394990759334664637743689750108042267324839281046456545168857"] +] diff --git a/crypto/func/auto-tests/legacy_tests/gg-marketplace/stdlib.fc b/crypto/func/auto-tests/legacy_tests/gg-marketplace/stdlib.fc index ba9177e97..f3ece83f3 100644 --- a/crypto/func/auto-tests/legacy_tests/gg-marketplace/stdlib.fc +++ b/crypto/func/auto-tests/legacy_tests/gg-marketplace/stdlib.fc @@ -1,215 +1,215 @@ ;; Standard library for funC ;; -forall X -> tuple cons(X head, tuple tail) asm "CONS"; -forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; -forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; -forall X -> X car(tuple list) asm "CAR"; -tuple cdr(tuple list) asm "CDR"; -tuple empty_tuple() asm "NIL"; -forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; -forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; -forall X -> [X] single(X x) asm "SINGLE"; -forall X -> X unsingle([X] t) asm "UNSINGLE"; -forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; -forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; -forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; -forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; -forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; -forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; -forall X -> X first(tuple t) asm "FIRST"; -forall X -> X second(tuple t) asm "SECOND"; -forall X -> X third(tuple t) asm "THIRD"; -forall X -> X fourth(tuple t) asm "3 INDEX"; -forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; -forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; -forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; -forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; -forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; -forall X -> X null() asm "PUSHNULL"; -forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; - -int now() asm "NOW"; -slice my_address() asm "MYADDR"; -[int, cell] get_balance() asm "BALANCE"; -int cur_lt() asm "LTIME"; -int block_lt() asm "BLOCKLT"; - -int cell_hash(cell c) asm "HASHCU"; -int slice_hash(slice s) asm "HASHSU"; -int string_hash(slice s) asm "SHA256U"; - -int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; -int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; - -(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; -(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; -(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; -(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; - -;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; - -() dump_stack() impure asm "DUMPSTK"; - -cell get_data() asm "c4 PUSH"; -() set_data(cell c) impure asm "c4 POP"; -cont get_c3() impure asm "c3 PUSH"; -() set_c3(cont c) impure asm "c3 POP"; -cont bless(slice s) impure asm "BLESS"; - -() accept_message() impure asm "ACCEPT"; -() set_gas_limit(int limit) impure asm "SETGASLIMIT"; -() commit() impure asm "COMMIT"; -() buy_gas(int gram) impure asm "BUYGAS"; - -int min(int x, int y) asm "MIN"; -int max(int x, int y) asm "MAX"; -(int, int) minmax(int x, int y) asm "MINMAX"; -int abs(int x) asm "ABS"; - -slice begin_parse(cell c) asm "CTOS"; -() end_parse(slice s) impure asm "ENDS"; -(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; -cell preload_ref(slice s) asm "PLDREF"; -;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; -;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; -;; int preload_int(slice s, int len) asm "PLDIX"; -;; int preload_uint(slice s, int len) asm "PLDUX"; -;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; -;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; -(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; -slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; -(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; -slice first_bits(slice s, int len) asm "SDCUTFIRST"; -slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -slice slice_last(slice s, int len) asm "SDCUTLAST"; -(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; -cell preload_dict(slice s) asm "PLDDICT"; -slice skip_dict(slice s) asm "SKIPDICT"; - -(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; -cell preload_maybe_ref(slice s) asm "PLDOPTREF"; -builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; - -int cell_depth(cell c) asm "CDEPTH"; - -int slice_refs(slice s) asm "SREFS"; -int slice_bits(slice s) asm "SBITS"; -(int, int) slice_bits_refs(slice s) asm "SBITREFS"; -int slice_empty?(slice s) asm "SEMPTY"; -int slice_data_empty?(slice s) asm "SDEMPTY"; -int slice_refs_empty?(slice s) asm "SREMPTY"; -int slice_depth(slice s) asm "SDEPTH"; - -int builder_refs(builder b) asm "BREFS"; -int builder_bits(builder b) asm "BBITS"; -int builder_depth(builder b) asm "BDEPTH"; - -builder begin_cell() asm "NEWC"; -cell end_cell(builder b) asm "ENDC"; - builder store_ref(builder b, cell c) asm(c b) "STREF"; -;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; -;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; -builder store_slice(builder b, slice s) asm "STSLICER"; -builder store_grams(builder b, int x) asm "STGRAMS"; -builder store_dict(builder b, cell c) asm(c b) "STDICT"; - -(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; -tuple parse_addr(slice s) asm "PARSEMSGADDR"; -(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; -(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; - -cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; -(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF"; -(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF"; -(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; -(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; -(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; -(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; -(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; -(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; -(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; -(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; -(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; -(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; -cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; -(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; -(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; -(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; -(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; -cell new_dict() asm "NEWDICT"; -int dict_empty?(cell c) asm "DICTEMPTY"; - -(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; -(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; -(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; - -cell config_param(int x) asm "CONFIGOPTPARAM"; -int cell_null?(cell c) asm "ISNULL"; - -() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; -() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; -() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; -() set_code(cell new_code) impure asm "SETCODE"; - -int random() impure asm "RANDU256"; -int rand(int range) impure asm "RAND"; -int get_seed() impure asm "RANDSEED"; -int set_seed() impure asm "SETRAND"; -() randomize(int x) impure asm "ADDRAND"; -() randomize_lt() impure asm "LTIME" "ADDRAND"; - -builder store_coins(builder b, int x) asm "STVARUINT16"; -(slice, int) load_coins(slice s) asm( -> 1 0) "LDVARUINT16"; - -int equal_slices (slice a, slice b) asm "SDEQ"; -int builder_null?(builder b) asm "ISNULL"; -builder store_builder(builder to, builder from) asm "STBR"; \ No newline at end of file +forall X -> tuple cons(X head, tuple tail) pure asm "CONS"; +forall X -> (X, tuple) uncons(tuple list) pure asm "UNCONS"; +forall X -> (tuple, X) list_next(tuple list) pure asm( -> 1 0) "UNCONS"; +forall X -> X car(tuple list) pure asm "CAR"; +tuple cdr(tuple list) pure asm "CDR"; +tuple empty_tuple() pure asm "NIL"; +forall X -> tuple tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> [X] single(X x) pure asm "SINGLE"; +forall X -> X unsingle([X] t) pure asm "UNSINGLE"; +forall X, Y -> [X, Y] pair(X x, Y y) pure asm "PAIR"; +forall X, Y -> (X, Y) unpair([X, Y] t) pure asm "UNPAIR"; +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) pure asm "TRIPLE"; +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) pure asm "UNTRIPLE"; +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) pure asm "4 TUPLE"; +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) pure asm "4 UNTUPLE"; +forall X -> X first(tuple t) pure asm "FIRST"; +forall X -> X second(tuple t) pure asm "SECOND"; +forall X -> X third(tuple t) pure asm "THIRD"; +forall X -> X fourth(tuple t) pure asm "3 INDEX"; +forall X, Y -> X pair_first([X, Y] p) pure asm "FIRST"; +forall X, Y -> Y pair_second([X, Y] p) pure asm "SECOND"; +forall X, Y, Z -> X triple_first([X, Y, Z] p) pure asm "FIRST"; +forall X, Y, Z -> Y triple_second([X, Y, Z] p) pure asm "SECOND"; +forall X, Y, Z -> Z triple_third([X, Y, Z] p) pure asm "THIRD"; +forall X -> X null() pure asm "PUSHNULL"; +forall X -> (X, ()) ~impure_touch(X x) asm "NOP"; + +int now() pure asm "NOW"; +slice my_address() pure asm "MYADDR"; +[int, cell] get_balance() pure asm "BALANCE"; +int cur_lt() pure asm "LTIME"; +int block_lt() pure asm "BLOCKLT"; + +int cell_hash(cell c) pure asm "HASHCU"; +int slice_hash(slice s) pure asm "HASHSU"; +int string_hash(slice s) pure asm "SHA256U"; + +int check_signature(int hash, slice signature, int public_key) pure asm "CHKSIGNU"; +int check_data_signature(slice data, slice signature, int public_key) pure asm "CHKSIGNS"; + +(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE"; +(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE"; +(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) pure asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; + +;; () throw_if(int excno, int cond) asm "THROWARGIF"; + +() dump_stack() asm "DUMPSTK"; + +cell get_data() pure asm "c4 PUSH"; +() set_data(cell c) asm "c4 POP"; +cont get_c3() asm "c3 PUSH"; +() set_c3(cont c) asm "c3 POP"; +cont bless(slice s) asm "BLESS"; + +() accept_message() asm "ACCEPT"; +() set_gas_limit(int limit) asm "SETGASLIMIT"; +() commit() asm "COMMIT"; +() buy_gas(int gram) asm "BUYGAS"; + +int min(int x, int y) pure asm "MIN"; +int max(int x, int y) pure asm "MAX"; +(int, int) minmax(int x, int y) pure asm "MINMAX"; +int abs(int x) pure asm "ABS"; + +slice begin_parse(cell c) pure asm "CTOS"; +() end_parse(slice s) asm "ENDS"; +(slice, cell) load_ref(slice s) pure asm( -> 1 0) "LDREF"; +cell preload_ref(slice s) pure asm "PLDREF"; +;; (slice, int) ~load_int(slice s, int len) pure asm(s len -> 1 0) "LDIX"; +;; (slice, int) ~load_uint(slice s, int len) pure asm( -> 1 0) "LDUX"; +;; int preload_int(slice s, int len) pure asm "PLDIX"; +;; int preload_uint(slice s, int len) pure asm "PLDUX"; +;; (slice, slice) load_bits(slice s, int len) pure asm(s len -> 1 0) "LDSLICEX"; +;; slice preload_bits(slice s, int len) pure asm "PLDSLICEX"; +(slice, int) load_grams(slice s) pure asm( -> 1 0) "LDGRAMS"; +slice skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +slice first_bits(slice s, int len) pure asm "SDCUTFIRST"; +slice skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +slice slice_last(slice s, int len) pure asm "SDCUTLAST"; +(slice, cell) load_dict(slice s) pure asm( -> 1 0) "LDDICT"; +cell preload_dict(slice s) pure asm "PLDDICT"; +slice skip_dict(slice s) pure asm "SKIPDICT"; + +(slice, cell) load_maybe_ref(slice s) pure asm( -> 1 0) "LDOPTREF"; +cell preload_maybe_ref(slice s) pure asm "PLDOPTREF"; +builder store_maybe_ref(builder b, cell c) pure asm(c b) "STOPTREF"; + +int cell_depth(cell c) pure asm "CDEPTH"; + +int slice_refs(slice s) pure asm "SREFS"; +int slice_bits(slice s) pure asm "SBITS"; +(int, int) slice_bits_refs(slice s) pure asm "SBITREFS"; +int slice_empty?(slice s) pure asm "SEMPTY"; +int slice_data_empty?(slice s) pure asm "SDEMPTY"; +int slice_refs_empty?(slice s) pure asm "SREMPTY"; +int slice_depth(slice s) pure asm "SDEPTH"; + +int builder_refs(builder b) pure asm "BREFS"; +int builder_bits(builder b) pure asm "BBITS"; +int builder_depth(builder b) pure asm "BDEPTH"; + +builder begin_cell() pure asm "NEWC"; +cell end_cell(builder b) pure asm "ENDC"; + builder store_ref(builder b, cell c) pure asm(c b) "STREF"; +;; builder store_uint(builder b, int x, int len) pure asm(x b len) "STUX"; +;; builder store_int(builder b, int x, int len) pure asm(x b len) "STIX"; +builder store_slice(builder b, slice s) pure asm "STSLICER"; +builder store_grams(builder b, int x) pure asm "STGRAMS"; +builder store_dict(builder b, cell c) pure asm(c b) "STDICT"; + +(slice, slice) load_msg_addr(slice s) pure asm( -> 1 0) "LDMSGADDR"; +tuple parse_addr(slice s) pure asm "PARSEMSGADDR"; +(int, int) parse_std_addr(slice s) pure asm "REWRITESTDADDR"; +(int, slice) parse_var_addr(slice s) pure asm "REWRITEVARADDR"; + +cell idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +cell udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +cell idict_get_ref(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETREF"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGETREF"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; +cell new_dict() pure asm "NEWDICT"; +int dict_empty?(cell c) pure asm "DICTEMPTY"; + +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) pure asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTDEL"; + +cell config_param(int x) pure asm "CONFIGOPTPARAM"; +int cell_null?(cell c) pure asm "ISNULL"; + +() raw_reserve(int amount, int mode) asm "RAWRESERVE"; +() raw_reserve_extra(int amount, cell extra_amount, int mode) asm "RAWRESERVEX"; +() send_raw_message(cell msg, int mode) asm "SENDRAWMSG"; +() set_code(cell new_code) asm "SETCODE"; + +int random() asm "RANDU256"; +int rand(int range) asm "RAND"; +int get_seed() asm "RANDSEED"; +int set_seed() asm "SETRAND"; +() randomize(int x) asm "ADDRAND"; +() randomize_lt() asm "LTIME" "ADDRAND"; + +builder store_coins(builder b, int x) pure asm "STVARUINT16"; +(slice, int) load_coins(slice s) pure asm( -> 1 0) "LDVARUINT16"; + +int equal_slices (slice a, slice b) pure asm "SDEQ"; +int builder_null?(builder b) pure asm "ISNULL"; +builder store_builder(builder to, builder from) pure asm "STBR"; \ No newline at end of file diff --git a/crypto/func/auto-tests/legacy_tests/nominator-pool/stdlib.fc b/crypto/func/auto-tests/legacy_tests/nominator-pool/stdlib.fc index 0431d32de..9f1437212 100644 --- a/crypto/func/auto-tests/legacy_tests/nominator-pool/stdlib.fc +++ b/crypto/func/auto-tests/legacy_tests/nominator-pool/stdlib.fc @@ -1,211 +1,211 @@ ;; Standard library for funC ;; -forall X -> tuple cons(X head, tuple tail) asm "CONS"; -forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; -forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; -forall X -> X car(tuple list) asm "CAR"; -tuple cdr(tuple list) asm "CDR"; -tuple empty_tuple() asm "NIL"; -forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; -forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; -forall X -> [X] single(X x) asm "SINGLE"; -forall X -> X unsingle([X] t) asm "UNSINGLE"; -forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; -forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; -forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; -forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; -forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; -forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; -forall X -> X first(tuple t) asm "FIRST"; -forall X -> X second(tuple t) asm "SECOND"; -forall X -> X third(tuple t) asm "THIRD"; -forall X -> X fourth(tuple t) asm "3 INDEX"; -forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; -forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; -forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; -forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; -forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; -forall X -> X null() asm "PUSHNULL"; -forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; - -int now() asm "NOW"; -slice my_address() asm "MYADDR"; -[int, cell] get_balance() asm "BALANCE"; -int cur_lt() asm "LTIME"; -int block_lt() asm "BLOCKLT"; - -int cell_hash(cell c) asm "HASHCU"; -int slice_hash(slice s) asm "HASHSU"; -int string_hash(slice s) asm "SHA256U"; - -int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; -int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; - -(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; -(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; -(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; -(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; - -;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; - -() dump_stack() impure asm "DUMPSTK"; - -cell get_data() asm "c4 PUSH"; -() set_data(cell c) impure asm "c4 POP"; -cont get_c3() impure asm "c3 PUSH"; -() set_c3(cont c) impure asm "c3 POP"; -cont bless(slice s) impure asm "BLESS"; - -() accept_message() impure asm "ACCEPT"; -() set_gas_limit(int limit) impure asm "SETGASLIMIT"; -() commit() impure asm "COMMIT"; -() buy_gas(int gram) impure asm "BUYGAS"; - -int min(int x, int y) asm "MIN"; -int max(int x, int y) asm "MAX"; -(int, int) minmax(int x, int y) asm "MINMAX"; -int abs(int x) asm "ABS"; - -slice begin_parse(cell c) asm "CTOS"; -() end_parse(slice s) impure asm "ENDS"; -(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; -cell preload_ref(slice s) asm "PLDREF"; -;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; -;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; -;; int preload_int(slice s, int len) asm "PLDIX"; -;; int preload_uint(slice s, int len) asm "PLDUX"; -;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; -;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; -(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; -slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; -(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; -slice first_bits(slice s, int len) asm "SDCUTFIRST"; -slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -slice slice_last(slice s, int len) asm "SDCUTLAST"; -(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; -cell preload_dict(slice s) asm "PLDDICT"; -slice skip_dict(slice s) asm "SKIPDICT"; - -(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; -cell preload_maybe_ref(slice s) asm "PLDOPTREF"; -builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; - -int cell_depth(cell c) asm "CDEPTH"; - -int slice_refs(slice s) asm "SREFS"; -int slice_bits(slice s) asm "SBITS"; -(int, int) slice_bits_refs(slice s) asm "SBITREFS"; -int slice_empty?(slice s) asm "SEMPTY"; -int slice_data_empty?(slice s) asm "SDEMPTY"; -int slice_refs_empty?(slice s) asm "SREMPTY"; -int slice_depth(slice s) asm "SDEPTH"; - -int builder_refs(builder b) asm "BREFS"; -int builder_bits(builder b) asm "BBITS"; -int builder_depth(builder b) asm "BDEPTH"; - -builder begin_cell() asm "NEWC"; -cell end_cell(builder b) asm "ENDC"; -builder store_ref(builder b, cell c) asm(c b) "STREF"; -;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; -;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; -builder store_slice(builder b, slice s) asm "STSLICER"; -builder store_grams(builder b, int x) asm "STGRAMS"; -builder store_dict(builder b, cell c) asm(c b) "STDICT"; - -(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; -tuple parse_addr(slice s) asm "PARSEMSGADDR"; -(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; -(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; - -cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; -(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF"; -(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF"; -(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; -(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; -(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; -(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; -(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; -(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; -(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; -(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; -(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; -(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; -cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; -(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; -(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; -(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; -(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; -cell new_dict() asm "NEWDICT"; -int dict_empty?(cell c) asm "DICTEMPTY"; - -(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; -(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; -(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; - -cell config_param(int x) asm "CONFIGOPTPARAM"; -int cell_null?(cell c) asm "ISNULL"; - -() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; -() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; -() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; -() set_code(cell new_code) impure asm "SETCODE"; - -int random() impure asm "RANDU256"; -int rand(int range) impure asm "RAND"; -int get_seed() impure asm "RANDSEED"; -int set_seed() impure asm "SETRAND"; -() randomize(int x) impure asm "ADDRAND"; -() randomize_lt() impure asm "LTIME" "ADDRAND"; - -builder store_coins(builder b, int x) asm "STVARUINT16"; -(slice, int) load_coins(slice s) asm( -> 1 0) "LDVARUINT16"; \ No newline at end of file +forall X -> tuple cons(X head, tuple tail) pure asm "CONS"; +forall X -> (X, tuple) uncons(tuple list) pure asm "UNCONS"; +forall X -> (tuple, X) list_next(tuple list) pure asm( -> 1 0) "UNCONS"; +forall X -> X car(tuple list) pure asm "CAR"; +tuple cdr(tuple list) pure asm "CDR"; +tuple empty_tuple() pure asm "NIL"; +forall X -> tuple tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> [X] single(X x) pure asm "SINGLE"; +forall X -> X unsingle([X] t) pure asm "UNSINGLE"; +forall X, Y -> [X, Y] pair(X x, Y y) pure asm "PAIR"; +forall X, Y -> (X, Y) unpair([X, Y] t) pure asm "UNPAIR"; +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) pure asm "TRIPLE"; +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) pure asm "UNTRIPLE"; +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) pure asm "4 TUPLE"; +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) pure asm "4 UNTUPLE"; +forall X -> X first(tuple t) pure asm "FIRST"; +forall X -> X second(tuple t) pure asm "SECOND"; +forall X -> X third(tuple t) pure asm "THIRD"; +forall X -> X fourth(tuple t) pure asm "3 INDEX"; +forall X, Y -> X pair_first([X, Y] p) pure asm "FIRST"; +forall X, Y -> Y pair_second([X, Y] p) pure asm "SECOND"; +forall X, Y, Z -> X triple_first([X, Y, Z] p) pure asm "FIRST"; +forall X, Y, Z -> Y triple_second([X, Y, Z] p) pure asm "SECOND"; +forall X, Y, Z -> Z triple_third([X, Y, Z] p) pure asm "THIRD"; +forall X -> X null() pure asm "PUSHNULL"; +forall X -> (X, ()) ~impure_touch(X x) asm "NOP"; + +int now() pure asm "NOW"; +slice my_address() pure asm "MYADDR"; +[int, cell] get_balance() pure asm "BALANCE"; +int cur_lt() pure asm "LTIME"; +int block_lt() pure asm "BLOCKLT"; + +int cell_hash(cell c) pure asm "HASHCU"; +int slice_hash(slice s) pure asm "HASHSU"; +int string_hash(slice s) pure asm "SHA256U"; + +int check_signature(int hash, slice signature, int public_key) pure asm "CHKSIGNU"; +int check_data_signature(slice data, slice signature, int public_key) pure asm "CHKSIGNS"; + +(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE"; +(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE"; +(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) pure asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; + +;; () throw_if(int excno, int cond) asm "THROWARGIF"; + +() dump_stack() asm "DUMPSTK"; + +cell get_data() pure asm "c4 PUSH"; +() set_data(cell c) asm "c4 POP"; +cont get_c3() asm "c3 PUSH"; +() set_c3(cont c) asm "c3 POP"; +cont bless(slice s) asm "BLESS"; + +() accept_message() asm "ACCEPT"; +() set_gas_limit(int limit) asm "SETGASLIMIT"; +() commit() asm "COMMIT"; +() buy_gas(int gram) asm "BUYGAS"; + +int min(int x, int y) pure asm "MIN"; +int max(int x, int y) pure asm "MAX"; +(int, int) minmax(int x, int y) pure asm "MINMAX"; +int abs(int x) pure asm "ABS"; + +slice begin_parse(cell c) pure asm "CTOS"; +() end_parse(slice s) asm "ENDS"; +(slice, cell) load_ref(slice s) pure asm( -> 1 0) "LDREF"; +cell preload_ref(slice s) pure asm "PLDREF"; +;; (slice, int) ~load_int(slice s, int len) pure asm(s len -> 1 0) "LDIX"; +;; (slice, int) ~load_uint(slice s, int len) pure asm( -> 1 0) "LDUX"; +;; int preload_int(slice s, int len) pure asm "PLDIX"; +;; int preload_uint(slice s, int len) pure asm "PLDUX"; +;; (slice, slice) load_bits(slice s, int len) pure asm(s len -> 1 0) "LDSLICEX"; +;; slice preload_bits(slice s, int len) pure asm "PLDSLICEX"; +(slice, int) load_grams(slice s) pure asm( -> 1 0) "LDGRAMS"; +slice skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +slice first_bits(slice s, int len) pure asm "SDCUTFIRST"; +slice skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +slice slice_last(slice s, int len) pure asm "SDCUTLAST"; +(slice, cell) load_dict(slice s) pure asm( -> 1 0) "LDDICT"; +cell preload_dict(slice s) pure asm "PLDDICT"; +slice skip_dict(slice s) pure asm "SKIPDICT"; + +(slice, cell) load_maybe_ref(slice s) pure asm( -> 1 0) "LDOPTREF"; +cell preload_maybe_ref(slice s) pure asm "PLDOPTREF"; +builder store_maybe_ref(builder b, cell c) pure asm(c b) "STOPTREF"; + +int cell_depth(cell c) pure asm "CDEPTH"; + +int slice_refs(slice s) pure asm "SREFS"; +int slice_bits(slice s) pure asm "SBITS"; +(int, int) slice_bits_refs(slice s) pure asm "SBITREFS"; +int slice_empty?(slice s) pure asm "SEMPTY"; +int slice_data_empty?(slice s) pure asm "SDEMPTY"; +int slice_refs_empty?(slice s) pure asm "SREMPTY"; +int slice_depth(slice s) pure asm "SDEPTH"; + +int builder_refs(builder b) pure asm "BREFS"; +int builder_bits(builder b) pure asm "BBITS"; +int builder_depth(builder b) pure asm "BDEPTH"; + +builder begin_cell() pure asm "NEWC"; +cell end_cell(builder b) pure asm "ENDC"; +builder store_ref(builder b, cell c) pure asm(c b) "STREF"; +;; builder store_uint(builder b, int x, int len) pure asm(x b len) "STUX"; +;; builder store_int(builder b, int x, int len) pure asm(x b len) "STIX"; +builder store_slice(builder b, slice s) pure asm "STSLICER"; +builder store_grams(builder b, int x) pure asm "STGRAMS"; +builder store_dict(builder b, cell c) pure asm(c b) "STDICT"; + +(slice, slice) load_msg_addr(slice s) pure asm( -> 1 0) "LDMSGADDR"; +tuple parse_addr(slice s) pure asm "PARSEMSGADDR"; +(int, int) parse_std_addr(slice s) pure asm "REWRITESTDADDR"; +(int, slice) parse_var_addr(slice s) pure asm "REWRITEVARADDR"; + +cell idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +cell udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +cell idict_get_ref(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETREF"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGETREF"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; +cell new_dict() pure asm "NEWDICT"; +int dict_empty?(cell c) pure asm "DICTEMPTY"; + +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) pure asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTDEL"; + +cell config_param(int x) pure asm "CONFIGOPTPARAM"; +int cell_null?(cell c) pure asm "ISNULL"; + +() raw_reserve(int amount, int mode) asm "RAWRESERVE"; +() raw_reserve_extra(int amount, cell extra_amount, int mode) asm "RAWRESERVEX"; +() send_raw_message(cell msg, int mode) asm "SENDRAWMSG"; +() set_code(cell new_code) asm "SETCODE"; + +int random() asm "RANDU256"; +int rand(int range) asm "RAND"; +int get_seed() asm "RANDSEED"; +int set_seed() asm "SETRAND"; +() randomize(int x) asm "ADDRAND"; +() randomize_lt() asm "LTIME" "ADDRAND"; + +builder store_coins(builder b, int x) pure asm "STVARUINT16"; +(slice, int) load_coins(slice s) pure asm( -> 1 0) "LDVARUINT16"; \ No newline at end of file diff --git a/crypto/func/auto-tests/legacy_tests/storage/stdlib.fc b/crypto/func/auto-tests/legacy_tests/storage/stdlib.fc index 781fdcbcc..b55209d64 100644 --- a/crypto/func/auto-tests/legacy_tests/storage/stdlib.fc +++ b/crypto/func/auto-tests/legacy_tests/storage/stdlib.fc @@ -20,122 +20,122 @@ -} ;;; Adds an element to the beginning of lisp-style list. -forall X -> tuple cons(X head, tuple tail) asm "CONS"; +forall X -> tuple cons(X head, tuple tail) pure asm "CONS"; ;;; Extracts the head and the tail of lisp-style list. -forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; +forall X -> (X, tuple) uncons(tuple list) pure asm "UNCONS"; ;;; Extracts the tail and the head of lisp-style list. -forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; +forall X -> (tuple, X) list_next(tuple list) pure asm( -> 1 0) "UNCONS"; ;;; Returns the head of lisp-style list. -forall X -> X car(tuple list) asm "CAR"; +forall X -> X car(tuple list) pure asm "CAR"; ;;; Returns the tail of lisp-style list. -tuple cdr(tuple list) asm "CDR"; +tuple cdr(tuple list) pure asm "CDR"; ;;; Creates tuple with zero elements. -tuple empty_tuple() asm "NIL"; +tuple empty_tuple() pure asm "NIL"; ;;; Appends a value `x` to a `Tuple t = (x1, ..., xn)`, but only if the resulting `Tuple t' = (x1, ..., xn, x)` ;;; is of length at most 255. Otherwise throws a type check exception. -forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; -forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; +forall X -> tuple tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) pure asm "TPUSH"; ;;; Creates a tuple of length one with given argument as element. -forall X -> [X] single(X x) asm "SINGLE"; +forall X -> [X] single(X x) pure asm "SINGLE"; ;;; Unpacks a tuple of length one -forall X -> X unsingle([X] t) asm "UNSINGLE"; +forall X -> X unsingle([X] t) pure asm "UNSINGLE"; ;;; Creates a tuple of length two with given arguments as elements. -forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; +forall X, Y -> [X, Y] pair(X x, Y y) pure asm "PAIR"; ;;; Unpacks a tuple of length two -forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; +forall X, Y -> (X, Y) unpair([X, Y] t) pure asm "UNPAIR"; ;;; Creates a tuple of length three with given arguments as elements. -forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) pure asm "TRIPLE"; ;;; Unpacks a tuple of length three -forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) pure asm "UNTRIPLE"; ;;; Creates a tuple of length four with given arguments as elements. -forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) pure asm "4 TUPLE"; ;;; Unpacks a tuple of length four -forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) pure asm "4 UNTUPLE"; ;;; Returns the first element of a tuple (with unknown element types). -forall X -> X first(tuple t) asm "FIRST"; +forall X -> X first(tuple t) pure asm "FIRST"; ;;; Returns the second element of a tuple (with unknown element types). -forall X -> X second(tuple t) asm "SECOND"; +forall X -> X second(tuple t) pure asm "SECOND"; ;;; Returns the third element of a tuple (with unknown element types). -forall X -> X third(tuple t) asm "THIRD"; +forall X -> X third(tuple t) pure asm "THIRD"; ;;; Returns the fourth element of a tuple (with unknown element types). -forall X -> X fourth(tuple t) asm "3 INDEX"; +forall X -> X fourth(tuple t) pure asm "3 INDEX"; ;;; Returns the first element of a pair tuple. -forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; +forall X, Y -> X pair_first([X, Y] p) pure asm "FIRST"; ;;; Returns the second element of a pair tuple. -forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; +forall X, Y -> Y pair_second([X, Y] p) pure asm "SECOND"; ;;; Returns the first element of a triple tuple. -forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; +forall X, Y, Z -> X triple_first([X, Y, Z] p) pure asm "FIRST"; ;;; Returns the second element of a triple tuple. -forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; +forall X, Y, Z -> Y triple_second([X, Y, Z] p) pure asm "SECOND"; ;;; Returns the third element of a triple tuple. -forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; +forall X, Y, Z -> Z triple_third([X, Y, Z] p) pure asm "THIRD"; ;;; Push null element (casted to given type) ;;; By the TVM type `Null` FunC represents absence of a value of some atomic type. ;;; So `null` can actually have any atomic type. -forall X -> X null() asm "PUSHNULL"; +forall X -> X null() pure asm "PUSHNULL"; ;;; Moves a variable [x] to the top of the stack -forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; +forall X -> (X, ()) ~impure_touch(X x) asm "NOP"; ;;; Returns the current Unix time as an Integer -int now() asm "NOW"; +int now() pure asm "NOW"; ;;; Returns the internal address of the current smart contract as a Slice with a `MsgAddressInt`. ;;; If necessary, it can be parsed further using primitives such as [parse_std_addr]. -slice my_address() asm "MYADDR"; +slice my_address() pure asm "MYADDR"; ;;; Returns the balance of the smart contract as a tuple consisting of an int ;;; (balance in nanotoncoins) and a `cell` ;;; (a dictionary with 32-bit keys representing the balance of "extra currencies") ;;; at the start of Computation Phase. ;;; Note that RAW primitives such as [send_raw_message] do not update this field. -[int, cell] get_balance() asm "BALANCE"; +[int, cell] get_balance() pure asm "BALANCE"; ;;; Returns the logical time of the current transaction. -int cur_lt() asm "LTIME"; +int cur_lt() pure asm "LTIME"; ;;; Returns the starting logical time of the current block. -int block_lt() asm "BLOCKLT"; +int block_lt() pure asm "BLOCKLT"; ;;; Computes the representation hash of a `cell` [c] and returns it as a 256-bit unsigned integer `x`. ;;; Useful for signing and checking signatures of arbitrary entities represented by a tree of cells. -int cell_hash(cell c) asm "HASHCU"; +int cell_hash(cell c) pure asm "HASHCU"; ;;; Computes the hash of a `slice s` and returns it as a 256-bit unsigned integer `x`. ;;; The result is the same as if an ordinary cell containing only data and references from `s` had been created ;;; and its hash computed by [cell_hash]. -int slice_hash(slice s) asm "HASHSU"; +int slice_hash(slice s) pure asm "HASHSU"; ;;; Computes sha256 of the data bits of `slice` [s]. If the bit length of `s` is not divisible by eight, ;;; throws a cell underflow exception. The hash value is returned as a 256-bit unsigned integer `x`. -int string_hash(slice s) asm "SHA256U"; +int string_hash(slice s) pure asm "SHA256U"; {- # Signature checks @@ -148,14 +148,14 @@ int string_hash(slice s) asm "SHA256U"; ;;; Note that `CHKSIGNU` creates a 256-bit slice with the hash and calls `CHKSIGNS`. ;;; That is, if [hash] is computed as the hash of some data, these data are hashed twice, ;;; the second hashing occurring inside `CHKSIGNS`. -int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; +int check_signature(int hash, slice signature, int public_key) pure asm "CHKSIGNU"; ;;; Checks whether [signature] is a valid Ed25519-signature of the data portion of `slice data` using `public_key`, ;;; similarly to [check_signature]. ;;; If the bit length of [data] is not divisible by eight, throws a cell underflow exception. ;;; The verification of Ed25519 signatures is the standard one, ;;; with sha256 used to reduce [data] to the 256-bit number that is actually signed. -int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; +int check_data_signature(slice data, slice signature, int public_key) pure asm "CHKSIGNS"; {--- # Computation of boc size @@ -171,54 +171,54 @@ int check_data_signature(slice data, slice signature, int public_key) asm "CHKSI ;;; The total count of visited cells `x` cannot exceed non-negative [max_cells]; ;;; otherwise the computation is aborted before visiting the `(max_cells + 1)`-st cell and ;;; a zero flag is returned to indicate failure. If [c] is `null`, returns `x = y = z = 0`. -(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; +(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE"; ;;; Similar to [compute_data_size?], but accepting a `slice` [s] instead of a `cell`. ;;; The returned value of `x` does not take into account the cell that contains the `slice` [s] itself; ;;; however, the data bits and the cell references of [s] are accounted for in `y` and `z`. -(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; +(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE"; ;;; A non-quiet version of [compute_data_size?] that throws a cell overflow exception (`8`) on failure. -(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; ;;; A non-quiet version of [slice_compute_data_size?] that throws a cell overflow exception (8) on failure. -(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) pure asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; ;;; Throws an exception with exit_code excno if cond is not 0 (commented since implemented in compilator) -;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; +;; () throw_if(int excno, int cond) asm "THROWARGIF"; {-- # Debug primitives Only works for local TVM execution with debug level verbosity -} ;;; Dumps the stack (at most the top 255 values) and shows the total stack depth. -() dump_stack() impure asm "DUMPSTK"; +() dump_stack() asm "DUMPSTK"; {- # Persistent storage save and load -} ;;; Returns the persistent contract storage cell. It can be parsed or modified with slice and builder primitives later. -cell get_data() asm "c4 PUSH"; +cell get_data() pure asm "c4 PUSH"; ;;; Sets `cell` [c] as persistent contract data. You can update persistent contract storage with this primitive. -() set_data(cell c) impure asm "c4 POP"; +() set_data(cell c) asm "c4 POP"; {- # Continuation primitives -} ;;; Usually `c3` has a continuation initialized by the whole code of the contract. It is used for function calls. ;;; The primitive returns the current value of `c3`. -cont get_c3() impure asm "c3 PUSH"; +cont get_c3() asm "c3 PUSH"; ;;; Updates the current value of `c3`. Usually, it is used for updating smart contract code in run-time. ;;; Note that after execution of this primitive the current code ;;; (and the stack of recursive function calls) won't change, ;;; but any other function call will use a function from the new code. -() set_c3(cont c) impure asm "c3 POP"; +() set_c3(cont c) asm "c3 POP"; ;;; Transforms a `slice` [s] into a simple ordinary continuation `c`, with `c.code = s` and an empty stack and savelist. -cont bless(slice s) impure asm "BLESS"; +cont bless(slice s) asm "BLESS"; {--- # Gas related primitives @@ -230,37 +230,37 @@ cont bless(slice s) impure asm "BLESS"; ;;; This action is required to process external messages, which bring no value (hence no gas) with themselves. ;;; ;;; For more details check [accept_message effects](https://ton.org/docs/#/smart-contracts/accept). -() accept_message() impure asm "ACCEPT"; +() accept_message() asm "ACCEPT"; ;;; Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero. ;;; If the gas consumed so far (including the present instruction) exceeds the resulting value of `gl`, ;;; an (unhandled) out of gas exception is thrown before setting new gas limits. ;;; Notice that [set_gas_limit] with an argument `limit ≥ 2^63 − 1` is equivalent to [accept_message]. -() set_gas_limit(int limit) impure asm "SETGASLIMIT"; +() set_gas_limit(int limit) asm "SETGASLIMIT"; ;;; Commits the current state of registers `c4` (“persistent data”) and `c5` (“actions”) ;;; so that the current execution is considered “successful” with the saved values even if an exception ;;; in Computation Phase is thrown later. -() commit() impure asm "COMMIT"; +() commit() asm "COMMIT"; ;;; Not implemented -;;() buy_gas(int gram) impure asm "BUYGAS"; +;;() buy_gas(int gram) asm "BUYGAS"; ;;; Computes the amount of gas that can be bought for `amount` nanoTONs, ;;; and sets `gl` accordingly in the same way as [set_gas_limit]. -() buy_gas(int amount) impure asm "BUYGAS"; +() buy_gas(int amount) asm "BUYGAS"; ;;; Computes the minimum of two integers [x] and [y]. -int min(int x, int y) asm "MIN"; +int min(int x, int y) pure asm "MIN"; ;;; Computes the maximum of two integers [x] and [y]. -int max(int x, int y) asm "MAX"; +int max(int x, int y) pure asm "MAX"; ;;; Sorts two integers. -(int, int) minmax(int x, int y) asm "MINMAX"; +(int, int) minmax(int x, int y) pure asm "MINMAX"; ;;; Computes the absolute value of an integer [x]. -int abs(int x) asm "ABS"; +int abs(int x) pure asm "ABS"; {- # Slice primitives @@ -279,80 +279,80 @@ int abs(int x) asm "ABS"; ;;; Converts a `cell` [c] into a `slice`. Notice that [c] must be either an ordinary cell, ;;; or an exotic cell (see [TVM.pdf](https://ton-blockchain.github.io/docs/tvm.pdf), 3.1.2) ;;; which is automatically loaded to yield an ordinary cell `c'`, converted into a `slice` afterwards. -slice begin_parse(cell c) asm "CTOS"; +slice begin_parse(cell c) pure asm "CTOS"; ;;; Checks if [s] is empty. If not, throws an exception. -() end_parse(slice s) impure asm "ENDS"; +() end_parse(slice s) asm "ENDS"; ;;; Loads the first reference from the slice. -(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; +(slice, cell) load_ref(slice s) pure asm( -> 1 0) "LDREF"; ;;; Preloads the first reference from the slice. -cell preload_ref(slice s) asm "PLDREF"; +cell preload_ref(slice s) pure asm "PLDREF"; {- Functions below are commented because are implemented on compilator level for optimisation -} ;;; Loads a signed [len]-bit integer from a slice [s]. -;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; +;; (slice, int) ~load_int(slice s, int len) pure asm(s len -> 1 0) "LDIX"; ;;; Loads an unsigned [len]-bit integer from a slice [s]. -;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; +;; (slice, int) ~load_uint(slice s, int len) pure asm( -> 1 0) "LDUX"; ;;; Preloads a signed [len]-bit integer from a slice [s]. -;; int preload_int(slice s, int len) asm "PLDIX"; +;; int preload_int(slice s, int len) pure asm "PLDIX"; ;;; Preloads an unsigned [len]-bit integer from a slice [s]. -;; int preload_uint(slice s, int len) asm "PLDUX"; +;; int preload_uint(slice s, int len) pure asm "PLDUX"; ;;; Loads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`. -;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; +;; (slice, slice) load_bits(slice s, int len) pure asm(s len -> 1 0) "LDSLICEX"; ;;; Preloads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`. -;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; +;; slice preload_bits(slice s, int len) pure asm "PLDSLICEX"; ;;; Loads serialized amount of TonCoins (any unsigned integer up to `2^128 - 1`). -(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; -(slice, int) load_coins(slice s) asm( -> 1 0) "LDGRAMS"; +(slice, int) load_grams(slice s) pure asm( -> 1 0) "LDGRAMS"; +(slice, int) load_coins(slice s) pure asm( -> 1 0) "LDGRAMS"; ;;; Returns all but the first `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; -(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; +slice skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; ;;; Returns the first `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice first_bits(slice s, int len) asm "SDCUTFIRST"; +slice first_bits(slice s, int len) pure asm "SDCUTFIRST"; ;;; Returns all but the last `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; +slice skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; ;;; Returns the last `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice slice_last(slice s, int len) asm "SDCUTLAST"; +slice slice_last(slice s, int len) pure asm "SDCUTLAST"; ;;; Loads a dictionary `D` (HashMapE) from `slice` [s]. ;;; (returns `null` if `nothing` constructor is used). -(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; +(slice, cell) load_dict(slice s) pure asm( -> 1 0) "LDDICT"; ;;; Preloads a dictionary `D` from `slice` [s]. -cell preload_dict(slice s) asm "PLDDICT"; +cell preload_dict(slice s) pure asm "PLDDICT"; ;;; Loads a dictionary as [load_dict], but returns only the remainder of the slice. -slice skip_dict(slice s) asm "SKIPDICT"; +slice skip_dict(slice s) pure asm "SKIPDICT"; ;;; Loads (Maybe ^Cell) from `slice` [s]. ;;; In other words loads 1 bit and if it is true ;;; loads first ref and return it with slice remainder ;;; otherwise returns `null` and slice remainder -(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; +(slice, cell) load_maybe_ref(slice s) pure asm( -> 1 0) "LDOPTREF"; ;;; Preloads (Maybe ^Cell) from `slice` [s]. -cell preload_maybe_ref(slice s) asm "PLDOPTREF"; +cell preload_maybe_ref(slice s) pure asm "PLDOPTREF"; ;;; Returns the depth of `cell` [c]. ;;; If [c] has no references, then return `0`; ;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [c]. ;;; If [c] is a `null` instead of a cell, returns zero. -int cell_depth(cell c) asm "CDEPTH"; +int cell_depth(cell c) pure asm "CDEPTH"; {- @@ -360,42 +360,42 @@ int cell_depth(cell c) asm "CDEPTH"; -} ;;; Returns the number of references in `slice` [s]. -int slice_refs(slice s) asm "SREFS"; +int slice_refs(slice s) pure asm "SREFS"; ;;; Returns the number of data bits in `slice` [s]. -int slice_bits(slice s) asm "SBITS"; +int slice_bits(slice s) pure asm "SBITS"; ;;; Returns both the number of data bits and the number of references in `slice` [s]. -(int, int) slice_bits_refs(slice s) asm "SBITREFS"; +(int, int) slice_bits_refs(slice s) pure asm "SBITREFS"; ;;; Checks whether a `slice` [s] is empty (i.e., contains no bits of data and no cell references). -int slice_empty?(slice s) asm "SEMPTY"; +int slice_empty?(slice s) pure asm "SEMPTY"; ;;; Checks whether `slice` [s] has no bits of data. -int slice_data_empty?(slice s) asm "SDEMPTY"; +int slice_data_empty?(slice s) pure asm "SDEMPTY"; ;;; Checks whether `slice` [s] has no references. -int slice_refs_empty?(slice s) asm "SREMPTY"; +int slice_refs_empty?(slice s) pure asm "SREMPTY"; ;;; Returns the depth of `slice` [s]. ;;; If [s] has no references, then returns `0`; ;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [s]. -int slice_depth(slice s) asm "SDEPTH"; +int slice_depth(slice s) pure asm "SDEPTH"; {- # Builder size primitives -} ;;; Returns the number of cell references already stored in `builder` [b] -int builder_refs(builder b) asm "BREFS"; +int builder_refs(builder b) pure asm "BREFS"; ;;; Returns the number of data bits already stored in `builder` [b]. -int builder_bits(builder b) asm "BBITS"; +int builder_bits(builder b) pure asm "BBITS"; ;;; Returns the depth of `builder` [b]. ;;; If no cell references are stored in [b], then returns 0; ;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [b]. -int builder_depth(builder b) asm "BDEPTH"; +int builder_depth(builder b) pure asm "BDEPTH"; {- # Builder primitives @@ -408,23 +408,23 @@ int builder_depth(builder b) asm "BDEPTH"; -} ;;; Creates a new empty `builder`. -builder begin_cell() asm "NEWC"; +builder begin_cell() pure asm "NEWC"; ;;; Converts a `builder` into an ordinary `cell`. -cell end_cell(builder b) asm "ENDC"; +cell end_cell(builder b) pure asm "ENDC"; ;;; Stores a reference to `cell` [c] into `builder` [b]. -builder store_ref(builder b, cell c) asm(c b) "STREF"; +builder store_ref(builder b, cell c) pure asm(c b) "STREF"; ;;; Stores an unsigned [len]-bit integer `x` into `b` for `0 ≤ len ≤ 256`. -;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; +;; builder store_uint(builder b, int x, int len) pure asm(x b len) "STUX"; ;;; Stores a signed [len]-bit integer `x` into `b` for` 0 ≤ len ≤ 257`. -;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; +;; builder store_int(builder b, int x, int len) pure asm(x b len) "STIX"; ;;; Stores `slice` [s] into `builder` [b] -builder store_slice(builder b, slice s) asm "STSLICER"; +builder store_slice(builder b, slice s) pure asm "STSLICER"; ;;; Stores (serializes) an integer [x] in the range `0..2^128 − 1` into `builder` [b]. ;;; The serialization of [x] consists of a 4-bit unsigned big-endian integer `l`, @@ -433,17 +433,17 @@ builder store_slice(builder b, slice s) asm "STSLICER"; ;;; If [x] does not belong to the supported range, a range check exception is thrown. ;;; ;;; Store amounts of TonCoins to the builder as VarUInteger 16 -builder store_grams(builder b, int x) asm "STGRAMS"; -builder store_coins(builder b, int x) asm "STGRAMS"; +builder store_grams(builder b, int x) pure asm "STGRAMS"; +builder store_coins(builder b, int x) pure asm "STGRAMS"; ;;; Stores dictionary `D` represented by `cell` [c] or `null` into `builder` [b]. ;;; In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise. -builder store_dict(builder b, cell c) asm(c b) "STDICT"; +builder store_dict(builder b, cell c) pure asm(c b) "STDICT"; ;;; Stores (Maybe ^Cell) to builder: ;;; if cell is null store 1 zero bit ;;; otherwise store 1 true bit and ref to cell -builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; +builder store_maybe_ref(builder b, cell c) pure asm(c b) "STOPTREF"; {- @@ -485,22 +485,22 @@ builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; ;;; 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. -(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; +(slice, slice) load_msg_addr(slice s) pure 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. -tuple parse_addr(slice s) asm "PARSEMSGADDR"; +tuple parse_addr(slice s) pure asm "PARSEMSGADDR"; ;;; Parses slice [s] containing a valid `MsgAddressInt` (usually a `msg_addr_std`), ;;; applies rewriting from the anycast (if present) to the same-length prefix of the address, ;;; and returns both the workchain and the 256-bit address as integers. ;;; If the address is not 256-bit, or if [s] is not a valid serialization of `MsgAddressInt`, ;;; throws a cell deserialization exception. -(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; +(int, int) parse_std_addr(slice s) pure asm "REWRITESTDADDR"; ;;; A variant of [parse_std_addr] that returns the (rewritten) address as a slice [s], ;;; even if it is not exactly 256 bit long (represented by a `msg_addr_var`). -(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; +(int, slice) parse_var_addr(slice s) pure asm "REWRITEVARADDR"; {- # Dictionary primitives @@ -509,117 +509,117 @@ tuple parse_addr(slice s) asm "PARSEMSGADDR"; ;;; Sets the value associated with [key_len]-bit key signed index in dictionary [dict] to [value] (cell), ;;; and returns the resulting dictionary. -cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; +cell idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; ;;; Sets the value associated with [key_len]-bit key unsigned index in dictionary [dict] to [value] (cell), ;;; and returns the resulting dictionary. -cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; - -cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; -(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; -(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; -(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; -(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; -(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; -(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; -(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; -(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; -(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; -(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; -(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; -(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; -cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; -(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; -(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; -(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; -(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; +cell udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; + +cell idict_get_ref(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; ;;; Creates an empty dictionary, which is actually a null value. Equivalent to PUSHNULL -cell new_dict() asm "NEWDICT"; +cell new_dict() pure asm "NEWDICT"; ;;; Checks whether a dictionary is empty. Equivalent to cell_null?. -int dict_empty?(cell c) asm "DICTEMPTY"; +int dict_empty?(cell c) pure asm "DICTEMPTY"; {- Prefix dictionary primitives -} -(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; -(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; -(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) pure asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTDEL"; ;;; Returns the value of the global configuration parameter with integer index `i` as a `cell` or `null` value. -cell config_param(int x) asm "CONFIGOPTPARAM"; +cell config_param(int x) pure asm "CONFIGOPTPARAM"; ;;; Checks whether c is a null. Note, that FunC also has polymorphic null? built-in. -int cell_null?(cell c) asm "ISNULL"; +int cell_null?(cell c) pure asm "ISNULL"; ;;; Creates an output action which would reserve exactly amount nanotoncoins (if mode = 0), at most amount nanotoncoins (if mode = 2), or all but amount nanotoncoins (if mode = 1 or mode = 3), from the remaining balance of the account. It is roughly equivalent to creating an outbound message carrying amount nanotoncoins (or b − amount nanotoncoins, where b is the remaining balance) to oneself, so that the subsequent output actions would not be able to spend more money than the remainder. Bit +2 in mode means that the external action does not fail if the specified amount cannot be reserved; instead, all remaining balance is reserved. Bit +8 in mode means `amount <- -amount` before performing any further actions. Bit +4 in mode means that amount is increased by the original balance of the current account (before the compute phase), including all extra currencies, before performing any other checks and actions. Currently, amount must be a non-negative integer, and mode must be in the range 0..15. -() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; +() raw_reserve(int amount, int mode) asm "RAWRESERVE"; ;;; Similar to raw_reserve, but also accepts a dictionary extra_amount (represented by a cell or null) with extra currencies. In this way currencies other than TonCoin can be reserved. -() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; +() raw_reserve_extra(int amount, cell extra_amount, int mode) asm "RAWRESERVEX"; ;;; Sends a raw message contained in msg, which should contain a correctly serialized object Message X, with the only exception that the source address is allowed to have dummy value addr_none (to be automatically replaced with the current smart contract address), and ihr_fee, fwd_fee, created_lt and created_at fields can have arbitrary values (to be rewritten with correct values during the action phase of the current transaction). Integer parameter mode contains the flags. Currently mode = 0 is used for ordinary messages; mode = 128 is used for messages that are to carry all the remaining balance of the current smart contract (instead of the value originally indicated in the message); mode = 64 is used for messages that carry all the remaining value of the inbound message in addition to the value initially indicated in the new message (if bit 0 is not set, the gas fees are deducted from this amount); mode' = mode + 1 means that the sender wants to pay transfer fees separately; mode' = mode + 2 means that any errors arising while processing this message during the action phase should be ignored. Finally, mode' = mode + 32 means that the current account must be destroyed if its resulting balance is zero. This flag is usually employed together with +128. -() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; +() send_raw_message(cell msg, int mode) asm "SENDRAWMSG"; ;;; Creates an output action that would change this smart contract code to that given by cell new_code. Notice that this change will take effect only after the successful termination of the current run of the smart contract -() set_code(cell new_code) impure asm "SETCODE"; +() set_code(cell new_code) asm "SETCODE"; ;;; Generates a new pseudo-random unsigned 256-bit integer x. The algorithm is as follows: if r is the old value of the random seed, considered as a 32-byte array (by constructing the big-endian representation of an unsigned 256-bit integer), then its sha512(r) is computed; the first 32 bytes of this hash are stored as the new value r' of the random seed, and the remaining 32 bytes are returned as the next random value x. -int random() impure asm "RANDU256"; +int random() asm "RANDU256"; ;;; Generates a new pseudo-random integer z in the range 0..range−1 (or range..−1, if range < 0). More precisely, an unsigned random value x is generated as in random; then z := x * range / 2^256 is computed. -int rand(int range) impure asm "RAND"; +int rand(int range) asm "RAND"; ;;; Returns the current random seed as an unsigned 256-bit Integer. -int get_seed() impure asm "RANDSEED"; +int get_seed() asm "RANDSEED"; ;;; Sets the random seed to unsigned 256-bit seed. -() set_seed(int) impure asm "SETRAND"; +() set_seed(int) asm "SETRAND"; ;;; Mixes unsigned 256-bit integer x into the random seed r by setting the random seed to sha256 of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r, and the second with the big-endian representation of x. -() randomize(int x) impure asm "ADDRAND"; +() randomize(int x) asm "ADDRAND"; ;;; Equivalent to randomize(cur_lt());. -() randomize_lt() impure asm "LTIME" "ADDRAND"; +() randomize_lt() asm "LTIME" "ADDRAND"; ;;; Checks whether the data parts of two slices coinside -int equal_slice_bits (slice a, slice b) asm "SDEQ"; +int equal_slice_bits (slice a, slice b) pure asm "SDEQ"; ;;; Concatenates two builders -builder store_builder(builder to, builder from) asm "STBR"; +builder store_builder(builder to, builder from) pure asm "STBR"; diff --git a/crypto/func/auto-tests/legacy_tests/tele-nft-item/stdlib.fc b/crypto/func/auto-tests/legacy_tests/tele-nft-item/stdlib.fc index 45d01f322..f93ebf792 100644 --- a/crypto/func/auto-tests/legacy_tests/tele-nft-item/stdlib.fc +++ b/crypto/func/auto-tests/legacy_tests/tele-nft-item/stdlib.fc @@ -1,208 +1,208 @@ ;; Standard library for funC ;; -forall X -> tuple cons(X head, tuple tail) asm "CONS"; -forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; -forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; -forall X -> X car(tuple list) asm "CAR"; -tuple cdr(tuple list) asm "CDR"; -tuple empty_tuple() asm "NIL"; -forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; -forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; -forall X -> [X] single(X x) asm "SINGLE"; -forall X -> X unsingle([X] t) asm "UNSINGLE"; -forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; -forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; -forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; -forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; -forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; -forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; -forall X -> X first(tuple t) asm "FIRST"; -forall X -> X second(tuple t) asm "SECOND"; -forall X -> X third(tuple t) asm "THIRD"; -forall X -> X fourth(tuple t) asm "3 INDEX"; -forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; -forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; -forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; -forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; -forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; -forall X -> X null() asm "PUSHNULL"; -forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; - -int now() asm "NOW"; -slice my_address() asm "MYADDR"; -[int, cell] get_balance() asm "BALANCE"; -int cur_lt() asm "LTIME"; -int block_lt() asm "BLOCKLT"; - -int cell_hash(cell c) asm "HASHCU"; -int slice_hash(slice s) asm "HASHSU"; -int string_hash(slice s) asm "SHA256U"; - -int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; -int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; - -(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; -(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; -(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; -(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; - -;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; - -() dump_stack() impure asm "DUMPSTK"; - -cell get_data() asm "c4 PUSH"; -() set_data(cell c) impure asm "c4 POP"; -cont get_c3() impure asm "c3 PUSH"; -() set_c3(cont c) impure asm "c3 POP"; -cont bless(slice s) impure asm "BLESS"; - -() accept_message() impure asm "ACCEPT"; -() set_gas_limit(int limit) impure asm "SETGASLIMIT"; -() commit() impure asm "COMMIT"; -() buy_gas(int gram) impure asm "BUYGAS"; - -int min(int x, int y) asm "MIN"; -int max(int x, int y) asm "MAX"; -(int, int) minmax(int x, int y) asm "MINMAX"; -int abs(int x) asm "ABS"; - -slice begin_parse(cell c) asm "CTOS"; -() end_parse(slice s) impure asm "ENDS"; -(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; -cell preload_ref(slice s) asm "PLDREF"; -;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; -;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; -;; int preload_int(slice s, int len) asm "PLDIX"; -;; int preload_uint(slice s, int len) asm "PLDUX"; -;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; -;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; -(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; -slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; -(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; -slice first_bits(slice s, int len) asm "SDCUTFIRST"; -slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -slice slice_last(slice s, int len) asm "SDCUTLAST"; -(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; -cell preload_dict(slice s) asm "PLDDICT"; -slice skip_dict(slice s) asm "SKIPDICT"; - -(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; -cell preload_maybe_ref(slice s) asm "PLDOPTREF"; -builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; - -int cell_depth(cell c) asm "CDEPTH"; - -int slice_refs(slice s) asm "SREFS"; -int slice_bits(slice s) asm "SBITS"; -(int, int) slice_bits_refs(slice s) asm "SBITREFS"; -int slice_empty?(slice s) asm "SEMPTY"; -int slice_data_empty?(slice s) asm "SDEMPTY"; -int slice_refs_empty?(slice s) asm "SREMPTY"; -int slice_depth(slice s) asm "SDEPTH"; - -int builder_refs(builder b) asm "BREFS"; -int builder_bits(builder b) asm "BBITS"; -int builder_depth(builder b) asm "BDEPTH"; - -builder begin_cell() asm "NEWC"; -cell end_cell(builder b) asm "ENDC"; -builder store_ref(builder b, cell c) asm(c b) "STREF"; -;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; -;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; -builder store_slice(builder b, slice s) asm "STSLICER"; -builder store_grams(builder b, int x) asm "STGRAMS"; -builder store_dict(builder b, cell c) asm(c b) "STDICT"; - -(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; -tuple parse_addr(slice s) asm "PARSEMSGADDR"; -(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; -(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; - -cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; -(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; -(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; -(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; -(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; -(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; -(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; -(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; -(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; -(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; -(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; -(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; -(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; -cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; -(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; -(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; -(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; -(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; -cell new_dict() asm "NEWDICT"; -int dict_empty?(cell c) asm "DICTEMPTY"; - -(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; -(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; -(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; - -cell config_param(int x) asm "CONFIGOPTPARAM"; -int cell_null?(cell c) asm "ISNULL"; - -() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; -() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; -() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; -() set_code(cell new_code) impure asm "SETCODE"; - -int random() impure asm "RANDU256"; -int rand(int range) impure asm "RAND"; -int get_seed() impure asm "RANDSEED"; -int set_seed() impure asm "SETRAND"; -() randomize(int x) impure asm "ADDRAND"; -() randomize_lt() impure asm "LTIME" "ADDRAND"; +forall X -> tuple cons(X head, tuple tail) pure asm "CONS"; +forall X -> (X, tuple) uncons(tuple list) pure asm "UNCONS"; +forall X -> (tuple, X) list_next(tuple list) pure asm( -> 1 0) "UNCONS"; +forall X -> X car(tuple list) pure asm "CAR"; +tuple cdr(tuple list) pure asm "CDR"; +tuple empty_tuple() pure asm "NIL"; +forall X -> tuple tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> [X] single(X x) pure asm "SINGLE"; +forall X -> X unsingle([X] t) pure asm "UNSINGLE"; +forall X, Y -> [X, Y] pair(X x, Y y) pure asm "PAIR"; +forall X, Y -> (X, Y) unpair([X, Y] t) pure asm "UNPAIR"; +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) pure asm "TRIPLE"; +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) pure asm "UNTRIPLE"; +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) pure asm "4 TUPLE"; +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) pure asm "4 UNTUPLE"; +forall X -> X first(tuple t) pure asm "FIRST"; +forall X -> X second(tuple t) pure asm "SECOND"; +forall X -> X third(tuple t) pure asm "THIRD"; +forall X -> X fourth(tuple t) pure asm "3 INDEX"; +forall X, Y -> X pair_first([X, Y] p) pure asm "FIRST"; +forall X, Y -> Y pair_second([X, Y] p) pure asm "SECOND"; +forall X, Y, Z -> X triple_first([X, Y, Z] p) pure asm "FIRST"; +forall X, Y, Z -> Y triple_second([X, Y, Z] p) pure asm "SECOND"; +forall X, Y, Z -> Z triple_third([X, Y, Z] p) pure asm "THIRD"; +forall X -> X null() pure asm "PUSHNULL"; +forall X -> (X, ()) ~impure_touch(X x) asm "NOP"; + +int now() pure asm "NOW"; +slice my_address() pure asm "MYADDR"; +[int, cell] get_balance() pure asm "BALANCE"; +int cur_lt() pure asm "LTIME"; +int block_lt() pure asm "BLOCKLT"; + +int cell_hash(cell c) pure asm "HASHCU"; +int slice_hash(slice s) pure asm "HASHSU"; +int string_hash(slice s) pure asm "SHA256U"; + +int check_signature(int hash, slice signature, int public_key) pure asm "CHKSIGNU"; +int check_data_signature(slice data, slice signature, int public_key) pure asm "CHKSIGNS"; + +(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE"; +(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE"; +(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) pure asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; + +;; () throw_if(int excno, int cond) asm "THROWARGIF"; + +() dump_stack() asm "DUMPSTK"; + +cell get_data() pure asm "c4 PUSH"; +() set_data(cell c) asm "c4 POP"; +cont get_c3() asm "c3 PUSH"; +() set_c3(cont c) asm "c3 POP"; +cont bless(slice s) asm "BLESS"; + +() accept_message() asm "ACCEPT"; +() set_gas_limit(int limit) asm "SETGASLIMIT"; +() commit() asm "COMMIT"; +() buy_gas(int gram) asm "BUYGAS"; + +int min(int x, int y) pure asm "MIN"; +int max(int x, int y) pure asm "MAX"; +(int, int) minmax(int x, int y) pure asm "MINMAX"; +int abs(int x) pure asm "ABS"; + +slice begin_parse(cell c) pure asm "CTOS"; +() end_parse(slice s) asm "ENDS"; +(slice, cell) load_ref(slice s) pure asm( -> 1 0) "LDREF"; +cell preload_ref(slice s) pure asm "PLDREF"; +;; (slice, int) ~load_int(slice s, int len) pure asm(s len -> 1 0) "LDIX"; +;; (slice, int) ~load_uint(slice s, int len) pure asm( -> 1 0) "LDUX"; +;; int preload_int(slice s, int len) pure asm "PLDIX"; +;; int preload_uint(slice s, int len) pure asm "PLDUX"; +;; (slice, slice) load_bits(slice s, int len) pure asm(s len -> 1 0) "LDSLICEX"; +;; slice preload_bits(slice s, int len) pure asm "PLDSLICEX"; +(slice, int) load_grams(slice s) pure asm( -> 1 0) "LDGRAMS"; +slice skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +slice first_bits(slice s, int len) pure asm "SDCUTFIRST"; +slice skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +slice slice_last(slice s, int len) pure asm "SDCUTLAST"; +(slice, cell) load_dict(slice s) pure asm( -> 1 0) "LDDICT"; +cell preload_dict(slice s) pure asm "PLDDICT"; +slice skip_dict(slice s) pure asm "SKIPDICT"; + +(slice, cell) load_maybe_ref(slice s) pure asm( -> 1 0) "LDOPTREF"; +cell preload_maybe_ref(slice s) pure asm "PLDOPTREF"; +builder store_maybe_ref(builder b, cell c) pure asm(c b) "STOPTREF"; + +int cell_depth(cell c) pure asm "CDEPTH"; + +int slice_refs(slice s) pure asm "SREFS"; +int slice_bits(slice s) pure asm "SBITS"; +(int, int) slice_bits_refs(slice s) pure asm "SBITREFS"; +int slice_empty?(slice s) pure asm "SEMPTY"; +int slice_data_empty?(slice s) pure asm "SDEMPTY"; +int slice_refs_empty?(slice s) pure asm "SREMPTY"; +int slice_depth(slice s) pure asm "SDEPTH"; + +int builder_refs(builder b) pure asm "BREFS"; +int builder_bits(builder b) pure asm "BBITS"; +int builder_depth(builder b) pure asm "BDEPTH"; + +builder begin_cell() pure asm "NEWC"; +cell end_cell(builder b) pure asm "ENDC"; +builder store_ref(builder b, cell c) pure asm(c b) "STREF"; +;; builder store_uint(builder b, int x, int len) pure asm(x b len) "STUX"; +;; builder store_int(builder b, int x, int len) pure asm(x b len) "STIX"; +builder store_slice(builder b, slice s) pure asm "STSLICER"; +builder store_grams(builder b, int x) pure asm "STGRAMS"; +builder store_dict(builder b, cell c) pure asm(c b) "STDICT"; + +(slice, slice) load_msg_addr(slice s) pure asm( -> 1 0) "LDMSGADDR"; +tuple parse_addr(slice s) pure asm "PARSEMSGADDR"; +(int, int) parse_std_addr(slice s) pure asm "REWRITESTDADDR"; +(int, slice) parse_var_addr(slice s) pure asm "REWRITEVARADDR"; + +cell idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +cell udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +cell idict_get_ref(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; +cell new_dict() pure asm "NEWDICT"; +int dict_empty?(cell c) pure asm "DICTEMPTY"; + +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) pure asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTDEL"; + +cell config_param(int x) pure asm "CONFIGOPTPARAM"; +int cell_null?(cell c) pure asm "ISNULL"; + +() raw_reserve(int amount, int mode) asm "RAWRESERVE"; +() raw_reserve_extra(int amount, cell extra_amount, int mode) asm "RAWRESERVEX"; +() send_raw_message(cell msg, int mode) asm "SENDRAWMSG"; +() set_code(cell new_code) asm "SETCODE"; + +int random() asm "RANDU256"; +int rand(int range) asm "RAND"; +int get_seed() asm "RANDSEED"; +int set_seed() asm "SETRAND"; +() randomize(int x) asm "ADDRAND"; +() randomize_lt() asm "LTIME" "ADDRAND"; diff --git a/crypto/func/auto-tests/legacy_tests/whales-nominators/modules/utils.fc b/crypto/func/auto-tests/legacy_tests/whales-nominators/modules/utils.fc index 50e4e57c1..551a89788 100644 --- a/crypto/func/auto-tests/legacy_tests/whales-nominators/modules/utils.fc +++ b/crypto/func/auto-tests/legacy_tests/whales-nominators/modules/utils.fc @@ -21,7 +21,7 @@ int parse_work_addr(slice cs) { ;; Custom Commands ;; -(int) equal_slices (slice s1, slice s2) asm "SDEQ"; +(int) equal_slices (slice s1, slice s2) pure asm "SDEQ"; builder store_builder(builder to, builder what) asm(what to) "STB"; builder store_builder_ref(builder to, builder what) asm(what to) "STBREFR"; (slice, cell) load_maybe_cell(slice s) asm( -> 1 0) "LDDICT"; diff --git a/crypto/func/auto-tests/legacy_tests/whales-nominators/nominators.fc b/crypto/func/auto-tests/legacy_tests/whales-nominators/nominators.fc index 8dee4e5ec..198bb6d24 100644 --- a/crypto/func/auto-tests/legacy_tests/whales-nominators/nominators.fc +++ b/crypto/func/auto-tests/legacy_tests/whales-nominators/nominators.fc @@ -8,8 +8,8 @@ #include "modules/store-validator.fc"; #include "modules/model.fc"; #include "modules/op-controller.fc"; -#include "modules/op-owner.fc"; #include "modules/op-common.fc"; +#include "modules/op-owner.fc"; #include "modules/op-nominators.fc"; #include "modules/get.fc"; diff --git a/crypto/func/auto-tests/legacy_tests/whales-nominators/stdlib.fc b/crypto/func/auto-tests/legacy_tests/whales-nominators/stdlib.fc index dcc5f423c..18be14037 100644 --- a/crypto/func/auto-tests/legacy_tests/whales-nominators/stdlib.fc +++ b/crypto/func/auto-tests/legacy_tests/whales-nominators/stdlib.fc @@ -1,212 +1,212 @@ ;; Standard library for funC ;; -forall X -> tuple cons(X head, tuple tail) asm "CONS"; -forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; -forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; -forall X -> X car(tuple list) asm "CAR"; -tuple cdr(tuple list) asm "CDR"; -tuple empty_tuple() asm "NIL"; -forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; -forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; -forall X -> [X] single(X x) asm "SINGLE"; -forall X -> X unsingle([X] t) asm "UNSINGLE"; -forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; -forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; -forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; -forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; -forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; -forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; -forall X -> X first(tuple t) asm "FIRST"; -forall X -> X second(tuple t) asm "SECOND"; -forall X -> X third(tuple t) asm "THIRD"; -forall X -> X fourth(tuple t) asm "3 INDEX"; -forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; -forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; -forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; -forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; -forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; -forall X -> X null() asm "PUSHNULL"; -forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; - -int now() asm "NOW"; -slice my_address() asm "MYADDR"; -[int, cell] get_balance() asm "BALANCE"; -int cur_lt() asm "LTIME"; -int block_lt() asm "BLOCKLT"; - -int cell_hash(cell c) asm "HASHCU"; -int slice_hash(slice s) asm "HASHSU"; -int string_hash(slice s) asm "SHA256U"; - -int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; -int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; - -(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; -(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; -(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; -(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; - -;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; - -() dump_stack() impure asm "DUMPSTK"; - -cell get_data() asm "c4 PUSH"; -() set_data(cell c) impure asm "c4 POP"; -cont get_c3() impure asm "c3 PUSH"; -() set_c3(cont c) impure asm "c3 POP"; -cont bless(slice s) impure asm "BLESS"; - -() accept_message() impure asm "ACCEPT"; -() set_gas_limit(int limit) impure asm "SETGASLIMIT"; -() commit() impure asm "COMMIT"; -() buy_gas(int gram) impure asm "BUYGAS"; - -int min(int x, int y) asm "MIN"; -int max(int x, int y) asm "MAX"; -(int, int) minmax(int x, int y) asm "MINMAX"; -int abs(int x) asm "ABS"; - -slice begin_parse(cell c) asm "CTOS"; -() end_parse(slice s) impure asm "ENDS"; -(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; -cell preload_ref(slice s) asm "PLDREF"; -;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; -;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; -;; int preload_int(slice s, int len) asm "PLDIX"; -;; int preload_uint(slice s, int len) asm "PLDUX"; -;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; -;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; -(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; -slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; -(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; -slice first_bits(slice s, int len) asm "SDCUTFIRST"; -slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -slice slice_last(slice s, int len) asm "SDCUTLAST"; -(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; -cell preload_dict(slice s) asm "PLDDICT"; -slice skip_dict(slice s) asm "SKIPDICT"; - -(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; -cell preload_maybe_ref(slice s) asm "PLDOPTREF"; -builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; - -int cell_depth(cell c) asm "CDEPTH"; - -int slice_refs(slice s) asm "SREFS"; -int slice_bits(slice s) asm "SBITS"; -(int, int) slice_bits_refs(slice s) asm "SBITREFS"; -int slice_empty?(slice s) asm "SEMPTY"; -int slice_data_empty?(slice s) asm "SDEMPTY"; -int slice_refs_empty?(slice s) asm "SREMPTY"; -int slice_depth(slice s) asm "SDEPTH"; - -int builder_refs(builder b) asm "BREFS"; -int builder_bits(builder b) asm "BBITS"; -int builder_depth(builder b) asm "BDEPTH"; - -builder begin_cell() asm "NEWC"; -cell end_cell(builder b) asm "ENDC"; - builder store_ref(builder b, cell c) asm(c b) "STREF"; -;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; -;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; -builder store_slice(builder b, slice s) asm "STSLICER"; -builder store_grams(builder b, int x) asm "STGRAMS"; -builder store_dict(builder b, cell c) asm(c b) "STDICT"; - -(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; -tuple parse_addr(slice s) asm "PARSEMSGADDR"; -(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; -(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; - -cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; -(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF"; -(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF"; -(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; -(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; -(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; -(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; -(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; -(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; -(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; -(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; -(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; -(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; -cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; -(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; -(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; -(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; -(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; -cell new_dict() asm "NEWDICT"; -int dict_empty?(cell c) asm "DICTEMPTY"; - -(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; -(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; -(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; - -cell config_param(int x) asm "CONFIGOPTPARAM"; -int cell_null?(cell c) asm "ISNULL"; - -() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; -() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; -() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; -() set_code(cell new_code) impure asm "SETCODE"; - -int random() impure asm "RANDU256"; -int rand(int range) impure asm "RAND"; -int get_seed() impure asm "RANDSEED"; -int set_seed() impure asm "SETRAND"; -() randomize(int x) impure asm "ADDRAND"; -() randomize_lt() impure asm "LTIME" "ADDRAND"; - - -int equal_slices (slice a, slice b) asm "SDEQ"; -int builder_null?(builder b) asm "ISNULL"; +forall X -> tuple cons(X head, tuple tail) pure asm "CONS"; +forall X -> (X, tuple) uncons(tuple list) pure asm "UNCONS"; +forall X -> (tuple, X) list_next(tuple list) pure asm( -> 1 0) "UNCONS"; +forall X -> X car(tuple list) pure asm "CAR"; +tuple cdr(tuple list) pure asm "CDR"; +tuple empty_tuple() pure asm "NIL"; +forall X -> tuple tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> [X] single(X x) pure asm "SINGLE"; +forall X -> X unsingle([X] t) pure asm "UNSINGLE"; +forall X, Y -> [X, Y] pair(X x, Y y) pure asm "PAIR"; +forall X, Y -> (X, Y) unpair([X, Y] t) pure asm "UNPAIR"; +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) pure asm "TRIPLE"; +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) pure asm "UNTRIPLE"; +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) pure asm "4 TUPLE"; +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) pure asm "4 UNTUPLE"; +forall X -> X first(tuple t) pure asm "FIRST"; +forall X -> X second(tuple t) pure asm "SECOND"; +forall X -> X third(tuple t) pure asm "THIRD"; +forall X -> X fourth(tuple t) pure asm "3 INDEX"; +forall X, Y -> X pair_first([X, Y] p) pure asm "FIRST"; +forall X, Y -> Y pair_second([X, Y] p) pure asm "SECOND"; +forall X, Y, Z -> X triple_first([X, Y, Z] p) pure asm "FIRST"; +forall X, Y, Z -> Y triple_second([X, Y, Z] p) pure asm "SECOND"; +forall X, Y, Z -> Z triple_third([X, Y, Z] p) pure asm "THIRD"; +forall X -> X null() pure asm "PUSHNULL"; +forall X -> (X, ()) ~impure_touch(X x) asm "NOP"; + +int now() pure asm "NOW"; +slice my_address() pure asm "MYADDR"; +[int, cell] get_balance() pure asm "BALANCE"; +int cur_lt() pure asm "LTIME"; +int block_lt() pure asm "BLOCKLT"; + +int cell_hash(cell c) pure asm "HASHCU"; +int slice_hash(slice s) pure asm "HASHSU"; +int string_hash(slice s) pure asm "SHA256U"; + +int check_signature(int hash, slice signature, int public_key) pure asm "CHKSIGNU"; +int check_data_signature(slice data, slice signature, int public_key) pure asm "CHKSIGNS"; + +(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE"; +(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE"; +(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) pure asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; + +;; () throw_if(int excno, int cond) asm "THROWARGIF"; + +() dump_stack() asm "DUMPSTK"; + +cell get_data() pure asm "c4 PUSH"; +() set_data(cell c) asm "c4 POP"; +cont get_c3() asm "c3 PUSH"; +() set_c3(cont c) asm "c3 POP"; +cont bless(slice s) asm "BLESS"; + +() accept_message() asm "ACCEPT"; +() set_gas_limit(int limit) asm "SETGASLIMIT"; +() commit() asm "COMMIT"; +() buy_gas(int gram) asm "BUYGAS"; + +int min(int x, int y) pure asm "MIN"; +int max(int x, int y) pure asm "MAX"; +(int, int) minmax(int x, int y) pure asm "MINMAX"; +int abs(int x) pure asm "ABS"; + +slice begin_parse(cell c) pure asm "CTOS"; +() end_parse(slice s) asm "ENDS"; +(slice, cell) load_ref(slice s) pure asm( -> 1 0) "LDREF"; +cell preload_ref(slice s) pure asm "PLDREF"; +;; (slice, int) ~load_int(slice s, int len) pure asm(s len -> 1 0) "LDIX"; +;; (slice, int) ~load_uint(slice s, int len) pure asm( -> 1 0) "LDUX"; +;; int preload_int(slice s, int len) pure asm "PLDIX"; +;; int preload_uint(slice s, int len) pure asm "PLDUX"; +;; (slice, slice) load_bits(slice s, int len) pure asm(s len -> 1 0) "LDSLICEX"; +;; slice preload_bits(slice s, int len) pure asm "PLDSLICEX"; +(slice, int) load_grams(slice s) pure asm( -> 1 0) "LDGRAMS"; +slice skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +slice first_bits(slice s, int len) pure asm "SDCUTFIRST"; +slice skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +slice slice_last(slice s, int len) pure asm "SDCUTLAST"; +(slice, cell) load_dict(slice s) pure asm( -> 1 0) "LDDICT"; +cell preload_dict(slice s) pure asm "PLDDICT"; +slice skip_dict(slice s) pure asm "SKIPDICT"; + +(slice, cell) load_maybe_ref(slice s) pure asm( -> 1 0) "LDOPTREF"; +cell preload_maybe_ref(slice s) pure asm "PLDOPTREF"; +builder store_maybe_ref(builder b, cell c) pure asm(c b) "STOPTREF"; + +int cell_depth(cell c) pure asm "CDEPTH"; + +int slice_refs(slice s) pure asm "SREFS"; +int slice_bits(slice s) pure asm "SBITS"; +(int, int) slice_bits_refs(slice s) pure asm "SBITREFS"; +int slice_empty?(slice s) pure asm "SEMPTY"; +int slice_data_empty?(slice s) pure asm "SDEMPTY"; +int slice_refs_empty?(slice s) pure asm "SREMPTY"; +int slice_depth(slice s) pure asm "SDEPTH"; + +int builder_refs(builder b) pure asm "BREFS"; +int builder_bits(builder b) pure asm "BBITS"; +int builder_depth(builder b) pure asm "BDEPTH"; + +builder begin_cell() pure asm "NEWC"; +cell end_cell(builder b) pure asm "ENDC"; + builder store_ref(builder b, cell c) pure asm(c b) "STREF"; +;; builder store_uint(builder b, int x, int len) pure asm(x b len) "STUX"; +;; builder store_int(builder b, int x, int len) pure asm(x b len) "STIX"; +builder store_slice(builder b, slice s) pure asm "STSLICER"; +builder store_grams(builder b, int x) pure asm "STGRAMS"; +builder store_dict(builder b, cell c) pure asm(c b) "STDICT"; + +(slice, slice) load_msg_addr(slice s) pure asm( -> 1 0) "LDMSGADDR"; +tuple parse_addr(slice s) pure asm "PARSEMSGADDR"; +(int, int) parse_std_addr(slice s) pure asm "REWRITESTDADDR"; +(int, slice) parse_var_addr(slice s) pure asm "REWRITEVARADDR"; + +cell idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +cell udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +cell idict_get_ref(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETREF"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGETREF"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; +cell new_dict() pure asm "NEWDICT"; +int dict_empty?(cell c) pure asm "DICTEMPTY"; + +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) pure asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTDEL"; + +cell config_param(int x) pure asm "CONFIGOPTPARAM"; +int cell_null?(cell c) pure asm "ISNULL"; + +() raw_reserve(int amount, int mode) asm "RAWRESERVE"; +() raw_reserve_extra(int amount, cell extra_amount, int mode) asm "RAWRESERVEX"; +() send_raw_message(cell msg, int mode) asm "SENDRAWMSG"; +() set_code(cell new_code) asm "SETCODE"; + +int random() asm "RANDU256"; +int rand(int range) asm "RAND"; +int get_seed() asm "RANDSEED"; +int set_seed() asm "SETRAND"; +() randomize(int x) asm "ADDRAND"; +() randomize_lt() asm "LTIME" "ADDRAND"; + + +int equal_slices (slice a, slice b) pure asm "SDEQ"; +int builder_null?(builder b) pure asm "ISNULL"; diff --git a/crypto/func/auto-tests/tests/default-impure.fc b/crypto/func/auto-tests/tests/default-impure.fc new file mode 100644 index 000000000..25e6637e6 --- /dev/null +++ b/crypto/func/auto-tests/tests/default-impure.fc @@ -0,0 +1,25 @@ +global int x; + +() foo1() { + x = 5; +} +() foo2() { + foo1(); +} +() foo3() { + foo2(); +} + +int run() method_id(11) { + x = 3; + foo3(); + return x; +} + +() main() { +} + +{- + method_id | in | out +TESTCASE | 11 | | 5 +-} diff --git a/crypto/func/auto-tests/tests/explicit-pure.fc b/crypto/func/auto-tests/tests/explicit-pure.fc new file mode 100644 index 000000000..e51db9549 --- /dev/null +++ b/crypto/func/auto-tests/tests/explicit-pure.fc @@ -0,0 +1,33 @@ +global int x; + +() foo1() { + x = 5; +} +int foo2() pure { + foo1(); + return 1; +} +() foo3() { + foo2(); +} + +int run() method_id(11) { + x = 3; + foo3(); + return x; +} + +(int, int) run2() method_id(12) { + x = 3; + int y = foo2(); + return (x, y); +} + +() main() { +} + +{- + method_id | in | out +TESTCASE | 11 | | 3 +TESTCASE | 12 | | 5 1 +-} diff --git a/crypto/func/func.cpp b/crypto/func/func.cpp index 812738f05..39648c05a 100644 --- a/crypto/func/func.cpp +++ b/crypto/func/func.cpp @@ -40,7 +40,6 @@ bool stack_layout_comments, op_rewrite_comments, program_envelope, asm_preamble; bool interactive = false; GlobalPragma pragma_allow_post_modification{"allow-post-modification"}; GlobalPragma pragma_compute_asm_ltr{"compute-asm-ltr"}; -GlobalPragma pragma_strict_purity_check{"strict-purity-check"}; std::string generated_from, boc_output_filename; ReadCallback::Callback read_callback; @@ -240,7 +239,6 @@ int func_proceed(const std::vector &sources, std::ostream &outs, st } pragma_allow_post_modification.check_enable_in_libs(); pragma_compute_asm_ltr.check_enable_in_libs(); - pragma_strict_purity_check.check_enable_in_libs(); return funC::generate_output(outs, errs); } catch (src::Fatal& fatal) { errs << "fatal: " << fatal << std::endl; diff --git a/crypto/func/func.h b/crypto/func/func.h index a04ffdd42..0e69f18cf 100644 --- a/crypto/func/func.h +++ b/crypto/func/func.h @@ -108,6 +108,7 @@ enum Keyword { _Forall, _Asm, _Impure, + _Pure, _Global, _Extern, _Inline, @@ -602,7 +603,6 @@ struct Op { bool unreachable() { return !(flags & _Reachable); } - void set_impure(const CodeBlob& code); void flags_set_clear(int set, int clear); void show(std::ostream& os, const std::vector& vars, std::string pfx = "", int mode = 0) const; void show_var_list(std::ostream& os, const std::vector& idx_list, const std::vector& vars) const; @@ -690,7 +690,7 @@ typedef std::vector FormalArgList; struct AsmOpList; struct CodeBlob { - enum { _AllowPostModification = 1, _ComputeAsmLtr = 2, _ForbidImpure = 4 }; + enum { _AllowPostModification = 1, _ComputeAsmLtr = 2 }; int var_cnt, in_var_cnt, op_cnt; TypeExpr* ret_type; std::string name; @@ -1778,7 +1778,7 @@ class GlobalPragma { bool enabled_ = false; std::vector locs_; }; -extern GlobalPragma pragma_allow_post_modification, pragma_compute_asm_ltr, pragma_strict_purity_check; +extern GlobalPragma pragma_allow_post_modification, pragma_compute_asm_ltr; /* * diff --git a/crypto/func/gen-abscode.cpp b/crypto/func/gen-abscode.cpp index cf4b6089f..9989d10c4 100644 --- a/crypto/func/gen-abscode.cpp +++ b/crypto/func/gen-abscode.cpp @@ -229,7 +229,7 @@ var_idx_t Expr::new_tmp(CodeBlob& code) const { void add_set_globs(CodeBlob& code, std::vector>& globs, const SrcLocation& here) { for (const auto& p : globs) { auto& op = code.emplace_back(here, Op::_SetGlob, std::vector{}, std::vector{ p.second }, p.first); - op.set_impure(code); + op.flags |= Op::_Impure; } } @@ -351,7 +351,7 @@ std::vector Expr::pre_compile(CodeBlob& code, std::vector Expr::pre_compile(CodeBlob& code, std::vectorsym); if (args[0]->flags & _IsImpure) { - op.set_impure(code); + op.flags |= Op::_Impure; } return rvect; } else { diff --git a/crypto/func/keywords.cpp b/crypto/func/keywords.cpp index fedce9db2..0248a65ac 100644 --- a/crypto/func/keywords.cpp +++ b/crypto/func/keywords.cpp @@ -120,6 +120,7 @@ void define_keywords() { .add_keyword("global", Kw::_Global) .add_keyword("asm", Kw::_Asm) .add_keyword("impure", Kw::_Impure) + .add_keyword("pure", Kw::_Pure) .add_keyword("inline", Kw::_Inline) .add_keyword("inline_ref", Kw::_InlineRef) .add_keyword("auto_apply", Kw::_AutoApply) diff --git a/crypto/func/parse-func.cpp b/crypto/func/parse-func.cpp index 574bb7395..cf4946b51 100644 --- a/crypto/func/parse-func.cpp +++ b/crypto/func/parse-func.cpp @@ -1211,7 +1211,7 @@ blk_fl::val parse_stmt(Lexer& lex, CodeBlob& code) { } } -CodeBlob* parse_func_body(Lexer& lex, FormalArgList arg_list, TypeExpr* ret_type, bool impure) { +CodeBlob* parse_func_body(Lexer& lex, FormalArgList arg_list, TypeExpr* ret_type) { lex.expect('{'); CodeBlob* blob = new CodeBlob{ret_type}; if (pragma_allow_post_modification.enabled()) { @@ -1220,9 +1220,6 @@ CodeBlob* parse_func_body(Lexer& lex, FormalArgList arg_list, TypeExpr* ret_type if (pragma_compute_asm_ltr.enabled()) { blob->flags |= CodeBlob::_ComputeAsmLtr; } - if (pragma_strict_purity_check.enabled() && !impure) { - blob->flags |= CodeBlob::_ForbidImpure; - } blob->import_params(std::move(arg_list)); blk_fl::val res = blk_fl::init; bool warned = false; @@ -1441,8 +1438,17 @@ void parse_func_def(Lexer& lex) { Lexem func_name = lex.cur(); lex.next(); FormalArgList arg_list = parse_formal_args(lex); - bool impure = (lex.tp() == _Impure); - if (impure) { + bool impure = true; + if (lex.tp() == _Impure) { + static bool warning_shown = false; + if (!warning_shown) { + lex.cur().loc.show_warning( + "`impure` specifier is deprecated. All functions are impure by default, use `pure` to mark function as pure"); + warning_shown = true; + } + lex.next(); + } else if (lex.tp() == _Pure) { + impure = false; lex.next(); } int f = 0; @@ -1520,7 +1526,7 @@ void parse_func_def(Lexer& lex) { if (func_sym_code->code) { lex.cur().error("redefinition of function `"s + func_name.str + "`"); } - CodeBlob* code = parse_func_body(lex, arg_list, ret_type, impure); + CodeBlob* code = parse_func_body(lex, arg_list, ret_type); code->name = func_name.str; code->loc = loc; // code->print(std::cerr); // !!!DEBUG!!! @@ -1704,8 +1710,6 @@ void parse_pragma(Lexer& lex) { pragma_allow_post_modification.enable(lex.cur().loc); } else if (pragma_name == pragma_compute_asm_ltr.name()) { pragma_compute_asm_ltr.enable(lex.cur().loc); - } else if (pragma_name == pragma_strict_purity_check.name()) { - pragma_strict_purity_check.enable(lex.cur().loc); } else { lex.cur().error(std::string{"unknown pragma `"} + pragma_name + "`"); } diff --git a/crypto/smartcont/stdlib.fc b/crypto/smartcont/stdlib.fc index e3c28dcab..497d9cd1d 100644 --- a/crypto/smartcont/stdlib.fc +++ b/crypto/smartcont/stdlib.fc @@ -35,122 +35,122 @@ -} ;;; Adds an element to the beginning of lisp-style list. -forall X -> tuple cons(X head, tuple tail) asm "CONS"; +forall X -> tuple cons(X head, tuple tail) pure asm "CONS"; ;;; Extracts the head and the tail of lisp-style list. -forall X -> (X, tuple) uncons(tuple list) asm "UNCONS"; +forall X -> (X, tuple) uncons(tuple list) pure asm "UNCONS"; ;;; Extracts the tail and the head of lisp-style list. -forall X -> (tuple, X) list_next(tuple list) asm( -> 1 0) "UNCONS"; +forall X -> (tuple, X) list_next(tuple list) pure asm( -> 1 0) "UNCONS"; ;;; Returns the head of lisp-style list. -forall X -> X car(tuple list) asm "CAR"; +forall X -> X car(tuple list) pure asm "CAR"; ;;; Returns the tail of lisp-style list. -tuple cdr(tuple list) asm "CDR"; +tuple cdr(tuple list) pure asm "CDR"; ;;; Creates tuple with zero elements. -tuple empty_tuple() asm "NIL"; +tuple empty_tuple() pure asm "NIL"; ;;; Appends a value `x` to a `Tuple t = (x1, ..., xn)`, but only if the resulting `Tuple t' = (x1, ..., xn, x)` ;;; is of length at most 255. Otherwise throws a type check exception. -forall X -> tuple tpush(tuple t, X value) asm "TPUSH"; -forall X -> (tuple, ()) ~tpush(tuple t, X value) asm "TPUSH"; +forall X -> tuple tpush(tuple t, X value) pure asm "TPUSH"; +forall X -> (tuple, ()) ~tpush(tuple t, X value) pure asm "TPUSH"; ;;; Creates a tuple of length one with given argument as element. -forall X -> [X] single(X x) asm "SINGLE"; +forall X -> [X] single(X x) pure asm "SINGLE"; ;;; Unpacks a tuple of length one -forall X -> X unsingle([X] t) asm "UNSINGLE"; +forall X -> X unsingle([X] t) pure asm "UNSINGLE"; ;;; Creates a tuple of length two with given arguments as elements. -forall X, Y -> [X, Y] pair(X x, Y y) asm "PAIR"; +forall X, Y -> [X, Y] pair(X x, Y y) pure asm "PAIR"; ;;; Unpacks a tuple of length two -forall X, Y -> (X, Y) unpair([X, Y] t) asm "UNPAIR"; +forall X, Y -> (X, Y) unpair([X, Y] t) pure asm "UNPAIR"; ;;; Creates a tuple of length three with given arguments as elements. -forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) asm "TRIPLE"; +forall X, Y, Z -> [X, Y, Z] triple(X x, Y y, Z z) pure asm "TRIPLE"; ;;; Unpacks a tuple of length three -forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) asm "UNTRIPLE"; +forall X, Y, Z -> (X, Y, Z) untriple([X, Y, Z] t) pure asm "UNTRIPLE"; ;;; Creates a tuple of length four with given arguments as elements. -forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) asm "4 TUPLE"; +forall X, Y, Z, W -> [X, Y, Z, W] tuple4(X x, Y y, Z z, W w) pure asm "4 TUPLE"; ;;; Unpacks a tuple of length four -forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) asm "4 UNTUPLE"; +forall X, Y, Z, W -> (X, Y, Z, W) untuple4([X, Y, Z, W] t) pure asm "4 UNTUPLE"; ;;; Returns the first element of a tuple (with unknown element types). -forall X -> X first(tuple t) asm "FIRST"; +forall X -> X first(tuple t) pure asm "FIRST"; ;;; Returns the second element of a tuple (with unknown element types). -forall X -> X second(tuple t) asm "SECOND"; +forall X -> X second(tuple t) pure asm "SECOND"; ;;; Returns the third element of a tuple (with unknown element types). -forall X -> X third(tuple t) asm "THIRD"; +forall X -> X third(tuple t) pure asm "THIRD"; ;;; Returns the fourth element of a tuple (with unknown element types). -forall X -> X fourth(tuple t) asm "3 INDEX"; +forall X -> X fourth(tuple t) pure asm "3 INDEX"; ;;; Returns the first element of a pair tuple. -forall X, Y -> X pair_first([X, Y] p) asm "FIRST"; +forall X, Y -> X pair_first([X, Y] p) pure asm "FIRST"; ;;; Returns the second element of a pair tuple. -forall X, Y -> Y pair_second([X, Y] p) asm "SECOND"; +forall X, Y -> Y pair_second([X, Y] p) pure asm "SECOND"; ;;; Returns the first element of a triple tuple. -forall X, Y, Z -> X triple_first([X, Y, Z] p) asm "FIRST"; +forall X, Y, Z -> X triple_first([X, Y, Z] p) pure asm "FIRST"; ;;; Returns the second element of a triple tuple. -forall X, Y, Z -> Y triple_second([X, Y, Z] p) asm "SECOND"; +forall X, Y, Z -> Y triple_second([X, Y, Z] p) pure asm "SECOND"; ;;; Returns the third element of a triple tuple. -forall X, Y, Z -> Z triple_third([X, Y, Z] p) asm "THIRD"; +forall X, Y, Z -> Z triple_third([X, Y, Z] p) pure asm "THIRD"; ;;; Push null element (casted to given type) ;;; By the TVM type `Null` FunC represents absence of a value of some atomic type. ;;; So `null` can actually have any atomic type. -forall X -> X null() asm "PUSHNULL"; +forall X -> X null() pure asm "PUSHNULL"; ;;; Moves a variable [x] to the top of the stack -forall X -> (X, ()) ~impure_touch(X x) impure asm "NOP"; +forall X -> (X, ()) ~impure_touch(X x) asm "NOP"; ;;; Returns the current Unix time as an Integer -int now() asm "NOW"; +int now() pure asm "NOW"; ;;; Returns the internal address of the current smart contract as a Slice with a `MsgAddressInt`. ;;; If necessary, it can be parsed further using primitives such as [parse_std_addr]. -slice my_address() asm "MYADDR"; +slice my_address() pure asm "MYADDR"; ;;; Returns the balance of the smart contract as a tuple consisting of an int ;;; (balance in nanotoncoins) and a `cell` ;;; (a dictionary with 32-bit keys representing the balance of "extra currencies") ;;; at the start of Computation Phase. ;;; Note that RAW primitives such as [send_raw_message] do not update this field. -[int, cell] get_balance() asm "BALANCE"; +[int, cell] get_balance() pure asm "BALANCE"; ;;; Returns the logical time of the current transaction. -int cur_lt() asm "LTIME"; +int cur_lt() pure asm "LTIME"; ;;; Returns the starting logical time of the current block. -int block_lt() asm "BLOCKLT"; +int block_lt() pure asm "BLOCKLT"; ;;; Computes the representation hash of a `cell` [c] and returns it as a 256-bit unsigned integer `x`. ;;; Useful for signing and checking signatures of arbitrary entities represented by a tree of cells. -int cell_hash(cell c) asm "HASHCU"; +int cell_hash(cell c) pure asm "HASHCU"; ;;; Computes the hash of a `slice s` and returns it as a 256-bit unsigned integer `x`. ;;; The result is the same as if an ordinary cell containing only data and references from `s` had been created ;;; and its hash computed by [cell_hash]. -int slice_hash(slice s) asm "HASHSU"; +int slice_hash(slice s) pure asm "HASHSU"; ;;; Computes sha256 of the data bits of `slice` [s]. If the bit length of `s` is not divisible by eight, ;;; throws a cell underflow exception. The hash value is returned as a 256-bit unsigned integer `x`. -int string_hash(slice s) asm "SHA256U"; +int string_hash(slice s) pure asm "SHA256U"; {- # Signature checks @@ -163,14 +163,14 @@ int string_hash(slice s) asm "SHA256U"; ;;; Note that `CHKSIGNU` creates a 256-bit slice with the hash and calls `CHKSIGNS`. ;;; That is, if [hash] is computed as the hash of some data, these data are hashed twice, ;;; the second hashing occurring inside `CHKSIGNS`. -int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU"; +int check_signature(int hash, slice signature, int public_key) pure asm "CHKSIGNU"; ;;; Checks whether [signature] is a valid Ed25519-signature of the data portion of `slice data` using `public_key`, ;;; similarly to [check_signature]. ;;; If the bit length of [data] is not divisible by eight, throws a cell underflow exception. ;;; The verification of Ed25519 signatures is the standard one, ;;; with sha256 used to reduce [data] to the 256-bit number that is actually signed. -int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS"; +int check_data_signature(slice data, slice signature, int public_key) pure asm "CHKSIGNS"; {--- # Computation of boc size @@ -186,54 +186,54 @@ int check_data_signature(slice data, slice signature, int public_key) asm "CHKSI ;;; The total count of visited cells `x` cannot exceed non-negative [max_cells]; ;;; otherwise the computation is aborted before visiting the `(max_cells + 1)`-st cell and ;;; a zero flag is returned to indicate failure. If [c] is `null`, returns `x = y = z = 0`. -(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE"; +(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE"; ;;; Similar to [compute_data_size?], but accepting a `slice` [s] instead of a `cell`. ;;; The returned value of `x` does not take into account the cell that contains the `slice` [s] itself; ;;; however, the data bits and the cell references of [s] are accounted for in `y` and `z`. -(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE"; +(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE"; ;;; A non-quiet version of [compute_data_size?] that throws a cell overflow exception (`8`) on failure. -(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) compute_data_size?(cell c, int max_cells) pure asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; ;;; A non-quiet version of [slice_compute_data_size?] that throws a cell overflow exception (8) on failure. -(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; +(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) pure asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT"; ;;; Throws an exception with exit_code excno if cond is not 0 (commented since implemented in compilator) -;; () throw_if(int excno, int cond) impure asm "THROWARGIF"; +;; () throw_if(int excno, int cond) asm "THROWARGIF"; {-- # Debug primitives Only works for local TVM execution with debug level verbosity -} ;;; Dumps the stack (at most the top 255 values) and shows the total stack depth. -() dump_stack() impure asm "DUMPSTK"; +() dump_stack() asm "DUMPSTK"; {- # Persistent storage save and load -} ;;; Returns the persistent contract storage cell. It can be parsed or modified with slice and builder primitives later. -cell get_data() asm "c4 PUSH"; +cell get_data() pure asm "c4 PUSH"; ;;; Sets `cell` [c] as persistent contract data. You can update persistent contract storage with this primitive. -() set_data(cell c) impure asm "c4 POP"; +() set_data(cell c) asm "c4 POP"; {- # Continuation primitives -} ;;; Usually `c3` has a continuation initialized by the whole code of the contract. It is used for function calls. ;;; The primitive returns the current value of `c3`. -cont get_c3() asm "c3 PUSH"; +cont get_c3() pure asm "c3 PUSH"; ;;; Updates the current value of `c3`. Usually, it is used for updating smart contract code in run-time. ;;; Note that after execution of this primitive the current code ;;; (and the stack of recursive function calls) won't change, ;;; but any other function call will use a function from the new code. -() set_c3(cont c) impure asm "c3 POP"; +() set_c3(cont c) asm "c3 POP"; ;;; Transforms a `slice` [s] into a simple ordinary continuation `c`, with `c.code = s` and an empty stack and savelist. -cont bless(slice s) asm "BLESS"; +cont bless(slice s) pure asm "BLESS"; {--- # Gas related primitives @@ -245,37 +245,37 @@ cont bless(slice s) asm "BLESS"; ;;; This action is required to process external messages, which bring no value (hence no gas) with themselves. ;;; ;;; For more details check [accept_message effects](https://ton.org/docs/#/smart-contracts/accept). -() accept_message() impure asm "ACCEPT"; +() accept_message() asm "ACCEPT"; ;;; Sets current gas limit `gl` to the minimum of limit and `gm`, and resets the gas credit `gc` to zero. ;;; If the gas consumed so far (including the present instruction) exceeds the resulting value of `gl`, ;;; an (unhandled) out of gas exception is thrown before setting new gas limits. ;;; Notice that [set_gas_limit] with an argument `limit ≥ 2^63 − 1` is equivalent to [accept_message]. -() set_gas_limit(int limit) impure asm "SETGASLIMIT"; +() set_gas_limit(int limit) asm "SETGASLIMIT"; ;;; Commits the current state of registers `c4` (“persistent data”) and `c5` (“actions”) ;;; so that the current execution is considered “successful” with the saved values even if an exception ;;; in Computation Phase is thrown later. -() commit() impure asm "COMMIT"; +() commit() asm "COMMIT"; ;;; Not implemented -;;() buy_gas(int gram) impure asm "BUYGAS"; +;;() buy_gas(int gram) asm "BUYGAS"; ;;; Computes the amount of gas that can be bought for `amount` nanoTONs, ;;; and sets `gl` accordingly in the same way as [set_gas_limit]. -() buy_gas(int amount) impure asm "BUYGAS"; +() buy_gas(int amount) asm "BUYGAS"; ;;; Computes the minimum of two integers [x] and [y]. -int min(int x, int y) asm "MIN"; +int min(int x, int y) pure asm "MIN"; ;;; Computes the maximum of two integers [x] and [y]. -int max(int x, int y) asm "MAX"; +int max(int x, int y) pure asm "MAX"; ;;; Sorts two integers. -(int, int) minmax(int x, int y) asm "MINMAX"; +(int, int) minmax(int x, int y) pure asm "MINMAX"; ;;; Computes the absolute value of an integer [x]. -int abs(int x) asm "ABS"; +int abs(int x) pure asm "ABS"; {- # Slice primitives @@ -294,80 +294,80 @@ int abs(int x) asm "ABS"; ;;; Converts a `cell` [c] into a `slice`. Notice that [c] must be either an ordinary cell, ;;; or an exotic cell (see [TVM.pdf](https://ton-blockchain.github.io/docs/tvm.pdf), 3.1.2) ;;; which is automatically loaded to yield an ordinary cell `c'`, converted into a `slice` afterwards. -slice begin_parse(cell c) asm "CTOS"; +slice begin_parse(cell c) pure asm "CTOS"; ;;; Checks if [s] is empty. If not, throws an exception. -() end_parse(slice s) impure asm "ENDS"; +() end_parse(slice s) asm "ENDS"; ;;; Loads the first reference from the slice. -(slice, cell) load_ref(slice s) asm( -> 1 0) "LDREF"; +(slice, cell) load_ref(slice s) pure asm( -> 1 0) "LDREF"; ;;; Preloads the first reference from the slice. -cell preload_ref(slice s) asm "PLDREF"; +cell preload_ref(slice s) pure asm "PLDREF"; {- Functions below are commented because are implemented on compilator level for optimisation -} ;;; Loads a signed [len]-bit integer from a slice [s]. -;; (slice, int) ~load_int(slice s, int len) asm(s len -> 1 0) "LDIX"; +;; (slice, int) ~load_int(slice s, int len) pure asm(s len -> 1 0) "LDIX"; ;;; Loads an unsigned [len]-bit integer from a slice [s]. -;; (slice, int) ~load_uint(slice s, int len) asm( -> 1 0) "LDUX"; +;; (slice, int) ~load_uint(slice s, int len) pure asm( -> 1 0) "LDUX"; ;;; Preloads a signed [len]-bit integer from a slice [s]. -;; int preload_int(slice s, int len) asm "PLDIX"; +;; int preload_int(slice s, int len) pure asm "PLDIX"; ;;; Preloads an unsigned [len]-bit integer from a slice [s]. -;; int preload_uint(slice s, int len) asm "PLDUX"; +;; int preload_uint(slice s, int len) pure asm "PLDUX"; ;;; Loads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`. -;; (slice, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX"; +;; (slice, slice) load_bits(slice s, int len) pure asm(s len -> 1 0) "LDSLICEX"; ;;; Preloads the first `0 ≤ len ≤ 1023` bits from slice [s] into a separate `slice s''`. -;; slice preload_bits(slice s, int len) asm "PLDSLICEX"; +;; slice preload_bits(slice s, int len) pure asm "PLDSLICEX"; ;;; Loads serialized amount of TonCoins (any unsigned integer up to `2^120 - 1`). -(slice, int) load_grams(slice s) asm( -> 1 0) "LDGRAMS"; -(slice, int) load_coins(slice s) asm( -> 1 0) "LDGRAMS"; +(slice, int) load_grams(slice s) pure asm( -> 1 0) "LDGRAMS"; +(slice, int) load_coins(slice s) pure asm( -> 1 0) "LDGRAMS"; ;;; Returns all but the first `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice skip_bits(slice s, int len) asm "SDSKIPFIRST"; -(slice, ()) ~skip_bits(slice s, int len) asm "SDSKIPFIRST"; +slice skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; +(slice, ()) ~skip_bits(slice s, int len) pure asm "SDSKIPFIRST"; ;;; Returns the first `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice first_bits(slice s, int len) asm "SDCUTFIRST"; +slice first_bits(slice s, int len) pure asm "SDCUTFIRST"; ;;; Returns all but the last `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice skip_last_bits(slice s, int len) asm "SDSKIPLAST"; -(slice, ()) ~skip_last_bits(slice s, int len) asm "SDSKIPLAST"; +slice skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; +(slice, ()) ~skip_last_bits(slice s, int len) pure asm "SDSKIPLAST"; ;;; Returns the last `0 ≤ len ≤ 1023` bits of `slice` [s]. -slice slice_last(slice s, int len) asm "SDCUTLAST"; +slice slice_last(slice s, int len) pure asm "SDCUTLAST"; ;;; Loads a dictionary `D` (HashMapE) from `slice` [s]. ;;; (returns `null` if `nothing` constructor is used). -(slice, cell) load_dict(slice s) asm( -> 1 0) "LDDICT"; +(slice, cell) load_dict(slice s) pure asm( -> 1 0) "LDDICT"; ;;; Preloads a dictionary `D` from `slice` [s]. -cell preload_dict(slice s) asm "PLDDICT"; +cell preload_dict(slice s) pure asm "PLDDICT"; ;;; Loads a dictionary as [load_dict], but returns only the remainder of the slice. -slice skip_dict(slice s) asm "SKIPDICT"; +slice skip_dict(slice s) pure asm "SKIPDICT"; ;;; Loads (Maybe ^Cell) from `slice` [s]. ;;; In other words loads 1 bit and if it is true ;;; loads first ref and return it with slice remainder ;;; otherwise returns `null` and slice remainder -(slice, cell) load_maybe_ref(slice s) asm( -> 1 0) "LDOPTREF"; +(slice, cell) load_maybe_ref(slice s) pure asm( -> 1 0) "LDOPTREF"; ;;; Preloads (Maybe ^Cell) from `slice` [s]. -cell preload_maybe_ref(slice s) asm "PLDOPTREF"; +cell preload_maybe_ref(slice s) pure asm "PLDOPTREF"; ;;; Returns the depth of `cell` [c]. ;;; If [c] has no references, then return `0`; ;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [c]. ;;; If [c] is a `null` instead of a cell, returns zero. -int cell_depth(cell c) asm "CDEPTH"; +int cell_depth(cell c) pure asm "CDEPTH"; {- @@ -375,42 +375,42 @@ int cell_depth(cell c) asm "CDEPTH"; -} ;;; Returns the number of references in `slice` [s]. -int slice_refs(slice s) asm "SREFS"; +int slice_refs(slice s) pure asm "SREFS"; ;;; Returns the number of data bits in `slice` [s]. -int slice_bits(slice s) asm "SBITS"; +int slice_bits(slice s) pure asm "SBITS"; ;;; Returns both the number of data bits and the number of references in `slice` [s]. -(int, int) slice_bits_refs(slice s) asm "SBITREFS"; +(int, int) slice_bits_refs(slice s) pure asm "SBITREFS"; ;;; Checks whether a `slice` [s] is empty (i.e., contains no bits of data and no cell references). -int slice_empty?(slice s) asm "SEMPTY"; +int slice_empty?(slice s) pure asm "SEMPTY"; ;;; Checks whether `slice` [s] has no bits of data. -int slice_data_empty?(slice s) asm "SDEMPTY"; +int slice_data_empty?(slice s) pure asm "SDEMPTY"; ;;; Checks whether `slice` [s] has no references. -int slice_refs_empty?(slice s) asm "SREMPTY"; +int slice_refs_empty?(slice s) pure asm "SREMPTY"; ;;; Returns the depth of `slice` [s]. ;;; If [s] has no references, then returns `0`; ;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [s]. -int slice_depth(slice s) asm "SDEPTH"; +int slice_depth(slice s) pure asm "SDEPTH"; {- # Builder size primitives -} ;;; Returns the number of cell references already stored in `builder` [b] -int builder_refs(builder b) asm "BREFS"; +int builder_refs(builder b) pure asm "BREFS"; ;;; Returns the number of data bits already stored in `builder` [b]. -int builder_bits(builder b) asm "BBITS"; +int builder_bits(builder b) pure asm "BBITS"; ;;; Returns the depth of `builder` [b]. ;;; If no cell references are stored in [b], then returns 0; ;;; otherwise the returned value is one plus the maximum of depths of cells referred to from [b]. -int builder_depth(builder b) asm "BDEPTH"; +int builder_depth(builder b) pure asm "BDEPTH"; {- # Builder primitives @@ -423,23 +423,23 @@ int builder_depth(builder b) asm "BDEPTH"; -} ;;; Creates a new empty `builder`. -builder begin_cell() asm "NEWC"; +builder begin_cell() pure asm "NEWC"; ;;; Converts a `builder` into an ordinary `cell`. -cell end_cell(builder b) asm "ENDC"; +cell end_cell(builder b) pure asm "ENDC"; ;;; Stores a reference to `cell` [c] into `builder` [b]. -builder store_ref(builder b, cell c) asm(c b) "STREF"; +builder store_ref(builder b, cell c) pure asm(c b) "STREF"; ;;; Stores an unsigned [len]-bit integer `x` into `b` for `0 ≤ len ≤ 256`. -;; builder store_uint(builder b, int x, int len) asm(x b len) "STUX"; +;; builder store_uint(builder b, int x, int len) pure asm(x b len) "STUX"; ;;; Stores a signed [len]-bit integer `x` into `b` for` 0 ≤ len ≤ 257`. -;; builder store_int(builder b, int x, int len) asm(x b len) "STIX"; +;; builder store_int(builder b, int x, int len) pure asm(x b len) "STIX"; ;;; Stores `slice` [s] into `builder` [b] -builder store_slice(builder b, slice s) asm "STSLICER"; +builder store_slice(builder b, slice s) pure asm "STSLICER"; ;;; Stores (serializes) an integer [x] in the range `0..2^120 − 1` into `builder` [b]. ;;; The serialization of [x] consists of a 4-bit unsigned big-endian integer `l`, @@ -448,17 +448,17 @@ builder store_slice(builder b, slice s) asm "STSLICER"; ;;; If [x] does not belong to the supported range, a range check exception is thrown. ;;; ;;; Store amounts of TonCoins to the builder as VarUInteger 16 -builder store_grams(builder b, int x) asm "STGRAMS"; -builder store_coins(builder b, int x) asm "STGRAMS"; +builder store_grams(builder b, int x) pure asm "STGRAMS"; +builder store_coins(builder b, int x) pure asm "STGRAMS"; ;;; Stores dictionary `D` represented by `cell` [c] or `null` into `builder` [b]. ;;; In other words, stores a `1`-bit and a reference to [c] if [c] is not `null` and `0`-bit otherwise. -builder store_dict(builder b, cell c) asm(c b) "STDICT"; +builder store_dict(builder b, cell c) pure asm(c b) "STDICT"; ;;; Stores (Maybe ^Cell) to builder: ;;; if cell is null store 1 zero bit ;;; otherwise store 1 true bit and ref to cell -builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; +builder store_maybe_ref(builder b, cell c) pure asm(c b) "STOPTREF"; {- @@ -500,22 +500,22 @@ builder store_maybe_ref(builder b, cell c) asm(c b) "STOPTREF"; ;;; 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. -(slice, slice) load_msg_addr(slice s) asm( -> 1 0) "LDMSGADDR"; +(slice, slice) load_msg_addr(slice s) pure 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. -tuple parse_addr(slice s) asm "PARSEMSGADDR"; +tuple parse_addr(slice s) pure asm "PARSEMSGADDR"; ;;; Parses slice [s] containing a valid `MsgAddressInt` (usually a `msg_addr_std`), ;;; applies rewriting from the anycast (if present) to the same-length prefix of the address, ;;; and returns both the workchain and the 256-bit address as integers. ;;; If the address is not 256-bit, or if [s] is not a valid serialization of `MsgAddressInt`, ;;; throws a cell deserialization exception. -(int, int) parse_std_addr(slice s) asm "REWRITESTDADDR"; +(int, int) parse_std_addr(slice s) pure asm "REWRITESTDADDR"; ;;; A variant of [parse_std_addr] that returns the (rewritten) address as a slice [s], ;;; even if it is not exactly 256 bit long (represented by a `msg_addr_var`). -(int, slice) parse_var_addr(slice s) asm "REWRITEVARADDR"; +(int, slice) parse_var_addr(slice s) pure asm "REWRITEVARADDR"; {- # Dictionary primitives @@ -524,116 +524,116 @@ tuple parse_addr(slice s) asm "PARSEMSGADDR"; ;;; Sets the value associated with [key_len]-bit key signed index in dictionary [dict] to [value] (cell), ;;; and returns the resulting dictionary. -cell idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; -(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETREF"; +cell idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; +(cell, ()) ~idict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETREF"; ;;; Sets the value associated with [key_len]-bit key unsigned index in dictionary [dict] to [value] (cell), ;;; and returns the resulting dictionary. -cell udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; -(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETREF"; - -cell idict_get_ref(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETOPTREF"; -(cell, int) idict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; -(cell, int) udict_get_ref?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; -(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTISETGETOPTREF"; -(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) asm(value index dict key_len) "DICTUSETGETOPTREF"; -(cell, int) idict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDEL"; -(cell, int) udict_delete?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDEL"; -(slice, int) idict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; -(slice, int) udict_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; -(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; -(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; -cell udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUSET"; -cell idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTISET"; -cell dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) asm(value index dict key_len) "DICTSET"; -(cell, int) udict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUADD"; -(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTUREPLACE"; -(cell, int) idict_add?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIADD"; -(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) asm(value index dict key_len) "DICTIREPLACE"; -cell udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUSETB"; -cell idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTISETB"; -cell dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) asm(value index dict key_len) "DICTSETB"; -(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUADDB"; -(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTUREPLACEB"; -(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIADDB"; -(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) asm(value index dict key_len) "DICTIREPLACEB"; -(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; -(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; -(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; -(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) udict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_min?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_max?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_min_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; -(int, cell, int) idict_get_max_ref?(cell dict, int key_len) asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; -(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; +cell udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; +(cell, ()) ~udict_set_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETREF"; + +cell idict_get_ref(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETOPTREF"; +(cell, int) idict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGETREF" "NULLSWAPIFNOT"; +(cell, int) udict_get_ref?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGETREF" "NULLSWAPIFNOT"; +(cell, cell) idict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTISETGETOPTREF"; +(cell, cell) udict_set_get_ref(cell dict, int key_len, int index, cell value) pure asm(value index dict key_len) "DICTUSETGETOPTREF"; +(cell, int) idict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDEL"; +(cell, int) udict_delete?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDEL"; +(slice, int) idict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIGET" "NULLSWAPIFNOT"; +(slice, int) udict_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUGET" "NULLSWAPIFNOT"; +(cell, slice, int) idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, slice, int) udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~idict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTIDELGET" "NULLSWAPIFNOT"; +(cell, (slice, int)) ~udict_delete_get?(cell dict, int key_len, int index) pure asm(index dict key_len) "DICTUDELGET" "NULLSWAPIFNOT"; +cell udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +(cell, ()) ~udict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUSET"; +cell idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +(cell, ()) ~idict_set(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTISET"; +cell dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, ()) ~dict_set(cell dict, int key_len, slice index, slice value) pure asm(value index dict key_len) "DICTSET"; +(cell, int) udict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUADD"; +(cell, int) udict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTUREPLACE"; +(cell, int) idict_add?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIADD"; +(cell, int) idict_replace?(cell dict, int key_len, int index, slice value) pure asm(value index dict key_len) "DICTIREPLACE"; +cell udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +(cell, ()) ~udict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUSETB"; +cell idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +(cell, ()) ~idict_set_builder(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTISETB"; +cell dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, ()) ~dict_set_builder(cell dict, int key_len, slice index, builder value) pure asm(value index dict key_len) "DICTSETB"; +(cell, int) udict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUADDB"; +(cell, int) udict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTUREPLACEB"; +(cell, int) idict_add_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIADDB"; +(cell, int) idict_replace_builder?(cell dict, int key_len, int index, builder value) pure asm(value index dict key_len) "DICTIREPLACEB"; +(cell, int, slice, int) udict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMIN" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_min(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMIN" "NULLSWAPIFNOT2"; +(cell, int, slice, int) udict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~udict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTUREMMAX" "NULLSWAPIFNOT2"; +(cell, int, slice, int) idict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, (int, slice, int)) ~idict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTIREMMAX" "NULLSWAPIFNOT2"; +(cell, slice, slice, int) dict_delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(cell, (slice, slice, int)) ~dict::delete_get_max(cell dict, int key_len) pure asm(-> 0 2 1 3) "DICTREMMAX" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMIN" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAX" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) udict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTUMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_min?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMIN" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_max?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAX" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_min_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMINREF" "NULLSWAPIFNOT2"; +(int, cell, int) idict_get_max_ref?(cell dict, int key_len) pure asm (-> 1 0 2) "DICTIMAXREF" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) udict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTUGETPREVEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_next?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXT" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_nexteq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETNEXTEQ" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_prev?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREV" "NULLSWAPIFNOT2"; +(int, slice, int) idict_get_preveq?(cell dict, int key_len, int pivot) pure asm(pivot dict key_len -> 1 0 2) "DICTIGETPREVEQ" "NULLSWAPIFNOT2"; ;;; Creates an empty dictionary, which is actually a null value. Equivalent to PUSHNULL -cell new_dict() asm "NEWDICT"; +cell new_dict() pure asm "NEWDICT"; ;;; Checks whether a dictionary is empty. Equivalent to cell_null?. -int dict_empty?(cell c) asm "DICTEMPTY"; +int dict_empty?(cell c) pure asm "DICTEMPTY"; {- Prefix dictionary primitives -} -(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; -(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) asm(value key dict key_len) "PFXDICTSET"; -(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) asm(key dict key_len) "PFXDICTDEL"; +(slice, slice, slice, int) pfxdict_get?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTGETQ" "NULLSWAPIFNOT2"; +(cell, int) pfxdict_set?(cell dict, int key_len, slice key, slice value) pure asm(value key dict key_len) "PFXDICTSET"; +(cell, int) pfxdict_delete?(cell dict, int key_len, slice key) pure asm(key dict key_len) "PFXDICTDEL"; ;;; Returns the value of the global configuration parameter with integer index `i` as a `cell` or `null` value. -cell config_param(int x) asm "CONFIGOPTPARAM"; +cell config_param(int x) pure asm "CONFIGOPTPARAM"; ;;; Checks whether c is a null. Note, that FunC also has polymorphic null? built-in. -int cell_null?(cell c) asm "ISNULL"; +int cell_null?(cell c) pure asm "ISNULL"; ;;; Creates an output action which would reserve exactly amount nanotoncoins (if mode = 0), at most amount nanotoncoins (if mode = 2), or all but amount nanotoncoins (if mode = 1 or mode = 3), from the remaining balance of the account. It is roughly equivalent to creating an outbound message carrying amount nanotoncoins (or b − amount nanotoncoins, where b is the remaining balance) to oneself, so that the subsequent output actions would not be able to spend more money than the remainder. Bit +2 in mode means that the external action does not fail if the specified amount cannot be reserved; instead, all remaining balance is reserved. Bit +8 in mode means `amount <- -amount` before performing any further actions. Bit +4 in mode means that amount is increased by the original balance of the current account (before the compute phase), including all extra currencies, before performing any other checks and actions. Currently, amount must be a non-negative integer, and mode must be in the range 0..15. -() raw_reserve(int amount, int mode) impure asm "RAWRESERVE"; +() raw_reserve(int amount, int mode) asm "RAWRESERVE"; ;;; Similar to raw_reserve, but also accepts a dictionary extra_amount (represented by a cell or null) with extra currencies. In this way currencies other than TonCoin can be reserved. -() raw_reserve_extra(int amount, cell extra_amount, int mode) impure asm "RAWRESERVEX"; +() raw_reserve_extra(int amount, cell extra_amount, int mode) asm "RAWRESERVEX"; ;;; Sends a raw message contained in msg, which should contain a correctly serialized object Message X, with the only exception that the source address is allowed to have dummy value addr_none (to be automatically replaced with the current smart contract address), and ihr_fee, fwd_fee, created_lt and created_at fields can have arbitrary values (to be rewritten with correct values during the action phase of the current transaction). Integer parameter mode contains the flags. Currently mode = 0 is used for ordinary messages; mode = 128 is used for messages that are to carry all the remaining balance of the current smart contract (instead of the value originally indicated in the message); mode = 64 is used for messages that carry all the remaining value of the inbound message in addition to the value initially indicated in the new message (if bit 0 is not set, the gas fees are deducted from this amount); mode' = mode + 1 means that the sender wants to pay transfer fees separately; mode' = mode + 2 means that any errors arising while processing this message during the action phase should be ignored. Finally, mode' = mode + 32 means that the current account must be destroyed if its resulting balance is zero. This flag is usually employed together with +128. -() send_raw_message(cell msg, int mode) impure asm "SENDRAWMSG"; +() send_raw_message(cell msg, int mode) asm "SENDRAWMSG"; ;;; Creates an output action that would change this smart contract code to that given by cell new_code. Notice that this change will take effect only after the successful termination of the current run of the smart contract -() set_code(cell new_code) impure asm "SETCODE"; +() set_code(cell new_code) asm "SETCODE"; ;;; Generates a new pseudo-random unsigned 256-bit integer x. The algorithm is as follows: if r is the old value of the random seed, considered as a 32-byte array (by constructing the big-endian representation of an unsigned 256-bit integer), then its sha512(r) is computed; the first 32 bytes of this hash are stored as the new value r' of the random seed, and the remaining 32 bytes are returned as the next random value x. -int random() impure asm "RANDU256"; +int random() asm "RANDU256"; ;;; Generates a new pseudo-random integer z in the range 0..range−1 (or range..−1, if range < 0). More precisely, an unsigned random value x is generated as in random; then z := x * range / 2^256 is computed. -int rand(int range) impure asm "RAND"; +int rand(int range) asm "RAND"; ;;; Returns the current random seed as an unsigned 256-bit Integer. -int get_seed() asm "RANDSEED"; +int get_seed() pure asm "RANDSEED"; ;;; Sets the random seed to unsigned 256-bit seed. -() set_seed(int) impure asm "SETRAND"; +() set_seed(int) asm "SETRAND"; ;;; Mixes unsigned 256-bit integer x into the random seed r by setting the random seed to sha256 of the concatenation of two 32-byte strings: the first with the big-endian representation of the old seed r, and the second with the big-endian representation of x. -() randomize(int x) impure asm "ADDRAND"; +() randomize(int x) asm "ADDRAND"; ;;; Equivalent to randomize(cur_lt());. -() randomize_lt() impure asm "LTIME" "ADDRAND"; +() randomize_lt() asm "LTIME" "ADDRAND"; ;;; Checks whether the data parts of two slices coinside -int equal_slice_bits (slice a, slice b) asm "SDEQ"; +int equal_slice_bits (slice a, slice b) pure asm "SDEQ"; ;;; Concatenates two builders -builder store_builder(builder to, builder from) asm "STBR"; +builder store_builder(builder to, builder from) pure asm "STBR";