These changes make it ready for prime time, but main.py still does not expose the functionality.
Changes include:
- Instead of passing paths, we pass parameters, which are parsed to extract the paths (no syspaths, only regular paths) and the defines.
- Errors in the preprocessor are reported to the caller (i.e. to main).
1. When the last statement of a function is a RETURN statement which is syntactically required, it could still be deleted.
2. The child of a RETURN statement could be removed if the statement was not executed.
This commit fixes both issues.
Bug report and test case provided by @Tonaie. Fixes#14.
The limits were too low to be reasonable with more modern versions of Python.
Double exceptions were possible. Make use of soft/hard limits; raise the soft limit in case of exception. That should make it less likely to get a double exception.
Per bug report by @LeonaMorro (thanks!)
Fixes GitHub issue report #9 (fix#9).
E.g. llSubStringIndex(...) > -1 was converted into !~llSubStringIndex(...) which is incorrect. We even had a test case for it... with a wrong expected response file.
Bug report and test case by Sinha Hynes (thanks!)
vector * quaternion: Simplified by precalculating the repeated products and removing math.fsum.
quaternion * quaternion: Add more F32's to get a result closer to SL's (still not there, but we're definitively closer now).
We left out quaternion/quaternion in the tests, and the q*q test was not general enough (had many zeros). Remedied that.
The algorithm for adding parentheses around unary operators was not working properly. It converted a * (-b) * c into a * -b * c, which LSL handles as a * -(b * c).
Fix and add test cases for that. One of the test cases shows an example where the difference matters: 0 * (-1e20) * 1e20 should result in 0.0, but if wrongly parenthesized, it gives NaN, because 1e20*1e20 gives infinity due to float overflow, and minus infinity times 0 is indeterminate.
The addition of parentheses has been improved, but it still does not eliminate every redundant parenthesis.
Also fix the horrendous typo of using "operands" where it should be "operators".
In the same places as state changes are allowed, i.e. in places where a parent of the AST node is a WHILE/DO/FOR or an IF without ELSE, it's allowed to use return statements with expressions that return void, e.g. llDie(), provided the function itself is declared as returning void.
The construction, when found, is rewritten to '{<void expression>; return;}' because the optimizer is not designed to deal with these monsters.
We've renamed the variable SuspiciousStSw to PruneBug, because it's used for both purposes now, though a better name might have been PruneBugPendingChecks, because these are only errors if the IF has an ELSE. We've also added the exception to raise as part of the data stored in the list.
Per report by Tonaie Resident.
Revert "Add support for C11-style _Pragma operator on processpre".
Revert "Add unit test for the _Pragma operator".
This reverts commits 31fcb331c7 and e261ac2121.
This should rather be the job of the preprocessor, which should generate #pragma lines. gcc does that.
Reverts f958b1cdf9, and adds the possibility of adding parameters after the system-inserted ones through a new command line parameter -A/--postarg.
Enables using e.g. both a command interpreter which requires the file to execute before any other parameters, and overriding the default definitions.