Add a deep-annotate word that annotates each quotation in a word definition.

db4
Doug Coleman 2011-08-26 11:47:37 -05:00
parent 4603fb2499
commit 96209da661
1 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,7 @@ USING: accessors kernel math sorting words parser io summary
quotations sequences sequences.generalizations prettyprint
continuations effects definitions compiler.units namespaces
assocs tools.time generic inspector fry locals generalizations
macros ;
macros sequences.deep ;
IN: tools.annotations
<PRIVATE
@ -46,11 +46,24 @@ M: word (annotate)
[ dup def>> 2dup "unannotated-def" set-word-prop ] dip
call( old -- new ) define ;
GENERIC# (deep-annotate) 1 ( word quot -- )
M: generic (deep-annotate)
[ "methods" word-prop values ] dip '[ _ (deep-annotate) ] each ;
M: word (deep-annotate)
[ check-annotate-twice ] dip
[ dup def>> 2dup "unannotated-def" set-word-prop ] dip
'[ dup callable? [ _ call( old -- new ) ] when ] deep-map define ;
PRIVATE>
: annotate ( word quot -- )
[ (annotate) ] with-compilation-unit ;
: deep-annotate ( word quot -- )
[ (deep-annotate) ] with-compilation-unit ;
<PRIVATE
:: trace-quot ( word effect quot str -- quot' )