forked from M-Labs/artiq
1
0
Fork 0

transforms/inline: add sequential block when inlining function

This commit is contained in:
Sebastien Bourdeauducq 2014-09-09 22:01:28 +08:00
parent e6530075d9
commit 5144da3f9a
1 changed files with 7 additions and 2 deletions

View File

@ -164,7 +164,12 @@ class _ReferenceReplacer(ast.NodeTransformer):
args = [func.__self__] + new_args args = [func.__self__] + new_args
inlined, _ = inline(self.core, func.k_function_info.k_function, inlined, _ = inline(self.core, func.k_function_info.k_function,
args, dict(), self.rm) args, dict(), self.rm)
return inlined.body r = ast.With(
items=[ast.withitem(context_expr=ast.Name(id="sequential",
ctx=ast.Load()),
optional_vars=None)],
body=inlined.body)
return ast.copy_location(r, node)
else: else:
args = [ast.Str("rpc"), value_to_ast(self.rm.rpc_map[func])] args = [ast.Str("rpc"), value_to_ast(self.rm.rpc_map[func])]
args += new_args args += new_args
@ -176,7 +181,7 @@ class _ReferenceReplacer(ast.NodeTransformer):
def visit_Expr(self, node): def visit_Expr(self, node):
if isinstance(node.value, ast.Call): if isinstance(node.value, ast.Call):
r = self.visit_Call(node.value) r = self.visit_Call(node.value)
if isinstance(r, list): if isinstance(r, ast.With):
return r return r
else: else:
node.value = r node.value = r