Skip to content

Commit 0a706f5

Browse files
committed
Add: Array addition
1 parent d8a8e10 commit 0a706f5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

nml/expression/binop.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,12 @@ def reduce(self, id_dicts=None, unknown_id_fatal=True):
118118
elif op == nmlop.CMP_GT:
119119
op = nmlop.CMP_LT
120120

121-
if (
122-
isinstance(expr1, Array)
123-
and isinstance(expr2, ConstantNumeric)
124-
and self.op == nmlop.MUL
125-
):
121+
if (isinstance(expr1, Array) and isinstance(expr2, ConstantNumeric) and self.op == nmlop.MUL):
126122
return Array(self.op.compiletime_func(expr1.values, expr2.value), self.pos)
127123

124+
if (isinstance(expr1, Array) and isinstance(expr2, Array) and self.op == nmlop.ADD):
125+
return Array(self.op.compiletime_func(expr1.values, expr2.values), self.pos)
126+
128127
# - If the operation is a no-op, delete it.
129128
if op == nmlop.AND and isinstance(expr2, ConstantNumeric) and (expr2.value == -1 or expr2.value == 0xFFFFFFFF):
130129
return expr1

0 commit comments

Comments
 (0)