Skip to content

Commit

Permalink
Fixed write in augmented assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
AryazE committed Nov 2, 2023
1 parent 3148d14 commit e9142e6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dynapyt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""DynaPyt"""
__version__ = "1.2.1"
__version__ = "1.3.0"
31 changes: 29 additions & 2 deletions src/dynapyt/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,35 @@ def _aug_assign_(dyn_ast, iid, left, opr, right):
"binary_operation", dyn_ast, iid, operator[opr][:-6], left, right, None
)
call_if_exists(snake(operator[opr][:-6]), dyn_ast, iid, left, right, None)
call_if_exists("memory_access", dyn_ast, iid, right)
call_if_exists("write", dyn_ast, iid, [left], right)
eval_left = left()
if opr == 0:
new_val = eval_left + right
elif opr == 1:
new_val = eval_left & right
elif opr == 2:
new_val = eval_left | right
elif opr == 3:
new_val = eval_left ^ right
elif opr == 4:
new_val = eval_left / right
elif opr == 5:
new_val = eval_left // right
elif opr == 6:
new_val = eval_left << right
elif opr == 7:
new_val = eval_left @ right
elif opr == 8:
new_val = eval_left % right
elif opr == 9:
new_val = eval_left * right
elif opr == 10:
new_val = eval_left**right
elif opr == 11:
new_val = eval_left >> right
elif opr == 12:
new_val = eval_left - right
call_if_exists("memory_access", dyn_ast, iid, new_val)
call_if_exists("write", dyn_ast, iid, [left], new_val)
result_high = call_if_exists(
"augmented_assignment", dyn_ast, iid, left, operator[opr], right
)
Expand Down
2 changes: 2 additions & 0 deletions tests/trace_single_hook/write/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ begin execution
Writing 10 to [('a',)]
Writing test to [('b',)]
Writing testtesttesttesttesttesttesttesttesttest to [('c',)]
Writing testing to [('b',)]
Writing 30 to [('a',)]
end execution
2 changes: 2 additions & 0 deletions tests/trace_single_hook/write/program.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
a = 10
b = "test"
c = a * b
b += "ing"
a *= 3

0 comments on commit e9142e6

Please sign in to comment.