From 7b2da5294fddc3cc1754df466568388d59ace586 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 9 Jun 2017 05:53:20 +0000 Subject: [PATCH] compiler: add support for printing of bytes values (#714). --- artiq/compiler/transforms/artiq_ir_generator.py | 4 +++- artiq/test/lit/integration/print.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index 98fc8a90e..0d1d9c76d 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -1986,6 +1986,8 @@ class ARTIQIRGenerator(algorithm.Visitor): elif builtins.is_listish(value.type): if builtins.is_list(value.type): format_string += "["; flush() + elif builtins.is_bytes(value.type): + format_string += "bytes(["; flush() elif builtins.is_array(value.type): format_string += "array(["; flush() else: @@ -2014,7 +2016,7 @@ class ARTIQIRGenerator(algorithm.Visitor): if builtins.is_list(value.type): format_string += "]" - elif builtins.is_array(value.type): + elif builtins.is_array(value.type) or builtins.is_bytes(value.type): format_string += "])" elif builtins.is_range(value.type): format_string += "range("; flush() diff --git a/artiq/test/lit/integration/print.py b/artiq/test/lit/integration/print.py index eb7fda126..bd5bf555f 100644 --- a/artiq/test/lit/integration/print.py +++ b/artiq/test/lit/integration/print.py @@ -33,3 +33,6 @@ print(range(10)) # CHECK-L: array([1, 2]) print(array([1, 2])) + +# CHECK-L: bytes([97, 98]) +print(b"ab")