mirror of https://github.com/m-labs/artiq.git
compiler: support conversion of list to bytearray and bytes.
Fixes #1077.
This commit is contained in:
parent
e8092f6f11
commit
cccadd0a55
|
@ -1634,7 +1634,7 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||
else:
|
||||
assert False
|
||||
elif (types.is_builtin(typ, "list") or types.is_builtin(typ, "array") or
|
||||
types.is_builtin(typ, "bytearray")):
|
||||
types.is_builtin(typ, "bytearray") or types.is_builtin(typ, "bytes")):
|
||||
if len(node.args) == 0 and len(node.keywords) == 0:
|
||||
length = ir.Constant(0, builtins.TInt32())
|
||||
return self.append(ir.Alloc([length], node.type))
|
||||
|
@ -1645,6 +1645,7 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||
|
||||
def body_gen(index):
|
||||
elt = self.iterable_get(arg, index)
|
||||
elt = self.append(ir.Coerce(elt, builtins.get_iterable_elt(node.type)))
|
||||
self.append(ir.SetElem(result, index, elt))
|
||||
return self.append(ir.Arith(ast.Add(loc=None), index,
|
||||
ir.Constant(1, length.type)))
|
||||
|
|
|
@ -140,6 +140,8 @@ class _RPCTypes(EnvExperiment):
|
|||
self.accept("foo")
|
||||
self.accept(b"foo")
|
||||
self.accept(bytearray(b"foo"))
|
||||
self.accept(bytes([1, 2]))
|
||||
self.accept(bytearray([1, 2]))
|
||||
self.accept((2, 3))
|
||||
self.accept([1, 2])
|
||||
self.accept(range(10))
|
||||
|
|
Loading…
Reference in New Issue