Commit graph

643 commits

Author SHA1 Message Date
Sei Lisa
caf50c4e14 Change while (cond) /*empty*/; into do /*empty*/; while (cond); 2018-05-17 06:38:33 +02:00
Sei Lisa
8f93386108 Get rid of label checks in some situations no longer supported 2018-05-17 06:38:12 +02:00
Sei Lisa
c62773ad3f Refine the denormal check for Mono
The threshold for returning 0 for denormals is slightly different.
2018-05-09 19:04:09 +02:00
Sei Lisa
091f06cccc Fix threshold value for denormal to be taken as 0
(float)"1.1754944e-38" is != 0
(float)"1.1754943e-38" is == 0

Yet, 1.1754944e-38 == 1.1754943e-38.

The fix is to perform the operations as doubles, and convert to F32 *after* comparing the denormal range.
2018-04-27 23:44:27 +02:00
Sei Lisa
1afe1643c0 Allow lists to contain void elements if not optimizing and not lazy
LSO allows this. The compiler does too, but it chokes in RAIL.

This affected a test, which has been adjusted too.

Untyped lazy list elements can no longer be used in isolation in expression lists (including FOR initializator and iterator).

Also rename the terribly named 'self.forbidlabels' to 'self.optenabled' which is more descriptive.
2018-04-09 18:49:47 +02:00
Sei Lisa
4a554d60e8 Remove a TODO item that was already done 2018-04-02 13:42:28 +02:00
Sei Lisa
6ef4c03994 Remove support for labels as immediate children of IF/ELSE/WHILE/FOR/DO.
This extremely uncommon coding pattern was becoming a hell to support. It has caused many bugs in past that need them being treated as special cases.

Getting rid of the possibility entirely seems like the best approach.

It's still supported if the code is not to be optimized (e.g. with --pretty).
2018-04-01 20:05:35 +02:00
Sei Lisa
4ebd84f0ed Raise EParseSyntax on wrong minus sign (not followed by int or float)
While not strictly a bug because it would be caught later in the function (it passes the tests either way), it made me nervous to leave a dangling NextToken().
2018-04-01 02:14:53 +02:00
Sei Lisa
dc30d461e2 Format some docstrings better; make one more precise about the grammar 2018-04-01 02:14:53 +02:00
Sei Lisa
8d0b995f07 Accept library function names as vars in simple_expr in globals
This may cause more trouble than it's worth, but it's how LSL behaves and one of our objectives is to document the darker corners of LSL. Mono chokes at the RAIL postprocessing stage, not in compilation proper. LSO chokes at runtime for string, key and list, and works fine for the other types.
2018-04-01 02:14:53 +02:00
Sei Lisa
8289c14c81 Fix bug where types of expressions in vectors/rotations were not checked
E.g. this was a valid vector literal: <"",0,0>

Parse_simple_expr didn't have that problem, though.
2018-04-01 02:14:53 +02: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
d890f0b5fa Comment-at-eol cleanup
Ensure every comment has a double space after the code.
2018-03-27 13:29:04 +02:00
Sei Lisa
f3c87299c2 Move comment to its correct place 2018-03-23 22:05:05 +01:00
Sei Lisa
2b14acc8a0 Follow-up fix to 82081b2 (#3)
Globals appearing in vectors or rotations inside a list still caused a crash.

Fixes #3 again.
2018-03-23 21:57:33 +01:00
Sei Lisa
877d5fc10c Optimize -a == -b, !(a - b), !(a + b)
-a == -b  ->  a == b

If both a and b either are constants or have a minus sign, negate both.

!(a - b) can be optimized to a == b.

!(a + b) can be optimized to -a == b, relying on the first optimization to remove redundant minus signs.
2018-03-23 19:02:42 +01: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
a1f1f13739 Better optimization of (non-)equality comparisons.
int != int was not properly optimized, because the != was transformed into the equivalent !(int == int) at an earlier stage. Fixed.

!(a ^ b) can be optimized to a == b, so do it.
2018-03-23 16:04:18 +01:00
Sei Lisa
aad4cf3bee Fix the fix for the bug introduced in 097c054
Our previous fix was incomplete, because it failed to detect the last IF in a chain of ELSE IFs. For example:

if (a == 2) llDie(); else if (a) llDie(); else if (a == 3) llDie();

That would be transformed by the IF swapper into:

if (a ^ 2)
    if (a)
        llDie();
    else if (a == 3)
        llDie();
else
    llDie();

Note that the last 'else' would bind to the last 'if', not to the first one. So the condition is actually like this:

child[1] of an 'if' statement needs to be guarded in {} if the 'else' may belong to the wrong 'if'.

It will belong to the wrong 'if' if child[1] is a (possibly empty) chain of 'if {whatever} else ...', followed by an 'if' without 'else', that is:

   if (cond) stmt;

(which was what our previous check did), but also e.g.:

   if (cond) stmt; else if (cond) stmt; else if (cond) stmt;

which we neglected to consider in our previous fix.
2017-12-14 21:32:00 +01:00
Sei Lisa
f492d3e291 Add --prettify option, to reformat a script (losing comments).
Since our syntax extensions transform the source at parse time, all syntax extensions are disabled. The optimizations are disabled too, as it doesn't make sense to prettify and optimize at the same time (the optimizer would remove the constants that we're trying to keep).

Addresses #4 in a more user-friendly way.
2017-11-20 20:59:45 +01:00
Sei Lisa
e42479756b Fix bug with nested if's; fix missing EXPR wrap.
097c054 introduced a bug that we hadn't caught until now.

In some occasions, it could swap nested conditions in such a way that the 'else' of the outer statement was made to belong to the inner one, like this:

    if (a)
        if (b)
            stuff;
    else
        stuff;

That is of course parsed with the 'else' belonging to if(b).

Fix implemented at output time, by detecting 'if(a) stmt; else y;' with stmt being an 'if' without 'else', and wrapping the stmt in {} like this: 'if(a){if(b) x;} else y;'. This has some similarity with parenthesis addition.

But the fix has the corner case that, since {} hides visibility of labels, when the inner 'if' has a label as direct child, it can't be swapped lest the label becomes out of scope. So these cases are detected and skipped in the constant folding module.

