From 822e8565f74928df5673364186e061c9f1a4e8e6 Mon Sep 17 00:00:00 2001 From: pca006132 Date: Fri, 2 Jul 2021 16:28:47 +0800 Subject: [PATCH] compiler: supports kernel decorators with path --- artiq/compiler/transforms/inferencer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 7d6d065b7..fdc268d4f 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -6,6 +6,7 @@ from collections import OrderedDict from pythonparser import algorithm, diagnostic, ast from .. import asttyped, types, builtins from .typedtree_printer import TypedtreePrinter +from artiq.experiment import kernel def is_nested_empty_list(node): @@ -1662,7 +1663,14 @@ class Inferencer(algorithm.Visitor): def visit_FunctionDefT(self, node): for index, decorator in enumerate(node.decorator_list): - if types.is_builtin(decorator.type, "kernel") or \ + def eval_attr(attr): + if isinstance(attr.value, asttyped.QuoteT): + return getattr(attr.value.value, attr.attr) + return getattr(eval_attr(attr.value), attr.attr) + if isinstance(decorator, asttyped.AttributeT): + decorator = eval_attr(decorator) + if id(decorator) == id(kernel) or \ + types.is_builtin(decorator.type, "kernel") or \ isinstance(decorator, asttyped.CallT) and \ types.is_builtin(decorator.func.type, "kernel"): continue