mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Try to do better with the propagation of FoldCond.
Negation, specifically, didn't propagate to children. This might be redundant, though.
This commit is contained in:
parent
c5b5a8303c
commit
2e29cc9131
1 changed files with 8 additions and 4 deletions
|
@ -130,14 +130,18 @@ class foldconst(object):
|
||||||
return # Nothing to do if it's already simplified.
|
return # Nothing to do if it's already simplified.
|
||||||
child = node['ch'] if 'ch' in node else None
|
child = node['ch'] if 'ch' in node else None
|
||||||
|
|
||||||
if nt == '!' and child[0]['nt'] == '!':
|
if nt == '!':
|
||||||
# bool(!!a) equals bool(a)
|
self.FoldCond(child, 0, True)
|
||||||
parent[index] = child[0]['ch'][0]
|
|
||||||
return
|
if child[0]['nt'] == '!':
|
||||||
|
# bool(!!a) equals bool(a)
|
||||||
|
parent[index] = child[0]['ch'][0]
|
||||||
|
return
|
||||||
|
|
||||||
if nt == 'NEG':
|
if nt == 'NEG':
|
||||||
# bool(-a) equals bool(a)
|
# bool(-a) equals bool(a)
|
||||||
parent[index] = child[0]
|
parent[index] = child[0]
|
||||||
|
self.FoldCond(parent, index, ParentIsNegation)
|
||||||
return
|
return
|
||||||
|
|
||||||
if nt in self.binary_ops and child[0]['t'] == child[1]['t'] == 'integer':
|
if nt in self.binary_ops and child[0]['t'] == child[1]['t'] == 'integer':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue