From 2135e37dca0ac484e7350160066836edda45d711 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 13 Aug 2014 18:02:24 +0800 Subject: [PATCH] compiler: use value_to_ast(x) instead of ast.Num(x) --- artiq/compiler/inline.py | 2 +- artiq/compiler/interleave.py | 2 +- artiq/compiler/lower_time.py | 2 +- artiq/compiler/unroll_loops.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/artiq/compiler/inline.py b/artiq/compiler/inline.py index 019e3c0c0..a31ea91a5 100644 --- a/artiq/compiler/inline.py +++ b/artiq/compiler/inline.py @@ -149,7 +149,7 @@ class _ReferenceReplacer(ast.NodeTransformer): inlined, _ = inline(self.core, func.k_function_info.k_function, args, dict(), self.rm) return inlined else: - args = [ast.Str("rpc"), ast.Num(self.rm.rpc_map[func])] + args = [ast.Str("rpc"), value_to_ast(self.rm.rpc_map[func])] args += new_args return ast.copy_location( ast.Call(func=ast.Name("syscall", ast.Load()), diff --git a/artiq/compiler/interleave.py b/artiq/compiler/interleave.py index dcf6ba384..337b5e296 100644 --- a/artiq/compiler/interleave.py +++ b/artiq/compiler/interleave.py @@ -56,7 +56,7 @@ def _interleave_timelines(timelines): ref_stmt = stmt.stmt da_expr = ast.copy_location( ast.Call(func=ast.Name("Quantity", ast.Load()), - args=[ast.Num(dt), ast.Name("base_s_unit", ast.Load())], + args=[value_to_ast(dt), ast.Name("s_unit", ast.Load())], keywords=[], starargs=[], kwargs=[]), ref_stmt) delay_stmt = ast.copy_location( diff --git a/artiq/compiler/lower_time.py b/artiq/compiler/lower_time.py index 2705a84c7..7b363670a 100644 --- a/artiq/compiler/lower_time.py +++ b/artiq/compiler/lower_time.py @@ -38,6 +38,6 @@ def lower_time(stmts, ref_period, initial_time): transformer = _TimeLowerer(ref_period) new_stmts = [transformer.visit(stmt) for stmt in stmts] new_stmts.insert(0, ast.copy_location( - ast.Assign(targets=[ast.Name("now", ast.Store())], value=ast.Num(initial_time)), + ast.Assign(targets=[ast.Name("now", ast.Store())], value=value_to_ast(initial_time)), stmts[0])) stmts[:] = new_stmts diff --git a/artiq/compiler/unroll_loops.py b/artiq/compiler/unroll_loops.py index 553277eab..b4d47e891 100644 --- a/artiq/compiler/unroll_loops.py +++ b/artiq/compiler/unroll_loops.py @@ -1,6 +1,6 @@ import ast -from artiq.compiler.tools import eval_ast, make_stmt_transformer +from artiq.compiler.tools import eval_ast, make_stmt_transformer, value_to_ast def _count_stmts(node): if isinstance(node, (ast.For, ast.While, ast.If)): @@ -32,7 +32,7 @@ class _LoopUnroller(ast.NodeTransformer): replacement = None break replacement.append(ast.copy_location( - ast.Assign(targets=[node.target], value=ast.Num(n=i)), node)) + ast.Assign(targets=[node.target], value=value_to_ast(i)), node)) replacement += node.body if replacement is not None: return replacement