SeedV / SeedLang

An embeddable and visualizable scripting engine for .Net and Unity.
https://seedv.github.io/SeedLang/
Apache License 2.0
9 stars 1 forks source link

Include variable information into assignment, binary and comparison notification events #208

Closed codingpotato closed 2 years ago

codingpotato commented 2 years ago

After this change, the Compare VTag is not needed any more. Please run following command to see the notification of Assignment, Binary and Comparison.

dotnet run --project csharp/src/SeedLang.Shell -- -v "*" -f examples/seedpython/scripts/sorting/bubble_sort.py
codingpotato commented 2 years ago

Fixed the review comments and added another big change to fix bugs in variable tracking.

  1. Change the event data of visualization notification to LValue and RValue, so that the right value of assignment can also be represented as Variable, Element of Containers and Temporary Value.
  2. Added temporary register allocated notification to make variable tracking correct. It will add more instructions when the client would like to get variable related notifications. It makes the program ~5 times slower than normal case without variable tracking enabled. The performance is acceptable now.
  3. The variable tracking logic is quite complex. So there are some minor bugs now. I will check and fix them later.
  4. Please run following command to see the result of this PR.
    dotnet run --project csharp/src/SeedLang.Shell -- -v "Assignment,Comparison" -f examples/seedpython/scripts/sorting/bubble_sort.py

With this PR, the comparison notification events look like

6             if a[j] > a[j + 1]:
Comparison: a:Global[0] 0 > a:Global[1] 1 = False

And assignment notification events look like

8                 a[j], a[j + 1] = a[j + 1], a[j]
Assign: a:Global[5] = a:Global[6] 1
8                 a[j], a[j + 1] = a[j + 1], a[j]
Assign: a:Global[6] = a:Global[5] 5

It seems Compare VTag is not needed with this PR. Could the Swap VTag also be removed? Please have a review again.