Get rid of DoesSomething() in favour of SEF

The missing bit was to mark labels are SEF when they are not referenced. Label references are now counted at parse time, enabling us to do this.

Also, make FoldStmt clearer when the node is an expression.
This commit is contained in:
Sei Lisa 2018-05-17 08:12:33 +02:00
parent a93ea0ca19
commit 285c7172fd
3 changed files with 71 additions and 55 deletions

View file

@ -384,6 +384,12 @@ class deadcode(object):
node = curnode.ch[index]
if not hasattr(node, 'X'):
if curnode.ch[index].nt == 'JUMP':
# Decrease label reference count
scope = curnode.ch[index].scope
name = curnode.ch[index].name
assert self.symtab[scope][name]['ref'] > 0
self.symtab[scope][name]['ref'] -= 1
del curnode.ch[index]
continue