1 USING: help.markup help.syntax words parser quotations strings
5 ARTICLE: "tools.annotations" "Word annotations"
6 "The word annotation feature modifies word definitions to add debugging code. You can restore the old definition by calling " { $link reset } " on the word in question."
8 "Printing messages when a word is called or returns:"
10 { $subsection watch-vars }
11 "Starting the walker when a word is called:"
12 { $subsection breakpoint }
13 { $subsection breakpoint-if }
15 { $subsection reset-word-timing }
16 { $subsection add-timing }
17 { $subsection word-timing. }
18 "All of the above words are implemented using a single combinator which applies a quotation to a word definition to yield a new definition:"
19 { $subsection annotate } ;
21 ABOUT: "tools.annotations"
24 { $values { "word" "a word" } { "quot" { $quotation "( word def -- def )" } } }
25 { $description "Changes a word definition to the result of applying a quotation to the old definition." }
26 { $notes "This word is used to implement " { $link watch } "." } ;
29 { $values { "word" word } }
30 { $description "Annotates a word definition to print the data stack on entry and exit." } ;
32 { watch watch-vars reset } related-words
35 { $values { "word" word } }
36 { $description "Annotates a word definition to enter the single stepper when executed." } ;
39 { $values { "quot" { $quotation "( -- ? )" } } { "word" word } }
40 { $description "Annotates a word definition to enter the single stepper if the quotation yields true." } ;
42 HELP: annotate-methods
44 { "word" word } { "quot" quotation } }
45 { $description "Annotates the word -- for generic words, all its methods -- with the quotation." } ;
50 { $description "Prints a message and the inputs to the word before the word has been called." } ;
55 { $description "Prints a message and the outputs from a word after a word has been called." } ;
60 { $description "Resets any annotations on a word." }
61 { $notes "This word will remove a " { $link watch } "." } ;
65 { "word" word } { "vars" "a sequence of symbols" } }
66 { $description "Annotates a word definition to print the " { $snippet "vars" } " upon entering the word. This word is useful for debugging." } ;
72 { $description "Makes a sequence of the inputs to a word by counting the number of inputs in the stack effect and saving that many items from the datastack." } ;
75 { $values { "word" word } }
76 { $description "Adds timing code to a word, which records its total running time, including that of words it calls, on every invocation." }
77 { $see-also "timing" "profiling" } ;
79 HELP: reset-word-timing
80 { $description "Resets the word timing table." } ;
83 { $description "Prints the word timing table." } ;