Commit graph

501 commits

Author SHA1 Message Date
Sei Lisa
59451b90e5 On second thought, parentheses are only needed for ~ because it binds tighter. 2015-02-27 20:12:17 +01:00
Sei Lisa
25cbb91b6e Fix bug where n*3+1 was optimized as -~n*3 rather than as -~(n*3). Also merge -2 with -1 and +2 with +1. 2015-02-27 20:05:14 +01:00
Sei Lisa
2047a128fb Add two TODO items about parameters to common functions. 2015-02-27 19:20:31 +01:00
Sei Lisa
536b1ed2f9 Fix comments that mentioned the wrong property. 2015-02-27 19:18:28 +01:00
Sei Lisa
07590ea850 Fix bug where (a * 5) + 4 was converted to a + 5 + 4. 2015-02-27 19:12:22 +01:00
Sei Lisa
4c08b7173a minor clarification of comment 2015-02-27 04:46:23 +01:00
Sei Lisa
d2fb302684 Add more functions whose result is known for certain operands. 2015-02-12 07:49:32 +01:00
Sei Lisa
6fb947fbc9 (Limitedly) apply distributive law for string and integer addition. 2015-02-12 07:47:35 +01:00
Sei Lisa
4461f36dce Emergency fix for a bug discovered via a nPose plugin. 2015-02-12 07:46:02 +01:00
Sei Lisa
0a0e5926d5 Fix bug where negative signs of global integers weren't being output. 2015-02-12 04:23:47 +01:00
Sei Lisa
b62fb9a808 Make isstring and iskey stricter, plus one cosmetic change 2015-02-11 18:17:01 +01:00
Sei Lisa
86ca90a65b Remove obsolete comment 2015-02-11 17:12:35 +01:00
Sei Lisa
db862bb4a6 Multi-commit:
- Fix a bunch of bugs found during the debut of the LSL calculator.
- Add infrastructure for functions to be able to produce a result or not depending on arguments. Fixes the llBase64ToInteger/llXorBase64/llXorBase64StringsCorrect cases where they are not deterministic, and allows for the addition of some extra functions whose value can be determined in some cases (e.g. llDetectedType(-1) is always 0). Added several such functions in a new module.
- Add the constant folding option to the help and the default options.
2015-02-11 05:43:13 +01:00
Sei Lisa
716be215f2 Fix double negation and constant nodes; add optimization of -~-~ chains. Fix a case of addition. Add a case of parentheses.
(Changes were pending since Aug 19)
2014-12-13 14:16:28 +01:00
Sei Lisa
e89869a563 Add TODOs 2014-12-13 13:12:02 +01:00
Sei Lisa
c2a30fb9ee Simplify const + nonconst + const and nonconst + const + const. 2014-08-19 19:45:47 +02:00
Sei Lisa
c2437b33e7 Optimize [] + nonlist as (list)nonlist.
And minor comment changes.
2014-08-17 16:31:46 +02:00
Sei Lisa
2e87d6df8c llModPow has a delay so exclude it from SEF table. 2014-08-17 16:03:20 +02:00
Sei Lisa
f3bd091a6d Update Side-Effect Free table with latest additions. 2014-08-17 15:43:41 +02:00
Sei Lisa
8e5166bb2e Move the constant folding code to lslfoldconst.py.
lsloptimizer remains as the "conductor" and option handler.

