forked from M-Labs/artiq
1
0
Fork 0

language: Allow instantating TArray using bare ints

This commit is contained in:
David Nadlinger 2020-07-27 23:36:42 +01:00
parent 504b8f0148
commit a9a975e5d4
1 changed files with 4 additions and 1 deletions

View File

@ -82,9 +82,12 @@ class TList(types.TMono):
super().__init__("list", {"elt": elt})
class TArray(types.TMono):
def __init__(self, elt=None, num_dims=types.TValue(1)):
def __init__(self, elt=None, num_dims=1):
if elt is None:
elt = types.TVar()
if isinstance(num_dims, int):
# Make TArray more convenient to instantiate from (ARTIQ) user code.
num_dims = types.TValue(num_dims)
# For now, enforce number of dimensions to be known, as we'd otherwise
# need to implement custom unification logic for the type of `shape`.
# Default to 1 to keep compatibility with old user code from before