From 00b399c7a076b6f086c4ec6bc3c87046c9cdba84 Mon Sep 17 00:00:00 2001 From: Daniil Sedov <42098239+Gusarich@users.noreply.github.com> Date: Sun, 5 Feb 2023 13:18:57 +0300 Subject: [PATCH 1/3] Update stdlib.fc --- crypto/smartcont/stdlib.fc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crypto/smartcont/stdlib.fc b/crypto/smartcont/stdlib.fc index 3531608a..2ecf7f82 100644 --- a/crypto/smartcont/stdlib.fc +++ b/crypto/smartcont/stdlib.fc @@ -622,3 +622,32 @@ int equal_slice_bits (slice a, slice b) asm "SDEQ"; ;;; Concatenates two builders builder store_builder(builder to, builder from) asm "STBR"; + +;; Detaches the last element x=x_n from a non-empty Tuple t=(x_1,...,x_n), and returns both the resulting Tuple t'=(x_1,...,x_{n-1}) and the original last element x. +forall X -> tuple tpop(tuple t) asm "TPOP"; +forall X -> (tuple, X) ~tpop(tuple t) asm "TPOP"; + +;; Returns the length of a Tuple. +int tuple_length(tuple t) asm "TLEN"; + +;; type checks +forall X -> int is_int(X x) asm "<{ TRY:<{ 0 PUSHINT ADD DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS"; +forall X -> int is_cell(X x) asm "<{ TRY:<{ CTOS DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS"; +forall X -> int is_slice(X x) asm "<{ TRY:<{ SBITS DROP -1 PUSHINT }>CATCH<{ 2DROP 0 PUSHINT }> }>CONT 1 1 CALLXARGS"; +forall X -> int is_tuple(X x) asm "ISTUPLE"; + +;; type casts +forall X -> cell force_cast_to_cell(X x) asm "NOP"; +forall X -> slice force_cast_to_slice(X x) asm "NOP"; +forall X -> int force_cast_to_int(X x) asm "NOP"; +forall X -> tuple force_cast_to_tuple(X x) asm "NOP"; +forall X -> tuple unsafe_tuple(X x) asm "NOP"; + +;; get c5 register +cell get_c5() asm "c5 PUSH"; + +;; Creates an output action that would modify the collection of this smart contract libraries by adding or removing library with code given in Cell c. If x=0, the library is actually removed if it was previously present in the collection (if not, this action does nothing). If x=1, the library is added as a private library, and if x=2, the library is added as a public library (and becomes available to all smart contracts if the current smart contract resides in the masterchain); if the library was present in the collection before, its public/private status is changed according to x. Values of x other than 0...2 are invalid. +() set_lib_code(cell library, int x) impure asm "SETLIBCODE"; + +;; Creates an output action similarly to SETLIBCODE, but instead of the library code accepts its hash as an unsigned 256-bit integer h. If x!=0 and the library with hash h is absent from the library collection of this smart contract, this output action will fail. +() change_lib(int lib_hash, int x) impure asm "CHANGELIB"; From 7c7555300b55cad849926a1a6c35f93ebedc9dd7 Mon Sep 17 00:00:00 2001 From: Daniil Sedov <42098239+Gusarich@users.noreply.github.com> Date: Sun, 5 Feb 2023 13:28:53 +0300 Subject: [PATCH 2/3] fix tpop --- crypto/smartcont/stdlib.fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/smartcont/stdlib.fc b/crypto/smartcont/stdlib.fc index 2ecf7f82..0c621928 100644 --- a/crypto/smartcont/stdlib.fc +++ b/crypto/smartcont/stdlib.fc @@ -624,7 +624,7 @@ int equal_slice_bits (slice a, slice b) asm "SDEQ"; builder store_builder(builder to, builder from) asm "STBR"; ;; Detaches the last element x=x_n from a non-empty Tuple t=(x_1,...,x_n), and returns both the resulting Tuple t'=(x_1,...,x_{n-1}) and the original last element x. -forall X -> tuple tpop(tuple t) asm "TPOP"; +forall X -> (tuple, X) tpop(tuple t) asm "TPOP"; forall X -> (tuple, X) ~tpop(tuple t) asm "TPOP"; ;; Returns the length of a Tuple. From 3e9900feb14d49c397f8180c00100d37ae43a9fd Mon Sep 17 00:00:00 2001 From: Daniil Sedov <42098239+Gusarich@users.noreply.github.com> Date: Sun, 5 Feb 2023 23:56:21 +0300 Subject: [PATCH 3/3] Remove unsafe_tuple from stdlib --- crypto/smartcont/stdlib.fc | 1 - 1 file changed, 1 deletion(-) diff --git a/crypto/smartcont/stdlib.fc b/crypto/smartcont/stdlib.fc index 0c621928..5c6a823e 100644 --- a/crypto/smartcont/stdlib.fc +++ b/crypto/smartcont/stdlib.fc @@ -641,7 +641,6 @@ forall X -> cell force_cast_to_cell(X x) asm "NOP"; forall X -> slice force_cast_to_slice(X x) asm "NOP"; forall X -> int force_cast_to_int(X x) asm "NOP"; forall X -> tuple force_cast_to_tuple(X x) asm "NOP"; -forall X -> tuple unsafe_tuple(X x) asm "NOP"; ;; get c5 register cell get_c5() asm "c5 PUSH";