factor/extra/tools/annotations/annotations.factor

44 lines
1.1 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
! Copyright (C) 2005, 2007 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel words parser io inspector quotations sequences
prettyprint continuations effects definitions ;
2007-09-20 18:09:08 -04:00
IN: tools.annotations
: reset ( word -- )
2008-01-02 19:36:36 -05:00
dup "unannotated-def" word-prop define ;
2007-09-20 18:09:08 -04:00
: annotate ( word quot -- )
2007-12-30 15:08:48 -05:00
over dup word-def "unannotated-def" set-word-prop
2008-01-02 19:36:36 -05:00
[ >r dup word-def r> call define ] with-compilation-unit ;
inline
2007-09-20 18:09:08 -04:00
: entering ( str -- )
"/-- Entering: " write dup .
stack-effect [
>r datastack r> effect-in length tail* stack.
] [
.s
] if* "\\--" print flush ;
2007-09-20 18:09:08 -04:00
: leaving ( str -- )
"/-- Leaving: " write dup .
stack-effect [
>r datastack r> effect-out length tail* stack.
] [
.s
] if* "\\--" print flush ;
2007-09-20 18:09:08 -04:00
: (watch) ( word def -- def )
2007-09-20 18:09:08 -04:00
over [ entering ] curry
rot [ leaving ] curry
swapd 3append ;
: watch ( word -- )
dup [ (watch) ] annotate ;
2007-09-20 18:09:08 -04:00
: breakpoint ( word -- )
[ \ break add* ] annotate ;
: breakpoint-if ( word quot -- )
[ [ [ break ] when ] rot 3append ] curry annotate ;