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:
Sei Lisa 2019-01-02 20:41:14 +01:00
parent 5a5635358f
commit 454d44e85f

View file

@ -318,6 +318,15 @@ class deadcode(object):
node = sym['W']
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':
tcurnode = curnode.t
if tcurnode in ('integer', 'string', 'key'):