Skip to content

Commit

Permalink
transforms: assume isinstance(expr, ast.Call) => isinstance(expr.func…
Browse files Browse the repository at this point in the history
…, ast.Name) after inline
sbourdeauducq committed Nov 15, 2014
1 parent e02ca0b commit cbc629b
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion artiq/transforms/interleave.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def _get_duration(stmt):
return 0
else:
return -1
elif isinstance(stmt, ast.Call) and isinstance(stmt.func, ast.Name):
elif isinstance(stmt, ast.Call):
name = stmt.func.id
if name == "delay":
try:
5 changes: 2 additions & 3 deletions artiq/transforms/lower_time.py
Original file line number Diff line number Diff line change
@@ -19,16 +19,15 @@

class _TimeLowerer(ast.NodeTransformer):
def visit_Call(self, node):
if isinstance(node.func, ast.Name) and node.func.id == "now":
if node.func.id == "now":
return ast.copy_location(ast.Name("now", ast.Load()), node)
else:
self.generic_visit(node)
return node

def visit_Expr(self, node):
r = node
if (isinstance(node.value, ast.Call)
and isinstance(node.value.func, ast.Name)):
if isinstance(node.value, ast.Call):
funcname = node.value.func.id
if funcname == "delay":
r = ast.copy_location(
2 changes: 1 addition & 1 deletion artiq/transforms/tools.py
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ def _is_ref_transparent(dependencies, expr):
and _is_ref_transparent(dependencies, expr.right))
elif isinstance(expr, ast.BoolOp):
return all(_is_ref_transparent(dependencies, v) for v in expr.values)
elif isinstance(expr, ast.Call) and isinstance(expr.func, ast.Name):
elif isinstance(expr, ast.Call):
return (expr.func.id in _replaceable_funcs and
all(_is_ref_transparent(dependencies, arg) for arg in expr.args))
else:

0 comments on commit cbc629b

Please sign in to comment.