In the case of 'if(cond);', we transform it to 'cond;', but we forgot to wrap the cond in an EXPR node as required. Fixed too.
2017-11-13 04:04:13 +01:00
Sei Lisa
a4b3c1eadd Handle list+list more sanely. 2017-11-04 22:50:32 +01:00
Sei Lisa
0b1ad7c110 Add more results of operating an expression with itself.
Implemented a<a=0, a^a=0, a+-a=0, -a+a=0, a|a=a, a&a=a
2017-11-03 00:45:11 +01:00
Sei Lisa
4251d4c7f9 Improve CompareTrees.
Reorganize into different statements with early return.

Add constants, unary operators and binary operators. Check if operator is commutative and check with operands swapped when so.

Constant equality is somewhat sketchy at the moment: just compare the values with Python's ==.
2017-11-03 00:12:10 +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
93828b9286 Move a block. No functionality changes. 2017-11-02 21:50:55 +01:00
Sei Lisa
9c66380972 Add some early returns for performance. 2017-11-02 21:49:29 +01:00
Sei Lisa
a87022b73f Get rid of StSw craziness and use lsllastpass to make another pass.
This has been a TODO item for long. Now that we have lsllastpass, it's actually easy to implement.

Adds an LSLTypeDefaults dictionary to lslcommon, just in case the state-changing function returns a value and we need to insert a return statement.

We've also added subtree-local info to lsllastpass (lost when we return to the parent after visiting a subtree).

This fixes a bug where naked switch statements could appear as a result of optimization, and cause the compilation to fail.
2017-11-02 18:20:14 +01:00
Sei Lisa
e4eaab9e84 Move the print_node() subtree dump debug function to lslcommon. 2017-11-02 16:34:35 +01:00
Sei Lisa
ef6ed30536 Fix EParseCantChangeState so that it is always properly reported.
Still somewhat messy, but still reported as soon as it can be detected.

If an ELSE token is detected at the top level, for example, the error position will be rewound to the state change and reported there.

This means that in this situation:

x()
{
    if (1)
    {
        state default;
        x(2);
    }
    else ;
}
default{timer(){}}

an error will be reported in x(2), because the ELSE hasn't been found at that point, therefore the state change statement isn't found to be at fault yet.

However, in this case:

x()
{
    if (1)
        state default;
    else
        x(2);
}
default{timer(){}}

the error WILL be reported at the state change statement.

This commit also changes the position where the exception is reported, to be at the STATE token. As an inconsequential side effect, EParseCantChangeState takes precedence over undefined identifiers, in case the state change is to an undefined state, but only in cases where it can be immediately detected.
2017-11-02 13:45:01 +01:00
Sei Lisa
097c054494 Optimize 'if' statements better.
if (!cond) X; else Y;  ->  if (cond) Y; else X;

if (int1 == int2) X; else Y;  ->  if (int1 ^ int2) Y; else X;

When 'cond' is of a type other than 'key': if (cond) ; else X;  ->  if (!cond) X;  (this required changing if(str) to its compiled equivalent if(!(str == "")), so that 'cond' is always either key or integer).

if (cond) ;  ->  cond; and folds it as a statement, which may eliminate it if it's SEF. This is done after eliminating 'else ;' so that it also optimizes 'if (cond) ; else ;' the same way.

This removes a TODO item.
2017-10-30 19:23:01 +01:00
Sei Lisa
ed49170d87 Remove empty SEF events.
If the state becomes empty, add an empty timer() event. timer() is the parameter-less event with the shortest name.
2017-10-30 18:05:35 +01:00
Sei Lisa
e13f210695 Make DoesSomething apply to labels optionally.
Allows detection of empty events, for example, even if they have labels.

Also, it is OK if there's a label inserted in a nested {}; that case wasn't contemplated.
2017-10-30 18:05:28 +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
70f39d7f5e Remove "magic names" where possible, using new data from fndata.txt 2017-10-27 23:39:26 +02:00
Sei Lisa
b80b157489 Add a space between a minus sign and a negative constant.
When a constant was negative internally, it was output with the sign included. The code was not prepared to handle this, and could therefore cause double minus signs. For example, -2147483648 was output as --2147483648, and -4294967296 was output as --1.

Fixed by adding a space for floats, and by translating the number to the range 2147483648..4294967295 for integers (hex would have worked just as well).
2017-10-27 21:02:00 +02:00
Sei Lisa
14b13dc4e5 Implement flags aimed at removing "magic names" in the code.
strlen for llStringLength, detect for llDetected* and touch*/collision*/sensor, touch for touch*, grab for touch().
2017-10-27 18:49:58 +02:00
Sei Lisa
3bb5102f06 Improve llStringLength detection, to catch more cases.
For example, if (llStringLength(s) > 0)  ->  if (!(s == ""))
2017-10-27 16:07:36 +02:00
Sei Lisa
1dde2a1fb9 Use lslfuncs.less instead of > >= < <= to ensure proper type handling.
Float functions could be compared against integer args, or vice versa.
2017-10-27 11:20:42 +02:00
Sei Lisa
c0176ad738 Fix order change in comparisons when one side is not SEF.
The comment was wrong anyway. If one side changes x and the other side uses x, then order is still important, no matter whether one side is SEF.

But the reversal is safe when one side is a constant, so we still perform it, to enable optimization of some important cases.
2017-10-27 11:13:03 +02:00
Sei Lisa
106bb81543 Refine a comment.
Powers of two can't be zero anyway.
2017-10-26 01:07:48 +02:00
Sei Lisa
4ba71993a4 Optimize min/max in comparisons; undo problematic optimization.
For floats:

When const >= function.max, comparisons of function > const always yield FALSE.

When const <  function.min, comparisons of function > const always yield TRUE.

When const >  function.max, comparisons of function < const always yield TRUE.

When const <= function.min, comparisons of function < const always yield FALSE.

For integers:

When min = -1, cond(function > -1) is the same as cond(!~function).

When min = -1, cond(function < 0) is the same as cond(~function).

To implement the above, we got rid of the cond(x < 0)  ->  cond(x & 0x80000000) optimization, which has caused more trouble than it has solved for just 1 byte gain.

When min = 0, cond(function > 0) is the same as cond(function).

