From 8d4ba7e2b61c4013180e47ddc8c2fb43365e5577 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 26 Aug 2011 17:11:50 -0500 Subject: [PATCH] Clean up some duplication in annotate/deep-annotate --- basis/tools/annotations/annotations.factor | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/basis/tools/annotations/annotations.factor b/basis/tools/annotations/annotations.factor index c37df58519..c5c810fe04 100644 --- a/basis/tools/annotations/annotations.factor +++ b/basis/tools/annotations/annotations.factor @@ -36,24 +36,29 @@ M: cannot-annotate-twice summary drop "Cannot annotate a word twice" ; cannot-annotate-twice ] when ; +: annotate-generic ( word quot -- ) + [ "methods" word-prop values ] dip each ; inline + +: prepare-annotate ( word quot -- word quot quot ) + [ check-annotate-twice ] dip + [ dup def>> 2dup "unannotated-def" set-word-prop ] dip ; + GENERIC# (annotate) 1 ( word quot -- ) M: generic (annotate) - [ "methods" word-prop values ] dip '[ _ (annotate) ] each ; + '[ _ (annotate) ] annotate-generic ; M: word (annotate) - [ check-annotate-twice ] dip - [ dup def>> 2dup "unannotated-def" set-word-prop ] dip + prepare-annotate call( old -- new ) define ; GENERIC# (deep-annotate) 1 ( word quot -- ) M: generic (deep-annotate) - [ "methods" word-prop values ] dip '[ _ (deep-annotate) ] each ; + '[ _ (deep-annotate) ] annotate-generic ; M: word (deep-annotate) - [ check-annotate-twice ] dip - [ dup def>> 2dup "unannotated-def" set-word-prop ] dip + prepare-annotate '[ dup callable? [ _ call( old -- new ) ] when ] deep-map define ; PRIVATE>