mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2024-11-21 06:15:56 -07:00
Calculate llFrand's min and max when possible
This commit is contained in:
parent
65326115d8
commit
bf505220ac
8 changed files with 79 additions and 0 deletions
|
@ -528,6 +528,12 @@ def OptimizeFunc(self, parent, index):
|
|||
parent[index] = nr(nt='CONST', t='list', value=[], SEF=True)
|
||||
return
|
||||
|
||||
if name == 'llFrand' and child[0].nt == 'CONST':
|
||||
# We can set a range when the input is a constant
|
||||
value = child[0].value
|
||||
node.min = lslfuncs.F32(min(value, 0) * 0.9999999403953552)
|
||||
node.max = lslfuncs.F32(max(value, 0) * 0.9999999403953552)
|
||||
|
||||
def FuncOptSetup():
|
||||
# Patch the default values list for LSO
|
||||
if lslcommon.LSO:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Test that there's at least one 7-digit number
|
||||
[ llFrand(16777216)
|
||||
, llFrand(16777216)
|
||||
, llFrand(16777216)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// Test that there's at least one 8-digit number
|
||||
[ llFrand(16777216)
|
||||
, llFrand(16777216)
|
||||
, llFrand(16777216)
|
||||
|
|
23
unit_tests/expr.suite/llfrand-3.lsl
Normal file
23
unit_tests/expr.suite/llfrand-3.lsl
Normal file
|
@ -0,0 +1,23 @@
|
|||
[ llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
, llFrand(-5)
|
||||
, llFrand(-5.0)
|
||||
]
|
3
unit_tests/expr.suite/llfrand-3.out
Normal file
3
unit_tests/expr.suite/llfrand-3.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
REGEX
|
||||
(?:[\[,] -[0-4]\.[0-9]*
|
||||
){22}\]
|
20
unit_tests/regression.suite/llfrand.lsl
Normal file
20
unit_tests/regression.suite/llfrand.lsl
Normal file
|
@ -0,0 +1,20 @@
|
|||
default { timer() {
|
||||
llParticleSystem(
|
||||
[ llFrand(-5)
|
||||
, llFrand(-5) > -5
|
||||
, llFrand(-5) <= 0
|
||||
, llFrand(-5) > 0
|
||||
, llFrand(-5.)
|
||||
, llFrand(-16777216)
|
||||
, llFrand(-16777216.)
|
||||
, llFrand(5)
|
||||
, llFrand(5) < 5
|
||||
, llFrand(5) >= 0
|
||||
, llFrand(5) < 0
|
||||
, llFrand(5.)
|
||||
, llFrand(16777216)
|
||||
, llFrand(16777216.)
|
||||
, llFrand(33554433)
|
||||
, llFrand(33554433.)
|
||||
]);
|
||||
}}
|
24
unit_tests/regression.suite/llfrand.out
Normal file
24
unit_tests/regression.suite/llfrand.out
Normal file
|
@ -0,0 +1,24 @@
|
|||
default
|
||||
{
|
||||
timer()
|
||||
{
|
||||
llParticleSystem(
|
||||
[ llFrand(((integer)-5))
|
||||
, 1
|
||||
, 1
|
||||
, 0
|
||||
, llFrand(((float)-5))
|
||||
, llFrand(((integer)-16777216))
|
||||
, llFrand(((float)-16777216))
|
||||
, llFrand(5)
|
||||
, 1
|
||||
, 1
|
||||
, 0
|
||||
, llFrand(((float)5))
|
||||
, llFrand(16777216)
|
||||
, llFrand(((float)16777216))
|
||||
, llFrand(33554433)
|
||||
, llFrand(((float)33554432))
|
||||
]);
|
||||
}
|
||||
}
|
1
unit_tests/regression.suite/llfrand.run
Normal file
1
unit_tests/regression.suite/llfrand.run
Normal file
|
@ -0,0 +1 @@
|
|||
main.py -O -listadd -
|
Loading…
Reference in a new issue