mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Add a space between a minus sign and a negative constant.
When a constant was negative internally, it was output with the sign included. The code was not prepared to handle this, and could therefore cause double minus signs. For example, -2147483648 was output as --2147483648, and -4294967296 was output as --1. Fixed by adding a space for floats, and by translating the number to the range 2147483648..4294967295 for integers (hex would have worked just as well).
This commit is contained in:
parent
14b13dc4e5
commit
b80b157489
1 changed files with 12 additions and 2 deletions
|
@ -329,10 +329,20 @@ class outscript(object):
|
|||
paren = False
|
||||
if nt == 'NEG':
|
||||
ret = '-'
|
||||
if (lnt == 'CONST' and child[0]['t'] == 'integer'
|
||||
and child[0]['value'] < 0
|
||||
):
|
||||
# shortcut
|
||||
ret += str(child[0]['value'] + 4294967296)
|
||||
return ret
|
||||
if lnt in self.op_priority:
|
||||
paren = self.op_priority[lnt] <= self.op_priority['-']
|
||||
elif lnt == 'NEG' or lnt == '--V':
|
||||
ret += ' ' # don't output -- as that's a different token
|
||||
elif (lnt == 'NEG' or lnt == '--V'
|
||||
or lnt == 'CONST'
|
||||
and child[0]['t'] == 'float'
|
||||
and child[0]['value'] < 0
|
||||
):
|
||||
ret += ' ' # don't output "--" as that's a different token
|
||||
else:
|
||||
if lnt in self.op_priority:
|
||||
paren = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue