Skip to content

Commit

Permalink
tools.annotations: adding <WATCH ... WATCH> syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Dec 3, 2024
1 parent e729333 commit b4345e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions basis/tools/annotations/annotations-docs.factor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $nl
{ $subsections
watch
watch-vars
POSTPONE: <WATCH
}
"Timing words:"
{ $subsections
Expand All @@ -34,6 +35,10 @@ HELP: watch

{ watch watch-vars reset } related-words

HELP: <WATCH
{ $syntax "<WATCH ... WATCH>" }
{ $description "Allows wrapping a block of code and record stack values entering and exiting the block of code." } ;

HELP: reset
{ $values
{ "word" word } }
Expand Down
12 changes: 9 additions & 3 deletions basis/tools/annotations/annotations.factor
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
! Copyright (C) 2005, 2010 Slava Pestov.
! See https://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs combinators.short-circuit compiler.units effects
generalizations generic inspector io kernel math namespaces prettyprint
quotations sequences sequences.deep sequences.generalizations sorting summary
USING: accessors arrays assocs combinators.short-circuit
compiler.units effects generalizations generic inspector io
kernel math namespaces parser prettyprint quotations sequences
sequences.deep sequences.generalizations sorting summary
tools.time vocabs words ;
IN: tools.annotations

Expand Down Expand Up @@ -122,6 +123,11 @@ PRIVATE>
: watch-vars ( word vars -- )
dupd '[ [ _ _ ] dip (watch-vars) ] annotate ;

DEFER: <WATCH

SYNTAX: <WATCH
\ WATCH> parse-until >quotation dup (watch) append! ;

SYMBOL: word-timing

word-timing [ H{ } clone ] initialize
Expand Down

0 comments on commit b4345e1

Please sign in to comment.