Sei Lisa
c555a01a48
It's possible to enter Infinity as a float constant, so do that rather than the (float)"inf" kludge. It remains for NaN though.
2016-01-06 01:21:04 +01:00
Sei Lisa
1636e56266
The llGetListLength optimization can be applied to arbitrary expressions.
2015-07-13 07:16:32 +02:00
Sei Lisa
f5d150f7c9
Fix typo in IsBool and add coverage test. Report and fix by Code Violet.
2015-06-17 02:51:46 +02:00
Sei Lisa
4302ea846d
Don't fall through after optimizing a negable comparison, as it's folded already and the variables were incorrectly set and broke our invariants.
2015-04-21 06:11:25 +02:00
Sei Lisa
d58bc2d350
Implement library function parameter optimization.
...
So far only two kinds: angle in llSensor[Repeat] and null keys in functions that take a key parameter.
Closes two TODOs.
2015-04-21 04:56:09 +02:00
Sei Lisa
be86216124
Do -(b + -c) -> -b+c. Also when a-b is transformed to a+-b, fold -b.
2015-03-29 06:09:26 +02:00
Sei Lisa
a859b3e8e4
Loop over (0, 1) instead of duplicating the code.
2015-03-29 05:43:38 +02:00
Sei Lisa
a19d49d193
Implement optimization of a>=const -> a>const-1 and similar, and fix cases where | -> & or a<0 -> a&0x80000000 is counter-productive.
...
The logic becomes quite convoluted.
2015-03-29 03:47:54 +02:00
Sei Lisa
274b563390
No need to simplify !!! to ! as FoldCond already takes care of that.
2015-03-29 01:27:08 +01:00
Sei Lisa
9aae475125
Implement bool(x < 0) -> bool(x & 0x80000000) w/ function domain check.
...
Cleans up three TODOs.
2015-03-29 00:16:17 +01:00
Sei Lisa
2cb9ad6fe5
Implement a first version of IsBool and use it to optimize && -> &
2015-03-28 23:49:10 +01:00
Sei Lisa
08f48a5c32
Make program flow more consistent, add TODO, refine another TODO.
2015-03-28 23:47:45 +01:00
Sei Lisa
c154d5eb0d
Deal with a number of issues in some expressions.
...
- Move TODO of <0 to !=-1 to boolean, as it's counter-productive otherwise.
- All a!=b except list!=list are equivalent to !(a==b).
- Change a>b to b<a to simplify cases to analize.
- Proper fall-through in some spots, or return in some others where it didn't apply.
- Simplify handling of a<-2147483648 as a&0, falling through, instead of coping with it ourselves.
2015-03-28 20:23:47 +01:00
Sei Lisa
de33c2df01
Simplify operands of bitwise OR expressions as booleans. Deals with a TODO in a more general way.
2015-03-28 20:16:06 +01:00
Sei Lisa
2a617b34d0
Fix bug where a<<1 was not immediately optimized, and other minor changes.
...
* Add a TODO.
* Don't make two fold passes if DCR is off.
* Remove comment about parentheses that no longer applies.
2015-03-28 14:45:53 +01:00
Sei Lisa
edbc240408
Remove 'Local' from symbol table; add note about an unimplemented feature; improve symbol table documentation; rename a helper variable.
2015-03-27 02:12:32 +01:00
Sei Lisa
9bd66dd6fa
Optimize out function calls to SEF functions with non-SEF arguments.
...
The function call is removed, and the arguments transformed to a block of expression statements.
2015-03-13 23:48:24 +01:00
Sei Lisa
df31a69465
In functions that end in 'return;', remove the 'return;'.
...
This allows better side-effect analysis, because 'return' is not side-effect free unless it's the last statement. But that's better handled in the dead code removal module, as the comment specifies.
2015-03-13 23:46:23 +01:00
Sei Lisa
9cb02839bc
Remove extra code.
2015-03-13 23:45:56 +01:00
Sei Lisa
2948399bf8
Revert 3b7e461d82
, as it introduced bugs.
2015-03-13 22:13:00 +01:00
Sei Lisa
890e960b57
Implement Lazy List reading. Update docs according to last changes (in FS too).
...
Adds a new tree node type, SUBIDX, which hopefully should never appear in actual output. If it does, it's prefixed with the string (MISSING TYPE) as a cue to the programmer.
2015-03-13 06:38:35 +01:00
Sei Lisa
59cdd64228
Warn about float constants that can't be represented in globals. Also don't duplicate the globals warnings.
2015-03-06 23:26:58 +01:00
Sei Lisa
c1d837674c
Forgot to exclude globals from this optimization somehow.
2015-03-06 22:55:28 +01:00
Sei Lisa
c68a1f4ad6
Add copyright notices to all files, to prepare the program for release.
2015-03-05 23:18:41 +01:00
Sei Lisa
f730843762
More TODO tweaking.
2015-03-05 06:20:11 +01:00
Sei Lisa
b73805e0ce
Add "lazy lists" assignment support (mylist[index] = value).
...
Add support for LAMBDA (empty) tree nodes while on it, that allow us to define private stuff at the top without caring about Loc.
2015-03-03 17:59:51 +01:00
Sei Lisa
7e521780d6
Two more optimizations TODO
2015-03-03 17:49:57 +01:00
Sei Lisa
0b55f6e64d
Oops, the operator is !, not -
2015-03-03 02:20:31 +01:00
Sei Lisa
05d46e9ac3
Optimize comparisons of the form int>2147483647 or int<-2147483648 and expand (>=, <=, !=) to !(<, >, ==) respectively.
2015-03-03 02:16:00 +01:00
Sei Lisa
493aed6c39
Optimize (-a)*b or a*(-b) to -(a*b), revisiting the expression.
...
This obviates the need for (-a)*(-b) because it will be simplified automatically. It also enables (a+1)*b-1 to be simplified to just ~(~a*b). Still missing simplifying a*b+b to (a+1)*b, but that's more complicated.
2015-03-03 01:46:53 +01:00
Sei Lisa
01f2bba2f4
Make *-2 and *2 only work for local variables. Needed an adition to the parser.
2015-03-03 00:49:14 +01:00
Sei Lisa
d8f42a5071
Remove obsolete comment about parentheses (they are now implicit).
2015-03-03 00:47:15 +01:00
Sei Lisa
c650ad26f8
Comment changes only.
2015-03-02 23:28:14 +01:00
Sei Lisa
3b7e461d82
Convert [x] -> (list)x except in globals.
2015-02-28 22:48:11 +01:00
Sei Lisa
831296eddc
Minor shortening of name to fit in line
2015-02-28 21:46:19 +01:00
Sei Lisa
762bf1f27b
Add some FIXMEs and TODOs, remove comment that no longer makes sense.
2015-02-28 20:39:23 +01:00
Sei Lisa
e30a4ea25d
Fix addstrings option (oops).
2015-02-28 20:37:18 +01:00
Sei Lisa
8f83e2f1ab
Add "addstrings" option (disabled by default) to select whether to automatically concatenate strings during constant folding.
2015-02-28 20:01:51 +01:00
Sei Lisa
6ea01c4242
Added optimizations for most operators, and 'cornermath' option.
...
Only remaining operators are < <= > >= &.
2015-02-28 18:30:04 +01:00
Sei Lisa
42ac090f03
Big bunch of expressions optimized, boolean/bitwise, and some new ideas.
...
a != -1 is now optimized to ~a in conditions. a == 1, a != 1, etc. are all optimized. a||b -> a|b is done. a^0, a^-1 are optimized. a&&b is transformed to !(!a|!b), but not yet into a&b when possible.
2015-02-28 05:14:52 +01:00
Sei Lisa
1dea1bd12c
Make parentheses no longer explicit in the AST (Beta).
...
The output module adds parentheses where necessary, depending on the evaluation order in the tree. Or that's the idea. Prone to bugs, let's see how it bodes.
2015-02-28 00:43:26 +01:00
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
6fb947fbc9
(Limitedly) apply distributive law for string and integer addition.
2015-02-12 07:47: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
c2a30fb9ee
Simplify const + nonconst + const and nonconst + const + const.
2014-08-19 19:45:47 +02:00