'watch' now respects effect-in/effect-out

release
Slava Pestov 2007-11-25 04:35:16 -05:00
parent efde1afc2f
commit 75d9329f06
1 changed files with 17 additions and 5 deletions

View File

@ -1,7 +1,7 @@
! 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 ;
prettyprint continuations effects ;
IN: tools.annotations
: annotate ( word quot -- )
@ -9,17 +9,29 @@ IN: tools.annotations
swap define-compound do-parse-hook ;
inline
: entering ( str -- ) "! Entering: " write print .s flush ;
: entering ( str -- )
"/-- Entering: " write dup .
stack-effect [
>r datastack r> effect-in length tail* stack.
] [
.s
] if* "\\--" print flush ;
: leaving ( str -- ) "! Leaving: " write print .s flush ;
: leaving ( str -- )
"/-- Leaving: " write dup .
stack-effect [
>r datastack r> effect-out length tail* stack.
] [
.s
] if* "\\--" print flush ;
: (watch) ( str def -- def )
: (watch) ( word def -- def )
over [ entering ] curry
rot [ leaving ] curry
swapd 3append ;
: watch ( word -- )
dup word-name swap [ (watch) ] annotate ;
dup [ (watch) ] annotate ;
: breakpoint ( word -- )
[ \ break add* ] annotate ;