mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-15 04:32:21 +00:00
* FunC pragmas: allow-post-modification and compute-asm-ltr * Warn if #pragma is enabled only in included files * Add tests for new pragmas * Add special ops for "allow-post-modification" only when needed * Update FunC version to 0.4.1 * Allow empty inlines (#10) Co-authored-by: SpyCheese <mikle98@yandex.ru>
113 lines
3 KiB
Text
113 lines
3 KiB
Text
tuple empty_tuple() asm "NIL";
|
|
forall X -> (tuple, ()) tpush(tuple t, X x) asm "TPUSH";
|
|
|
|
tuple asm_func_1(int x, int y, int z) asm "3 TUPLE";
|
|
tuple asm_func_2(int x, int y, int z) asm (z y x -> 0) "3 TUPLE";
|
|
tuple asm_func_3(int x, int y, int z) asm (y z x -> 0) "3 TUPLE";
|
|
tuple asm_func_4(int a, (int, (int, int)) b, int c) asm (b a c -> 0) "5 TUPLE";
|
|
|
|
(tuple, ()) asm_func_modify(tuple a, int b, int c) asm (c b a -> 0) "SWAP TPUSH SWAP TPUSH";
|
|
|
|
global tuple t;
|
|
|
|
int foo(int x) {
|
|
t~tpush(x);
|
|
return x * 10;
|
|
}
|
|
|
|
(tuple, tuple) test_old_1() method_id(11) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_1(foo(11), foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_old_2() method_id(12) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_2(foo(11), foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_old_3() method_id(13) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_3(foo(11), foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_old_4() method_id(14) {
|
|
t = empty_tuple();
|
|
tuple t2 = empty_tuple();
|
|
;; This actually computes left-to-right even without compute-asm-ltr
|
|
tuple t2 = asm_func_4(foo(11), (foo(22), (foo(33), foo(44))), foo(55));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_old_modify() method_id(15) {
|
|
t = empty_tuple();
|
|
tuple t2 = empty_tuple();
|
|
t2~asm_func_modify(foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_old_dot() method_id(16) {
|
|
t = empty_tuple();
|
|
tuple t2 = foo(11).asm_func_3(foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
#pragma compute-asm-ltr;
|
|
|
|
(tuple, tuple) test_new_1() method_id(21) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_1(foo(11), foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_new_2() method_id(22) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_2(foo(11), foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_new_3() method_id(23) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_3(foo(11), foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_new_4() method_id(24) {
|
|
t = empty_tuple();
|
|
tuple t2 = asm_func_4(foo(11), (foo(22), (foo(33), foo(44))), foo(55));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_new_modify() method_id(25) {
|
|
t = empty_tuple();
|
|
tuple t2 = empty_tuple();
|
|
t2~asm_func_modify(foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
(tuple, tuple) test_new_dot() method_id(26) {
|
|
t = empty_tuple();
|
|
tuple t2 = foo(11).asm_func_3(foo(22), foo(33));
|
|
return (t, t2);
|
|
}
|
|
|
|
() main() {
|
|
}
|
|
|
|
{-
|
|
method_id | in | out
|
|
TESTCASE | 11 | | [ 11 22 33 ] [ 110 220 330 ]
|
|
TESTCASE | 12 | | [ 33 22 11 ] [ 330 220 110 ]
|
|
TESTCASE | 13 | | [ 22 33 11 ] [ 220 330 110 ]
|
|
TESTCASE | 14 | | [ 11 22 33 44 55 ] [ 220 330 440 110 550 ]
|
|
TESTCASE | 15 | | [ 33 22 ] [ 220 330 ]
|
|
TESTCASE | 16 | | [ 22 33 11 ] [ 220 330 110 ]
|
|
TESTCASE | 21 | | [ 11 22 33 ] [ 110 220 330 ]
|
|
TESTCASE | 22 | | [ 11 22 33 ] [ 330 220 110 ]
|
|
TESTCASE | 23 | | [ 11 22 33 ] [ 220 330 110 ]
|
|
TESTCASE | 24 | | [ 11 22 33 44 55 ] [ 220 330 440 110 550 ]
|
|
TESTCASE | 25 | | [ 22 33 ] [ 220 330 ]
|
|
TESTCASE | 26 | | [ 11 22 33 ] [ 220 330 110 ]
|
|
-}
|