From 1a969aa9e418ddb3176c0fcc404754dbb49aeeb3 Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 7 Aug 2015 07:54:35 +0300 Subject: [PATCH] compiler.transforms.inferencer: accept and ignore @kernel decorator. --- artiq/compiler/builtins.py | 3 +++ artiq/compiler/prelude.py | 1 + artiq/compiler/transforms/inferencer.py | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/builtins.py b/artiq/compiler/builtins.py index 903900540..6b9feb9e2 100644 --- a/artiq/compiler/builtins.py +++ b/artiq/compiler/builtins.py @@ -146,6 +146,9 @@ def fn_round(): def fn_print(): return types.TBuiltinFunction("print") +def fn_kernel(): + return types.TBuiltinFunction("kernel") + def fn_syscall(): return types.TBuiltinFunction("syscall") diff --git a/artiq/compiler/prelude.py b/artiq/compiler/prelude.py index 600b7a800..3c58674c6 100644 --- a/artiq/compiler/prelude.py +++ b/artiq/compiler/prelude.py @@ -19,5 +19,6 @@ def globals(): "len": builtins.fn_len(), "round": builtins.fn_round(), "print": builtins.fn_print(), + "kernel": builtins.fn_kernel(), "syscall": builtins.fn_syscall(), } diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 57aa9247d..e0338dcdc 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -887,10 +887,13 @@ class Inferencer(algorithm.Visitor): arg.loc, default.loc) def visit_FunctionDefT(self, node): - if any(node.decorator_list): + for index, decorator in enumerate(node.decorator_list): + if types.is_builtin(decorator.type, "kernel"): + continue + diag = diagnostic.Diagnostic("error", "decorators are not supported", {}, - node.at_locs[0], [node.decorator_list[0].loc]) + node.at_locs[index], [decorator.loc]) self.engine.process(diag) return