Commit graph

76 commits

Author SHA1 Message Date
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
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
b441c1774f Fix incorrect warning when a global vector/quat/list contains an ident 2014-07-28 18:46:37 +02:00
Sei Lisa
a6b3a0946f Enable foldtabs warning 2014-07-28 17:39:35 +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
64e5d0dc92 Check that it's a variable definition before collapsing or giving warning. 2014-07-27 22:04:15 +02:00
Sei Lisa
3dd73f218f Fix a few more statements missing. 2014-07-27 21:05:57 +02:00
Sei Lisa
6af4f40752 Add TODO items 2014-07-27 20:48:37 +02:00
Sei Lisa
1747028211 Finish coverage tests. 2014-07-27 20:26:24 +02:00
Sei Lisa
7623c444a8 Forgot empty statement. Also make warning more prominent. 2014-07-27 20:14:25 +02:00
Sei Lisa
e57c21a73a Fix FIELD and IDENT in globals. 2014-07-27 20:03:57 +02:00
Sei Lisa
f3339b0906 Fix an infinite recursion by disallowing forward globals in global var defs. 2014-07-27 18:42:55 +02:00
Sei Lisa
c483d5ea71 Bunch of bug fixes. 2014-07-27 18:07:35 +02:00
Sei Lisa
beb413420d Disable the debug code 2014-07-27 13:44:13 +02:00
Sei Lisa
0b74093255 Fix tuple mess, typecast bug, and boolean bug.
Fix the tuple mess with the right approach. The EXPR tuple should not be changed, only the content.

Fix bug with typecasts. (NOTE: Debug code active)

Fix bug where <= and >= were returning bool instead of int.
2014-07-27 13:43:16 +02:00
Sei Lisa
d98e145090 Add missing operators & returns, remove typecast bogus optimization. 2014-07-27 04:15:12 +02:00
Sei Lisa
33440f5dd4 Fold vector/rotation/list expressions into constants. 2014-07-27 03:17:38 +02:00
Sei Lisa
4f7933aa3b Remove "drunk" comment. 2014-07-27 02:56:35 +02:00
Sei Lisa
b76ae99616 Fixes and folding improvements to the FOR loop.
Added an utility function to fold a list of expressions and completely remove the unused members. No known use besides FOR.
2014-07-27 02:52:16 +02:00
Sei Lisa
59de1e1f4f First prototype version of the optimizer. 2014-07-27 02:19:54 +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