-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ivy: add a rudimentary tracing functionality to the interpreter
Add a ")debug trace" special command to enable execution tracing. If it's set to 1, it traces calls to user-defined operators. If it's set to 2 or highter, it traces all operators. The output is very simple and can get noisy fast, but should still be helpful. I've wanted this for a long time. Internally, this required the type of the debug map to change from boolean to integer, but that makes no real difference outside, and not much inside. Example: % ivy )debug cpu 0 panic 0 parse 0 tokens 0 trace 0 types 0 For trace: 1 traces user-defined only, 2 traces all operators op fac n = n < 1: 1; n*fac n-1 )debug trace 1 fac 3 > fac (3) | > fac (2) | | > fac (1) | | | > fac (0) 6 )debug trace 2 fac 3 > fac (3) | > (3) < (1) | > (3) - (1) | > fac (2) | | > (2) < (1) | | > (2) - (1) | | > fac (1) | | | > (1) < (1) | | | > (1) - (1) | | | > fac (0) | | | | > (0) < (1) | | | > (1) * (1) | | > (2) * (1) | > (3) * (2) 6 op a gcd b = a == b: a a > b: b gcd a-b a gcd b-a 8 gcd 2 > (8) gcd (2) | > (8) == (2) | > (8) > (2) | > (8) - (2) | > (2) gcd (6) | | > (2) == (6) | | > (2) > (6) | | > (6) - (2) | | > (2) gcd (4) | | | > (2) == (4) | | | > (2) > (4) | | | > (4) - (2) | | | > (2) gcd (2) | | | | > (2) == (2) 2
- Loading branch information
Showing
11 changed files
with
99 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters