From b3b61d8b6bae6031f74d9636f350d2db937ddbb9 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 18 Aug 2014 23:11:53 +0800 Subject: [PATCH] compiler/fold_constants: fix int/round --- artiq/compiler/fold_constants.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/fold_constants.py b/artiq/compiler/fold_constants.py index 0e0507df5..71f821917 100644 --- a/artiq/compiler/fold_constants.py +++ b/artiq/compiler/fold_constants.py @@ -61,12 +61,18 @@ class _ConstantFolder(ast.NodeTransformer): def visit_Call(self, node): self.generic_visit(node) fn = node.func.id - if fn in ("int", "int64", "round", "round64"): + constant_ops = { + "int": int, + "int64": int64, + "round": round, + "round64": round64 + } + if fn in constant_ops: try: arg = eval_constant(node.args[0]) except NotConstant: return node - result = value_to_ast(globals()[fn](arg)) + result = value_to_ast(constant_ops[fn](arg)) return ast.copy_location(result, node) else: return node