mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
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.
This commit is contained in:
parent
ac775c9999
commit
1262934baf
2 changed files with 12 additions and 7 deletions
|
@ -94,6 +94,11 @@ class ELSLInvalidType(Exception):
|
|||
class ELSLCantCompute(Exception):
|
||||
pass
|
||||
|
||||
# We don't yet support the LSO string model (arbitrary zero-terminated byte
|
||||
# sequences). This exception is triggered to report attempts at using it.
|
||||
class ELSONotSupported(Exception):
|
||||
pass
|
||||
|
||||
# LSL types are translated to Python types as follows:
|
||||
# * LSL string -> Python unicode
|
||||
# * LSL key -> Key (class derived from unicode, no significant changes except __repr__)
|
||||
|
@ -726,7 +731,7 @@ def mod(a, b, f32=True):
|
|||
def compare(a, b, Eq = True):
|
||||
"""Calculate a == b when Eq is True, or a != b when not"""
|
||||
|
||||
# Defined for all types as long as there's one that can be cast to the other
|
||||
# Defined for all types as long as one of them can be auto-cast to the other
|
||||
ta = type(a)
|
||||
tb = type(b)
|
||||
if ta in (int, float) and tb in (int, float):
|
||||
|
@ -808,7 +813,12 @@ def reduce(t):
|
|||
|
||||
def llAbs(i):
|
||||
assert isinteger(i)
|
||||
return abs(i) if i != -2147483648 else i
|
||||
if i != -2147483648:
|
||||
return abs(i)
|
||||
if lslcommon.LSO:
|
||||
return i
|
||||
# Mono raises an OverflowException in this case.
|
||||
raise ELSLCantCompute
|
||||
|
||||
def llAcos(f):
|
||||
assert isfloat(f)
|
||||
|
|
|
@ -30,11 +30,6 @@ class Quaternion(tuple):
|
|||
def __repr__(self):
|
||||
return 'Quaternion(' + super(Quaternion, self).__repr__() + ')'
|
||||
|
||||
# We don't yet support the LSO string model (arbitrary zero-terminated byte
|
||||
# sequences). This exception is triggered to report attempts at using it.
|
||||
class ELSONotSupported(Exception):
|
||||
pass
|
||||
|
||||
# Recognized: 3763, 6466, 6495
|
||||
# BUG-3763 affected llXorBase64 (see lslbasefuncs.py). It's been fixed.
|
||||
# BUG-6466 is about some valid numbers in JSON not being accepted. It's fixed.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue