mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18:20 +00:00
In functions that end in 'return;', remove the 'return;'.
This allows better side-effect analysis, because 'return' is not side-effect free unless it's the last statement. But that's better handled in the dead code removal module, as the comment specifies.
This commit is contained in:
parent
9cb02839bc
commit
df31a69465
1 changed files with 7 additions and 0 deletions
|
@ -812,6 +812,13 @@ class foldconst(object):
|
||||||
# event definition
|
# event definition
|
||||||
self.CurEvent = node['name']
|
self.CurEvent = node['name']
|
||||||
self.FoldTree(child, 0)
|
self.FoldTree(child, 0)
|
||||||
|
# TODO: This works, but analysis of code paths is DCR's thing
|
||||||
|
# and this is incomplete, e.g. x(){{return;}} is not detected.
|
||||||
|
while 'ch' in child[0] and child[0]['ch']:
|
||||||
|
last = child[0]['ch'][-1]
|
||||||
|
if last['nt'] != 'RETURN' or 'ch' in last:
|
||||||
|
break
|
||||||
|
del child[0]['ch'][-1]
|
||||||
if 'SEF' in child[0]:
|
if 'SEF' in child[0]:
|
||||||
node['SEF'] = True
|
node['SEF'] = True
|
||||||
if node['name'] in self.symtab[0]:
|
if node['name'] in self.symtab[0]:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue