Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FunC v0.5.0: syntax, refactoring, bugfixes, and a testing framework #1026

Open
wants to merge 30 commits into
base: testnet
Choose a base branch
from

Commits on Jun 14, 2024

  1. [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
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    0bc6305 View commit details
    Browse the repository at this point in the history
  2. [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
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    a5d2a10 View commit details
    Browse the repository at this point in the history
  3. [FunC] CMake option -DFUNC_DEBUG for development purposes

    Seeing function name in debugger
    makes it much easier to delve into FunC sources
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    cbd7896 View commit details
    Browse the repository at this point in the history
  4. [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
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    bac4e3d View commit details
    Browse the repository at this point in the history
  5. [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.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    18050a7 View commit details
    Browse the repository at this point in the history
  6. [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.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    c74e49d View commit details
    Browse the repository at this point in the history
  7. [FunC] Apply camelCase to some tests to ensure code_hash remains unch…

    …anged
    
    In auto-tests, @code_hash controls bytecode stability.
    In legacy tests, expected hashes are specified in a separate file.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    a174f85 View commit details
    Browse the repository at this point in the history
  8. [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)
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    30572c7 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4994ae8 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    f217a7d View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    a3e9e03 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    85c60d1 View commit details
    Browse the repository at this point in the history
  13. [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.)
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    ef5719d View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    0628e17 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    acf0043 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    cdef830 View commit details
    Browse the repository at this point in the history
  17. [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.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    de57087 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    bb86dc0 View commit details
    Browse the repository at this point in the history
  19. [FunC] Deprecate pragma allow-post-modification

    All tests pass: it does not affect hashes (since modifying
    variables in a single expression was an error)
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    aaf3ca3 View commit details
    Browse the repository at this point in the history
  20. [FunC] Deprecate pragma compute-asm-ltr

    It changes all hashes, since the compiler needs to manipulate the stack
    in a different way now.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    1e4b20a View commit details
    Browse the repository at this point in the history
  21. [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)
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    aee5173 View commit details
    Browse the repository at this point in the history
  22. [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.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    7afa929 View commit details
    Browse the repository at this point in the history
  23. [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.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    7b8268d View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    8932c51 View commit details
    Browse the repository at this point in the history
  25. [FunC] Fix an issue of funcfiftlib.wasm which truncated long fif output

    As it turned out, PSTRING() created a buffer of 128K.
    If asm_code exceeded this buffer, it was truncated.
    I've just dropped PSTRING() from there in favor of std::string.
    unserialize committed Jun 14, 2024
    Configuration menu
    Copy the full SHA
    2da85a6 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    49a0d32 View commit details
    Browse the repository at this point in the history

Commits on Jun 21, 2024

  1. Configuration menu
    Copy the full SHA
    3520184 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5867d52 View commit details
    Browse the repository at this point in the history
  3. [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.
    unserialize committed Jun 21, 2024
    Configuration menu
    Copy the full SHA
    79721d2 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2024

  1. Configuration menu
    Copy the full SHA
    e2467b8 View commit details
    Browse the repository at this point in the history