mirror of https://github.com/m-labs/artiq.git
unroll_loops: handle for/else
This commit is contained in:
parent
08ff5154a8
commit
956f75d168
|
@ -75,7 +75,10 @@ def unroll_loops(stmts, limit):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
unroll_loops(stmt.body, limit)
|
unroll_loops(stmt.body, limit)
|
||||||
n = len(it)*_count_stmts(stmt.body)
|
unroll_loops(stmt.orelse, limit)
|
||||||
|
l_it = len(it)
|
||||||
|
if l_it:
|
||||||
|
n = l_it*_count_stmts(stmt.body)
|
||||||
if n < limit:
|
if n < limit:
|
||||||
replacement = []
|
replacement = []
|
||||||
for i in it:
|
for i in it:
|
||||||
|
@ -87,6 +90,8 @@ def unroll_loops(stmts, limit):
|
||||||
replacement += stmt.body
|
replacement += stmt.body
|
||||||
if replacement is not None:
|
if replacement is not None:
|
||||||
replacements.append((stmt_i, replacement))
|
replacements.append((stmt_i, replacement))
|
||||||
|
else:
|
||||||
|
replacements.append((stmt_i, stmt.orelse))
|
||||||
if isinstance(stmt, (ast.While, ast.If)):
|
if isinstance(stmt, (ast.While, ast.If)):
|
||||||
unroll_loops(stmt.body, limit)
|
unroll_loops(stmt.body, limit)
|
||||||
unroll_loops(stmt.orelse, limit)
|
unroll_loops(stmt.orelse, limit)
|
||||||
|
|
Loading…
Reference in New Issue