mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-15 04:32:21 +00:00
`get` keyword behaves exactly like `method_id` (auto-calc hash), but it's placed on the left, similar to Tact: `get T name()`. `method_id(n)` is still valid, considering it can't be invoked by name, since a client will compute another hash. It's supposed it will be still used in tests and in low-level code (not to be called externally, but to be called after replacing c3). `get(hash)` is invalid, this keyword does not accept anything.
56 lines
1.5 KiB
Text
56 lines
1.5 KiB
Text
get slice ascii_slice() {
|
|
return "string";
|
|
}
|
|
|
|
get slice raw_slice() {
|
|
return "abcdef"s;
|
|
}
|
|
|
|
get slice addr_slice() {
|
|
return "Ef8zMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzM0vF"a;
|
|
}
|
|
|
|
get int string_hex() {
|
|
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"u;
|
|
}
|
|
|
|
get int string_minihash() {
|
|
return "transfer(slice, int)"h;
|
|
}
|
|
|
|
get int string_maxihash() {
|
|
return "transfer(slice, int)"H;
|
|
}
|
|
|
|
get int string_crc32() {
|
|
return "transfer(slice, int)"c;
|
|
}
|
|
|
|
builder newc() pure asm "NEWC";
|
|
slice endcs(builder b) asm "ENDC" "CTOS";
|
|
int sdeq (slice s1, slice s2) pure asm "SDEQ";
|
|
|
|
_ main() {
|
|
slice s_ascii = ascii_slice();
|
|
slice s_raw = raw_slice();
|
|
slice s_addr = addr_slice();
|
|
int i_hex = string_hex();
|
|
int i_mini = string_minihash();
|
|
int i_maxi = string_maxihash();
|
|
int i_crc = string_crc32();
|
|
throw_unless(101, sdeq(s_ascii, newc().store_uint(0x737472696E67, 12 * 4).endcs()));
|
|
throw_unless(102, sdeq(s_raw, newc().store_uint(0xABCDEF, 6 * 4).endcs()));
|
|
throw_unless(103, sdeq(s_addr, newc().store_uint(4, 3).store_int(-1, 8)
|
|
.store_uint(0x3333333333333333333333333333333333333333333333333333333333333333, 256).endcs()));
|
|
throw_unless(104, i_hex == 0x4142434445464748494A4B4C4D4E4F505152535455565758595A303132333435);
|
|
throw_unless(105, i_mini == 0x7a62e8a8);
|
|
throw_unless(106, i_maxi == 0x7a62e8a8ebac41bd6de16c65e7be363bc2d2cbc6a0873778dead4795c13db979);
|
|
throw_unless(107, i_crc == 2235694568);
|
|
return 0;
|
|
}
|
|
|
|
{-
|
|
TESTCASE | 0 | | 0
|
|
|
|
@code_hash 13830542019509784148027107880226447201604257839069192762244575629978154217223
|
|
-}
|