When min = 0, cond(function < 1) is the same as cond(!function).

Similar expressions can be obtained for max in [-1, 0], but it's not worth it, as there are no functions with -1 as maximum, and the ones with max=0 also have min=0 (always return 0).
2017-10-26 00:58:14 +02:00
Sei Lisa
22e057e2ec Move side-effect-free check for functions to a method.
This will in future allow us to check argument-dependent SEFness.
2017-10-25 19:24:12 +02:00
Sei Lisa
2580248c17 Minor reorganization and documentation of a section. 2017-10-25 18:04:27 +02:00
Sei Lisa
d5f5ab8b88 Add side-effect-free information for events. 2017-10-25 17:46:50 +02:00
Sei Lisa
2d823d8eae Fix Unicode in one error message. 2017-10-25 14:11:34 +02:00
Sei Lisa
7e39635b09 Transform !(x != y) into x == y.
Can happen with lists.
2017-10-21 20:38:54 +02:00
Sei Lisa
fd815f0bdb Fix compare and llListSort for LSO.
In LSO, they compare UTF-8 bytes, not Unicode codepoints.
2017-10-21 12:32:41 +02:00
Sei Lisa
a832f8d786 Remove min, max when min > max, and SEF when both SEF and delay present. 2017-10-21 11:47:29 +02:00
Sei Lisa
923309e4a1 Refine test for min and max.
We had dormant code to check for boolean-ness of functions, which is now active. But it didn't cover all possible booleans. Now it does.

An idea for the future is to associate ranges to expressions, and attach them to calculable functions. For example, (integer)llFrand(2) could be resolved to a boolean.
2017-10-21 11:31:53 +02:00
Sei Lisa
ea9711642c Add type casting comparison to CompareTrees.
It can now resolve e.g. (string)llGetPermissions() == (string)llGetPermissions() to TRUE.
2017-10-21 11:03:43 +02:00
Sei Lisa
dc117c2cbf Use CompareTrees to optimize the == operator.
Now we can.
2017-10-21 11:02:38 +02:00
Sei Lisa
e6b23a2d7a Fix CompareTrees to not compare unstable functions as equal. 2017-10-21 10:44:09 +02:00
Sei Lisa
4d92cc8838 Mark user functions as unstable.
Maybe in future we can perform further analysis to find some that are stable.
2017-10-21 10:42:46 +02:00
Sei Lisa
cdacc45bb0 Make functions unstable by default, for safety.
That ensures that if there's no data about a function, it is not optimizable.
2017-10-21 10:32:56 +02:00
Sei Lisa
ee8c2cde98 Cosmetic fixes. 2017-10-21 10:32:41 +02:00
Sei Lisa
b7700b7aab Remove debug code and seftable.txt 2017-10-21 10:29:12 +02:00
Sei Lisa
214d4a8a57 Add and read function properties table.
This solves a long-standing issue where we needed more data about LSL functions than just whether it's side-effect-free.

There's still some debug code, which is kept for history purposes.
2017-10-21 10:00:31 +02:00
Sei Lisa
3f6f8ed8ad Internal code reorganization.
- Separate library loading code into a new module. parser.__init__() no longer loads the library; it accepts (but does not depend on) a library as a parameter.
- Add an optional library argument to parse(). It's no longer mandatory to create a new parser for switching to a different builtins or seftable file.
- Move warning() and types from lslparse to lslcommon.
- Add .copy() to uses of base_keywords, to not rely on it being a frozen set.
- Adjust the test suite.
2017-10-20 18:19:48 +02:00
Sei Lisa
1a1531cb40 Use sys.getfilesystemencoding() to determine filename encoding. 2017-10-20 13:59:02 +02:00
Sei Lisa
cf3e4c21ec Comment fix.
Specify the name of the last llGetObjectDetails constant, to simplify manual checking.
2017-10-20 10:18:44 +02:00
Sei Lisa
36e336beee Add llGetStatus to lslextrafuncs. 2017-10-20 09:58:49 +02:00
Sei Lisa
3164a28c9b Add llGetAttachedList to lslextrafuncs.
Returns (list)"NOT FOUND" when passed a null key.
2017-10-18 21:57:33 +02:00
Sei Lisa
96a0aebe3a Fix the logic in llDetectedTouchST/UV.
They were returning TOUCH_INVALID_TEXCOORD for num <= idx <= 15 in detection events which were not touch events. That is incorrect.

Now it correctly returns:

- ZERO_VECTOR when idx < 0 or idx > 15 or the event is known not to be a detection event.
- TOUCH_INVALID_TEXCOORD when idx == 0 and the event is known to be a detection event that is not a touch event.
- Raises ELSLCantCompute otherwise.
2017-10-18 21:56:35 +02:00
Sei Lisa
028b244a9e lslbasefuncs: Rewrite some things in a different way.
Also some formatting changes. No functionality changes.
2017-10-18 15:20:19 +02:00
Sei Lisa
ea28e13e4a Implement llClearLinkMedia's known return values. 2017-10-18 13:43:53 +02:00
Sei Lisa
e051d49338 llAsin and llAcos return indet for indet input. 2017-10-18 02:42:58 +02:00
Sei Lisa
e8fb659592 Allow -2147483648 to count as a power of 2 in an optimization.
A case we oversought when implementing absorption of more than two flag tests into a single number.
2017-10-18 00:04:35 +02:00
Sei Lisa
2bee2db148 Remove duplicate check for '|'
Removed the 'if' and applied an indentation change; no further changes are done.
2017-10-17 23:59:41 +02:00
Sei Lisa
be767f24f0 Move things around to better places; undo 8d33746.
We oversought that the optimization that 8d33746 applied was already present, so no need to duplicate it.

A better place for handling '|' was under the code that already did so. No functionality change involved.
2017-10-17 23:53:24 +02:00
Sei Lisa
b4749d8fa4 Add debug code to display a subtree in a friendlier format than repr(). 2017-10-17 23:32:33 +02:00
Sei Lisa
4cbdbefe1b Fold again after applying distributibity or absortion.
Failure to do so was blocking some constant folding, like in:

if (a&1 || a&2 || a&4) -> if (a&(3|4))

