First of all, don't panic! It is a long lesson that explains the basics of variables and storage manipulation. You are going to set up your spaceship storage and make yourself one step closer to your trip through magnificent TON Universe.
Ready? Here goes!
FunC is static weakly typed language. TVM supports following types (don't care about it too much now):
int
).cell
).tuple
).slice
).builder
).cont
).Variables are declared quite similar to other languages. Syntax is following:
type name = value;
type name = function_with_return_value();
Definition must to have right value. For example:
int number = 10;
cell dictionary = new_dict()
To read the data from slice the functions preload_TYPE
and load_TYPE
are provided. They are declared in stdlib.fc (note: don't care about it too much now).
(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, slice) load_bits(slice s, int len) asm(s len -> 1 0) "LDSLICEX";
slice preload_bits(slice s, int len) asm "PLDSLICEX";
To sum up: