matchcompiler: don't emmit '!true' or '!false'. Fold to 'false' or 'true'.
This commit is contained in:
parent
92fe210217
commit
c65725cb1b
|
@ -188,7 +188,14 @@ class MatchCompiler:
|
||||||
gotoNextToken = ' tok = tok ? tok->next() : NULL;\n'
|
gotoNextToken = ' tok = tok ? tok->next() : NULL;\n'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
ret += ' if (!tok || !' + self._compileCmd(tok) + ')\n'
|
negatedTok ="!" + self._compileCmd(tok)
|
||||||
|
# fold !true => false ; !false => true
|
||||||
|
# this avoids cppcheck warnings about condition always being true/false
|
||||||
|
if (negatedTok == "!false"):
|
||||||
|
negatedTok = "true"
|
||||||
|
elif (negatedTok == "!true"):
|
||||||
|
negatedTok = "false"
|
||||||
|
ret += ' if (!tok || ' + negatedTok + ')\n'
|
||||||
ret += ' ' + returnStatement
|
ret += ' ' + returnStatement
|
||||||
|
|
||||||
if isFindMatch:
|
if isFindMatch:
|
||||||
|
|
Loading…
Reference in New Issue