Skip to content

Commit

Permalink
unary fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrusch committed May 2, 2023
1 parent 4019193 commit e09539e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions pymwp/analysis.py
Expand Up @@ -346,17 +346,10 @@ def if_branch(
Updated index value, relation list, and an exit flag.
"""
if node is not None:
# when branch has braces
if hasattr(node, 'block_items'):
for child in node.block_items:
index, rel_list, exit_ = Analysis.compute_relation(
index, child, dg)
if exit_:
return index, exit_
relation_list.composition(rel_list)
else:
index, rel_list, exit_ = Analysis.compute_relation(
index, node, dg)
for child in node.block_items \
if hasattr(node, 'block_items') else [node]:
index, rel_list, exit_ = Analysis \
.compute_relation(index, child, dg)
if exit_:
return index, exit_
relation_list.composition(rel_list)
Expand All @@ -378,7 +371,8 @@ def while_(index: int, node: pr.While, dg: DeltaGraph) \
logger.debug("analysing While")

relations = RelationList()
for child in node.stmt.block_items:
for child in node.stmt.block_items \
if hasattr(node, 'block_items') else [node.stmt]:
index, rel_list, exit_ = Analysis.compute_relation(
index, child, dg)
if exit_:
Expand Down Expand Up @@ -446,6 +440,7 @@ def compound_(index: int, node: pr.Compound, dg: DeltaGraph) \
Updated index value, relation list, and an exit flag.
"""
relations = RelationList()

if node.block_items:
for node in node.block_items:
index, rel_list, exit_ = Analysis.compute_relation(
Expand Down

0 comments on commit e09539e

Please sign in to comment.