1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors assocs checksums checksums.crc32
4 combinators.short-circuit io.encodings.utf8 io.files kernel
5 namespaces sequences sets source-files vocabs vocabs.loader ;
8 : source-modified? ( path -- ? )
9 dup source-files get at [
12 utf8 file-lines crc32 checksum-lines
21 SYMBOL: changed-vocabs
23 : changed-vocab ( vocab-name -- )
24 dup lookup-vocab changed-vocabs get and
25 [ changed-vocabs get adjoin ] [ drop ] if ;
27 : mark-unchanged-vocab ( vocab-name -- )
28 changed-vocabs get delete ;
30 : mark-unchanged-vocabs ( vocab-names -- )
31 [ mark-unchanged-vocab ] each ;
33 : changed-vocab? ( vocab-name -- ? )
34 changed-vocabs get [ in? ] [ drop t ] if* ;
36 : (to-refresh) ( vocab-name loaded? path -- ? )
45 : vocab-source-modified? ( vocab-name -- ? )
47 [ lookup-vocab source-loaded?>> ]
48 [ vocab-source-path ] tri (to-refresh) ;
50 : vocab-docs-modified? ( vocab-name -- ? )
52 [ lookup-vocab docs-loaded?>> ]
53 [ vocab-docs-path ] tri (to-refresh) ;
55 : to-refresh ( prefix -- modified-sources modified-docs unchanged )
56 loaded-child-vocab-names [ ".private" tail? ] reject
58 [ [ vocab-source-modified? ] filter ]
59 [ [ vocab-docs-modified? ] filter ] bi
61 [ 2dup append ] dip swap diff
64 : do-refresh ( modified-sources modified-docs unchanged -- )
67 [ [ lookup-vocab f >>source-loaded? drop ] each ]
68 [ [ lookup-vocab f >>docs-loaded? drop ] each ] bi*
71 [ mark-unchanged-vocabs ]
75 : refresh ( prefix -- ) to-refresh do-refresh ;
77 : refresh-all ( -- ) "" refresh ;