From fe948f0b26d115ac5a364f5e6d9e72d520eb7408 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 22 Sep 2009 03:16:31 -0500 Subject: [PATCH] Move breakpoint word from tools.annotations to tools.walker to reduce amount of dependencies tools.annotations pulls into a minimal image --- .../tools/annotations/annotations-docs.factor | 11 -------- basis/tools/annotations/annotations.factor | 11 ++------ basis/tools/walker/walker-docs.factor | 25 +++++++++++++++++-- basis/tools/walker/walker.factor | 8 +++++- basis/ui/tools/walker/walker-docs.factor | 8 ------ 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/basis/tools/annotations/annotations-docs.factor b/basis/tools/annotations/annotations-docs.factor index 89ef6192c6..17743610bc 100644 --- a/basis/tools/annotations/annotations-docs.factor +++ b/basis/tools/annotations/annotations-docs.factor @@ -8,9 +8,6 @@ $nl "Printing messages when a word is called or returns:" { $subsection watch } { $subsection watch-vars } -"Starting the walker when a word is called:" -{ $subsection breakpoint } -{ $subsection breakpoint-if } "Timing words:" { $subsection reset-word-timing } { $subsection add-timing } @@ -34,14 +31,6 @@ HELP: watch { watch watch-vars reset } related-words -HELP: breakpoint -{ $values { "word" word } } -{ $description "Annotates a word definition to enter the single stepper when executed." } ; - -HELP: breakpoint-if -{ $values { "quot" { $quotation "( -- ? )" } } { "word" word } } -{ $description "Annotates a word definition to enter the single stepper if the quotation yields true." } ; - HELP: reset { $values { "word" word } } diff --git a/basis/tools/annotations/annotations.factor b/basis/tools/annotations/annotations.factor index 2fb246786c..5d4a9226ce 100644 --- a/basis/tools/annotations/annotations.factor +++ b/basis/tools/annotations/annotations.factor @@ -2,9 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors kernel math sorting words parser io summary quotations sequences prettyprint continuations effects -definitions compiler.units namespaces assocs tools.walker -tools.time generic inspector fry tools.continuations -locals generalizations macros ; +definitions compiler.units namespaces assocs tools.time generic +inspector fry locals generalizations macros ; IN: tools.annotations : watch-vars ( word vars -- ) dupd '[ [ _ _ ] dip (watch-vars) ] annotate ; -: breakpoint ( word -- ) - [ add-breakpoint ] annotate ; - -: breakpoint-if ( word quot -- ) - '[ [ _ [ [ break ] when ] ] dip 3append ] annotate ; - SYMBOL: word-timing word-timing [ H{ } clone ] initialize diff --git a/basis/tools/walker/walker-docs.factor b/basis/tools/walker/walker-docs.factor index b636760634..5a78e0cfc2 100644 --- a/basis/tools/walker/walker-docs.factor +++ b/basis/tools/walker/walker-docs.factor @@ -1,5 +1,26 @@ IN: tools.walker -USING: help.syntax help.markup tools.continuations ; +USING: help.syntax help.markup tools.continuations sequences math words ; + +HELP: breakpoint +{ $values { "word" word } } +{ $description "Annotates a word definition to enter the single stepper when executed." } ; + +HELP: breakpoint-if +{ $values { "quot" { $quotation "( -- ? )" } } { "word" word } } +{ $description "Annotates a word definition to enter the single stepper if the quotation yields true." } ; HELP: B -{ $description "An alias for " { $link break } ", defined in the " { $vocab-link "syntax" } " vocabulary so that it is always available." } ; \ No newline at end of file +{ $description "An alias for " { $link break } ", defined in the " { $vocab-link "syntax" } " vocabulary so that it is always available." } ; + +ARTICLE: "breakpoints" "Setting breakpoints" +"In addition to invoking the walker explicitly through the UI, it is possible to set breakpoints on words using words in the " { $vocab-link "tools.walker" } " vocabulary." +$nl +"Annotating a word with a breakpoint (see " { $link "tools.annotations" } "):" +{ $subsection breakpoint } +{ $subsection breakpoint-if } +"Breakpoints can be inserted directly into code:" +{ $subsection break } +{ $subsection POSTPONE: B } +"Note that because the walker calls various core library and UI words while rendering its own user interface, setting a breakpoint on a word such as " { $link append } " or " { $link + } " will hang the UI." ; + +ABOUT: "breakpoints" diff --git a/basis/tools/walker/walker.factor b/basis/tools/walker/walker.factor index 4208c4420f..19924d67e4 100644 --- a/basis/tools/walker/walker.factor +++ b/basis/tools/walker/walker.factor @@ -5,7 +5,7 @@ sequences math namespaces.private continuations.private concurrency.messaging quotations kernel.private words sequences.private assocs models models.arrow arrays accessors generic generic.standard definitions make sbufs -tools.continuations parser ; +tools.continuations parser tools.annotations fry ; IN: tools.walker SYMBOL: show-walker-hook ! ( status continuation thread -- ) @@ -158,6 +158,12 @@ SYMBOL: +stopped+ "Walker on " self name>> append spawn [ associate-thread ] keep ; +: breakpoint ( word -- ) + [ add-breakpoint ] annotate ; + +: breakpoint-if ( word quot -- ) + '[ [ _ [ [ break ] when ] ] dip 3append ] annotate ; + ! For convenience IN: syntax diff --git a/basis/ui/tools/walker/walker-docs.factor b/basis/ui/tools/walker/walker-docs.factor index ce354da268..da4f345de2 100644 --- a/basis/ui/tools/walker/walker-docs.factor +++ b/basis/ui/tools/walker/walker-docs.factor @@ -23,14 +23,6 @@ ARTICLE: "ui-walker-step" "Stepping through code" $nl "The " { $link com-back } " command travels backwards through time, and restore stacks. This does not undo side effects (modifying array entries, writing to files, formatting the hard drive, etc) and therefore can only be used reliably on referentially transparent code." ; -ARTICLE: "breakpoints" "Setting breakpoints" -"In addition to invoking the walker explicitly through the UI, it is possible to set breakpoints on words. See " { $link "tools.annotations" } "." -$nl -"Breakpoints can be inserted directly into code:" -{ $subsection break } -{ $subsection POSTPONE: B } -"Note that because the walker calls various core library and UI words while rendering its own user interface, setting a breakpoint on a word such as " { $link append } " or " { $link draw-gadget } " will hang the UI." ; - ARTICLE: "ui-walker" "UI walker" "The walker single-steps through quotations. To use the walker, enter a piece of code in the listener's input area and press " { $operation walk } "." $nl