Fixed. Now it correctly outputs if (a&7).
2017-10-17 23:28:14 +02:00
Sei Lisa
6c73ba95c2 Allow (x&r) && (x&s) && (x&t) to be collapsed into a single number.
This is an addendum to 3a849fe that allows more than two tests to be chained and optimized.
2017-10-17 23:26:13 +02:00
Sei Lisa
8d337467cb Fold the children of | as conditions when | is folded as condition. 2017-10-17 23:25:26 +02:00
Sei Lisa
a6a16c6e8f Fold ==0, ==1, ==-1 in general expressions, not just in conditions.
Also add a couple FIXMEs.
2017-10-17 02:38:08 +02:00
Sei Lisa
82081b2206 Fix crash when variables appear inside global lists.
Fixes #3.
2017-10-16 02:22:52 +02:00
Sei Lisa
cc96850f66 Fix bug where list elements of global declarations were removed.
CleanNode was too greedy, because children of global declarations (particularly lists) are not marked executable. Make a special case for them and don't recurse, since what matters is whether the declaration itself is executed. Its contents can't be cleaned up.
2017-10-16 02:22:40 +02:00
Sei Lisa
f77590df67 Fix sign of NaN*Indet and NaN/Indet.
In Python, NaN*Indet in any order returns the second operand, and NaN/Indet in any order returns the first operand. LSL consistently returns NaN in all cases.
2017-10-14 15:16:18 +02:00
Sei Lisa
0dc8629007 Raise ELSLInvalidType on invalid type passed to cond(). 2017-10-14 14:17:42 +02:00
Sei Lisa
a5ec12c9e9 Change (float)"NaN" to (-1e40*0) in output.
Solves both an inconsistency and the need to create a string.
2017-10-14 13:05:14 +02:00
Sei Lisa
6faa7816e6 Change ELSLInvalidType to ELSLTypeMismatch where appropriate.
The force type functions ff(), fi(), fs()... should normally trigger ELSLTypeMismatch when the input is not in the expected range of types, rather than ELSLInvalidType, which is reserved for the case where the type is not a valid LSL type.
2017-10-14 11:33:18 +02:00
Sei Lisa
3a849fe4b9 Optimize a common condition of (x & flag1) && (x & flag2)
It can't be done always: flag1 and flag2 must be nonzero powers of two. In that case, we can transform it to:

!~(x|~(flag1|flag2)) = !~(x|constant)

The -2147483648 case has trouble with the sign hack detector and I couldn't trigger it.
2017-10-13 02:59:32 +02:00
Sei Lisa
6ad2ef04d7 Add support for function calls in CompareTrees. 2017-10-13 00:30:47 +02:00
Sei Lisa
7ae7fa4396 Apply two optimizations to bitwise operations.
Based on basic Boolean algebra: distributive and absorption laws.
2017-10-12 22:48:43 +02:00
Sei Lisa
9e7a5d1cdf Change strategy for the checking of function input types.
Rather than assert that the types are correct, use the force type functions on the parameters:
ff, fk, fs, q2f, v2f, and the new fi, fl.

These functions have also been modified to ensure that the input type supports an implicit typecast to the target type and perform it, or emit ELSLInvalidType otherwise, rather than an assertion failure. fl in particular returns the original list if it isn't changed, or a copy if it is.

A couple bugs were found in testfuncs.py as a result, which have been fixed as well. A test has been added to ensure that the exception that caught these bugs remains in place.

The isxxxx functions are no longer necessary, so they are removed. Same goes for the painful cast handling process in foldconst, which was basically performing this task, and not necessarily well.

This approach is much more robust and should have been used since the beginning, but I didn't figure it out then.
2017-10-12 17:16:16 +02:00
Sei Lisa
41d2c68cf8 Add some more functions with predictable results.
Also minor reformatting forgotten in a previous commit.
2017-10-12 12:43:54 +02:00
Sei Lisa
1071941301 Implement accurate error reporting through #line directives.
Also simplify and fix the matching expression for #line (gcc inserts numeric flags at the end).

It still has many problems. It's O(n^2). It's calculated at every EParse, and EParse can be triggered and ignored while scanning vectors or globals. UniConvScript doesn't read #line at all, thus failing to report a meaningful input line. But at least it's a start.
2017-10-11 05:04:13 +02:00
Sei Lisa
4ba0518353 Report EParseReturnIsEmpty at return, EParseReturnShouldBeEmpty at expression.
Also change idpos to savepos, for consistency, and add note on why EParseReturnShouldBeEmpty is named like that.
2017-10-09 11:35:59 +02:00
Sei Lisa
4633c87a7c Report EParseUndefined at the identifier causing it.
It was being reported at the next token in some cases, due to needing to resolve the scope.
2017-10-05 18:51:53 +02:00
Sei Lisa
c544b51e37 Rewrite ReportError() and change EParse to report columns in chars.
ReportError() needed to account for terminal encodings that don't support the characters being printed. It was also reporting an inaccurate column number and its corresponding marker position, because the count was in bytes, not in characters, so that has been fixed.

Now EParse.__init__() calls a new function GetErrLineCol() that calculates the line and column corresponding to an error position.

The algorithm for finding the start of the line has also been changed in both ReportError() and EParse.__init__(); as a result, function fieldpos() has been removed.

The exception's lno and cno fields have been changed to be 1-based, rather than 0-based.

Thanks to @Jomik for the report. Fixes #5.
2017-10-05 18:50:45 +02:00
Sei Lisa
08c69eee0f Simplify a = a = b -> a = b 2017-09-22 16:14:50 +02:00
Sei Lisa
bdd42199eb Fix bug where assignments were treated as statements.
This caused e.g. b = a = a to raise an exception, when a = a was folded into a ';' which isn't an expression.
2017-09-22 16:04:44 +02:00
Sei Lisa
a0d4c77081 Minor cleanups; no functional changes.
lslcleanup: Variables renamed, order changed, comments added.

Other changes: remove semicolon at end of sentence, use self.Cast instead of creating a CAST node on the fly.
2017-09-22 15:42:42 +02:00
Sei Lisa
0a7e2a9e1d Optimize llDeleteSubList(expr, 0, -1) to [] if expr is SEF
It also applies to llListReplaceList with [] as replacement.
2017-09-15 23:13:59 +02:00
Sei Lisa
a6a08fe3f3 Implement transformation of lists into additions.
If the list in brackets is SEF:
  [a, b, ...]  ->  (list)a + b + ...
  ListExpr + [a, b, ...]  ->  ListExpr + a + b + ...
