mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[FunC] Add builtin functions to stdlib.fc
Note, that I have not added all builtin functions. I filtered out strange and actually unused in practice, like "int_at()" and similar, or "run_method0()" and similar. (Probably, they should be dropped off even from builtins) Also, I've modified some stdlib.fc legacy tests just to ensure that a resulting hash doesn't change.
This commit is contained in:
parent
cdef8302b0
commit
de570873d7
10 changed files with 307 additions and 101 deletions
|
@ -21,12 +21,16 @@ 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 -> X at(tuple t, int index) pure builtin;
|
||||
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 -> int null?(X x) pure builtin;
|
||||
forall X -> X touch(X x) pure builtin;
|
||||
forall X -> (X, ()) ~touch(X x) pure builtin;
|
||||
forall X -> (X, ()) ~impure_touch(X x) asm "NOP";
|
||||
|
||||
int now() pure asm "NOW";
|
||||
|
@ -47,8 +51,15 @@ int check_data_signature(slice data, slice signature, int public_key) pure asm "
|
|||
(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";
|
||||
() throw(int excno) builtin;
|
||||
() throw_if(int excno, int cond) builtin;
|
||||
() throw_unless(int excno, int cond) builtin;
|
||||
forall X -> () throw_arg(X x, int excno) builtin;
|
||||
forall X -> () throw_arg_if(X x, int excno, int cond) builtin;
|
||||
forall X -> () throw_arg_unless(X x, int excno, int cond) builtin;
|
||||
|
||||
forall X -> (X, ()) ~dump(X x) builtin;
|
||||
forall X -> (X, ()) ~strdump(X x) builtin;
|
||||
() dump_stack() asm "DUMPSTK";
|
||||
|
||||
cell get_data() pure asm "c4 PUSH";
|
||||
|
@ -66,17 +77,23 @@ 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";
|
||||
(int, int) divmod(int x, int y) pure builtin;
|
||||
(int, int) moddiv(int x, int y) pure builtin;
|
||||
int muldiv(int x, int y, int z) pure builtin;
|
||||
int muldivr(int x, int y, int z) pure builtin;
|
||||
int muldivc(int x, int y, int z) pure builtin;
|
||||
(int, int) muldivmod(int x, int y, int z) pure builtin;
|
||||
|
||||
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_int(slice s, int len) pure builtin;
|
||||
(slice, int) load_uint(slice s, int len) pure builtin;
|
||||
int preload_int(slice s, int len) pure builtin;
|
||||
int preload_uint(slice s, int len) pure builtin;
|
||||
(slice, slice) load_bits(slice s, int len) pure builtin;
|
||||
slice preload_bits(slice s, int len) pure builtin;
|
||||
(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";
|
||||
|
@ -109,8 +126,8 @@ 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_uint(builder b, int x, int len) pure builtin;
|
||||
builder store_int(builder b, int x, int len) pure builtin;
|
||||
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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue