-
Notifications
You must be signed in to change notification settings - Fork 114
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
…s in partial-eval.spec.ts. Otherwise other rules interfere when testing edge cases.
anton-trunov
approved these changes
Jul 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Towards #435
Added more tests that show edge cases in the associative3 rule.
[ ] I have updated CHANGELOG.mdI have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER