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
|
2007-11-25 04:35:16 -05:00
|
|
|
prettyprint continuations effects ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: tools.annotations
|
|
|
|
|
|
|
|
: annotate ( word quot -- )
|
|
|
|
over >r >r word-def r> call r>
|
|
|
|
swap define-compound do-parse-hook ;
|
|
|
|
inline
|
|
|
|
|
2007-11-25 04:35:16 -05: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
|
|
|
|
2007-11-25 04:35:16 -05: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
|
|
|
|
2007-11-25 04:35:16 -05:00
|
|
|
: (watch) ( word def -- def )
|
2007-09-20 18:09:08 -04:00
|
|
|
over [ entering ] curry
|
|
|
|
rot [ leaving ] curry
|
|
|
|
swapd 3append ;
|
|
|
|
|
|
|
|
: watch ( word -- )
|
2007-11-25 04:35:16 -05:00
|
|
|
dup [ (watch) ] annotate ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: breakpoint ( word -- )
|
|
|
|
[ \ break add* ] annotate ;
|
|
|
|
|
|
|
|
: breakpoint-if ( quot word -- )
|
|
|
|
[ [ [ break ] when ] swap 3append ] annotate ;
|