mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-13 03:32:22 +00:00
* Add special string literals "..."? (s,a,u,h,) * Add string literal H (256-bit hash) * Add string literal c (crc32) * Use td::hex_encode instead of homebrew function and add test * Fix error codes and use more generic address * Add support for int and slice constants * Add support for strongly typed constants * Add support for precompiled constant expressions (hard!) Co-authored-by: starlightduck <starlightduck@gmail.com>
55 lines
1.3 KiB
Text
55 lines
1.3 KiB
Text
const int1 = 1, int2 = 2;
|
|
|
|
const int int101 = 101;
|
|
const int int111 = 111;
|
|
|
|
const int1r = int1;
|
|
|
|
const str1 = "const1", str2 = "aabbcc"s;
|
|
|
|
const slice str2r = str2;
|
|
|
|
const str1int = 0x636f6e737431;
|
|
const str2int = 0xAABBCC;
|
|
|
|
const int nibbles = 4;
|
|
|
|
int iget1() { return int1; }
|
|
int iget2() { return int2; }
|
|
int iget3() { return int1 + int2; }
|
|
|
|
int iget1r() { return int1r; }
|
|
|
|
slice sget1() { return str1; }
|
|
slice sget2() { return str2; }
|
|
slice sget2r() { return str2r; }
|
|
|
|
const int int240 = ((int1 + int2) * 10) << 3;
|
|
|
|
int iget240() { return int240; }
|
|
|
|
builder newc() asm "NEWC";
|
|
slice endcs(builder b) asm "ENDC" "CTOS";
|
|
int sdeq (slice s1, slice s2) asm "SDEQ";
|
|
builder stslicer(builder b, slice s) asm "STSLICER";
|
|
|
|
_ main() {
|
|
int i1 = iget1();
|
|
int i2 = iget2();
|
|
int i3 = iget3();
|
|
|
|
throw_unless(int101, i1 == 1);
|
|
throw_unless(102, i2 == 2);
|
|
throw_unless(103, i3 == 3);
|
|
|
|
slice s1 = sget1();
|
|
slice s2 = sget2();
|
|
slice s3 = newc().stslicer(str1).stslicer(str2r).endcs();
|
|
|
|
throw_unless(int111, sdeq(s1, newc().store_uint(str1int, 12 * nibbles).endcs()));
|
|
throw_unless(112, sdeq(s2, newc().store_uint(str2int, 6 * nibbles).endcs()));
|
|
throw_unless(113, sdeq(s3, newc().store_uint(0x636f6e737431ABCDEF, 18 * nibbles).endcs()));
|
|
|
|
int i4 = iget240();
|
|
throw_unless(104, i4 == 240);
|
|
}
|