forked from M-Labs/artiq
1
0
Fork 0

Fix assignment to tuples in IRGenerator.

This commit is contained in:
whitequark 2015-07-19 10:31:11 +03:00
parent 4bd83fb43d
commit adf18bb042
1 changed files with 7 additions and 7 deletions

View File

@ -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))