From 023f9ea86a0b15d3588f50601b5cea513311ccd3 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 26 Aug 2011 11:47:37 -0500 Subject: [PATCH] Add a deep-annotate word that annotates each quotation in a word definition. --- basis/tools/annotations/annotations.factor | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/basis/tools/annotations/annotations.factor b/basis/tools/annotations/annotations.factor index 5c9210e44a..c37df58519 100644 --- a/basis/tools/annotations/annotations.factor +++ b/basis/tools/annotations/annotations.factor @@ -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 > 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 ; +