]> gitweb.factorcode.org Git - factor.git/commitdiff
Add a deep-annotate word that annotates each quotation in a word definition.
authorDoug Coleman <doug.coleman@gmail.com>
Fri, 26 Aug 2011 16:47:37 +0000 (11:47 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 26 Aug 2011 16:47:37 +0000 (11:47 -0500)
basis/tools/annotations/annotations.factor

index 5c9210e44a6e39d0d8837a1c6903e0f73fb757b2..c37df58519fc08c9fd54874f8144047333fc006c 100644 (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' )