forked from M-Labs/artiq
Add channel name as the first argument to rtio_log (#206).
This commit is contained in:
parent
f28b259b5f
commit
1465fe6f81
|
@ -1608,10 +1608,16 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
|||
return self.append(ir.Builtin("round", [arg], node.type))
|
||||
else:
|
||||
assert False
|
||||
elif types.is_builtin(typ, "print") or types.is_builtin(typ, "rtio_log"):
|
||||
elif types.is_builtin(typ, "print"):
|
||||
self.polymorphic_print([self.visit(arg) for arg in node.args],
|
||||
separator=" ", suffix="\n",
|
||||
as_rtio=types.is_builtin(typ, "rtio_log"))
|
||||
separator=" ", suffix="\n")
|
||||
return ir.Constant(None, builtins.TNone())
|
||||
elif types.is_builtin(typ, "rtio_log"):
|
||||
prefix, *args = node.args
|
||||
self.polymorphic_print([self.visit(prefix)],
|
||||
separator=" ", suffix="\x1E", as_rtio=True)
|
||||
self.polymorphic_print([self.visit(arg) for arg in args],
|
||||
separator=" ", suffix="\n", as_rtio=True)
|
||||
return ir.Constant(None, builtins.TNone())
|
||||
elif types.is_builtin(typ, "now"):
|
||||
if len(node.args) == 0 and len(node.keywords) == 0:
|
||||
|
|
|
@ -753,7 +753,7 @@ class Inferencer(algorithm.Visitor):
|
|||
node.loc, None)
|
||||
else:
|
||||
diagnose(valid_forms())
|
||||
elif types.is_builtin(typ, "print") or types.is_builtin(typ, "rtio_log"):
|
||||
elif types.is_builtin(typ, "print"):
|
||||
valid_forms = lambda: [
|
||||
valid_form("print(args...) -> None"),
|
||||
]
|
||||
|
@ -766,6 +766,21 @@ class Inferencer(algorithm.Visitor):
|
|||
pass
|
||||
else:
|
||||
diagnose(valid_forms())
|
||||
elif types.is_builtin(typ, "rtio_log"):
|
||||
valid_forms = lambda: [
|
||||
valid_form("rtio_log(channel:str, args...) -> None"),
|
||||
]
|
||||
|
||||
self._unify(node.type, builtins.TNone(),
|
||||
node.loc, None)
|
||||
|
||||
if len(node.args) >= 1 and len(node.keywords) == 0:
|
||||
arg = node.args[0]
|
||||
|
||||
self._unify(arg.type, builtins.TStr(),
|
||||
arg.loc, None)
|
||||
else:
|
||||
diagnose(valid_forms())
|
||||
elif types.is_builtin(typ, "now"):
|
||||
simple_form("now() -> float",
|
||||
[], builtins.TFloat())
|
||||
|
|
Loading…
Reference in New Issue