Skip to content

Commit

Permalink
simplify if transform; remove current_rename_subs
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjoa committed Jul 18, 2024
1 parent 457de78 commit 6f2db07
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions program/transformer/if_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,14 @@ def _(self, ifstmt: IfStatem):
else And(not_previous, conditions[i])
)

# Remember variables which appear in a condition and are assigned within the branch
current_rename_subs = {}
# Remember variables which appear in a condition and are assigned
# within the branch or any previous one
for assign in branch:
if assign.variable in condition_symbols:
if assign.variable in rename_subs:
current_rename_subs[assign.variable] = rename_subs[
assign.variable
]
else:
current_rename_subs[assign.variable] = get_unique_var(
if assign.variable not in rename_subs:
rename_subs[assign.variable] = get_unique_var(
name="old"
)
rename_subs[assign.variable] = current_rename_subs[
assign.variable
]
extra_condition = current_condition.copy().simplify()
extra_condition.subs(rename_subs)

Expand Down

0 comments on commit 6f2db07

Please sign in to comment.