Skip to content

Commit

Permalink
Add channel name as the first argument to rtio_log (#206).
Browse files Browse the repository at this point in the history
whitequark committed Feb 15, 2016
1 parent f28b259 commit 1465fe6
Showing 2 changed files with 25 additions and 4 deletions.
12 changes: 9 additions & 3 deletions artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -1608,10 +1608,16 @@ def body_gen(index):
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:
17 changes: 16 additions & 1 deletion artiq/compiler/transforms/inferencer.py
Original file line number Diff line number Diff line change
@@ -753,7 +753,7 @@ def makenotes(printer, typea, typeb, loca, locb):
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 @@ def makenotes(printer, typea, typeb, loca, locb):
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())

0 comments on commit 1465fe6

Please sign in to comment.