mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Format LIST nodes; don't add indent to CONST list in calc mode
LIST nodes will be pretty-printed with newlines between elements if they have 5 elements or more. List constants won't be indented when in calc mode.
This commit is contained in:
parent
9a820a62d0
commit
906e76ea47
1 changed files with 16 additions and 4 deletions
|
@ -161,7 +161,7 @@ class outscript(object):
|
||||||
return ret
|
return ret
|
||||||
ret = '' if lslcommon.IsCalc else '\n'
|
ret = '' if lslcommon.IsCalc else '\n'
|
||||||
first = True
|
first = True
|
||||||
self.indentlevel += 1
|
self.indentlevel += 0 if lslcommon.IsCalc else 1
|
||||||
for entry in value:
|
for entry in value:
|
||||||
ret += self.dent() + ('[ ' if first else ', ')
|
ret += self.dent() + ('[ ' if first else ', ')
|
||||||
save_listmode = self.listmode
|
save_listmode = self.listmode
|
||||||
|
@ -169,8 +169,9 @@ class outscript(object):
|
||||||
ret += self.Value2LSL(entry) + '\n'
|
ret += self.Value2LSL(entry) + '\n'
|
||||||
self.listmode = save_listmode
|
self.listmode = save_listmode
|
||||||
first = False
|
first = False
|
||||||
self.indentlevel -= 1
|
ret += self.dent()
|
||||||
return ret + self.dent() + self.indent + ']'
|
self.indentlevel -= 0 if lslcommon.IsCalc else 1
|
||||||
|
return ret + ']'
|
||||||
|
|
||||||
assert False, u'Value of unknown type in Value2LSL: ' + repr(value)
|
assert False, u'Value of unknown type in Value2LSL: ' + repr(value)
|
||||||
|
|
||||||
|
@ -291,7 +292,18 @@ class outscript(object):
|
||||||
|
|
||||||
if nt == 'LIST':
|
if nt == 'LIST':
|
||||||
self.listmode = True
|
self.listmode = True
|
||||||
ret = '[' + self.OutExprList(child) + ']'
|
if len(child) < 5:
|
||||||
|
ret = '[' + self.OutExprList(child) + ']'
|
||||||
|
else:
|
||||||
|
self.indentlevel += 0 if lslcommon.IsCalc else 1
|
||||||
|
ret = '' if lslcommon.IsCalc else '\n'
|
||||||
|
first = True
|
||||||
|
for elem in child:
|
||||||
|
ret += self.dent() + ('[ ' if first else ', ')
|
||||||
|
ret += self.OutExpr(elem) + '\n'
|
||||||
|
first = False
|
||||||
|
ret += self.dent() + ']'
|
||||||
|
self.indentlevel -= 0 if lslcommon.IsCalc else 1
|
||||||
self.listmode = False
|
self.listmode = False
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue