Commit graph

604 commits

Author SHA1 Message Date
Sei Lisa
1df05ed0d7 The grammar comment for simple_expr_except_list was missing IDENT 2022-10-31 17:20:25 +01:00
Sei Lisa
9c281dec64 New function, llSHA256String
Implement it in lslbasefuncs.py, and add tests. Also add more test vectors for llMD5String and llSHA1String.
2022-10-14 18:39:04 +02:00
Sei Lisa
8966b9de97 New upstream function: llGetObjectLinkKey 2022-10-01 01:18:12 +02:00
Sei Lisa
bc992e6182 LL change: the status of STATUS_DIE_AT_* is returned
As of Second Life Server 2022-09-09.574921, STATUS_DIE_AT_EDGE and STATUS_DIE_AT_NO_ENTRY return their corresponding settings rather than always FALSE.

Regression/coverage tests are clearly lacking in this area, as the change didn't trigger any test breakage, therefore add some unit tests.
2022-09-15 01:09:12 +02:00
Sei Lisa
95d0fb4b13 New upstream version of builtins.txt; minor fix
Add comment to llGetStatus and make it more future-proof by adding unused flags.
2022-08-26 12:51:02 +02:00
Sei Lisa
8d413f910e Forgot to update copyright year 2022-06-07 19:46:31 +02:00
Sei Lisa
fb61e00780 Minor cleanup 2022-06-07 19:39:26 +02:00
Sei Lisa
9dedabfa71 Don't rely on Python generating Indet on (float)"-nan"
We did the same for vectors. We don't have enough guarantee that Python will return Indet when evaluating float(u"-nan").
2022-05-19 14:42:01 +02:00
Sei Lisa
07cf4fe30f LSO does not force positive zero in llDumpList2String
And minor aesthetic change.
2022-05-19 14:29:14 +02:00
Sei Lisa
828b020b8c Remove disabled code 2022-05-17 22:30:07 +02:00
Sei Lisa
d2e64e25a6 Rewrite Mono float to string conversion; fix llDumpList2String
llDumpList2String has changed its behaviour with respect to minus zero. Now it converts -0.0 to a string without the minus sign.

While testing this, we noticed several mismatches in the float to string conversions; the existing routine did not properly convert some values because as we discovered later, it is subject to double rounding; one of them is the built-in round-to-nearest-or-even while getting the first 7 significant digits, and the other is just an increment when the digit is a 5 or more, so round to nearest, ties away from zero, and is performed on the digit past the five or six visible digits that LSL shows.

The new code is a tad easier to understand and more robust.

A first variant of the new code is left commented out for history's sake, and will be removed in the next commit.
2022-05-17 22:28:49 +02:00
Sei Lisa
281ff4d96a Strings representing denormals no longer give 0 when cast to float
This annoyance and discrepancy with LSO was finally fixed by Linden Lab. The change has prompted some modifications to the test suite to accommodate for the new results. A further improvement has been to make these tests more friendly to be run in SL, making it easier to verify the results.

Fixes #17.

Reported by SaladDais@users.noreply.github.com - thanks!
2022-05-17 13:48:05 +02:00
Sei Lisa
7c630f4ce4 Fix crash in conversion to string for floats < 1e-13
Fixes part of #17.

Reported by SaladDais@users.noreply.github.com, thanks!
2022-05-17 13:37:39 +02:00
Sei Lisa
c29475d072 New constants and functions; some refactoring of lslfuncopt
TODO: unit tests
2022-05-13 14:49:18 +02:00
Sei Lisa
be479771aa Implement llListRandomize for the calculator 2022-03-29 23:29:09 +02:00
Sei Lisa
02b37d6dad Add OBJECT_ACCOUNT_LEVEL, fix PRIM_PROJECTOR 2022-03-06 02:54:58 +01:00
Sei Lisa
bf72d2c3bf Allow //pragma inline or /*pragma inline*/ for inlining a function
They are transformed by the scanner to the identifier `inline`, which is how the parser identifies it. This solves the comment problem, but it results in a funny side effect. Now, in inline mode, /*pragma inline*/ will always be the identifier `inline`, therefore this is valid:

    integer /*pragma inline*/ = 5;
    llOwnerSay((string)inline); // will say 5

Not overly elegant, but better than making up a specific token or declaring comments as tokens or the like.
2021-10-17 20:29:22 +02:00
Sei Lisa
064a8c4319 Add PRIM_PROJECTOR, add PRIM_TYPE_LEGACY, minor cleanups 2021-10-17 19:08:21 +02:00
Sei Lisa
03c33d1471 Simplify comparisons for most cases in llChar 2021-05-19 22:49:14 +02:00
Sei Lisa
c4f210138f Add newly introduced functions llOrd, llChar, llHash 2021-05-08 22:43:31 +02:00
Sei Lisa
53e8bd659a The Base64 functions that used to produce garbage no longer do 2021-03-21 19:05:37 +01:00
Sei Lisa
da05d1e1c2 Add Pop to the list of idents that GetNextShortest can't generate
It's unlikely to hit this one (requires more than 10,000 identifiers to trigger) but it's a bug nevertheless.

