Implement side-effect-free (SEF) analysis. Also optimize x++ to ++x.

As an additional bonus, the condition folding function is now the one that converts a condition to -1, relieving that burden from the rest of the code and simplifying tests.
This commit is contained in:
Sei Lisa 2014-08-06 04:30:26 +02:00
parent 0a7d409a4e
commit 9c4d81db08
2 changed files with 172 additions and 43 deletions

View file

@ -2050,3 +2050,16 @@ class parser(object):
finally:
f.close()
# Load the side-effect-free table as well.
f = open('seftable.txt', 'rb')
try:
while True:
line = f.readline()
if line == '':
break
line = line.strip()
if line and line[0] != '#' and line in self.functions:
self.functions[line]['SEF'] = True
finally:
f.close()