Commit graph

746 commits

Author SHA1 Message Date
Sei Lisa
3cfbbb923c The encoding of sys.stderr can exist and be None. 2019-05-01 01:22:54 +02:00
Sei Lisa
2c94905f1e Add regression test for the keyerror bug 2019-02-26 02:28:21 +01:00
Sei Lisa
73bc2c29a8 Fix a couple of slips that can cause crashes
'Type' is a string with a LSL type. 'Kind' is a single leter denoting the kind of identifier. We meant Kind. Twice.
2019-02-25 19:59:59 +01:00
Sei Lisa
985b9c4ef1 New upstream version of builtins.txt 2019-02-23 02:06:03 +01:00
Sei Lisa
7589d72572 Add missing functions to fndata.txt 2019-02-08 18:30:33 +01:00
Sei Lisa
4b83ae6c4e More upstream changes to builtins.txt 2019-02-07 14:46:53 +01:00
Sei Lisa
f2aa2ed231 New upstream version of builtins.txt adding INVENTORY_SETTING 2019-02-06 18:54:40 +01:00
Sei Lisa
7282e539d0 Add a directory that is important for tests
It had no files, so git didn't include it. Sigh.
2019-02-04 19:05:08 +01:00
Sei Lisa
2ade2804df Bug fix: include 'emap' attribute in UniConvScript
Fixes an AttributeError: 'UniConvScript' object has no attribute 'emap'
2019-02-04 19:03:46 +01:00
Sei Lisa
8cfcdd090a Fix --emap output when the error is not in the main file 2019-02-04 17:51:15 +01:00
Sei Lisa
68c8726a64 Option to output error messages suitable for automated processing
Enables use of the optimizer as an editor plug-in.
2019-02-04 17:20:12 +01:00
Sei Lisa
f0068dd3bc Style fixes
Calm pyflakes by using identifiers, and change hexversion to version.major.
2019-02-04 00:07:12 +01:00
Sei Lisa
09556d5fbc 'backslashreplace' makes no sense for str.decode() 2019-02-04 00:07:10 +01:00
Sei Lisa
128005e889 Fix bug in inlining of empty for() initializer
It was causing an exception. Fixed now.

Thanks to Cindy Reynaud for reporting the problem and sending a backtrace.
2019-02-02 00:50:05 +01:00
Sei Lisa
65f217afa8 Fix codec problem on MSW 2019-01-31 11:51:55 +01:00
Sei Lisa
326091624c Fix non-compliance problem with octal/hex literals without U suffix
To follow the standard, hexadecimal and octal values that don't fit an intmax_t must be of type uintmax_t, regardless of the presence of the U suffix.
2019-01-21 16:28:15 +01:00
Sei Lisa
dc41b36ace Update to latest pcpp (fixes __LINE__)
See https://github.com/ned14/pcpp/issues/25 for details.
2019-01-18 16:46:12 +01:00
Sei Lisa
36ed90c9ba Revert _Pragma operator
Revert "Add support for C11-style _Pragma operator on processpre".
Revert "Add unit test for the _Pragma operator".

This reverts commits 31fcb331c7 and e261ac2121.

This should rather be the job of the preprocessor, which should generate #pragma lines. gcc does that.
2019-01-17 20:30:04 +01:00
Sei Lisa
fba40123e1 Only include BOM if it isn't already present. 2019-01-17 12:55:49 +01:00
Sei Lisa
b5092c0be2 More Unicode vs str fixes 2019-01-16 20:24:31 +01:00
Sei Lisa
173a12be15 New feature: add preprocessor params before or after system's
Reverts f958b1cdf9, and adds the possibility of adding parameters after the system-inserted ones through a new command line parameter -A/--postarg.

