tact
tact copied to clipboard
First version of interpreter
Towards #512 and #455.
It supports expressions and statements. Specifically:
- Calls to module-level functions without attributes (including recursive calls). Unsupported attributes: native, inline, extends, mutates
- Reference to module-level constant declarations and declared local variables.
- All expressions supported by the constant evaluator. In fact, I refactored the constant evaluator and moved all its code into the interpreter, since the constant evaluator is basically an expression interpreter (otherwise I was producing a lot of code duplication, and moving the code to the interpreter I have more control, instead of having the code in two separate files.).
- All the following statements: simple and augmented assignments (but only for identifiers as path expressions), let, conditions, repeat, do-until, while, return. Unsupported: simple and augmened assignments for more complex path expressions, try/catch, foreach.
The interpreter assumes that before calling the interpreter, the user has executed the typechecker. The interpreter relies on CompilerContext to extract declarations.
- [ ] I have updated CHANGELOG.md
- [ ] ~~I have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER~~
- [X] I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
- [X] I have run all the tests locally and no test failure was reported
- [X] I have run the linter, formatter and spellchecker
- [X] I did not do unrelated and/or undiscussed refactorings