mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 07:38:21 +00:00
Further generalize the <
operator
Use the node's min and max for both sides. Constants are just a special case where min = max = value.
This commit is contained in:
parent
d2e3b9a3bd
commit
c1c1b8c58d
1 changed files with 11 additions and 23 deletions
|
@ -1331,38 +1331,26 @@ class foldconst(object):
|
||||||
SEF=True)
|
SEF=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
if child[0].nt == 'CONST' and child[1].SEF:
|
if child[0].SEF and child[1].SEF:
|
||||||
# when CONST >= second.max: always false
|
|
||||||
# when CONST < second.min: always true
|
|
||||||
rmin = self.getMin(child[1])
|
|
||||||
rmax = self.getMax(child[1])
|
|
||||||
if (rmax is not None
|
|
||||||
and not lslfuncs.less(child[0].value, rmax)
|
|
||||||
):
|
|
||||||
parent[index] = nr(nt='CONST', t='integer',
|
|
||||||
value=0, SEF=True)
|
|
||||||
return
|
|
||||||
if rmin is not None and lslfuncs.less(child[0].value, rmin):
|
|
||||||
parent[index] = nr(nt='CONST', t='integer',
|
|
||||||
value=1, SEF=True)
|
|
||||||
return
|
|
||||||
del rmin, rmax
|
|
||||||
if child[1].nt == 'CONST' and child[0].SEF:
|
|
||||||
# when first.max < CONST: always true
|
|
||||||
# when first.min >= CONST: always false
|
|
||||||
lmin = self.getMin(child[0])
|
lmin = self.getMin(child[0])
|
||||||
lmax = self.getMax(child[0])
|
lmax = self.getMax(child[0])
|
||||||
if lmax is not None and lslfuncs.less(lmax, child[1].value):
|
rmin = self.getMin(child[1])
|
||||||
|
rmax = self.getMax(child[1])
|
||||||
|
# when lmax < rmin: always true
|
||||||
|
if (rmin is not None and lmax is not None
|
||||||
|
and lslfuncs.less(lmax, rmin)
|
||||||
|
):
|
||||||
parent[index] = nr(nt='CONST', t='integer',
|
parent[index] = nr(nt='CONST', t='integer',
|
||||||
value=1, SEF=True)
|
value=1, SEF=True)
|
||||||
return
|
return
|
||||||
if (lmin is not None
|
# when lmin >= rmax: always false
|
||||||
and not lslfuncs.less(lmin, child[1].value)
|
if (rmax is not None and lmin is not None
|
||||||
|
and not lslfuncs.less(lmin, rmax)
|
||||||
):
|
):
|
||||||
parent[index] = nr(nt='CONST', t='integer',
|
parent[index] = nr(nt='CONST', t='integer',
|
||||||
value=0, SEF=True)
|
value=0, SEF=True)
|
||||||
return
|
return
|
||||||
del lmin, lmax
|
del lmin, lmax, rmin, rmax
|
||||||
|
|
||||||
# Convert 2147483647<i and i<-2147483648 to i&0
|
# Convert 2147483647<i and i<-2147483648 to i&0
|
||||||
if (child[0].t == child[1].t == 'integer'
|
if (child[0].t == child[1].t == 'integer'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue