2005-02-08 22:02:44 -05:00
|
|
|
! Copyright (C) 2003, 2005 Slava Pestov.
|
|
|
|
! See http://factor.sf.net/license.txt for BSD license.
|
2004-08-16 19:29:07 -04:00
|
|
|
IN: words
|
2005-02-08 22:02:44 -05:00
|
|
|
USING: files generic inspector lists kernel namespaces
|
2005-05-14 17:18:45 -04:00
|
|
|
prettyprint stdio streams strings sequences unparser math
|
|
|
|
hashtables parser ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-07-19 17:36:20 -04:00
|
|
|
: vocab-apropos ( substring vocab -- list )
|
2004-07-16 02:26:21 -04:00
|
|
|
#! Push a list of all words in a vocabulary whose names
|
|
|
|
#! contain a string.
|
2005-05-18 16:26:22 -04:00
|
|
|
words [ word-name dupd subseq? ] subset nip ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2004-07-19 17:36:20 -04:00
|
|
|
: vocab-apropos. ( substring vocab -- )
|
2004-07-16 02:26:21 -04:00
|
|
|
#! List all words in a vocabulary that contain a string.
|
2004-07-19 17:36:20 -04:00
|
|
|
tuck vocab-apropos dup [
|
2004-07-16 02:26:21 -04:00
|
|
|
"IN: " write swap print [.]
|
|
|
|
] [
|
|
|
|
2drop
|
|
|
|
] ifte ;
|
|
|
|
|
2004-07-19 17:36:20 -04:00
|
|
|
: apropos. ( substring -- )
|
2004-07-16 02:26:21 -04:00
|
|
|
#! List all words that contain a string.
|
2005-01-01 17:20:48 -05:00
|
|
|
vocabs [ vocab-apropos. ] each-with ;
|
2004-07-16 02:26:21 -04:00
|
|
|
|
2005-02-08 22:02:44 -05:00
|
|
|
: word-file ( word -- file )
|
2005-03-05 14:45:23 -05:00
|
|
|
"file" word-prop dup [
|
2005-05-18 16:26:22 -04:00
|
|
|
"resource:/" ?head [
|
2005-02-08 22:02:44 -05:00
|
|
|
resource-path swap path+
|
|
|
|
] when
|
|
|
|
] when ;
|
|
|
|
|
|
|
|
: reload ( word -- )
|
|
|
|
#! Reload the source file the word originated from.
|
2005-02-14 21:58:07 -05:00
|
|
|
word-file run-file ;
|
2005-04-10 18:58:30 -04:00
|
|
|
|
|
|
|
: implementors ( class -- list )
|
|
|
|
#! Find a list of generics that implement a method
|
|
|
|
#! specializing on this class.
|
|
|
|
[
|
|
|
|
"methods" word-prop [ dupd hash ] [ f ] ifte*
|
2005-04-22 00:22:36 -04:00
|
|
|
] word-subset nip ;
|
2005-04-10 18:58:30 -04:00
|
|
|
|
|
|
|
: classes ( -- list )
|
|
|
|
[ metaclass ] word-subset ;
|