While touching the file, try to explain the situation better in the first comment.
2021-01-05 23:27:49 +01:00
Sei Lisa
81906475ff Update copyright year 2021-01-05 23:27:21 +01:00
Sei Lisa
0b266db758 Fix InternalUTF8ToString to consider U+FFFE as invalid
This commit also adds the foldtabs option as default for the eval test suite, and substantially improves the Unicode valid/invalid character test.
2020-11-19 22:26:42 +01:00
Sei Lisa
4771c76d85 Greatly simplify InternalUTF8ToString using a regular expression 2020-11-19 20:23:44 +01:00
Sei Lisa
c77607d318 Document the behaviour of InternalUTF8ToString 2020-11-19 20:22:11 +01:00
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
4fd4bf71aa Use frozenset more consistently 2020-11-09 02:11:35 +01:00
Sei Lisa
d9938f1a37 Misc small non-user-visible fixes
Some are Unicode vs Str stuff, others are style adjustments, others in unused functions, and so on.
2020-11-09 02:00:40 +01:00
Sei Lisa
59c3f9fc71 Add newest llGetEnv settings 2020-11-09 01:27:13 +01:00
Sei Lisa
13e48ff956 Improve +processpre directive parsing to include #warning 2020-11-02 11:16:36 +01:00
Sei Lisa
90fddf9dcd Report EParseCodePathWithoutRet at a more meaningful position 2020-10-11 16:31:49 +02:00
Sei Lisa
9e5f6e928d Improve compatibility of llToLower/llToUpper
Based on sim experiments.
2020-09-23 01:11:21 +02:00
Sei Lisa
d6bf0c390e Fix two issues in the dead code removal module
1. When the last statement of a function is a RETURN statement which is syntactically required, it could still be deleted.
2. The child of a RETURN statement could be removed if the statement was not executed.

This commit fixes both issues.

Bug report and test case provided by @Tonaie. Fixes #14.
2020-06-01 20:49:48 +02:00
Sei Lisa
0affbf13dd Fix "" + list_expr producing list_expr
The type checks were not strong enough. While on it, strengthen other similar checks as well.

Reported by @Tonaie. Fixes #13.
2020-04-23 13:47:57 +02:00
Sei Lisa
c8a0a21823 Add llLinear2sRGB / llsRGB2Linear implementations 2020-04-23 01:10:37 +02:00
Sei Lisa
234b9b23a3 Bump copyright year 2020-04-23 00:38:20 +02:00
Sei Lisa
be850e69cc Move comment 2019-11-03 01:09:23 +01:00
Sei Lisa
a8d8c14c79 Fix NULL_KEY being optimized to "" in UDFs; do some minor changes
Bug reported by @tapple. Fixes #11.
2019-11-03 00:55:30 +01:00
Sei Lisa
6d959f6f90 Handle llGetLinkName with invalid values 2019-10-11 19:38:28 +02:00
Sei Lisa
980b588986 Add FIXME and TODO 2019-10-11 19:38:05 +02:00
Sei Lisa
c02998518a Rename FoldCond -> FoldAsBool which better expresses the idea 2019-07-25 17:44:45 +02:00
Sei Lisa
1ab9dd69b4 Fix optimization of fn > -1 and fn < 0 when fn's minimum is -1 in conditions
E.g. llSubStringIndex(...) > -1 was converted into !~llSubStringIndex(...) which is incorrect. We even had a test case for it... with a wrong expected response file.

Bug report and test case by Sinha Hynes (thanks!)
2019-07-16 01:58:19 +02:00
Sei Lisa
1bdaff32ab When optimizing nonconst * const, cast the result to the type of the operator.
Per bug report by @Welcius.

Fixes #8.
2019-07-02 15:40:20 +02:00
Sei Lisa
750465f17b New upstream version of builtins.txt, new OBJECT_* constants 2019-06-23 13:33:02 +02:00
Sei Lisa
00b103c8aa Simplify v*q, make q*q more accurate, add q*q and q/q unit tests
vector * quaternion: Simplified by precalculating the repeated products and removing math.fsum.

quaternion * quaternion: Add more F32's to get a result closer to SL's (still not there, but we're definitively closer now).

We left out quaternion/quaternion in the tests, and the q*q test was not general enough (had many zeros). Remedied that.
2019-05-23 01:57:27 +02:00
Sei Lisa
ec509b3840 Fix parenthesization of unary minus
The algorithm for adding parentheses around unary operators was not working properly. It converted a * (-b) * c into a * -b * c, which LSL handles as a * -(b * c).

Fix and add test cases for that. One of the test cases shows an example where the difference matters: 0 * (-1e20) * 1e20 should result in 0.0, but if wrongly parenthesized, it gives NaN, because 1e20*1e20 gives infinity due to float overflow, and minus infinity times 0 is indeterminate.

The addition of parentheses has been improved, but it still does not eliminate every redundant parenthesis.

Also fix the horrendous typo of using "operands" where it should be "operators".
2019-05-04 23:20:20 +02:00
Sei Lisa
9d540798b4 Allow returning void expressions where state changes are allowed
In the same places as state changes are allowed, i.e. in places where a parent of the AST node is a WHILE/DO/FOR or an IF without ELSE, it's allowed to use return statements with expressions that return void, e.g. llDie(), provided the function itself is declared as returning void.

The construction, when found, is rewritten to '{<void expression>; return;}' because the optimizer is not designed to deal with these monsters.

We've renamed the variable SuspiciousStSw to PruneBug, because it's used for both purposes now, though a better name might have been PruneBugPendingChecks, because these are only errors if the IF has an ELSE. We've also added the exception to raise as part of the data stored in the list.

Per report by Tonaie Resident.
2019-05-01 04:28:58 +02: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