forked from M-Labs/artiq
Fix assignment to tuples in IRGenerator.
This commit is contained in:
parent
4bd83fb43d
commit
adf18bb042
|
@ -721,22 +721,22 @@ class IRGenerator(algorithm.Visitor):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
old_assign = self.current_assign
|
old_assign = self.current_assign
|
||||||
for index, elt in enumerate(node.elts):
|
for index, elt_node in enumerate(node.elts):
|
||||||
self.current_assign = \
|
self.current_assign = \
|
||||||
self.append(ir.GetAttr(old_assign, index,
|
self.append(ir.GetAttr(old_assign, index,
|
||||||
name="{}.{}".format(old_assign.name,
|
name="{}.{}".format(old_assign.name, index)),
|
||||||
_readable_name(index))))
|
loc=elt_node.loc)
|
||||||
self.visit(elt)
|
self.visit(elt_node)
|
||||||
finally:
|
finally:
|
||||||
self.current_assign = old_assign
|
self.current_assign = old_assign
|
||||||
|
|
||||||
def visit_ListT(self, node):
|
def visit_ListT(self, node):
|
||||||
if self.current_assign is None:
|
if self.current_assign is None:
|
||||||
elts = [self.visit(elt) for elt in node.elts]
|
elts = [self.visit(elt_node) for elt_node in node.elts]
|
||||||
lst = self.append(ir.Alloc([ir.Constant(len(node.elts), self._size_type)],
|
lst = self.append(ir.Alloc([ir.Constant(len(node.elts), self._size_type)],
|
||||||
node.type))
|
node.type))
|
||||||
for index, elt in enumerate(elts):
|
for index, elt_node in enumerate(elts):
|
||||||
self.append(ir.SetElem(lst, ir.Constant(index, self._size_type), elt))
|
self.append(ir.SetElem(lst, ir.Constant(index, self._size_type), elt_node))
|
||||||
return lst
|
return lst
|
||||||
else:
|
else:
|
||||||
length = self.append(ir.Builtin("len", [self.current_assign], self._size_type))
|
length = self.append(ir.Builtin("len", [self.current_assign], self._size_type))
|
||||||
|
|
Loading…
Reference in New Issue