compiler: add support for printing of bytearray values (#714).

This commit is contained in:
whitequark 2017-06-09 07:04:14 +00:00
parent e9564b15c8
commit 9ed4e9c1cd
2 changed files with 7 additions and 1 deletions

View File

@ -1989,6 +1989,8 @@ class ARTIQIRGenerator(algorithm.Visitor):
format_string += "["; flush()
elif builtins.is_bytes(value.type):
format_string += "bytes(["; flush()
elif builtins.is_bytearray(value.type):
format_string += "bytearray(["; flush()
elif builtins.is_array(value.type):
format_string += "array(["; flush()
else:
@ -2017,7 +2019,8 @@ class ARTIQIRGenerator(algorithm.Visitor):
if builtins.is_list(value.type):
format_string += "]"
elif builtins.is_array(value.type) or builtins.is_bytes(value.type):
elif (builtins.is_bytes(value.type) or builtins.is_bytearray(value.type) or
builtins.is_array(value.type)):
format_string += "])"
elif builtins.is_range(value.type):
format_string += "range("; flush()

View File

@ -36,3 +36,6 @@ print(array([1, 2]))
# CHECK-L: bytes([97, 98])
print(b"ab")
# CHECK-L: bytearray([97, 98])
print(bytearray(b"ab"))