mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 19:22:37 +00:00
Lots of changes, actually. Most noticeable are: - traditional //comments - #include -> import - a rule "import what you use" - ~ found -> !found (for -1/0) - null() -> null - is_null?(v) -> v == null - throw is a keyword - catch with swapped arguments - throw_if, throw_unless -> assert - do until -> do while - elseif -> else if - drop ifnot, elseifnot - drop rarely used operators A testing framework also appears here. All tests existed earlier, but due to significant syntax changes, their history is useless.
48 lines
1.4 KiB
Text
48 lines
1.4 KiB
Text
fun unused1(): int { return 2; }
|
|
fun unused2(): int { return unused1(); }
|
|
fun unused3(x: int): int { return x * 2+unused2(); }
|
|
|
|
fun used_from_noncall1(): int { return 10; }
|
|
fun used_as_noncall1(): int { return used_from_noncall1(); }
|
|
|
|
const int20: int = 20;
|
|
fun used_from_noncall2(): int { return int20; }
|
|
fun used_as_noncall2(): int { return 0 * 0 + used_from_noncall2() + (0 << 0); }
|
|
|
|
global unused_gv: int;
|
|
global used_gv: auto;
|
|
|
|
fun receiveGetter(): (() -> int) { return used_as_noncall2; }
|
|
|
|
@pure
|
|
fun usedButOptimizedOut(x: int): int { return x + 2; }
|
|
|
|
fun main(): (int, int, int) {
|
|
used_gv = 1;
|
|
used_gv = used_gv + 2;
|
|
var getter1 = used_as_noncall1;
|
|
var getter2 = receiveGetter();
|
|
usedButOptimizedOut(used_gv);
|
|
return (used_gv, getter1(), getter2());
|
|
}
|
|
|
|
/**
|
|
@experimental_options remove-unused-functions
|
|
|
|
@testcase | 0 | | 3 10 20
|
|
|
|
@fif_codegen DECLPROC used_as_noncall1
|
|
@fif_codegen DECLGLOBVAR used_gv
|
|
|
|
@fif_codegen_avoid DECLPROC unused1
|
|
@fif_codegen_avoid DECLPROC unused2
|
|
@fif_codegen_avoid DECLPROC unused3
|
|
@fif_codegen_avoid DECLGLOBVAR unused_gv
|
|
|
|
Note, that `usedButOptimizedOut()` (a pure function which result is unused)
|
|
is currently codegenerated, since it's formally reachable.
|
|
This is because optimizing code is a moment of codegen for now (later than marking unused symbols).
|
|
|
|
@fif_codegen DECLPROC usedButOptimizedOut
|
|
@fif_codegen_avoid usedButOptimizedOut CALLDICT
|
|
*/
|