As a result, new options have been added to enable DCR and constant folding.
2014-08-13 14:19:58 +02:00
Sei Lisa
beea757a0a Fork (add a copy of) lsloptimizer.py as lslfoldconst.py.
This commit is just a copy, to hopefully help git track it. The changes come in the next commit.
2014-08-13 14:02:05 +02:00
Sei Lisa
36759cacba Move PythonType2LSL to the main lsloptimizer script.
This is preparation work for splitting the optimizer.
2014-08-13 13:44:54 +02:00
Sei Lisa
f3301b07c6 Fix test case. 2014-08-13 13:35:19 +02:00
Sei Lisa
ed4b963356 Rename _ops to _toks to eliminate ambiguity and facilitate a future merge. 2014-08-13 13:34:09 +02:00
Sei Lisa
62904dc02c BUG-6466 was resurrected; the previous RE is valid. 2014-08-13 13:31:10 +02:00
Sei Lisa
72b4b08cbe Add dead code elimination module. 2014-08-10 02:07:00 +02:00
Sei Lisa
e3d8533caf Use self.shrinknames instead of checking the options again. 2014-08-10 02:05:31 +02:00
Sei Lisa
9295cb104a Cast() now adds parentheses where necessary. 2014-08-10 01:14:29 +02:00
Sei Lisa
0d81f132ab Fix bug where the assigned type was not checked in declarations. 2014-08-10 00:44:57 +02:00
Sei Lisa
9cf18ade60 Improve output of floats by minimizing them further. 2014-08-09 23:20:40 +02:00
Sei Lisa
649de92ebd Restart numbering at every parameter table. Saves many identifiers. 2014-08-09 23:19:00 +02:00
Sei Lisa
de4d6f8857 Propagate X flag in Cast(): if the expression executes, so does the cast. 2014-08-08 04:05:01 +02:00
Sei Lisa
c080f4b596 Fix detection of SEF in assignments with vector/rot fields as LHS. 2014-08-08 04:03:37 +02:00
Sei Lisa
7a4a6d221e Fix field assignment. Add regression test. 2014-08-08 00:52:23 +02:00
Sei Lisa
bf238f79b6 Add Side-Effect-Free table of functions. 2014-08-08 00:42:52 +02:00
Sei Lisa
5d7829dc9d Fix a bunch of SEF-related bugs and forgotten cases. 2014-08-08 00:41:07 +02:00
Sei Lisa
7a6e13b786 Remove line that does nothing useful. 2014-08-07 22:10:15 +02:00
Sei Lisa
954b8d81d4 Forgot a SEF case. 2014-08-07 22:09:00 +02:00
Sei Lisa
a03e0261ff Add TODO 2014-08-06 22:49:57 +02:00
Sei Lisa
9c4d81db08 Implement side-effect-free (SEF) analysis. Also optimize x++ to ++x.
As an additional bonus, the condition folding function is now the one that converts a condition to -1, relieving that burden from the rest of the code and simplifying tests.
2014-08-06 04:30:26 +02:00
Sei Lisa
0a7d409a4e Report errors at EOL as errors at next line. 2014-08-06 04:12:44 +02:00
Sei Lisa
8d1e819771 Cosmetic changes: docstring style; remove commented code. 2014-08-06 04:11:57 +02:00
Sei Lisa
5773449edb Convert warnings to add the WARNING: title in the function. 2014-08-05 15:55:49 +02:00
Sei Lisa
58e22f77ce Prepare for the incoming Dead Code Removal module. 2014-08-05 15:47:14 +02:00
Sei Lisa
bcc7fe3524 Fix bug in FoldStmt where EXPR nodes were not optimized out. 2014-08-05 15:38:19 +02:00
Sei Lisa
24a32c30e3 Fix bug where folding a FOR loop with const false cond produced bad code.
More precisely, the initializator list was not wrapped into EXPR nodes. Now it is.

While on it, fix a minor bug (the substitutive of a FOR statement should produce no output type), and change order of execution to the actual one (iterators come last).
2014-08-04 02:19:36 +02:00
Sei Lisa
17e94a0d0f Add FoldCond as a stub. Change cond constant to -1. Add support for EXPR.
(EXPR as a statement, not as a general 'expression')
2014-08-03 20:06:50 +02:00
Sei Lisa
67f3061e19 Fix state switch error reporting bug. Add 'Not all code paths...' error.
Add corresponding tests too. Simplify the identifier renaming coverage test. Also remove extra newlines from library reading code.

We've had to give up on the 'else if' loop-instead-of-recurse optimization, to properly propagate the LastWasReturn flag.
2014-08-03 04:50:18 +02:00
Sei Lisa
14e5b78d94 Remove empty statements. Optimize out 'else ;' and 'else {}'.
Without empty statement removal, {;} would trick the optimizer into believing the statement was not empty. E.g. if(x) ; else {;} would not remove the else.
2014-08-02 10:40:59 +02:00
Sei Lisa
dce6419b4f Deal with the state change in globals error. 2014-08-01 23:51:24 +02:00