2017-09-15 22:30:22 +02:00
Sei Lisa
de29a9aa07 Fix for,while,if,do condition test during optimization.
That's exactly what 'cond' is for. Things like a loop with a constant zero vector condition should be recognized.

It was correct before just by chance, because FoldCond currently transforms a constant node into an integer node, but let's not rely on that.
2017-09-15 01:36:13 +02:00
Sei Lisa
b97b2a78e8 Fix return value for some detection functions.
When the index is good, on non-touch functions:
 - llDetectedTouchFace returns -1.
 - llDetectedTouchST and llDetectedTouchUV return TOUCH_INVALID_TEXCOORD.

We were returning 0 and ZERO_VECTOR respectively.
2017-08-30 19:23:38 +02:00
Sei Lisa
62eebb8bef Remove line no longer used from lsloptimizer.py. 2017-08-30 19:22:12 +02:00
Sei Lisa
2edd139a5c Fix copy/paste error in comment. 2017-08-25 20:45:24 +02:00
Sei Lisa
03c0e326c6 Remove "OK" from llDialog button list when it's the only element.
"OK" is the default; an empty list works just the same.
2017-08-25 20:35:24 +02:00
Sei Lisa
6738615360 Separate library function optimization into a different file.
No other functional changes. This required quite some reorganization affecting many files. As a side effect, PythonType2LSL and LSLType2Python aren't duplicate anymore.
2017-08-25 20:35:24 +02:00
Sei Lisa
36947b7b12 Rename lslfuncparams.py -> lslfuncopt.py
This is preparation work for splitting function optimization into a separate file, which will be the same that currently is lslfuncparams.py.
2017-08-25 20:35:24 +02:00
Sei Lisa
3ec460539e Implement the equivalent of GetObjectDetails for GPP/GLPP.
Removes the TODO item added in the last commit.
2017-08-25 20:35:24 +02:00
Sei Lisa
2a6e065c66 Optimize some llList2XXXX functions.
- Resolve for lists that aren't constants, but that are SEF, and reference a constant element, e.g. llList2String([llGetKey(), 5], 1) -> 5.
- Make it work with invalid conversions, if they are SEF.
- Simplify invalid conversions when the list argument is a llGetObjectDetails call and SEF.
- Simplify llList2String(llGetObjectDetails(id, [single_element]), 0) (or -1) to (string)llGetObjectDetails...; same with llList2Key and llList2Integer, converting it to (integer)((string)llGetObjectDetails...).
- Add TODO item to do it similarly for llGet[Link]PrimitiveParams.

Adds auxiliary functions to return a node or constant from a list in any of its forms, its length, and a constant for a node or constant.

Adds some utility members for LSL<->Python type conversion (one of them duplicated from lslparse.py).

Needs maintenance of the types returned by llGetObjectDetails.
2017-08-25 20:35:24 +02:00
Sei Lisa
906e76ea47 Format LIST nodes; don't add indent to CONST list in calc mode
LIST nodes will be pretty-printed with newlines between elements if they have 5 elements or more.

List constants won't be indented when in calc mode.
2017-08-25 20:35:24 +02:00
Sei Lisa
9a820a62d0 Simplify (type)sametype_expr -> sametype_expr. 2017-08-25 20:35:09 +02:00
Sei Lisa
2e09a3a986 Make some simplifications and keep PyFlakes happy. 2017-08-23 11:55:37 +02:00
Sei Lisa
ca3885c549 Expand conditions of types other than integer, string, key.
if(list!=[]) is always better than if(list), which compiles to if(!(list==[])).
if(float) can't be optimized, but it is equivalent to if(float!=0.0) which can. Same for vector, rotation.
2017-08-17 01:58:30 +02:00
Sei Lisa
a2e793df02 Parentheses around chained assignments are not necessary.
We follow the precedence and associativity rules, though.
2017-08-17 00:40:03 +02:00
Sei Lisa
2e29cc9131 Try to do better with the propagation of FoldCond.
Negation, specifically, didn't propagate to children. This might be redundant, though.
2017-08-16 22:02:11 +02:00
Sei Lisa
c5b5a8303c Add TODO item to lslrenamer. 2017-08-16 22:00:16 +02:00
Sei Lisa
6693022dfb Add !llStringLength(s) -> s == "" optimization. 2017-08-15 13:19:07 +02:00
Sei Lisa
0d76e09567 Propagate some SEF flags that we forgot 2017-08-15 13:19:07 +02:00
Sei Lisa
7c88acfe61 Fix type of != in llGetListLength substitution.
It was returning list instead of integer, causing inconsistencies in some comparisons depending on whether llGetListLength(L) or (L!=[]) was used.
2017-08-15 13:19:07 +02:00
Sei Lisa
fe574bb462 Bump copyright year.
'bout time.
2017-08-09 19:45:46 +02:00
Sei Lisa
e0fa1678a7 Optimize list addition when one list is known to have one element.
list + [element]  ->  list + element
list + (list)element  ->  list + element
[element] + list  ->  element + list
(list)element + list  ->  element + list
2017-08-09 16:41:36 +02:00
Sei Lisa
44e0db96d2 Optimize bool|1, bool&1 when possible.
a & 1 is always a, if a is boolean.

a | 1 is always 1, if a is boolean, but it can only be optimized out if a is side effect-free.
2017-08-02 01:40:48 +02:00
Sei Lisa
3f61e6f7bf Make IsBool smarter when finding whether an expression is boolean.
It was failing with a && b && c where a, b, c were known to be bools. It managed to simplify them to a & b & -c but that's not optimal.

