From 5c228f91146e3bff00ef31f3bf8c36001c81787c Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 13 Sep 2014 19:32:21 +0800 Subject: [PATCH] Consistent variable naming --- artiq/devices/core.py | 16 ++++++++-------- artiq/py2llvm/__init__.py | 4 ++-- artiq/py2llvm/fractions.py | 4 ++-- artiq/py2llvm/module.py | 14 +++++++------- artiq/transforms/interleave.py | 4 ++-- artiq/transforms/lower_time.py | 8 ++++---- artiq/transforms/lower_units.py | 4 ++-- test/py2llvm.py | 6 +++--- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/artiq/devices/core.py b/artiq/devices/core.py index 7e197afd7..5cd37b178 100644 --- a/artiq/devices/core.py +++ b/artiq/devices/core.py @@ -15,14 +15,14 @@ class Core: self.core_com = core_com def run(self, k_function, k_args, k_kwargs): - funcdef, rpc_map = inline(self, k_function, k_args, k_kwargs) - lower_units(funcdef, self.runtime_env.ref_period) - fold_constants(funcdef) - unroll_loops(funcdef, 50) - interleave(funcdef) - lower_time(funcdef, getattr(self.runtime_env, "initial_time", 0)) - fold_constants(funcdef) + func_def, rpc_map = inline(self, k_function, k_args, k_kwargs) + lower_units(func_def, self.runtime_env.ref_period) + fold_constants(func_def) + unroll_loops(func_def, 50) + interleave(func_def) + lower_time(func_def, getattr(self.runtime_env, "initial_time", 0)) + fold_constants(func_def) - binary = get_runtime_binary(self.runtime_env, funcdef) + binary = get_runtime_binary(self.runtime_env, func_def) self.core_com.run(binary) self.core_com.serve(rpc_map) diff --git a/artiq/py2llvm/__init__.py b/artiq/py2llvm/__init__.py index 88dd35808..fefb2b9ff 100644 --- a/artiq/py2llvm/__init__.py +++ b/artiq/py2llvm/__init__.py @@ -1,6 +1,6 @@ from artiq.py2llvm.module import Module -def get_runtime_binary(env, funcdef): +def get_runtime_binary(env, func_def): module = Module(env) - module.compile_function(funcdef, dict()) + module.compile_function(func_def, dict()) return module.emit_object() diff --git a/artiq/py2llvm/fractions.py b/artiq/py2llvm/fractions.py index e57d12a52..cf67a56ea 100644 --- a/artiq/py2llvm/fractions.py +++ b/artiq/py2llvm/fractions.py @@ -18,8 +18,8 @@ def _gcd(a, b): def init_module(module): - funcdef = ast.parse(inspect.getsource(_gcd)).body[0] - module.compile_function(funcdef, {"a": VInt(64), "b": VInt(64)}) + func_def = ast.parse(inspect.getsource(_gcd)).body[0] + module.compile_function(func_def, {"a": VInt(64), "b": VInt(64)}) def _reduce(builder, a, b): diff --git a/artiq/py2llvm/module.py b/artiq/py2llvm/module.py index 0ab6f5562..faa35ee55 100644 --- a/artiq/py2llvm/module.py +++ b/artiq/py2llvm/module.py @@ -31,25 +31,25 @@ class Module: self.finalize() return self.env.emit_object() - def compile_function(self, funcdef, param_types): - ns = infer_types.infer_function_types(self.env, funcdef, param_types) + def compile_function(self, func_def, param_types): + ns = infer_types.infer_function_types(self.env, func_def, param_types) retval = ns["return"] function_type = lc.Type.function(retval.get_llvm_type(), - [ns[arg.arg].get_llvm_type() for arg in funcdef.args.args]) - function = self.llvm_module.add_function(function_type, funcdef.name) + [ns[arg.arg].get_llvm_type() for arg in func_def.args.args]) + function = self.llvm_module.add_function(function_type, func_def.name) bb = function.append_basic_block("entry") builder = lc.Builder.new(bb) - for arg_ast, arg_llvm in zip(funcdef.args.args, function.args): + for arg_ast, arg_llvm in zip(func_def.args.args, function.args): arg_llvm.name = arg_ast.arg for k, v in ns.items(): v.alloca(builder, k) - for arg_ast, arg_llvm in zip(funcdef.args.args, function.args): + for arg_ast, arg_llvm in zip(func_def.args.args, function.args): ns[arg_ast.arg].auto_store(builder, arg_llvm) visitor = ast_body.Visitor(self.env, ns, builder) - visitor.visit_statements(funcdef.body) + visitor.visit_statements(func_def.body) if not tools.is_terminated(builder.basic_block): if isinstance(retval, base_types.VNone): diff --git a/artiq/transforms/interleave.py b/artiq/transforms/interleave.py index d8ab192c2..b98f7ea99 100644 --- a/artiq/transforms/interleave.py +++ b/artiq/transforms/interleave.py @@ -109,5 +109,5 @@ def _interleave_stmts(stmts): offset += len(new_stmts) - 1 -def interleave(funcdef): - _interleave_stmts(funcdef.body) +def interleave(func_def): + _interleave_stmts(func_def.body) diff --git a/artiq/transforms/lower_time.py b/artiq/transforms/lower_time.py index e4edbf982..76d2eab58 100644 --- a/artiq/transforms/lower_time.py +++ b/artiq/transforms/lower_time.py @@ -42,9 +42,9 @@ class _TimeLowerer(ast.NodeTransformer): return node -def lower_time(funcdef, initial_time): - _TimeLowerer().visit(funcdef) - funcdef.body.insert(0, ast.copy_location( +def lower_time(func_def, initial_time): + _TimeLowerer().visit(func_def) + func_def.body.insert(0, ast.copy_location( ast.Assign(targets=[ast.Name("now", ast.Store())], value=value_to_ast(int64(initial_time))), - funcdef)) + func_def)) diff --git a/artiq/transforms/lower_units.py b/artiq/transforms/lower_units.py index fa2262a00..16017a372 100644 --- a/artiq/transforms/lower_units.py +++ b/artiq/transforms/lower_units.py @@ -40,8 +40,8 @@ class _UnitsLowerer(ast.NodeTransformer): return node -def lower_units(funcdef, ref_period): +def lower_units(func_def, ref_period): if (not isinstance(ref_period, units.Quantity) or ref_period.unit is not units.s_unit): raise units.DimensionError("Reference period not expressed in seconds") - _UnitsLowerer(ref_period.amount).visit(funcdef) + _UnitsLowerer(ref_period.amount).visit(func_def) diff --git a/test/py2llvm.py b/test/py2llvm.py index f87136280..63c98fa18 100644 --- a/test/py2llvm.py +++ b/test/py2llvm.py @@ -78,10 +78,10 @@ class FunctionArrayTypesCase(unittest.TestCase): class CompiledFunction: def __init__(self, function, param_types): module = Module() - funcdef = ast.parse(inspect.getsource(function)).body[0] + func_def = ast.parse(inspect.getsource(function)).body[0] self.function, self.retval = module.compile_function( - funcdef, param_types) - self.argval = [param_types[arg.arg] for arg in funcdef.args.args] + func_def, param_types) + self.argval = [param_types[arg.arg] for arg in func_def.args.args] self.ee = module.get_ee() def __call__(self, *args):