Commit graph

27 commits

Author SHA1 Message Date
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
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
be9145e3c3 Fix bug in float shrinking code. 2014-07-31 18:47:40 +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
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
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
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
443b5a2258 Fix bug where floats in global lists would be output as integers. 2014-07-28 18:13:48 +02:00
Sei Lisa
d55f873fd5 Add tab warning and future option documentation. 2014-07-28 17:26:05 +02:00
Sei Lisa
eab0bec84b Add preprocessor skip option, command line options and help, options for all functions, and enhance parentheses removal. 2014-07-28 02:13:08 +02:00
Sei Lisa
8907a59d5f Fix remaining bug in optimizer, and minor fixes.
- Get rid of Fold().

- Handle globalmode properly. It was sometimes active during function calls.

- Change all warning() calls to not use Unicode, just in case the output is redirected to file.

- Cosmetic fixes and TODO items.
2014-07-27 23:33:20 +02:00
Sei Lisa
100de9c8e9 Fix output of lists < 5 elements 2014-07-27 21:23:57 +02:00
Sei Lisa
0f55129f71 Add important comment 2014-07-27 21:04:31 +02:00
Sei Lisa
f1656c41aa Import 'warning' from lslparse instead of redefining. Cosmetic fixes. 2014-07-27 18:05:11 +02:00
Sei Lisa
609df368f3 Fix a case with list mode for globals. 2014-07-27 13:47:18 +02:00
Sei Lisa
d856f62253 Fix optsigns treatment. 2014-07-27 04:31:45 +02:00
Sei Lisa
6e1357f4f3 Handle type cast optimization in the output module (easiest). 2014-07-27 04:24:14 +02:00
Sei Lisa
603b85afc8 Remove hack and output expressions where expected. 2014-07-27 02:18:37 +02:00
Sei Lisa
ecaa4b1af0 Output negative integers as hex. 2014-07-27 01:27:37 +02:00
Sei Lisa
a3354fae0e First steps in optimizer.
Still WIP, though, but it already optimizes e.g. this:

default { timer() { 2+2; } }

to this:

default { timer() { 4; } }
2014-07-26 21:32:01 +02:00
Sei Lisa
841413a2cf Remove bogus FIXME comment. 2014-07-26 04:35:57 +02:00
Sei Lisa
05d00e075b Initial commit. Status so far:
- Parser and output modules are thoroughly tested and working.
- Most LSL immutable functions are working; some not tested; llJsonSetValue not implemented.
- Parser recognizes the following flags that alter syntax:
   extendedglobalexpr: Allow full expression syntax in globals.
   extendedtypecast: Allow full unary expressions in typecasts e.g. (float)~i.
   extendedassignment: Enable the C assignment operators &=, ^=, |=, <<=, >>=.
   explicitcast: Add explicit casts wherever they are done implicitly, e.g. float f=3; -> float f=(float)3;.
  Of them, only extendedglobalexpr is useless so far, as it requires the optimizer to be working.
2014-07-26 02:43:44 +02:00