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:
Sei Lisa 2017-01-22 19:45:14 +01:00
parent ac775c9999
commit 1262934baf
2 changed files with 12 additions and 7 deletions

View file

@ -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)