Skip to content

Commit b4345e1

Browse files
committed
tools.annotations: adding <WATCH ... WATCH> syntax
1 parent e729333 commit b4345e1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

basis/tools/annotations/annotations-docs.factor

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ $nl
88
{ $subsections
99
watch
1010
watch-vars
11+
POSTPONE: <WATCH
1112
}
1213
"Timing words:"
1314
{ $subsections
@@ -34,6 +35,10 @@ HELP: watch
3435

3536
{ watch watch-vars reset } related-words
3637

38+
HELP: <WATCH
39+
{ $syntax "<WATCH ... WATCH>" }
40+
{ $description "Allows wrapping a block of code and record stack values entering and exiting the block of code." } ;
41+
3742
HELP: reset
3843
{ $values
3944
{ "word" word } }

basis/tools/annotations/annotations.factor

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
! Copyright (C) 2005, 2010 Slava Pestov.
22
! See https://factorcode.org/license.txt for BSD license.
3-
USING: accessors arrays assocs combinators.short-circuit compiler.units effects
4-
generalizations generic inspector io kernel math namespaces prettyprint
5-
quotations sequences sequences.deep sequences.generalizations sorting summary
3+
USING: accessors arrays assocs combinators.short-circuit
4+
compiler.units effects generalizations generic inspector io
5+
kernel math namespaces parser prettyprint quotations sequences
6+
sequences.deep sequences.generalizations sorting summary
67
tools.time vocabs words ;
78
IN: tools.annotations
89

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

126+
DEFER: <WATCH
127+
128+
SYNTAX: <WATCH
129+
\ WATCH> parse-until >quotation dup (watch) append! ;
130+
125131
SYMBOL: word-timing
126132

127133
word-timing [ H{ } clone ] initialize

0 commit comments

Comments
 (0)