Enables using e.g. both a command interpreter which requires the file to execute before any other parameters, and overriding the default definitions.
2019-01-16 19:19:27 +01:00
Sei Lisa
44ba2e2a8a Add digraph support to the default mcpp command line 2019-01-16 19:05:24 +01:00
Sei Lisa
fe2dd9a721 First baby steps towards dual Python2+3 compatibility 2019-01-16 00:15:06 +01:00
Sei Lisa
789eb85bfe Add the outfile.tmp file generated by a test to .gitignore 2019-01-15 23:22:02 +01:00
Sei Lisa
8c1dc90cc8 Add a routine used to generate some of the test cases
When run in SL, this program generates a list in pretty much the format expected by the test suite, therefore it's quite convenient to have.
2019-01-15 23:19:02 +01:00
Sei Lisa
d394adf45a Add a test case to the infinity vector conversion 2019-01-15 23:18:10 +01:00
Sei Lisa
e261ac2121 Add unit test for the _Pragma operator 2019-01-15 20:38:19 +01:00
Sei Lisa
7fd7eae56c Add *- to gitignore 2019-01-15 20:37:07 +01:00
Sei Lisa
8043cb7c9f Add two forgotten files from the inline tests 2019-01-15 20:35:17 +01:00
Sei Lisa
bb841eb65a Remove obsolete test programs 2019-01-15 18:47:10 +01:00
Sei Lisa
138d042b2e Fix bug in type conciliation function
Casting wasn't enough, it needed to call to_uint().
2019-01-15 01:22:44 +01:00
Sei Lisa
6dfbd804d0 Update PCPP with latest fixes 2019-01-13 19:33:13 +01:00
Sei Lisa
31fcb331c7 Add support for C11-style _Pragma operator on processpre
A minor difference is that strings and whitespace are parsed according to LSL rules, not to C rules, since this processing is performed in the lexer.

This could be fixed, but is it worth the trouble?
2019-01-13 19:03:10 +01:00
Sei Lisa
4a9cc9e20f Add support for comment passthrough to expression evaluator 2019-01-13 13:51:13 +01:00
Sei Lisa
a1b5f1bb45 Avoid exposing our sint/uint class outside 2019-01-13 03:40:24 +01:00
Sei Lisa
01d45191ae Minor fixes in encoding handling
This actually needs a complete overhaul, factorization et al.
2019-01-13 00:25:28 +01:00
Sei Lisa
f958b1cdf9 Append --preargs options at the end of the command line
Allows the user to override default defines, for example.

Also add docstring to PreparePreproc().
2019-01-12 21:16:35 +01:00
Sei Lisa
7dcd7aa315 Add link to ned14/pcpp, moving the long link further down. 2019-01-12 20:35:10 +01:00
Sei Lisa
67164f4fbe Don't report pcpp as modified if it has untracked files 2019-01-12 20:33:52 +01:00
Sei Lisa
d2c25c7812 Simplify a comparison in cpreproc.c 2019-01-12 00:29:06 +01:00
Sei Lisa
c0168c8a34 Add files necessary to add an internal preprocessor (not implemented yet)
Includes PCPP as a submodule (which in turn pulls PLY as a submodule, so be sure to initialize submodules recursively). Also includes a file to interface PCPP with the optimizer, patching its behaviour according to our needs.

Special thanks to Niall Douglas and David Bezley for authoring PCPP.
2019-01-11 21:21:36 +01:00
Sei Lisa
352f410d12 Add forgotten unit tests for the identifier substitution fiasco 2019-01-11 21:20:21 +01:00
Sei Lisa
0877f8c7e6 Forgot unit_tests/__init__.py necessary to run the JSON test 2019-01-11 17:34:10 +01:00
Sei Lisa
42f47d38f0 Fix swaps and other misoptimizations
This undoes 454d44e85f
2019-01-11 02:09:15 +01:00
Sei Lisa
c3bb056f05 Revert the optimization re-added in 1946acf3a4
That change needs much more analysis and thought. And we need more testcases.
2019-01-10 23:26:58 +01:00
Sei Lisa
06f8370886 Add a reference to the author name's origin
Add TODO on vectors and rotations, too.
2019-01-10 21:56:26 +01:00
Sei Lisa
1b3c8a4d89 Check min and max to determine truth value of condition
Also added some min/max values for a few functions.

This allows optimizing things like:

  ! llGetNumberOfPrims()  ->  0
2019-01-07 00:15:38 +01:00
Sei Lisa
5bfb218505 Perform redundant jump elimination in lastpass
This is a first try at redundant jump removal (jumps that target the very next instruction). It's too basic in several ways.

- The statement is replaced by a ';' instead of removed.
- If the jump was the only statement in an if, when the if becomes empty, it's not folded.
- Jumps that are last in the 'then' branch of if+else are not visible. This would need either to track multiple last statements, or to have some means to anticipate what the next statement is at every statement. A Control Flow Graph would help a lot.
- When a label is immediately followed by a jump, all jumps to that label should target the destination of that jump if it's in scope. Added to TODO.
- It misses some optimizations when not expanding WHILE and FOR into IF/JUMP.

Moving everything to an earlier stage would help with some of these, especially with ';' and 'if' folding. Unconditionally expanding WHILE and FOR would also help.
2019-01-06 22:32:19 +01:00
Sei Lisa
574f92d08e Allow #pragma OPT inline 2019-01-06 02:20:34 +01:00
Sei Lisa
c5fd4932f1 Finish inlining for all loop conditions 2019-01-06 01:59:36 +01:00