1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-02-15 04:32:21 +00:00
Commit graph

86 commits

Author SHA1 Message Date
Aleksandr Kirsanov
e2467b8ba4
[FunC] Reserve '!' for the future, identifiers can't start with it 2024-06-24 14:32:12 +03:00
Aleksandr Kirsanov
79721d230e
[FunC] Require parenthesis in tricky bitwise precedence cases
Example: "flags & 0xFF != 0" is equivalent to "flags & 1",
most likely it's unexpected.
Example: "a << 2 + 1" (equal to "a << 3", probably unexpected).

The only way to suppress this error for the programmer
is to use parenthesis.
2024-06-22 01:49:27 +03:00
Aleksandr Kirsanov
5867d52926
[FunC] Bump FunC version to v0.5.0 2024-06-21 15:41:03 +03:00
Aleksandr Kirsanov
3520184553
[FunC] Fix a bug with << operator to zero value 2024-06-21 15:40:39 +03:00
Aleksandr Kirsanov
49a0d32c1b
[FunC] Drop a folder crypto/func/test, it's unused 2024-06-14 15:22:59 +03:00
Aleksandr Kirsanov
8932c515c9
[FunC] Produce an error on get methods hash (method_id) collision 2024-06-14 15:22:59 +03:00
Aleksandr Kirsanov
7b8268d99f
[FunC] Deprecate method_id specifier, introduce get keyword
`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.
2024-06-14 15:22:59 +03:00
Aleksandr Kirsanov
7afa9292c3
[FunC] Change priority of & | ^ operators to a more intuitive one
Before, such code `if (slices_equal() & status == 1)` was parsed
as `if( (slices_equal()&status) == 1 )`.
Note, that this change leads to hash changes of some verified contracts,
but a new priority is more expected from the user experience.
2024-06-14 15:22:59 +03:00
Aleksandr Kirsanov
aee51731ce
[FunC] Refactor allow-post-modification, stop producing disabled Op::_Let
Before, #pragma allow-post-modification produced Op::_Let for every
tensor entity (which became non-disabled if modification really happened).
Although they are stripped off by the compiler and don't affect fif output,
they pollute intermediate "AST" representation (ops).
Now, Op::_Let is added only if var modification actually happens
(which is very uncommon for real-wise code)
2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
1e4b20a061
[FunC] Deprecate pragma compute-asm-ltr
It changes all hashes, since the compiler needs to manipulate the stack
in a different way now.
2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
aaf3ca335d
[FunC] Deprecate pragma allow-post-modification
All tests pass: it does not affect hashes (since modifying
variables in a single expression was an error)
2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
bb86dc0f96
[FunC] Add an ability to deprecate pragmas 2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
de570873d7
[FunC] Add builtin functions to stdlib.fc
Note, that I have not added all builtin functions.
I filtered out strange and actually unused in practice,
like "int_at()" and similar, or "run_method0()" and similar.
(Probably, they should be dropped off even from builtins)

Also, I've modified some stdlib.fc legacy tests just to ensure
that a resulting hash doesn't change.
2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
cdef8302b0
[FunC] Add builtin keyword to be used in stdlib later on 2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
acf0043342
[FunC] Add pragma remove-unused-functions for simple dead code elimination 2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
0628e17c7d
[FunC] Use td::OptionParser in func-main.cpp 2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
ef5719d7e6
[FunC] Forbid impure operations inside pure functions
In stdlib, all existing pure functions are asm-implemented.
But since we introduced a `pure` keyword applicable to user-defined functions,
we need to check that they won't have any side effects
(exceptions, globals modification, etc.)
2024-06-14 15:22:58 +03:00
Aleksandr Kirsanov
85c60d1263
[FunC] Make all functions impure by default, add "pure" specifier 2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
a3e9e03019
[FunC] Fixed some impure specifiers in stdlib.fc 2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
f217a7d312
[FunC] Forbid auto-creating undefined symbols 2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
4994ae8edd
[FunC] Convert stdlib.fc to traditional-style //comments 2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
30572c77d6
[FunC] Support traditional // and /**/ comments
They work alongside Lisp-style ;; and {--}, without any #pragma.
Conceptually, a new syntax should be disabled by default
and activated using a special compiler option.
But now, we don't have an easy way to provide compiler options
in func-js, blueprint, etc.
Note, that introducing per-file #pragma is a wrong approach here,
since if we want to fire human-readable error on using '//' without pragma,
lexer should nevertheless work differently.
(this could be controlled by a launch option, but see above)
2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
a174f858be
[FunC] Apply camelCase to some tests to ensure code_hash remains unchanged
In auto-tests, @code_hash controls bytecode stability.
In legacy tests, expected hashes are specified in a separate file.
2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
c74e49d467
[FunC] Enrich testing framework, add code hash checking
@code_hash to match (boc) hash of compiled.fif against expected.
While being much less flexible than @fif_codegen, it nevertheless
gives a guarantee of bytecode stability on compiler modifications.
2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
18050a7591
[FunC] Auto-inline functions-wrappers T f(...args) { return anotherF(...args); }
This will allow to easily implement camelCase wrappers aside stdlib,
even without changing hashes of existing contracts.
Also, stdlib renamings could be easily performed in the same manner,
even with arguments reordered.
2024-06-14 15:22:57 +03:00
Aleksandr Kirsanov
bac4e3df97
[FunC] Enrich testing framework, add fif output patterns
* @fif_codegen to match compiled.fif against an expected pattern
* @fif_codegen_avoid to ensure compiled.fif doesn't contain a substring
* both in Python and JS run_tests
* consider tests/codegen_check_demo.fc for examples
2024-06-14 15:22:56 +03:00
Aleksandr Kirsanov
cbd78964c5
[FunC] CMake option -DFUNC_DEBUG for development purposes
Seeing function name in debugger
makes it much easier to delve into FunC sources
2024-06-14 15:22:56 +03:00
Aleksandr Kirsanov
a5d2a1003f
[FunC] Enrich and refactor testing framework, add negative tests
* fully refactor run_tests.py, make it extensible for the future
* an ability to write @compilation_should_fail tests
* an ability to launch run_tests.py for a single .fc file
* keep run_tests.js in sync with run_tests.py
* extract legacy_tests names/hashes to a separate file
  shared between legacy_tester.py and legacy_tester.js
2024-06-14 15:22:56 +03:00
Aleksandr Kirsanov
0bc6305f96
[FunC] Change some fields to enums instead of integers
It makes it easier to understand/debug
Also, drop some unused enum values from that cases
2024-06-14 15:22:56 +03:00
SpyCheese
5847897b37
Various changes in TVM, github builds and tests (#793)
* Bugfixes in TVM and node

* Upgrade to C++17

* Improve GitHub builds

* Fix existing tests and partially integrate them into builds

---------

Co-authored-by: neodiX42 <namlem@gmail.com>
Co-authored-by: EmelyanenkoK <emelyanenko.kirill@gmail.com>
2023-11-03 14:43:34 +03:00
EmelyanenkoK
583178ccb1
FunC: enable asserts and fix try/catch stack corruption (#699)
* FunC: enable asserts in Release

* FunC: Fix analyzing infinite loops

* FunC: Allow catch with one tensor argument

* FunC: Fix try/catch stack corruption

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2023-05-15 15:31:42 +03:00
SpyCheese
5abfe2337e
Catchain improvements (#698)
* Fix "sgn" in fift; fix marking infinite loops as noterurn in func

* TON-P1-1: Remove unused catchain queries

* TON-P1-15: Avoid synchronization with self

* TON-P1-3, TON-P1-17: Disallow more than one candidate per src per round (to prevent flood), add checks to process_broadcast

* TON-P1-10: Fix fast/slow attempts

* TON-P1-14: Add named constants

* TON-P1-18, TON-P1-19: Alloc temporary memory in the same way as persistent memory

* TON-P1-20: Add comment to choose_blocks_to_approve

* TON-P1-16: Avoid creating two catchain blocks on need_new_block

* TON-P1-8: Add some validation to validator-engine parameters

* TON-P1-6: Don't allow sending the same block many times

Many requests for the same block are not unusual (however, there's no need to answer them all)

* TON-P1-2: Enable prohibiting dependencies from blamed nodes (2.7.5 in CatChain doc), fix processing blame proofs

* Best practices

bp-6: Fix incorrect warning
bp-7: Remove unused code
bp-8: Bring back PerfWarningTimer logging (only when no callback)
bp-9: Remove unnecessary condition
bp-11: Remove commented-out code
bp-13: Divide code in validator-session-state
Adherence to Specification: Fix typo
2023-05-10 12:57:57 +03:00
EmelyanenkoK
5606418234
FunC: Prohibit unifying tensors and "forall" vars (#684)
* FunC: Prohibit unifying tensors and "forall" vars

* Bump funC version to 0.4.4

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2023-04-27 10:23:04 +03:00
EmelyanenkoK
8b0d6a2665
Add WASM FunC autotests (#673)
* feat: func wasm autotests

* fixes necessary for func wasm autotests

---------

Co-authored-by: krigga <krigga7@gmail.com>
2023-04-19 21:29:41 +03:00
EmelyanenkoK
8eb167b76a
Fix FunC UB (#656)
* Fix UB in func

* Improve optimizing int consts and unused variables in FunC

* Bump funC version to 0.4.3

* Fix analyzing repeat loop

---------

Co-authored-by: SpyCheese <mikle98@yandex.ru>
2023-04-03 10:13:39 +03:00
EmelyanenkoK
7da30e1e7f
Add PRNG with normal distribution to mathlib.fc (#646)
* Add random with normal distribution

* Fix hex arguments in mathlib testcases
2023-03-13 16:49:30 +03:00
Dan Volkov
4590ed381b
Make funcfiftlib compilation compatible with modern compilers (#618)
* wip: make funcfiftlib compilation compatible with modern compilers

* wip: add methods needed for another compiler

* fix: tdutils port config if emscripten

* feat: func source and realpath callback

* fix: invalid fift compilation exceptions

---------

Co-authored-by: krigga <krigga7@gmail.com>
2023-03-09 17:37:15 +03:00
EmelyanenkoK
04d4ae2dec Add version printing to legacy tester 2023-03-06 14:03:29 +03:00
EmelyanenkoK
c2c9a93916
Bump funC version to 0.4.2 2023-03-03 10:33:22 +03:00
SpyCheese
0578cb4a42
Fix typos, UBs and warnings (#625) 2023-02-28 12:06:09 +03:00
SpyCheese
c6143715cc
Fix some error handling in FunC (#599) 2023-01-23 13:01:40 +03:00
EmelyanenkoK
653c88aa9d
Add pragmas to funC for precise control of computation order (#589)
* 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>
2023-01-13 12:45:04 +03:00
EmelyanenkoK
6b49d6a382
Add legacy_tester for existing funC contracts (#588)
* Add legacy_tester for existing funC contracts

* Add storage-contracts and pragma options
2023-01-12 12:33:15 +03:00
EmelyanenkoK
a1d8a5e4f3
Add complex assigns to FunC and fix UB (#574)
* Fixed complex funC setglob cases

* Forbid modifying local variables after using them in the same tensor

* Fix analyzing "while" in func

* Update funC version (#9)

* Update stress tester

* Fix using variable after move

Co-authored-by: krigga <krigga7@gmail.com>
Co-authored-by: SpyCheese <mikle98@yandex.ru>
2022-12-29 18:06:13 +03:00
SpyCheese
8bfad35e93
Add try/catch to func stress-tester (#565) 2022-12-22 15:26:58 +03:00
EmelyanenkoK
e1be988df5
Add try/catch to FunC (#560)
* Add try-catch

* Fix 'return' bugs

* Update tests

* Fix 'SETCONTVARARGS' bug

* Fix 'SETCONTVARARGS' bug again

* Check deep stack

* Add throw_arg

Co-authored-by: legaii <jgates.ardux@gmail.com>
2022-12-22 15:26:39 +03:00
SpyCheese
91580e7ebf Fix emulate_not in func 2022-10-12 14:09:15 +03:00
SpyCheese
fc8da44940
Fix compilation of muliplication (#475) 2022-09-29 09:24:15 +03:00
SpyCheese
5c2ad4a6c7 Tests for func with scripts 2022-09-23 16:27:18 +03:00
EmelyanenkoK
6a72aba9af
Bump func version 2022-09-22 16:55:14 +03:00