2006-03-25 01:06:52 -05:00
|
|
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2006-09-05 01:29:26 -04:00
|
|
|
IN: tools
|
|
|
|
USING: arrays definitions hashtables help tools io kernel
|
2006-09-16 17:11:55 -04:00
|
|
|
math namespaces prettyprint sequences strings styles words
|
2006-10-06 16:46:35 -04:00
|
|
|
generic completion ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-09-16 17:11:55 -04:00
|
|
|
: word-outliner ( seq -- )
|
|
|
|
natural-sort [
|
|
|
|
[ synopsis ] keep dup [ see ] curry
|
2006-06-14 01:47:28 -04:00
|
|
|
write-outliner terpri
|
2006-09-16 17:11:55 -04:00
|
|
|
] each ;
|
|
|
|
|
|
|
|
: method-usage ( word generic -- methods )
|
|
|
|
tuck methods
|
|
|
|
[ second flatten memq? ] subset-with
|
|
|
|
[ first ] map
|
|
|
|
[ swap 2array ] map-with ;
|
2006-06-26 01:54:25 -04:00
|
|
|
|
|
|
|
: usage. ( word -- )
|
2006-09-16 17:11:55 -04:00
|
|
|
dup usage dup
|
|
|
|
[ generic? not ] subset
|
|
|
|
"Words calling " write pick pprint ":" print
|
|
|
|
word-outliner
|
|
|
|
"Methods calling " write over pprint ":" print
|
|
|
|
[ generic? ] subset
|
|
|
|
[ method-usage word-outliner ] each-with ;
|
2006-06-12 02:41:19 -04:00
|
|
|
|
2006-08-15 16:29:35 -04:00
|
|
|
: annotate ( word quot -- )
|
2005-08-23 15:50:32 -04:00
|
|
|
over >r >r dup word-def r> call r> swap define-compound ;
|
2005-04-01 12:42:14 -05:00
|
|
|
inline
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-03-18 01:57:57 -05:00
|
|
|
: watch-msg ( word prefix -- ) write word-name print .s flush ;
|
2005-09-14 00:37:50 -04:00
|
|
|
|
2005-04-14 19:37:13 -04:00
|
|
|
: (watch) ( word def -- def )
|
2005-08-08 15:21:14 -04:00
|
|
|
[
|
2005-09-14 00:37:50 -04:00
|
|
|
swap literalize
|
|
|
|
dup , "===> Entering: " , \ watch-msg ,
|
|
|
|
swap %
|
|
|
|
, "===> Leaving: " , \ watch-msg ,
|
2005-08-25 15:27:38 -04:00
|
|
|
] [ ] make ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2006-03-25 01:06:52 -05:00
|
|
|
: watch ( word -- ) [ (watch) ] annotate ;
|
2005-03-10 17:57:22 -05:00
|
|
|
|
2005-08-24 21:52:10 -04:00
|
|
|
: profile ( word -- )
|
2006-08-12 16:57:49 -04:00
|
|
|
[
|
|
|
|
swap [ global [ inc ] bind ] curry swap append
|
|
|
|
] annotate ;
|
|
|
|
|
2006-10-06 04:15:34 -04:00
|
|
|
: word-completion. ( pair -- )
|
2006-10-06 16:46:35 -04:00
|
|
|
first2 over summary completion>string swap write-object ;
|
2006-08-12 16:57:49 -04:00
|
|
|
|
2006-10-06 04:15:34 -04:00
|
|
|
: word-completions ( str words -- seq )
|
|
|
|
[ word-name ] swap completions ;
|
2006-08-12 16:57:49 -04:00
|
|
|
|
2006-10-06 04:15:34 -04:00
|
|
|
: apropos ( str -- )
|
2006-10-06 16:46:35 -04:00
|
|
|
all-words word-completions
|
|
|
|
[ word-completion. terpri ] each ;
|