From b6ac4bdbf30d25e78003c9f2e3eceaa7a833bdad Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 14 Oct 2014 15:14:39 +0800 Subject: [PATCH] transforms/tools: support NameConstant --- artiq/transforms/tools.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/artiq/transforms/tools.py b/artiq/transforms/tools.py index 02eecab45..085a23a14 100644 --- a/artiq/transforms/tools.py +++ b/artiq/transforms/tools.py @@ -19,6 +19,10 @@ def value_to_ast(value): func=ast.Name("int64", ast.Load()), args=[ast.Num(int(value))], keywords=[], starargs=None, kwargs=None) + elif isinstance(value, bool) or value is None: + # must also be before int + # isinstance(True/False, int) == True + return ast.NameConstant(value) elif isinstance(value, (int, float)): return ast.Num(value) elif isinstance(value, Fraction): @@ -49,6 +53,8 @@ def eval_constant(node): return node.n elif isinstance(node, ast.Str): return node.s + elif isinstance(node, ast.NameConstant): + return node.value elif isinstance(node, ast.Call): funcname = node.func.id if funcname == "Fraction":