Save a comparison (fixes a FIXME)

This commit is contained in:
Sei Lisa 2018-06-08 00:07:36 +02:00
parent 0808938894
commit e88e39127b

View file

@ -1347,27 +1347,27 @@ class foldconst(object):
node.ch = [child[a]] node.ch = [child[a]]
return return
#FIXME: Could remove one comparison if nt == '||':
if nt == '&&' or nt == '||': # Expand to its equivalent a || b -> !!(a | b)
if nt == '||': node = nr(nt='|', t='integer', ch=[child[0], child[1]],
# Expand to its equivalent a || b -> !!(a | b) SEF=child[0].SEF and child[1].SEF)
node = nr(nt='|', t='integer', ch=[child[0], child[1]], node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
SEF=child[0].SEF and child[1].SEF) node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF) parent[index] = node
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF) # Make another pass with the substitution
parent[index] = node self.FoldTree(parent, index)
else: elif nt == '&&':
orchildren = [ # Expand to its equivalent a && b -> !(!a | !b)
nr(nt='!',t='integer',ch=[child[0]],SEF=child[0].SEF), orchildren = [
nr(nt='!',t='integer',ch=[child[1]],SEF=child[1].SEF) nr(nt='!', t='integer', ch=[child[0]], SEF=child[0].SEF),
] nr(nt='!', t='integer', ch=[child[1]], SEF=child[1].SEF)
node = nr(nt='|', t='integer', ch=orchildren, ]
SEF=child[0].SEF and child[1].SEF) node = nr(nt='|', t='integer', ch=orchildren,
node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF) SEF=child[0].SEF and child[1].SEF)
parent[index] = node node = nr(nt='!', t='integer', ch=[node], SEF=node.SEF)
parent[index] = node
# Make another pass with the substitution # Make another pass with the substitution
self.FoldTree(parent, index) self.FoldTree(parent, index)
return
return return