Fix addstrings option (oops).
This commit is contained in:
@@ -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}
|
||||||
|
|||||||
Reference in New Issue
Block a user