Commit graph

155 commits

Author SHA1 Message Date
Sei Lisa
308ca7c8ff Add support for 'break n;' and 'continue n;'. Also simplify the break/continue stacks handling code and fix some bugs. 2015-03-05 20:12:32 +01:00
Sei Lisa
cbcf60767a Implement break/continue and switch().
While on it, reorganize the help text and enable 'dcr' by default.
2015-03-05 01:37:32 +01:00
Sei Lisa
a36715f121 Add reference source, comments. 2015-03-04 02:01:03 +01:00
Sei Lisa
8b9676e5dc Fix missing 'paramscope', remove commented out old body, simplify. 2015-03-04 01:51:08 +01:00
Sei Lisa
a6127cf144 lazylistcompat idea ditched. 2015-03-04 00:40:07 +01:00
Sei Lisa
8ea6ae50fd Replace the lazy_list_set function with a more compact one. 2015-03-03 20:00:40 +01:00
Sei Lisa
b73805e0ce Add "lazy lists" assignment support (mylist[index] = value).
Add support for LAMBDA (empty) tree nodes while on it, that allow us to define private stuff at the top without caring about Loc.
2015-03-03 17:59:51 +01:00
Sei Lisa
22a1a2e8ba Document the change to the symtab structure. 2015-03-03 00:51:48 +01:00
Sei Lisa
01f2bba2f4 Make *-2 and *2 only work for local variables. Needed an adition to the parser. 2015-03-03 00:49:14 +01:00
Sei Lisa
1dea1bd12c Make parentheses no longer explicit in the AST (Beta).
The output module adds parentheses where necessary, depending on the evaluation order in the tree. Or that's the idea. Prone to bugs, let's see how it bodes.
2015-02-28 00:43:26 +01:00
Sei Lisa
4c08b7173a minor clarification of comment 2015-02-27 04:46:23 +01:00
Sei Lisa
0a0e5926d5 Fix bug where negative signs of global integers weren't being output. 2015-02-12 04:23:47 +01:00
Sei Lisa
db862bb4a6 Multi-commit:
- Fix a bunch of bugs found during the debut of the LSL calculator.
- Add infrastructure for functions to be able to produce a result or not depending on arguments. Fixes the llBase64ToInteger/llXorBase64/llXorBase64StringsCorrect cases where they are not deterministic, and allows for the addition of some extra functions whose value can be determined in some cases (e.g. llDetectedType(-1) is always 0). Added several such functions in a new module.
- Add the constant folding option to the help and the default options.
2015-02-11 05:43:13 +01:00
Sei Lisa
e89869a563 Add TODOs 2014-12-13 13:12:02 +01:00
Sei Lisa
ed4b963356 Rename _ops to _toks to eliminate ambiguity and facilitate a future merge. 2014-08-13 13:34:09 +02:00
Sei Lisa
0d81f132ab Fix bug where the assigned type was not checked in declarations. 2014-08-10 00:44:57 +02:00
Sei Lisa
7a4a6d221e Fix field assignment. Add regression test. 2014-08-08 00:52:23 +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
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
dce6419b4f Deal with the state change in globals error. 2014-08-01 23:51:24 +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
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
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
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
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
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
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
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
56d51b835c Hack to make identifiers in globals in non-global-expression mode work. 2014-07-28 19:20:36 +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
dde3c08f61 Add TODO item: skip preprocessor directives. 2014-07-27 21:05:01 +02:00
Sei Lisa
30efb5d14c Bug fix: look up library functions too! 2014-07-27 19:18:05 +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
124a2823a0 builtins.txt was not named as the source of some errors. Fixed. 2014-07-27 13:49:18 +02:00
Sei Lisa
cef3e626a9 Associate identifiers with their direct location.
Instead of returning the scope level at which search can start, return the scope level at which the symbol actually is.
2014-07-27 01:49:44 +02:00
Sei Lisa
12a1245102 Add ';' to the interning string table. 2014-07-27 01:28:35 +02:00
Sei Lisa
de4a8d4dac Add the Firestorm features as TODO tasks. 2014-07-26 04:57:58 +02:00
Sei Lisa
8078be8401 Cosmetic: make another comment clearer 2014-07-26 04:45:56 +02:00
Sei Lisa
cfa7e1de89 Cosmetic: make a comment clearer 2014-07-26 04:44:02 +02:00