mirror of
https://github.com/m-labs/artiq.git
synced 2024-12-25 03:08:27 +08:00
compiler: print the builtin type int(width=...) as np.int...
This commit is contained in:
parent
73ac153509
commit
fa71b40c80
@ -44,6 +44,13 @@ def TInt32():
|
||||
def TInt64():
|
||||
return TInt(types.TValue(64))
|
||||
|
||||
def _int_printer(typ, depth, max_depth):
|
||||
if types.is_var(typ["width"]):
|
||||
return "numpy.int?"
|
||||
else:
|
||||
return "numpy.int{}".format(types.get_value(typ.find()["width"]))
|
||||
types.TypePrinter.custom_printers['int'] = _int_printer
|
||||
|
||||
class TFloat(types.TMono):
|
||||
def __init__(self):
|
||||
super().__init__("float")
|
||||
@ -83,7 +90,7 @@ class TException(types.TMono):
|
||||
# (which also serves as the EHABI type_info).
|
||||
# * File, line and column where it was raised (str, int, int).
|
||||
# * Message, which can contain substitutions {0}, {1} and {2} (str).
|
||||
# * Three 64-bit integers, parameterizing the message (int(width=64)).
|
||||
# * Three 64-bit integers, parameterizing the message (numpy.int64).
|
||||
|
||||
# Keep this in sync with the function ARTIQIRGenerator.alloc_exn.
|
||||
attributes = OrderedDict([
|
||||
|
@ -579,11 +579,11 @@ class Inferencer(algorithm.Visitor):
|
||||
valid_forms = lambda: [
|
||||
valid_form("{exn}() -> {exn}".format(exn=typ.name)),
|
||||
valid_form("{exn}(message:str) -> {exn}".format(exn=typ.name)),
|
||||
valid_form("{exn}(message:str, param1:int(width=64)) -> {exn}".format(exn=typ.name)),
|
||||
valid_form("{exn}(message:str, param1:int(width=64), "
|
||||
"param2:int(width=64)) -> {exn}".format(exn=typ.name)),
|
||||
valid_form("{exn}(message:str, param1:int(width=64), "
|
||||
"param2:int(width=64), param3:int(width=64)) "
|
||||
valid_form("{exn}(message:str, param1:numpy.int64) -> {exn}".format(exn=typ.name)),
|
||||
valid_form("{exn}(message:str, param1:numpy.int64, "
|
||||
"param2:numpy.int64) -> {exn}".format(exn=typ.name)),
|
||||
valid_form("{exn}(message:str, param1:numpy.int64, "
|
||||
"param2:numpy.int64, param3:numpy.int64) "
|
||||
"-> {exn}".format(exn=typ.name)),
|
||||
]
|
||||
|
||||
@ -858,19 +858,19 @@ class Inferencer(algorithm.Visitor):
|
||||
simple_form("at(time:float) -> None",
|
||||
[builtins.TFloat()])
|
||||
elif types.is_builtin(typ, "now_mu"):
|
||||
simple_form("now_mu() -> int(width=64)",
|
||||
simple_form("now_mu() -> numpy.int64",
|
||||
[], builtins.TInt64())
|
||||
elif types.is_builtin(typ, "delay_mu"):
|
||||
simple_form("delay_mu(time_mu:int(width=64)) -> None",
|
||||
simple_form("delay_mu(time_mu:numpy.int64) -> None",
|
||||
[builtins.TInt64()])
|
||||
elif types.is_builtin(typ, "at_mu"):
|
||||
simple_form("at_mu(time_mu:int(width=64)) -> None",
|
||||
simple_form("at_mu(time_mu:numpy.int64) -> None",
|
||||
[builtins.TInt64()])
|
||||
elif types.is_builtin(typ, "mu_to_seconds"):
|
||||
simple_form("mu_to_seconds(time_mu:int(width=64)) -> float",
|
||||
simple_form("mu_to_seconds(time_mu:numpy.int64) -> float",
|
||||
[builtins.TInt64()], builtins.TFloat())
|
||||
elif types.is_builtin(typ, "seconds_to_mu"):
|
||||
simple_form("seconds_to_mu(time:float) -> int(width=64)",
|
||||
simple_form("seconds_to_mu(time:float) -> numpy.int64",
|
||||
[builtins.TFloat()], builtins.TInt64())
|
||||
elif types.is_builtin(typ, "watchdog"):
|
||||
simple_form("watchdog(time:float) -> [builtin context manager]",
|
||||
|
@ -670,6 +670,8 @@ class TypePrinter(object):
|
||||
type variables sequential alphabetic names.
|
||||
"""
|
||||
|
||||
custom_printers = {}
|
||||
|
||||
def __init__(self):
|
||||
self.gen = genalnum()
|
||||
self.map = {}
|
||||
@ -694,7 +696,9 @@ class TypePrinter(object):
|
||||
self.recurse_guard.add(typ)
|
||||
return "<instance {} {{}}>".format(typ.name)
|
||||
elif isinstance(typ, TMono):
|
||||
if typ.params == {}:
|
||||
if typ.name in self.custom_printers:
|
||||
return self.custom_printers[typ.name](typ, depth + 1, max_depth)
|
||||
elif typ.params == {}:
|
||||
return typ.name
|
||||
else:
|
||||
return "%s(%s)" % (typ.name, ", ".join(
|
||||
|
@ -15,7 +15,7 @@ i2.x = 1.0
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK-L: <synthesized>:1: error: host object has an attribute 'x' of type float, which is different from previously inferred type int(width=32) for the same attribute
|
||||
# CHECK-L: <synthesized>:1: error: host object has an attribute 'x' of type float, which is different from previously inferred type numpy.int32 for the same attribute
|
||||
i1.x
|
||||
# CHECK-L: ${LINE:+1}: note: expanded from here
|
||||
i2.x
|
||||
|
@ -9,7 +9,7 @@ class c:
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
# CHECK-L: <synthesized>:1: error: cannot unify int(width='a) with str
|
||||
# CHECK-L: <synthesized>:1: error: cannot unify numpy.int? with str
|
||||
# CHECK-NEXT-L: [1, 'x']
|
||||
# CHECK-L: ${LINE:+1}: note: expanded from here
|
||||
a = c
|
||||
|
@ -7,29 +7,29 @@ bool()
|
||||
# CHECK-L: bool:<constructor bool>([]:list(elt='a)):bool
|
||||
bool([])
|
||||
|
||||
# CHECK-L: int:<constructor int {}>():int(width='b)
|
||||
# CHECK-L: int:<constructor int {}>():numpy.int?
|
||||
int()
|
||||
|
||||
# CHECK-L: int:<constructor int>(1.0:float):int(width='c)
|
||||
# CHECK-L: int:<constructor int>(1.0:float):numpy.int?
|
||||
int(1.0)
|
||||
|
||||
# CHECK-L: int:<constructor int>(1.0:float, width=64:int(width='d)):int(width=64)
|
||||
# CHECK-L: int:<constructor int>(1.0:float, width=64:numpy.int?):numpy.int64
|
||||
int(1.0, width=64)
|
||||
|
||||
# CHECK-L: float:<constructor float {}>():float
|
||||
float()
|
||||
|
||||
# CHECK-L: float:<constructor float>(1:int(width='e)):float
|
||||
# CHECK-L: float:<constructor float>(1:numpy.int?):float
|
||||
float(1)
|
||||
|
||||
# CHECK-L: list:<constructor list {}>():list(elt='f)
|
||||
# CHECK-L: list:<constructor list {}>():list(elt='b)
|
||||
list()
|
||||
|
||||
# CHECK-L: len:<function len>([]:list(elt='g)):int(width=32)
|
||||
# CHECK-L: len:<function len>([]:list(elt='c)):numpy.int32
|
||||
len([])
|
||||
|
||||
# CHECK-L: round:<function round>(1.0:float):int(width='h)
|
||||
# CHECK-L: round:<function round>(1.0:float):numpy.int?
|
||||
round(1.0)
|
||||
|
||||
# CHECK-L: round:<function round>(1.0:float, width=64:int(width='i)):int(width=64)
|
||||
# CHECK-L: round:<function round>(1.0:float, width=64:numpy.int?):numpy.int64
|
||||
round(1.0, width=64)
|
||||
|
@ -8,12 +8,12 @@ class c:
|
||||
def m(self):
|
||||
pass
|
||||
|
||||
# CHECK-L: c:<constructor c {a: int(width='a), f: ()->NoneType delay('b), m: (self:<instance c>)->NoneType delay('c)}>
|
||||
# CHECK-L: c:<constructor c {a: numpy.int?, f: ()->NoneType delay('a), m: (self:<instance c>)->NoneType delay('b)}>
|
||||
c
|
||||
# CHECK-L: .a:int(width='a)
|
||||
# CHECK-L: .a:numpy.int?
|
||||
c.a
|
||||
# CHECK-L: .f:()->NoneType delay('b)
|
||||
# CHECK-L: .f:()->NoneType delay('a)
|
||||
c.f
|
||||
|
||||
# CHECK-L: .m:method(fn=(self:<instance c>)->NoneType delay('c), self=<instance c>)
|
||||
# CHECK-L: .m:method(fn=(self:<instance c>)->NoneType delay('b), self=<instance c>)
|
||||
c().m()
|
||||
|
@ -2,40 +2,40 @@
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
1 | 2
|
||||
# CHECK-L: 1:int(width='a):int(width='b) | 2:int(width='c):int(width='b):int(width='b)
|
||||
# CHECK-L: 1:numpy.int?:numpy.int? | 2:numpy.int?:numpy.int?:numpy.int?
|
||||
|
||||
1 + 2
|
||||
# CHECK-L: 1:int(width='d):int(width='e) + 2:int(width='f):int(width='e):int(width='e)
|
||||
# CHECK-L: 1:numpy.int?:numpy.int? + 2:numpy.int?:numpy.int?:numpy.int?
|
||||
|
||||
(1,) + (2.0,)
|
||||
# CHECK-L: (1:int(width='g),):(int(width='g),) + (2.0:float,):(float,):(int(width='g), float)
|
||||
# CHECK-L: (1:numpy.int?,):(numpy.int?,) + (2.0:float,):(float,):(numpy.int?, float)
|
||||
|
||||
[1] + [2]
|
||||
# CHECK-L: [1:int(width='h)]:list(elt=int(width='h)) + [2:int(width='h)]:list(elt=int(width='h)):list(elt=int(width='h))
|
||||
# CHECK-L: [1:numpy.int?]:list(elt=numpy.int?) + [2:numpy.int?]:list(elt=numpy.int?):list(elt=numpy.int?)
|
||||
|
||||
1 * 2
|
||||
# CHECK-L: 1:int(width='i):int(width='j) * 2:int(width='k):int(width='j):int(width='j)
|
||||
# CHECK-L: 1:numpy.int?:numpy.int? * 2:numpy.int?:numpy.int?:numpy.int?
|
||||
|
||||
[1] * 2
|
||||
# CHECK-L: [1:int(width='l)]:list(elt=int(width='l)) * 2:int(width='m):list(elt=int(width='l))
|
||||
# CHECK-L: [1:numpy.int?]:list(elt=numpy.int?) * 2:numpy.int?:list(elt=numpy.int?)
|
||||
|
||||
1 // 2
|
||||
# CHECK-L: 1:int(width='n):int(width='o) // 2:int(width='p):int(width='o):int(width='o)
|
||||
# CHECK-L: 1:numpy.int?:numpy.int? // 2:numpy.int?:numpy.int?:numpy.int?
|
||||
|
||||
1 + 1.0
|
||||
# CHECK-L: 1:int(width='q):float + 1.0:float:float
|
||||
# CHECK-L: 1:numpy.int?:float + 1.0:float:float
|
||||
|
||||
a = []; a += [1]
|
||||
# CHECK-L: a:list(elt=int(width='r)) = []:list(elt=int(width='r)); a:list(elt=int(width='r)) += [1:int(width='r)]:list(elt=int(width='r))
|
||||
# CHECK-L: a:list(elt=numpy.int?) = []:list(elt=numpy.int?); a:list(elt=numpy.int?) += [1:numpy.int?]:list(elt=numpy.int?)
|
||||
|
||||
[] is [1]
|
||||
# CHECK-L: []:list(elt=int(width='s)) is [1:int(width='s)]:list(elt=int(width='s)):bool
|
||||
# CHECK-L: []:list(elt=numpy.int?) is [1:numpy.int?]:list(elt=numpy.int?):bool
|
||||
|
||||
1 in [1]
|
||||
# CHECK-L: 1:int(width='t) in [1:int(width='t)]:list(elt=int(width='t)):bool
|
||||
# CHECK-L: 1:numpy.int? in [1:numpy.int?]:list(elt=numpy.int?):bool
|
||||
|
||||
[] < [1]
|
||||
# CHECK-L: []:list(elt=int(width='u)) < [1:int(width='u)]:list(elt=int(width='u)):bool
|
||||
# CHECK-L: []:list(elt=numpy.int?) < [1:numpy.int?]:list(elt=numpy.int?):bool
|
||||
|
||||
1.0 < 1
|
||||
# CHECK-L: 1.0:float < 1:int(width='v):float:bool
|
||||
# CHECK-L: 1.0:float < 1:numpy.int?:float:bool
|
||||
|
@ -1,7 +1,7 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.inferencer +diag %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: cannot call this expression of type int
|
||||
# CHECK-L: ${LINE:+1}: error: cannot call this expression of type numpy.int?
|
||||
(1)()
|
||||
|
||||
def f(x, y, z=1):
|
||||
|
@ -5,33 +5,33 @@
|
||||
1 << 2.0
|
||||
|
||||
# CHECK-L: ${LINE:+3}: error: expected every '+' operand to be a list in this context
|
||||
# CHECK-L: ${LINE:+2}: note: list of type list(elt=int(width='a))
|
||||
# CHECK-L: ${LINE:+1}: note: int(width='b), which cannot be added to a list
|
||||
# CHECK-L: ${LINE:+2}: note: list of type list(elt=numpy.int?)
|
||||
# CHECK-L: ${LINE:+1}: note: numpy.int?, which cannot be added to a list
|
||||
[1] + 2
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify list(elt=int(width='a)) with list(elt=float): int(width='a) is incompatible with float
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify list(elt=numpy.int?) with list(elt=float): numpy.int? is incompatible with float
|
||||
[1] + [2.0]
|
||||
|
||||
# CHECK-L: ${LINE:+3}: error: expected every '+' operand to be a tuple in this context
|
||||
# CHECK-L: ${LINE:+2}: note: tuple of type (int(width='a),)
|
||||
# CHECK-L: ${LINE:+1}: note: int(width='b), which cannot be added to a tuple
|
||||
# CHECK-L: ${LINE:+2}: note: tuple of type (numpy.int?,)
|
||||
# CHECK-L: ${LINE:+1}: note: numpy.int?, which cannot be added to a tuple
|
||||
(1,) + 2
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: passing tuples to '*' is not supported
|
||||
(1,) * 2
|
||||
|
||||
# CHECK-L: ${LINE:+3}: error: expected '*' operands to be a list and an integer in this context
|
||||
# CHECK-L: ${LINE:+2}: note: list operand of type list(elt=int(width='a))
|
||||
# CHECK-L: ${LINE:+1}: note: operand of type list(elt='b), which is not a valid repetition amount
|
||||
# CHECK-L: ${LINE:+2}: note: list operand of type list(elt=numpy.int?)
|
||||
# CHECK-L: ${LINE:+1}: note: operand of type list(elt='a), which is not a valid repetition amount
|
||||
[1] * []
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: cannot coerce list(elt='a) to a numeric type
|
||||
[] - 1.0
|
||||
|
||||
# CHECK-L: ${LINE:+2}: error: expression of type int(width='a) has to be coerced to float, which makes assignment invalid
|
||||
# CHECK-L: ${LINE:+2}: error: expression of type numpy.int? has to be coerced to float, which makes assignment invalid
|
||||
# CHECK-L: ${LINE:+1}: note: expression of type float
|
||||
a = 1; a += 1.0
|
||||
|
||||
# CHECK-L: ${LINE:+2}: error: the result of this operation has type (int(width='a), float), which makes assignment to a slot of type (int(width='a),) invalid
|
||||
# CHECK-L: ${LINE:+2}: error: the result of this operation has type (numpy.int?, float), which makes assignment to a slot of type (numpy.int?,) invalid
|
||||
# CHECK-L: ${LINE:+1}: note: expression of type (float,)
|
||||
b = (1,); b += (1.0,)
|
||||
|
@ -9,6 +9,6 @@ except 1:
|
||||
|
||||
try:
|
||||
pass
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with Exception
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify numpy.int? with Exception
|
||||
except Exception as e:
|
||||
e = 1
|
||||
|
@ -1,5 +1,5 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.inferencer +diag %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: type int(width='a) is not iterable
|
||||
# CHECK-L: ${LINE:+1}: error: type numpy.int? is not iterable
|
||||
for x in 1: pass
|
||||
|
@ -12,5 +12,5 @@ class c:
|
||||
c().f()
|
||||
|
||||
c.g(1)
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify <instance c> with int(width='a) while inferring the type for self argument
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify <instance c> with numpy.int? while inferring the type for self argument
|
||||
c().g()
|
||||
|
@ -1,16 +1,16 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.inferencer +diag %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: ${LINE:+2}: error: cannot unify int(width='a) with NoneType
|
||||
# CHECK-L: ${LINE:+1}: note: function with return type int(width='a)
|
||||
# CHECK-L: ${LINE:+2}: error: cannot unify numpy.int? with NoneType
|
||||
# CHECK-L: ${LINE:+1}: note: function with return type numpy.int?
|
||||
def a():
|
||||
return 1
|
||||
# CHECK-L: ${LINE:+1}: note: a statement returning NoneType
|
||||
return
|
||||
|
||||
# CHECK-L: ${LINE:+2}: error: cannot unify int(width='a) with list(elt='b)
|
||||
# CHECK-L: ${LINE:+1}: note: function with return type int(width='a)
|
||||
# CHECK-L: ${LINE:+2}: error: cannot unify numpy.int? with list(elt='a)
|
||||
# CHECK-L: ${LINE:+1}: note: function with return type numpy.int?
|
||||
def b():
|
||||
return 1
|
||||
# CHECK-L: ${LINE:+1}: note: a statement returning list(elt='b)
|
||||
# CHECK-L: ${LINE:+1}: note: a statement returning list(elt='a)
|
||||
return []
|
||||
|
@ -4,17 +4,17 @@
|
||||
a = 1
|
||||
b = []
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with list(elt='b)
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify numpy.int? with list(elt='a)
|
||||
a = b
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with list(elt='b)
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify numpy.int? with list(elt='a)
|
||||
[1, []]
|
||||
# CHECK-L: note: a list element of type int(width='a)
|
||||
# CHECK-L: note: a list element of type list(elt='b)
|
||||
# CHECK-L: note: a list element of type numpy.int?
|
||||
# CHECK-L: note: a list element of type list(elt='a)
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool
|
||||
# CHECK-L: ${LINE:+1}: error: cannot unify numpy.int? with bool
|
||||
1 and False
|
||||
# CHECK-L: note: an operand of type int(width='a)
|
||||
# CHECK-L: note: an operand of type numpy.int?
|
||||
# CHECK-L: note: an operand of type bool
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: expected unary '+' operand to be of numeric type, not list(elt='a)
|
||||
@ -23,5 +23,5 @@ a = b
|
||||
# CHECK-L: ${LINE:+1}: error: expected '~' operand to be of integer type, not float
|
||||
~1.0
|
||||
|
||||
# CHECK-L: ${LINE:+1}: error: type int(width='a) does not have an attribute 'x'
|
||||
# CHECK-L: ${LINE:+1}: error: type numpy.int? does not have an attribute 'x'
|
||||
(1).x
|
||||
|
@ -10,7 +10,7 @@ class contextmgr:
|
||||
pass
|
||||
|
||||
def foo():
|
||||
# CHECK-L: ${LINE:+2}: error: cannot unify int(width='a) with NoneType
|
||||
# CHECK-L: ${LINE:+1}: note: exception handling via context managers is not supported; the argument 'n3' of function '__exit__(self:<instance contextmgr>, n1:NoneType, n2:NoneType, n3:int(width='a))->NoneType delay('b)' will always be None
|
||||
# CHECK-L: ${LINE:+2}: error: cannot unify numpy.int? with NoneType
|
||||
# CHECK-L: ${LINE:+1}: note: exception handling via context managers is not supported; the argument 'n3' of function '__exit__(self:<instance contextmgr>, n1:NoneType, n2:NoneType, n3:numpy.int?)->NoneType delay('a)' will always be None
|
||||
with contextmgr():
|
||||
pass
|
||||
|
@ -10,8 +10,8 @@ class contextmgr:
|
||||
|
||||
def foo():
|
||||
contextmgr.__enter__(1)
|
||||
# CHECK-L: ${LINE:+3}: error: cannot unify <instance contextmgr> with int(width='a) while inferring the type for self argument
|
||||
# CHECK-L: ${LINE:+3}: error: cannot unify <instance contextmgr> with numpy.int? while inferring the type for self argument
|
||||
# CHECK-L: ${LINE:+2}: note: expression of type <instance contextmgr {}>
|
||||
# CHECK-L: ${LINE:+1}: note: reference to an instance with a method '__enter__(self:int(width='a))->NoneType delay('b)'
|
||||
# CHECK-L: ${LINE:+1}: note: reference to an instance with a method '__enter__(self:numpy.int?)->NoneType delay('a)'
|
||||
with contextmgr():
|
||||
pass
|
||||
|
@ -9,5 +9,5 @@ def _gcd(a, b):
|
||||
b = c
|
||||
return b
|
||||
|
||||
# CHECK-L: _gcd:(a:int(width='a), b:int(width='a))->int(width='a)(10:int(width='a), 25:int(width='a)):int(width='a)
|
||||
# CHECK-L: _gcd:(a:numpy.int?, b:numpy.int?)->numpy.int?(10:numpy.int?, 25:numpy.int?):numpy.int?
|
||||
_gcd(10, 25)
|
||||
|
@ -6,5 +6,5 @@ x = len
|
||||
|
||||
def f():
|
||||
global len
|
||||
# CHECK-L: len:int(width='a) =
|
||||
# CHECK-L: len:numpy.int? =
|
||||
len = 1
|
||||
|
@ -1,7 +1,7 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.inferencer %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: []:list(elt=int(width='a))
|
||||
# CHECK-L: []:list(elt=numpy.int?)
|
||||
x = []
|
||||
|
||||
def f():
|
||||
|
@ -2,5 +2,5 @@
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
x = [0]
|
||||
# CHECK-L: [::int(width=32)]
|
||||
# CHECK-L: [::numpy.int32]
|
||||
x[:] = [1]
|
||||
|
@ -2,10 +2,10 @@
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
a = 1
|
||||
# CHECK-L: a:int(width='a)
|
||||
# CHECK-L: a:numpy.int?
|
||||
|
||||
b = a
|
||||
# CHECK-L: b:int(width='a)
|
||||
# CHECK-L: b:numpy.int?
|
||||
|
||||
c = True
|
||||
# CHECK-L: c:bool
|
||||
@ -20,39 +20,39 @@ f = 1.0
|
||||
# CHECK-L: f:float
|
||||
|
||||
g = []
|
||||
# CHECK-L: g:list(elt='b)
|
||||
# CHECK-L: g:list(elt='a)
|
||||
|
||||
h = [1]
|
||||
# CHECK-L: h:list(elt=int(width='c))
|
||||
# CHECK-L: h:list(elt=numpy.int?)
|
||||
|
||||
i = []
|
||||
i[0] = 1
|
||||
# CHECK-L: i:list(elt=int(width='d))
|
||||
# CHECK-L: i:list(elt=numpy.int?)
|
||||
|
||||
j = []
|
||||
j += [1.0]
|
||||
# CHECK-L: j:list(elt=float)
|
||||
|
||||
1 if a else 2
|
||||
# CHECK-L: 1:int(width='f) if a:int(width='a) else 2:int(width='f):int(width='f)
|
||||
# CHECK-L: 1:numpy.int? if a:numpy.int? else 2:numpy.int?:numpy.int?
|
||||
|
||||
True and False
|
||||
# CHECK-L: True:bool and False:bool:bool
|
||||
|
||||
1 and 0
|
||||
# CHECK-L: 1:int(width='g) and 0:int(width='g):int(width='g)
|
||||
# CHECK-L: 1:numpy.int? and 0:numpy.int?:numpy.int?
|
||||
|
||||
~1
|
||||
# CHECK-L: 1:int(width='h):int(width='h)
|
||||
# CHECK-L: 1:numpy.int?:numpy.int?
|
||||
|
||||
not 1
|
||||
# CHECK-L: 1:int(width='i):bool
|
||||
# CHECK-L: 1:numpy.int?:bool
|
||||
|
||||
[x for x in [1]]
|
||||
# CHECK-L: [x:int(width='j) for x:int(width='j) in [1:int(width='j)]:list(elt=int(width='j))]:list(elt=int(width='j))
|
||||
# CHECK-L: [x:numpy.int? for x:numpy.int? in [1:numpy.int?]:list(elt=numpy.int?)]:list(elt=numpy.int?)
|
||||
|
||||
lambda x, y=1: x
|
||||
# CHECK-L: lambda x:'k, y:int(width='l)=1:int(width='l): x:'k:(x:'k, ?y:int(width='l))->'k
|
||||
# CHECK-L: lambda x:'b, y:numpy.int?=1:numpy.int?: x:'b:(x:'b, ?y:numpy.int?)->'b
|
||||
|
||||
k = "x"
|
||||
# CHECK-L: k:str
|
||||
@ -64,10 +64,10 @@ IndexError("x")
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str):IndexError
|
||||
|
||||
IndexError("x", 1)
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str, 1:int(width=64)):IndexError
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str, 1:numpy.int64):IndexError
|
||||
|
||||
IndexError("x", 1, 1)
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str, 1:int(width=64), 1:int(width=64)):IndexError
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str, 1:numpy.int64, 1:numpy.int64):IndexError
|
||||
|
||||
IndexError("x", 1, 1, 1)
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str, 1:int(width=64), 1:int(width=64), 1:int(width=64)):IndexError
|
||||
# CHECK-L: IndexError:<constructor IndexError>("x":str, 1:numpy.int64, 1:numpy.int64, 1:numpy.int64):IndexError
|
||||
|
@ -1,7 +1,7 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: f: (a:float, b:int(width=64))->NoneType delay(s->mu(a) + b mu)
|
||||
# CHECK-L: f: (a:float, b:numpy.int64)->NoneType delay(s->mu(a) + b mu)
|
||||
def f(a, b):
|
||||
delay(a)
|
||||
delay_mu(b)
|
||||
|
@ -1,7 +1,7 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: f: (a:int(width=32), b:int(width=32), c:int(width=32), d:int(width=32), e:int(width=32))->NoneType delay(s->mu(a * b // c + d - 10 / e) mu)
|
||||
# CHECK-L: f: (a:numpy.int32, b:numpy.int32, c:numpy.int32, d:numpy.int32, e:numpy.int32)->NoneType delay(s->mu(a * b // c + d - 10 / e) mu)
|
||||
def f(a, b, c, d, e):
|
||||
delay(a * b // c + d - 10 / e)
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: f: (a:int(width=64), b:int(width=64))->NoneType delay(max(a, b) mu)
|
||||
# CHECK-L: f: (a:numpy.int64, b:numpy.int64)->NoneType delay(max(a, b) mu)
|
||||
def f(a, b):
|
||||
with interleave:
|
||||
delay_mu(a)
|
||||
delay_mu(b)
|
||||
|
||||
# CHECK-L: g: (a:int(width=64))->NoneType delay(max(a, 200) mu)
|
||||
# CHECK-L: g: (a:numpy.int64)->NoneType delay(max(a, 200) mu)
|
||||
def g(a):
|
||||
with interleave:
|
||||
delay_mu(100)
|
||||
|
@ -1,17 +1,17 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: f: (a:int(width=32))->NoneType delay(3 * a mu)
|
||||
# CHECK-L: f: (a:numpy.int32)->NoneType delay(3 * a mu)
|
||||
def f(a):
|
||||
for _ in range(a):
|
||||
delay_mu(3)
|
||||
|
||||
# CHECK-L: g: (a:int(width=32), b:int(width=32))->NoneType delay(3 * (b - a) mu)
|
||||
# CHECK-L: g: (a:numpy.int32, b:numpy.int32)->NoneType delay(3 * (b - a) mu)
|
||||
def g(a, b):
|
||||
for _ in range(a, b):
|
||||
delay_mu(3)
|
||||
|
||||
# CHECK-L: h: (a:int(width=32), b:int(width=32), c:int(width=32))->NoneType delay(3 * (b - a) // c mu)
|
||||
# CHECK-L: h: (a:numpy.int32, b:numpy.int32, c:numpy.int32)->NoneType delay(3 * (b - a) // c mu)
|
||||
def h(a, b, c):
|
||||
for _ in range(a, b, c):
|
||||
delay_mu(3)
|
||||
|
@ -1,13 +1,13 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: f: ()->int(width=32) delay(30 mu)
|
||||
# CHECK-L: f: ()->numpy.int32 delay(30 mu)
|
||||
def f():
|
||||
for _ in range(10):
|
||||
delay_mu(3)
|
||||
return 10
|
||||
|
||||
# CHECK-L: g: (x:float)->int(width=32)
|
||||
# CHECK-L: g: (x:float)->numpy.int32
|
||||
# CHECK-NOT-L: delay
|
||||
def g(x):
|
||||
if x > 1.0:
|
||||
|
@ -1,7 +1,7 @@
|
||||
# RUN: %python -m artiq.compiler.testbench.signature %s >%t
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
# CHECK-L: f: (a:int(width=64), b:int(width=64))->NoneType delay(a + b mu)
|
||||
# CHECK-L: f: (a:numpy.int64, b:numpy.int64)->NoneType delay(a + b mu)
|
||||
def f(a, b):
|
||||
with sequential:
|
||||
delay_mu(a)
|
||||
|
@ -2,10 +2,10 @@
|
||||
# RUN: OutputCheck %s --file-to-check=%t
|
||||
|
||||
x = 1
|
||||
# CHECK-L: x: int(width=32)
|
||||
# CHECK-L: x: numpy.int32
|
||||
|
||||
y = int(1)
|
||||
# CHECK-L: y: int(width=32)
|
||||
# CHECK-L: y: numpy.int32
|
||||
|
||||
z = round(1.0)
|
||||
# CHECK-L: z: int(width=32)
|
||||
# CHECK-L: z: numpy.int32
|
||||
|
Loading…
Reference in New Issue
Block a user