2005-03-10 17:57:22 -05:00
|
|
|
! Copyright (C) 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
|
|
|
IN: words
|
|
|
|
|
|
|
|
! The annotation words let you flag a word for either tracing
|
|
|
|
! or single-stepping. Note that currently, words referring to
|
|
|
|
! annotated words cannot be compiled; and annotating a word has
|
|
|
|
! no effect of compiled calls to that word.
|
|
|
|
USING: interpreter kernel lists stdio strings ;
|
|
|
|
|
|
|
|
: annotate ( word quot -- ) #! Quotation: ( word def -- def )
|
2005-03-26 20:12:14 -05:00
|
|
|
over [ word-def swap call ] keep (define-compound) ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
|
|
|
: (watch) >r "==> " swap word-name cat2 \ print r> cons cons ;
|
|
|
|
|
|
|
|
: watch ( word -- )
|
|
|
|
#! Cause a message to be printed out when the word is
|
|
|
|
#! executed. To undo the effect of this, reload the
|
|
|
|
#! word with \ foo reload.
|
|
|
|
[ (watch) ] annotate ;
|
|
|
|
|
|
|
|
: (break) [ walk ] cons ;
|
|
|
|
|
|
|
|
: break ( word -- )
|
|
|
|
#! Cause the word to start the code walker when executed.
|
|
|
|
[ nip (break) ] annotate ;
|