mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix addstrings option (oops).
This commit is contained in:
parent
8f83e2f1ab
commit
e30a4ea25d
1 changed files with 5 additions and 4 deletions
|
@ -225,8 +225,9 @@ class foldconst(object):
|
|||
op1 = lval['value']
|
||||
op2 = rval['value']
|
||||
if nt == '+':
|
||||
if ltype != 'string' or rtype != 'string' or self.addstrings:
|
||||
result = lslfuncs.add(op1, op2)
|
||||
if ltype == rtype == 'string' and not self.addstrings:
|
||||
return
|
||||
result = lslfuncs.add(op1, op2)
|
||||
elif nt == '-':
|
||||
result = lslfuncs.sub(op1, op2)
|
||||
elif nt == '*':
|
||||
|
@ -300,14 +301,14 @@ class foldconst(object):
|
|||
# Tough one. Remove neutral elements for the diverse types,
|
||||
# and more.
|
||||
|
||||
# Addition of integers, strings, and lists is associative
|
||||
# Addition of integers, strings, and lists is associative.
|
||||
# Addition of floats, vectors and rotations would be, except
|
||||
# for FP precision.
|
||||
# TODO: associative addition of lists
|
||||
# Associative lists are trickier, because unlike the others,
|
||||
# the types of the operands may not be lists
|
||||
# so e.g. list+(integer+integer) != (list+integer)+integer.
|
||||
if optype in ('integer', 'string'):
|
||||
if optype == 'integer' or optype == 'string' and self.addstrings:
|
||||
if lnt == '+' and rnt == 'CONST' and lval['ch'][1]['nt'] == 'CONST':
|
||||
# (var + ct1) + ct2 -> var + (ct1 + ct2)
|
||||
child[1] = {'nt': '+', 't': optype, 'ch':[lval['ch'][1], rval], 'SEF':True}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue