Commit graph

23 commits

Author SHA1 Message Date
Sei Lisa
16d8c4c9d1 More progress in migration to dual Python 2&3. Just 2 tests left. 2020-11-10 00:15:48 +01:00
Sei Lisa
f8cf78dfac Progress towards dual Python 2 & 3 2020-11-09 02:28:57 +01:00
Sei Lisa
234b9b23a3 Bump copyright year 2020-04-23 00:38:20 +02:00
Sei Lisa
f243f3a3c1 New copyright year 2019-01-01 22:54:34 +01:00
Sei Lisa
075d3aba0c Change the AST node type from dict to object
That was long overdue. Obviously, this is a large commit.

The new nr (node record) class has built-in dump capabilities, rather than using print_node().

SEF always exists now, and is a boolean, rather than using the existence of SEF as the flag. This was changed for sanity. However, other flags like 'X' are still possibly absent, and in some cases the absence itself has meaning (in the case of 'X', its absence means that the node has not yet been analyzed).

Similarly, an event is distinguished from a UDF by checking for the existence of the 'scope' attribute. This trick works because events are not in the symbol table therefore they have no scope. But this should probably be changed in future to something more rational and faster.

A few minor bugfixes were applied while going through the code.

- Some tabs used as Unicode were written as byte strings. Add the u'\t' prefix.
- After simplifying a%1 -> a&0, fold again the node and return. It's not clear why it didn't return, and whether it depended on subsequent passes (e.g. after DCR) for possibly optimizing out the result. Now we're sure.
- A few places lacked a SEF declaration.
- Formatting changes to split lines that spilled the margin.
- Some comment changes.
- Expanded lazy_list_set definition while adapting it to object format. The plan was to re-compress it after done, but decided to leave it in expanded form.
- Added a few TODOs & FIXMEs, resisting the temptation to fix them in the same commit:
  - TODO: ~-~-~-expr  ->  expr + -3.
  - FIXME: Now that we have CompareTrees, we can easily check if expr + -expr cancels out and remove a TODO. Low-hanging fruit.
  - TODO: Check what we can do when comparing non-SEF and non-CONST values in '>' (current code relies on converting '>' to '<' for applying more optimizations, but that may miss some opportunities).
  - FIXME: Could remove one comparison in nt == '&&' or nt == '||'. Low-hanging fruit.
2018-04-01 02:14:00 +02:00
Sei Lisa
d0d6d6744b Bump copyright year
The help text in main.py was still at 2015. Oops.
2018-03-23 16:36:45 +01:00
Sei Lisa
1cdf9f7ff0 Collect used library functions as reusable names for the renamer.
Implements another TODO.

There was a TODO about a new counter per scope, but that makes no sense. The renamer only acts on global variables, global function and parameter names, state names, and event parameters. We're already restarting the counters at every function, which is the closest to what that TODO was about.
2017-11-02 23:19:33 +01:00
Sei Lisa
f2a6243695 Reuse state names for function parameters; restart UsedNames.
Gives us a few more opportunities for catching single-letter identifiers.

UsedNames was not restarted. It's unlikely that this had any detrimental effect on optimization, and it was certainly safe to not restart it. But it looks more correct like this.
2017-10-28 23:39:25 +02:00
Sei Lisa
c5b5a8303c Add TODO item to lslrenamer. 2017-08-16 22:00:16 +02:00
Sei Lisa
fe574bb462 Bump copyright year.
'bout time.
2017-08-09 19:45:46 +02:00
Sei Lisa
3686d490a2 Improve savings in ShrinkNames.
The reusable names table was being emptied as identifiers were used. This was sub-optimal for function parameters, because new identifiers would need to be created when exhausted.

Reset the reusable names list to a saved copy every time a new parameter list is started, in a similar fashion to what we did with the sequentially generated identifiers.
2017-01-28 03:36:25 +01:00
Sei Lisa
7659eb1654 Use frozenset for keywords; allow Pop.
Rather than using tuples for set belonging, use a frozen set. That eliminates the need to separate them by lengths.

Also, 'Pop' is not a reserved word. It's perfectly valid as a possible substitution identifier, so allow it. If used, it will go to the used words anyway and thus will be skipped by the sequential name generator.
2017-01-28 03:13:25 +01:00
Sei Lisa
9469855769 Document the internal behaviour of run_time_permissions under LSO 2015-12-11 02:28:51 +01:00
Sei Lisa
91201f1e30 Remove old TODO and add new one.
Identifiers can be equal if they belong to different syntactic scopes. That will allow better reuse and less creation of new identifiers, most notably as function and event parameter names.

The implementation would require a stack of counters where the current value is pushed when entering a new scope, and popped when exiting, rather than using a single counter for the whole program.
2015-12-09 05:11:53 +01:00
Sei Lisa
15f1a07a72 There were more translated events. After an exhaustive analysis this is the definitive list. 2015-08-21 03:35:20 +02:00
Sei Lisa
e264260477 Two events produce different internal names than the event name itself. This was causing the reused names for these events to increase memory usage instead of reducing it. Fixed. 2015-08-21 01:20:28 +02:00
Sei Lisa
cd9bfd426e Update list of pre-allocated keywords. 2015-07-26 00:13:00 +02:00
Sei Lisa
1e8b77bf50 Rather than generating random identifiers for locals, prefix them with 'loc_'.
Should help improving readability of the optimized script.
2015-03-07 14:51:51 +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
7fb345b222 'case' needed to be in the list of 4-char words to avoid. Also tweak a comment. 2015-03-05 06:18:53 +01:00
Sei Lisa
649de92ebd Restart numbering at every parameter table. Saves many identifiers. 2014-08-09 23:19:00 +02:00
Sei Lisa
400809671e Fix GetNextShortest. Add test and regression cases. Rename AssignNewNames. 2014-08-01 18:02:55 +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