mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Optimize chains of assignments
This allows optimizing, for example: integer a = 1; integer b = a; llOwnerSay((string)b); which wasn't done before. This case is prone to happen with inlined functions, e.g. using the result of an inlined function as a parameter to another.
This commit is contained in:
parent
5a5635358f
commit
454d44e85f
1 changed files with 9 additions and 0 deletions
|
@ -318,6 +318,15 @@ class deadcode(object):
|
||||||
|
|
||||||
node = sym['W']
|
node = sym['W']
|
||||||
nt = node.nt
|
nt = node.nt
|
||||||
|
|
||||||
|
while nt == 'IDENT':
|
||||||
|
# Follow the chain of identifiers all the way to the original
|
||||||
|
if self.symtab[node.scope][node.name].get('W', False) is False:
|
||||||
|
return sym
|
||||||
|
sym = self.symtab[node.scope][node.name]
|
||||||
|
node = sym['W']
|
||||||
|
nt = node.nt
|
||||||
|
|
||||||
if nt == 'CONST':
|
if nt == 'CONST':
|
||||||
tcurnode = curnode.t
|
tcurnode = curnode.t
|
||||||
if tcurnode in ('integer', 'string', 'key'):
|
if tcurnode in ('integer', 'string', 'key'):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue