Optimize [elem] -> (list)elem on output. Saves us headaches.

This commit is contained in:
Sei Lisa 2015-03-13 22:42:00 +01:00
parent 2948399bf8
commit f6b472133a

View file

@ -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 = ' '