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

More test cases for partial evaluator #598

Merged
merged 36 commits into from
Jul 22, 2024
Merged

More test cases for partial evaluator #598

merged 36 commits into from
Jul 22, 2024

Conversation

jeshecdom
Copy link
Contributor

@jeshecdom jeshecdom commented Jul 22, 2024

Towards #435

Added more tests that show edge cases in the associative3 rule.

  • [ ] I have updated CHANGELOG.md
  • I have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER
  • 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
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

jeshecdom added 30 commits June 28, 2024 13:12
There are still some TODOs (so, this is only a partial commit):
- Implementation of association rule 3 and simple algebraic rules (to be added to file algebraic.ts)
described in comments of issue: #435
- Processing of structs, function calls, id lookups, ternary conditional operator.
- Extensive documentation, specially in the description of what each rule does.
- Extensive testing of the rewrite rules.
…Priorities are no longer a property of rules, but are managed by the optimizer.
…ded a function to call the partial evaluator in the interpreter to ease testing.
…-lang/tact/pull/528/files#r1666596822)

- Added `dummySrcInfo` as default parameter values to functions `__evalUnaryOp` and `__evalBinaryOp`. This way I was able to eliminate them and simply leave `evalUnaryOp` and `evalBinaryOp` as exportable functions. (https://github.com/tact-lang/tact/pull/528/files#r1666598821)
- Renamed ValueExpression for AstValue (https://github.com/tact-lang/tact/pull/528/files#r1666602072)
- Used Dummy interval in grammar.ts (https://github.com/tact-lang/tact/pull/528/files#r1666602072)
- Changed interfaces for abstract classes (https://github.com/tact-lang/tact/pull/528/files#r1666604615)
- Renamed `areEqualExpressions` to `eqExpressions`, and moved it to `ast.ts`. Used `eqNames` and moved `ast1.kind === ast2.kind` check before switch. (https://github.com/tact-lang/tact/pull/528/files#r1666609433)
…ity. Still in the middle of major refactoring, but I expect an increase in the expressions that can be simplified,

specially after I add operators /, >>, <<, %, and further combinations of -,+ that previously was not possible to simplify.
- Added test cases for eqExpressions function in ast.ts.
- Changed if statement for conditional expressions in optimizer/util.ts.
- Changed lookupID for lookupName and evalX for fullyEvalX in constEval.ts.
- Moved AstValue to ast.ts.
- Removed try/catch from eqExpressions in ast.ts.
- Removed `traverse` from ast.ts since it has been already moved to iterators.ts
- Moved expr-equality.spec.ts and partial-eval.spec.ts to src/grammar/test
- Added test cases for `isValue' function in ast.ts in src/grammar/test/expr-is-value.spec.ts.
- Supports further combinations of +/-, specially when - is on the right, i.e., x + (y - z).
- Supports all the following algebraic rules (in file src/optimizer/algebraic.ts):
  . x + 0 ---> x
  . x - 0 ---> x
  . 0 - x ---> -x
  . x * 0 ---> 0  (x an identifier)
  . x * 1 ---> x
  . x - x ---> 0  (x an identifier)
  . x + x ---> x * 2
@anton-trunov anton-trunov self-assigned this Jul 22, 2024
@anton-trunov anton-trunov added this to the v1.4.1 milestone Jul 22, 2024
@anton-trunov anton-trunov merged commit ce7c502 into main Jul 22, 2024
3 checks passed
@anton-trunov anton-trunov deleted the partial_evaluator branch July 22, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants