Commit graph

646 commits

Author SHA1 Message Date
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
Sei Lisa
400809671e Fix GetNextShortest. Add test and regression cases. Rename AssignNewNames. 2014-08-01 18:02:55 +02:00
Sei Lisa
50d1bb2c41 Bug fix: Error on existing events in current state. 2014-08-01 17:57:55 +02:00
Sei Lisa
dd446217a9 Fix bug with user function calls not being renamed. 2014-08-01 05:34:09 +02:00
Sei Lisa
6a9278cd28 Typo 2014-08-01 05:33:34 +02:00
Sei Lisa
6c248c46e3 Implement the shrinknames option.
Fixes some bugs with the treatment of the shrink attribute, some others with the output of renamed stuff.
2014-08-01 05:07:50 +02:00
Sei Lisa
847d7b1e20 Oops, forgot these in the editor without saving.
They belong to the output module general preparation for renaming.
2014-08-01 02:02:24 +02:00
Sei Lisa
fb65144e1b One less to-do. 2014-08-01 02:02:01 +02:00
Sei Lisa
d65f0f1f75 Fully implement duplabels, and prepare output for general renaming.
There's also a new hidden option, shrinknames, which automatically enables duplabels due to its nature. The idea is that once general renaming is implemented, in order for label names to not cause collision trouble, they are renamed out of the way with unique names.

Not entirely sure this is really necessary.
2014-08-01 01:41:21 +02:00
Sei Lisa
b5c440e4bc Change __self__.__classname__ to the actual class name in exceptions. 2014-08-01 00:37:44 +02:00
Sei Lisa
e29f16d3eb Add duplabels option (not yet implemented).
When disabled, it now disallows duplicate labels. The plan is that when enabled, it will auto-rename labels so that there are no repetitions within a function.

Add coverage tests too, and also a coverage test that was missed after the latest changes.
2014-08-01 00:33:20 +02:00
Sei Lisa
523857ed23 Slight wording change in a comment. 2014-07-31 23:21:50 +02:00
Sei Lisa
cf880b8dbf Fix priorities for x << const optimization. 2014-07-31 19:45:30 +02:00
Sei Lisa
f03466629f Fix several bugs in lslbasefuncs; change InternalJsonScanMatching strategy.
Fix bug: add(Key, Key) is not valid.
Fix bug: llList2CSV was raising an exception always.
Fix bug in test program: llDumpList2String requires Unicode separator.
Patch test program to not output the passed tests.
2014-07-31 19:18:26 +02:00
Sei Lisa
e620c9f305 Additional notes on choices. We're changing it next to the latest one.
Preserved for the record.
2014-07-31 18:58:19 +02:00
Sei Lisa
be9145e3c3 Fix bug in float shrinking code. 2014-07-31 18:47:40 +02:00
Sei Lisa
a303ef2066 Unfold all assignment+operation operators to optimize them better.
With test case.
2014-07-31 18:44:50 +02:00
Sei Lisa
cb66f1ff4e Make if ... else if ... chains iterative, rather than recursive.
Should save some stack if the chain is long.
2014-07-31 05:41:15 +02:00
Sei Lisa
5bedc17b73 Fix bug where optimization disabled didn't return a value. 2014-07-31 05:39:20 +02:00
Sei Lisa
e5714eba25 Fix the obnoxious issue with globals propagation in full expressions.
Fixed by backtracking in the parser, and keeping a copy of the original expression if it's a simple_expr, which is used for output in place of the folded one.

There's still the potential issue that if a global is optimized away, then it will "come back" during output and cause an error because the definition is missing.
2014-07-31 04:47:19 +02:00
Sei Lisa
5b401ff9a5 Copy the node, don't just ref it. Also add comments on the simple_expr issue. 2014-07-31 04:07:03 +02:00
Sei Lisa
2cbed52bf7 Add optimization of declarations.
integer a = 0; -> integer a;
float f; -> float f = 0;
vector v; -> vector v = <0,0,0>;
rotation r -> rotation r = <0,0,0,1>;
2014-07-31 03:29:21 +02:00
Sei Lisa
6ec39aa745 Add a bunch of optimizations. Fix || and && results.
Notably, addition/subtraction, and llGetListLength -> !=[]

But also parenthesis removal etc.

With test coverage.
2014-07-31 02:53:51 +02:00
Sei Lisa
3ac4bc4f0d New option to optimize float-to-int conversion separately from sign optim.
The option is optfloats. Add support everywhere.
2014-07-31 01:37:18 +02:00
Sei Lisa
efc7f4406a Fix typo. Oops! 2014-07-31 01:34:34 +02:00
Sei Lisa
d1bbe26c49 vector v;<0,0,0>-v; triggered EParseTypeMismatch. Fixed. Also minor fixes.
Convert the self.__class__, which was terrible syntax, to the respective classes in the exceptions.

Fix the EInternal hack in the buitins.txt parser.
2014-07-31 01:25:15 +02:00
Sei Lisa
5e4c19e5ec Fix bug with adding immutable functions. 2014-07-30 23:36:35 +02:00
Sei Lisa
c724b53f20 Simplify main loop of lsloutput.py a bit 2014-07-30 16:01:23 +02:00
Sei Lisa
895e4f4668 Overall renaming of stuff to make it more understandable. 2014-07-30 16:00:00 +02:00
Sei Lisa
fb68273eed Turned everything upside down, and fixed a couple bugs.
Bugs fixed:
- %= and the new assignment operators were not emitting error on invalid types.
- List globals referenced in another global were duplicated entirely.
- Properly recognize -option in the command line.

Rest:
- Complete overhaul of the internal data structure.
  - Got rid of the symbol table plus mini-trees, and made everything one big tree plus an auxiliary symbol table.
  - No more special case hacks like using tuples instead of lists...
  - Got rid of the EXPR hack.
  - Dict-based, rather than list-based. Allows adding arbitrary data to any node or symbol entry.
- Added a few coverage tests for the new code.
- Return values can now be chained; the functions parameter requirement is gone. Still not fully convinced, though. My guess is that a parser object should be passed between functions instead. Will do for now.
2014-07-30 04:54:16 +02:00
Sei Lisa
5d4abf967d Comment changes - just make the idea more explicit. 2014-07-28 21:39:36 +02:00
Sei Lisa
c748472187 Compress floats as much as possible. Also output NaN and Infinity as strings. 2014-07-28 20:38:44 +02:00
Sei Lisa
cd9fa96055 Format ELSE IF in a single line. 2014-07-28 19:36:01 +02:00
Sei Lisa
56d51b835c Hack to make identifiers in globals in non-global-expression mode work. 2014-07-28 19:20:36 +02:00
Sei Lisa
b441c1774f Fix incorrect warning when a global vector/quat/list contains an ident 2014-07-28 18:46:37 +02:00
Sei Lisa
443b5a2258 Fix bug where floats in global lists would be output as integers. 2014-07-28 18:13:48 +02:00
Sei Lisa
a6b3a0946f Enable foldtabs warning 2014-07-28 17:39:35 +02:00