Now it recurses on some operators that may return bool when used with bool operands: &, |, ^, * (in the case of &, it's bool if either operand is; for the rest, it's bool if both are). As a result, the above now simplifies to a & b & c, which is optimal.
2017-08-02 01:15:25 +02:00
Sei Lisa
61565470a2 New upstream version of builtins.txt, and minor code style changes. 2017-06-15 21:11:54 +02:00
Sei Lisa
b5994b79fe Optimize llDumpList2String(expr, "") to (string)expr.
It works on all VMs and it's always a gain, so it's not worth adding an option to deactivate it.
2017-05-31 14:39:42 +02:00
Sei Lisa
f1b05dd2ff Give more meaningful errors when break/continue parameter is wrong.
Adds a new EParseInvalidBrkContArg exception. Previously it raised EParseInvalidBreak or EParseInvalidCont, whose text was misleading for this type of error.
2017-04-29 13:47:45 +02:00
Sei Lisa
84e4543300 Allow empty list as constant in builtins.txt, for testing purposes. 2017-04-29 03:32:16 +02:00
Sei Lisa
0af2349ef9 Add command-line options to change default builtins and SEF table files. 2017-04-28 23:43:15 +02:00
Sei Lisa
2d78239d23 print returns the same type as the argument. 2017-04-28 23:04:42 +02:00
Sei Lisa
9a1421aeeb Fix (float)"nan" and (vector)"<nan,-nan..." on Windows.
We were letting Python typecast, and that causes the wrong result on Windows. Return the correct result explicitly when "nan" is found in the string.

Also, small reformatting of an else if -> elif.
2017-02-12 06:05:57 +01:00
Sei Lisa
9f8441bc65 Fix lslparse.DoesSomething.
It was non-funcional because of a copy/paste error.
2017-02-04 04:08:18 +01:00
Sei Lisa
c71b0eea2f Fix error type on non-var global identifier in expression.
The error message should be EParseUndefined, not EParseTypeMismatch.
2017-01-30 06:07:52 +01:00
Sei Lisa
7419ac4982 Don't run dead code removal when in calc mode. Add TODO item.
Running 'main.py -O expr' without disabling DCR led to an immediate crash, due to it trying to access the default state.
2017-01-28 06:36:49 +01:00
Sei Lisa
250090f418 Downgrade a FIXME item to TODO. 2017-01-28 05:04:26 +01: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
37a4c86516 Change the llRotBetween algorithm.
The former ones don't match LSL's behaviour, in particular llRotBetween(<1,0,0>,<-1,0,0>) should return <0,0,1,0> but it didn't. Fix by using an algorithm that is closer to the one used by the sim.
2017-01-27 19:50:05 +01:00
Sei Lisa
48e1035ac3 Minor comment fix. 2017-01-26 03:01:34 +01:00
Sei Lisa
813bdf36e9 Comment out Moon Metty's llRotBetween algorithm. 2017-01-25 19:29:57 +01:00
Sei Lisa
f0c115f924 Add optimizer option 'listlength' to optimize llGetListLength.
llGetListLength(arg) was transformed to arg!=[] whenever constant folding was active. This option allows disabling that optimization.
2017-01-25 19:22:36 +01:00
Sei Lisa
e8852ad124 Fix llFabs with corner cases.
Minus zero is returned unchanged. Indet and NaN are returned unchanged too.
2017-01-24 06:02:45 +01:00
Sei Lisa
27adfdbfb9 Fix llRound behaviour in corner cases.
We had too much precision. In LSL, llRound(0.49999997) gives 1, not 0, because the loss of precision after adding 0.5 to that makes the result 1. Fixed by converting to F32 prior to flooring.
2017-01-24 05:50:07 +01:00
Sei Lisa
80cbaf8fd5 Fix llEuler2Rot's sign.
LL's algorithm for llEuler2Rot involves calculating a rotation matrix from the Eulers, then transforming the rotation matrix to quaternion. This generates sign discrepancies with our direct quaternion calculation algorithm.

Fixed by making only the necessary calculations to find the correct sign. Unfortunately, they are still heavy (notably, six more trig functions).
2017-01-24 05:45:42 +01:00
Sei Lisa
390de46bdb Fix more issues with llRot2Euler.
Mainly, the input quaternion wasn't being normalized prior to using it for calculations, and that broke compatibility. But even then, sometimes the arc sine of a value greater than 1 could be calculated, so we clamp it.
2017-01-23 18:55:30 +01:00
Sei Lisa
250438dfe9 Simplify the llRot2Euler equations.
We save a few multiplications by dividing both atan2 arguments by 2.
2017-01-23 16:41:56 +01:00
Sei Lisa
6ac02854aa Fix llRot2Euler's return types.
It didn't return Vector in the singularity case. Also, it neglected to truncate the result to single precision.
2017-01-23 16:39:58 +01:00
Sei Lisa
84648dadea Fix a couple mismatches of llAxes2Rot with actual behaviour.
For all zeros input, the result was <1,0,0,0> but we were producing <0,0,0,.5> because the first branch was taken. Fixed.

We forgot to take the square root when calculating the magnitude of the quaternion while normalizing. Fixed.

Use qnz instead of special casing.
2017-01-23 02:06:16 +01:00
Sei Lisa
2cca835ae9 Fix evaluation order for vectors, rotations and lists.
Vectors, rotations and lists are evaluated left-to-right.
2017-01-23 01:18:50 +01:00
Sei Lisa
13c7b0ef17 Convert output of llAxes2Rot to F32. 2017-01-23 01:18:19 +01:00
Sei Lisa
dd1b7ed594 Fix llAngleBetween when given a quaternion with all zeros.
LSL behaves as if it was ZERO_ROTATION instead, so we fix it by creating a function that returns ZERO_ROTATION when given <0,0,0,0>. Use it for llRot2{Fwd,Left,Up} as well.
2017-01-23 00:08:24 +01:00
Sei Lisa
1262934baf Fix llAbs raising a run-time exception in Mono.
llAbs(-2147483648) raises this:
 System.OverflowException: Value is too small.
  at System.Math.Abs (Int32 value) [0x00000] in <filename unknown>:0
  at LindenLab.SecondLife.Library.llAbs (Int32 i) [0x00000] in <filename unknown>:0

