mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
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!)
This commit is contained in:
parent
1bdaff32ab
commit
1ab9dd69b4
2 changed files with 7 additions and 7 deletions
|
@ -549,23 +549,23 @@ class foldconst(object):
|
|||
sym = self.symtab[0][child[a].name]
|
||||
break
|
||||
|
||||
# cond(FNCALL < 0) -> cond(~FNCALL) if min == -1
|
||||
# cond(FNCALL < 0) -> cond(!~FNCALL) if min == -1
|
||||
if (child[1].nt == 'CONST' and child[1].value == 0
|
||||
and child[0].nt == 'FNCALL'
|
||||
and 'min' in sym and sym['min'] == -1
|
||||
):
|
||||
node = parent[index] = nr(nt='~', t='integer',
|
||||
ch=[child[0]])
|
||||
node = parent[index] = nr(nt='!', t='integer',
|
||||
ch=[nr(nt='~', t='integer', ch=[child[0]])])
|
||||
self.FoldTree(parent, index)
|
||||
return
|
||||
|
||||
# cond(FNCALL > -1) -> cond(!~FNCALL) if min == -1
|
||||
# cond(FNCALL > -1) -> cond(~FNCALL) if min == -1
|
||||
if (child[0].nt == 'CONST' and child[0].value == -1
|
||||
and child[1].nt == 'FNCALL'
|
||||
and 'min' in sym and sym['min'] == -1
|
||||
):
|
||||
node = parent[index] = nr(nt='!', t='integer',
|
||||
ch=[nr(nt='~', t='integer', ch=[child[1]])])
|
||||
node = parent[index] = nr(nt='~', t='integer',
|
||||
ch=[child[1]])
|
||||
self.FoldTree(parent, index)
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue