mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18:20 +00:00
Optimize [elem] -> (list)elem on output. Saves us headaches.
This commit is contained in:
parent
2948399bf8
commit
f6b472133a
1 changed files with 4 additions and 1 deletions
|
@ -229,9 +229,11 @@ class outscript(object):
|
||||||
return self.FindName(expr)
|
return self.FindName(expr)
|
||||||
|
|
||||||
if nt == 'CONST':
|
if nt == 'CONST':
|
||||||
|
if self.foldconst and expr['t'] == 'list' and len(expr['value'])==1 and not self.globalmode:
|
||||||
|
return '(list)' + self.Value2LSL(expr['value'][0])
|
||||||
return self.Value2LSL(expr['value'])
|
return self.Value2LSL(expr['value'])
|
||||||
|
|
||||||
if nt == 'CAST':
|
if nt == 'CAST' or self.foldconst and nt in ('LIST', 'CONST') and len(child)==1 and not self.globalmode:
|
||||||
ret = '(' + expr['t'] + ')'
|
ret = '(' + expr['t'] + ')'
|
||||||
expr = child[0]
|
expr = child[0]
|
||||||
if expr['nt'] in ('CONST', 'IDENT', 'V++', 'V--', 'VECTOR',
|
if expr['nt'] in ('CONST', 'IDENT', 'V++', 'V--', 'VECTOR',
|
||||||
|
@ -399,6 +401,7 @@ class outscript(object):
|
||||||
# Optimize signs
|
# Optimize signs
|
||||||
self.optsigns = 'optsigns' in options
|
self.optsigns = 'optsigns' in options
|
||||||
self.optfloats = 'optfloats' in options
|
self.optfloats = 'optfloats' in options
|
||||||
|
self.foldconst = 'constfold' in options
|
||||||
|
|
||||||
ret = ''
|
ret = ''
|
||||||
self.indent = ' '
|
self.indent = ' '
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue