forked from M-Labs/artiq
compiler: use value_to_ast(x) instead of ast.Num(x)
This commit is contained in:
parent
3446c1f914
commit
2135e37dca
@ -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()),
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user