From 2e29cc91310cb533c18e29adf0c14943fe126d3b Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Tue, 15 Aug 2017 13:07:30 +0200 Subject: [PATCH] Try to do better with the propagation of FoldCond. Negation, specifically, didn't propagate to children. This might be redundant, though. --- lslopt/lslfoldconst.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 47f9a9f..70f32df 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -130,14 +130,18 @@ 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'] == '!': - # bool(!!a) equals bool(a) - parent[index] = child[0]['ch'][0] - return + if nt == '!': + self.FoldCond(child, 0, True) + + if child[0]['nt'] == '!': + # bool(!!a) equals bool(a) + parent[index] = child[0]['ch'][0] + return 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':