So it's actually not computable. In LSO it returns -2147483648, though.
2017-01-22 19:54:01 +01:00
Sei Lisa
ac775c9999 Join Internal{Get|Delete}SubSequence, fixing a bug in Get.
llGetSubString and llList2List could produce output longer than the input for some params. Fix that, and join the functions into one unique function for uniformity. Also, get rid of the special case of empty elements, because it can be treated properly by the general case, and it's not so common as to merit special attention.
2017-01-22 18:08:44 +01:00
Sei Lisa
9b812a2d2a Add no-coverage markers to Windows-specific code.
It won't be reached. Also, simplify the expected errors line to make it shorter.
2017-01-22 01:32:50 +01:00
Sei Lisa
007a726bee Fix llUnescapeURL with % in place of the second hex character.
When the input was of the form e.g. "%4%40", the second "%" was erroneously starting another quoted character. LSL doesn't behave that way: parsing resumes without starting another quoted character. Disturbingly, the expected result in the corresponding test was wrong. Fixed both the test case and the code to match actual LSL behaviour.
2017-01-20 01:59:59 +01:00
Sei Lisa
b0f8b7036b A bit of reordering, to put some similar tests together. 2017-01-20 01:40:19 +01:00
Sei Lisa
551a6ece12 Make llGetListEntryType of a list-type element return 0 (TYPE_INVALID).
It was triggering ELSLInvalidType, which is not a good approach.
2017-01-20 01:18:13 +01:00
Sei Lisa
d1ff8a86dd Additional fixes to llBase64ToString behaviour.
llBase64ToString hid another surprise: characters in range from U+0000 to U+001F are substituted by "?" except for tabs (\x09), form feeds (\x0A), shift ins (\x0F) and unit separators (\x1F), which were kept verbatim. So, mimic this behaviour.
2017-01-19 07:00:06 +01:00
Sei Lisa
a6955c4057 Fix llGetListEntryType. 2017-01-19 04:46:57 +01:00
Sei Lisa
94550af95a Minor style change. 2017-01-19 03:31:02 +01:00
Sei Lisa
7c2b76949e Make one more llXorBase64[StringsCorrect] case computable.
When the input string is at most 1 byte (2 base64 characters), the result is computable because the first byte is always zero.
2017-01-19 02:58:42 +01:00
Sei Lisa
7f8cb4ec58 Fix llAbs corner case.
As an exception, llAbs(-2147483648) equals -2147483648.
2017-01-18 00:50:59 +01:00
Sei Lisa
a65300ed49 Typo in a comment. 2017-01-17 02:53:26 +01:00
Sei Lisa
c8bfd40c66 Ensure that floats are compared with 32-bit precision.
The equality operator was comparing the raw floats when two were given. Also, type() was called when it was not needed.
2017-01-17 02:38:52 +01:00
Sei Lisa
6591b5dfd8 Fix return type of cross product.
mod(Vector, Vector) was returning tuple, not Vector.
2017-01-17 02:22:10 +01:00
Sei Lisa
13f3c951e1 Mark returned constant node as side effect-free.
When a function was successfully applied, the resulting constant node was not marked as side effect-free. This could potentially lead to poor optimization.
2017-01-17 01:00:04 +01:00
Sei Lisa
65d3f1130a Fix llDetectedName return value.
Astonishingly, llDetectedName returns NULL_KEY for invalid indices.
2017-01-17 00:20:38 +01:00
Sei Lisa
d8cf384ccc Fix llGetColor return value for invalid face.
It returns <1,1,1>, not ZERO_VECTOR.
2017-01-16 23:51:40 +01:00
Sei Lisa
f657d3e875 Use hex notation for a denormal float. 2017-01-16 23:33:49 +01:00
Sei Lisa
68902c20f4 Make llGetAgentList more specific.
Testing shows that AGENT_LIST_xxx values are not used as a bitfield, but as an enum. There are only three possible valid values. Check only those three.
2017-01-16 23:23:34 +01:00
Sei Lisa
1a06bf4eb9 Fix minus zero in llFrand().
llFrand returns minus zero when given a negative denormal.
2017-01-16 20:37:11 +01:00
Sei Lisa
9d63e7268d Fix reference to vector components in llEdgeOfWorld. 2017-01-16 19:34:04 +01:00
Sei Lisa
c08d1edb5d Fix nested lists disabling list mode.
Lists can't contain lists at runtime, but they can at parse time, so the optimizer must behave properly when handling nested lists. And it didn't, because it neglected to preserve the previous state of self.listmode. So we fix that.
2017-01-13 00:36:09 +01:00
Sei Lisa
983808f022 Remove dot from floats when there are no decimals and there's an exponent. 2017-01-12 17:41:34 +01:00
Sei Lisa
2cf5ede817 Fix optimization of -0.0.
It was optimized to ((float)0) because integers are cheaper. But that loses the sign, so that needed to be fixed.
2017-01-12 15:36:08 +01:00
Sei Lisa
4ec9396688 (float)"-NaN" should produce NaN, not Indet.
But (vector)"<-NaN, 0, 0>" produces Indet, not NaN.
2017-01-12 03:29:38 +01:00
Sei Lisa
a961fee1c3 Minor formatting fix for calculator.
Don't output a newline before a list constant if in calculator mode. While we're there, make a comparison more compact.
2017-01-12 01:57:40 +01:00
Sei Lisa
3afd961cf7 Fix functions with side effects being erroneously optimized.
The function's SEF status was not taken into account when substituting functions with their values. This affected llModPow and llXorBase64Strings, both of which have a delay, and were erroneously substituted.

But allow them to be substituted when in calculator mode.
2017-01-08 05:53:10 +01:00
Sei Lisa
19dec1d79e Allow llModPow and llXorBase64Strings to work in calculator mode.
e16fad0 was somewhat hurried. Revert it and use ELSLCantCompute, which is intended exactly for that purpose.
2017-01-07 20:46:14 +01:00
Sei Lisa
ab8f8a28a9 'default' is also a switch keyword.
This is academic, because 'default' is also an LSL keyword, which is why it wasn't included, but just for correctness' sake, we add it.
2017-01-07 20:24:28 +01:00
Sei Lisa
63e4425cd5 Fix corner case with labels.
When 'if', 'for', and 'while' statements have a label as the sub-statement, e.g. `while (FALSE) @label;`, the label was improperly removed in some cases, causing a potential compilation failure.

