mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18: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']
|
op1 = lval['value']
|
||||||
op2 = rval['value']
|
op2 = rval['value']
|
||||||
if nt == '+':
|
if nt == '+':
|
||||||
if ltype != 'string' or rtype != 'string' or self.addstrings:
|
if ltype == rtype == 'string' and not self.addstrings:
|
||||||
result = lslfuncs.add(op1, op2)
|
return
|
||||||
|
result = lslfuncs.add(op1, op2)
|
||||||
elif nt == '-':
|
elif nt == '-':
|
||||||
result = lslfuncs.sub(op1, op2)
|
result = lslfuncs.sub(op1, op2)
|
||||||
elif nt == '*':
|
elif nt == '*':
|
||||||
|
@ -300,14 +301,14 @@ class foldconst(object):
|
||||||
# Tough one. Remove neutral elements for the diverse types,
|
# Tough one. Remove neutral elements for the diverse types,
|
||||||
# and more.
|
# 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
|
# Addition of floats, vectors and rotations would be, except
|
||||||
# for FP precision.
|
# for FP precision.
|
||||||
# TODO: associative addition of lists
|
# TODO: associative addition of lists
|
||||||
# Associative lists are trickier, because unlike the others,
|
# Associative lists are trickier, because unlike the others,
|
||||||
# the types of the operands may not be lists
|
# the types of the operands may not be lists
|
||||||
# so e.g. list+(integer+integer) != (list+integer)+integer.
|
# 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':
|
if lnt == '+' and rnt == 'CONST' and lval['ch'][1]['nt'] == 'CONST':
|
||||||
# (var + ct1) + ct2 -> var + (ct1 + ct2)
|
# (var + ct1) + ct2 -> var + (ct1 + ct2)
|
||||||
child[1] = {'nt': '+', 't': optype, 'ch':[lval['ch'][1], rval], 'SEF':True}
|
child[1] = {'nt': '+', 't': optype, 'ch':[lval['ch'][1], rval], 'SEF':True}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue