Skip to content

Commit

Permalink
ARTIQIRGenerator.polymorphic_print: str([x]) uses repr(x), not str(x).
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Aug 9, 2015
1 parent f7b64db commit dfc91a3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions artiq/compiler/transforms/artiq_ir_generator.py
Expand Up @@ -1489,7 +1489,7 @@ def visit_Assert(self, node):
tail = self.current_block = self.add_block()
self.append(ir.BranchIf(cond, tail, if_failed), block=head)

def polymorphic_print(self, values, separator, suffix=""):
def polymorphic_print(self, values, separator, suffix="", as_repr=False):
format_string = ""
args = []
def flush():
Expand All @@ -1508,7 +1508,7 @@ def flush():
format_string += "("; flush()
self.polymorphic_print([self.append(ir.GetAttr(value, index))
for index in range(len(value.type.elts))],
separator=", ")
separator=", ", as_repr=True)
if len(value.type.elts) == 1:
format_string += ",)"
else:
Expand Down Expand Up @@ -1538,7 +1538,10 @@ def flush():
format_string += "%g"
args.append(value)
elif builtins.is_str(value.type):
format_string += "%s"
if as_repr:
format_string += "\"%s\""
else:
format_string += "%s"
args.append(value)
elif builtins.is_list(value.type):
format_string += "["; flush()
Expand All @@ -1547,7 +1550,7 @@ def flush():
last = self.append(ir.Arith(ast.Sub(loc=None), length, ir.Constant(1, length.type)))
def body_gen(index):
elt = self.iterable_get(value, index)
self.polymorphic_print([elt], separator="")
self.polymorphic_print([elt], separator="", as_repr=True)
is_last = self.append(ir.Compare(ast.Lt(loc=None), index, last))
head = self.current_block

Expand Down

0 comments on commit dfc91a3

Please sign in to comment.