Why someone would want to do that, one never knows, but just to be sure, it has been fixed.
2017-01-05 02:55:06 +01:00
Sei Lisa
c7e8c04349 Tentatively add support for an LSO quirk with global lists.
When a global list includes a reference to a global variable of type key, the corresponding list entry type is string, not key (SCR-295, possibly caused by SVC-1710 or SVC-4485).

This implementation is fishy, because it hard-codes the type in the node regardless of the child types. But in some quick experimenting, it seemed to work. And since the main purpose is to document LSO's behaviour, rather than actually being usable, it's OK like that.
2017-01-04 05:10:12 +01:00
Sei Lisa
8609c38451 In LSO, lists of 1 element also evaluate to false (SVC-689). 2017-01-04 05:06:56 +01:00
Sei Lisa
b04df456cb Output 1 instead of -1 on constant true conditions.
The rationale for using -1 was that it had all bits set, but that's a pretty weak argument, really. Lack of optimization of the sign could be worse, so we change it to 1, which is the value of the constant TRUE.

Also change the wording of a comment, for clarity.
2017-01-04 00:41:08 +01:00
Sei Lisa
e16fad0366 llXorBase64Strings and llModPow are not safe to precompute.
The reason is they have an embedded delay. A script might rely on it, therefore substituting the call with its value is not equivalent to leaving the call. They were both already excluded from the SEF table for the same reason.
2016-12-25 05:25:24 +01:00
Sei Lisa
7ca81020a0 Fix llGetAgentList function name in lslextrafuncs.py.
For some reason, llGetListEntryType slipped in there. The prototype and behaviour were both correct, though.
2016-12-25 01:01:28 +01:00
Sei Lisa
f222289673 Fix crash on non-computable function.
When we reduced the scope of the try block in commit a823158, we introduced a bug because the tree modification was attempted even if no value was assigned (when the exception was triggered). Returning when the function is not computable ensures that this won't happen.

Scaringly, there was no check that caught this.
2016-12-25 00:56:50 +01:00
Sei Lisa
d54ba42330 Fix more test failures on Windows.
On Windows, float('nan') produces Indeterminate. To fix, set Indet first and then set NaN to the opposite.
2016-12-22 06:05:47 +01:00
Sei Lisa
efcf1cb1df Fix llListSort problem on Windows.
Apparently, under Windows, Python does a UTF-16 word-by-word comparison when comparing two strings:

>>> u'\ud700' < u'\U0001d41a'
True
>>> u'\ue000' < u'\U0001d41a'
False

Fix it by encoding as UTF-32 big endian before comparison, when that happens.
2016-12-22 05:50:18 +01:00
Sei Lisa
91fd9734c8 Fix llRot2Fwd/llRot2Left/llRot2Up and add regression tests. 2016-12-22 03:06:56 +01:00
Sei Lisa
a8231586c1 Reduce the scope of the try...except block to only cover the call.
Major indentation changes, but minor actual changes.
2016-12-22 01:24:44 +01:00
Sei Lisa
14488ddd92 Improve behaviour of llAtan2 to make it closer to SL's.
Especially regarding NaN inputs. Add regression tests.
2016-12-22 01:08:07 +01:00
Sei Lisa
159fae90bf Improve llFrand.
- Remove it from lslextrafuncs, and move all the code to lslbasefuncs.
- Make it behave like SL's more accurately. Denormals return 0 always in SL.
- Use int() for truncation rather then floor/ceil.
- Add test cases.
2016-12-22 01:05:21 +01:00
Sei Lisa
fc97ce42df Be explicit about corner cases for llFrand.
inf and nan already did the right thing in Python, but just in case that doesn't happen in all platforms, we handle them explicitly. Also, that will make it more immune to bugs in future.
2016-12-21 21:49:43 +01:00
Sei Lisa
2327613423 Follow-up to ba9511e: Fix rounding of result. 2016-12-21 20:26:40 +01:00
Sei Lisa
6879037735 Fix type conversion on calling LSL functions.
We had a big chaos with type conversion. That caused a bug where passing a key to a function that required a string, or vice versa, crashed the script.

Diminish the chaos by modifying the parameters just prior to invocation (in lslfoldconst). We also remove the, now unnecessary, calls to force floats, either alone or within vectors or quaternions.
2016-12-21 06:01:03 +01:00
Sei Lisa
27eeec06cf Fix type of parameter not being adjusted after optimizing parameter. 2016-12-21 05:44:32 +01:00
Sei Lisa
5105cee2e4 We already had imported hashlib. 2016-12-21 02:45:17 +01:00
Sei Lisa
7ebd68c7b2 llGenerateKey() returns key, not string 2016-12-21 01:32:54 +01:00
Sei Lisa
ba9511e2ff Implement llFrand and llGenerateKey when in Calc mode. 2016-12-21 01:18:25 +01:00
Sei Lisa
1b7dbd9453 Fix llGetColor in lslextrafuncs.py
Too much copy-paste. The name of the parameter should have been 'face', not 'id'.
2016-12-21 00:41:08 +01:00
Sei Lisa
991e811f2d Fix Python gotcha with module globals, and missing 'cond' in lslextrafuncs.
The previous commit didn't work as expected. "from module import var" freezes the value at load time; changing it later has no effect. A reference to the module needs to be used.

Fix that and the similar problem with LSO. Also revert some "from lslcommon import *" introduced earlier.

That also revealed another bug about missing 'cond' in the import list of lslextrafuncs. This should fix all functions that return values on null key input.
2016-12-21 00:22:49 +01:00
Sei Lisa
7c2c09188d Change how LSLCalc is handled.
Instead of using an option in the command line, use a global in lslcommon, settable by the main program (only the main LSLCalc program, which differs from LSL-PyOptimizer's main, changes it).
2016-12-20 21:25:33 +01:00
Sei Lisa
1b6777e47b Comment the LSO and ELSONotSupported globals in lslcommon.py. 2016-12-20 21:19:48 +01:00
Sei Lisa
39261cbfc8 Make Unicode some strings that should be, and improve error reporting in builtins.txt
Also work towards the convention that strings that represent text (possibly translatable) are in double quotes, not single.
2016-12-20 20:13:53 +01:00
Sei Lisa
0b0f10007b Update copyright year. 2016-12-15 04:37:33 +01:00