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:
Sei Lisa 2017-08-15 13:07:30 +02:00
parent c5b5a8303c
commit 2e29cc9131

View file

@ -130,7 +130,10 @@ class foldconst(object):
return # Nothing to do if it's already simplified.
child = node['ch'] if 'ch' in node else None
if nt == '!' and child[0]['nt'] == '!':
if nt == '!':
self.FoldCond(child, 0, True)
if child[0]['nt'] == '!':
# bool(!!a) equals bool(a)
parent[index] = child[0]['ch'][0]
return
@ -138,6 +141,7 @@ class foldconst(object):
if nt == 'NEG':
# bool(-a) equals bool(a)
parent[index] = child[0]
self.FoldCond(parent, index, ParentIsNegation)
return
if nt in self.binary_ops and child[0]['t'] == child[1]['t'] == 'integer':