From b04df456cbd12d45998fc7fd179e5778060a0704 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Wed, 4 Jan 2017 00:41:08 +0100 Subject: [PATCH] Output 1 instead of -1 on constant true conditions. The rationale for using -1 was that it had all bits set, but that's a pretty weak argument, really. Lack of optimization of the sign could be worse, so we change it to 1, which is the value of the constant TRUE. Also change the wording of a comment, for clarity. --- lslopt/lslfoldconst.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index ca3f5e8..40fb09b 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -107,7 +107,7 @@ class foldconst(object): if nt in ('CONST', 'IDENT', 'FLD'): if node['nt'] == 'CONST': node['t'] = 'integer' - node['value'] = -1 if lslfuncs.cond(node['value']) else 0 + node['value'] = 1 if lslfuncs.cond(node['value']) else 0 return # Nothing to do if it's already simplified. child = node['ch'] if 'ch' in node else None @@ -1173,7 +1173,8 @@ class foldconst(object): # And if there is more than one, these expressions will need a # new block, which means new scope, which is dangerous. # They are expressions, no declarations or labels allowed, thus - # no new identifiers, but it still feels uneasy. + # no new identifiers may be created in the new scope, but it + # still feels dodgy. if child[1]['value']: # Endless loop. Traverse the loop and the iterator. self.FoldTree(child, 3)