"tools.test"
"tools.time"
"tools.threads"
- "tools.vocabs"
- "tools.vocabs.monitor"
+ "vocabs.hierarchy"
+ "vocabs.refresh"
+ "vocabs.refresh.monitor"
"editors"
} [ require ] each
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: parser lexer kernel namespaces sequences definitions io.files
-io.backend io.pathnames io summary continuations tools.crossref
-tools.vocabs prettyprint source-files source-files.errors assocs
-vocabs vocabs.loader splitting accessors debugger prettyprint
-help.topics ;
+USING: parser lexer kernel namespaces sequences definitions
+io.files io.backend io.pathnames io summary continuations
+tools.crossref vocabs.hierarchy prettyprint source-files
+source-files.errors assocs vocabs vocabs.loader splitting
+accessors debugger prettyprint help.topics ;
IN: editors
TUPLE: no-edit-hook ;
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs fry help.markup help.topics io
kernel make math math.parser namespaces sequences sorting
-summary tools.completion tools.vocabs help.vocabs
+summary tools.completion vocabs.hierarchy help.vocabs
vocabs words unicode.case help ;
IN: help.apropos
{ $heading "Workflow" }
{ $subsection "listener" }
{ $subsection "editor" }
-{ $subsection "tools.vocabs" }
+{ $subsection "vocabs.refresh" }
{ $subsection "tools.test" }
{ $subsection "help" }
{ $heading "Debugging" }
{ $heading "Browsing" }
{ $subsection "see" }
{ $subsection "tools.crossref" }
+{ $subsection "vocabs.hierarchy" }
{ $heading "Performance" }
{ $subsection "timing" }
{ $subsection "profiling" }
USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary
io.files io.files.temp io.directories html.streams help kernel
assocs sequences make words accessors arrays help.topics vocabs
-tools.vocabs help.vocabs namespaces prettyprint io
+vocabs.hierarchy help.vocabs namespaces prettyprint io
vocabs.loader serialize fry memoize ascii unicode.case math.order
sorting debugger html xml.syntax xml.writer math.parser ;
IN: help.html
! See http://factorcode.org/license.txt for BSD license.
USING: assocs continuations fry help help.lint.checks
help.topics io kernel namespaces parser sequences
-source-files.errors tools.vocabs vocabs words classes
+source-files.errors vocabs.hierarchy vocabs words classes
locals tools.errors ;
FROM: help.lint.checks => all-vocabs ;
IN: help.lint
USING: help.markup help.syntax ui.commands ui.operations
editors vocabs.loader kernel sequences prettyprint tools.test
-tools.vocabs strings unicode.categories unicode.case
+vocabs.refresh strings unicode.categories unicode.case
ui.tools.browser ui.tools.common ;
IN: help.tutorial
definitions effects fry generic help help.markup help.stylesheet
help.topics io io.files io.pathnames io.styles kernel macros
make namespaces prettyprint sequences sets sorting summary
-tools.vocabs vocabs vocabs.loader words words.symbol definitions.icons ;
+vocabs vocabs.files vocabs.hierarchy vocabs.loader
+vocabs.metadata words words.symbol definitions.icons ;
IN: help.vocabs
: about ( vocab -- )
-USING: help.markup help.syntax io.streams.string quotations strings urls http tools.vocabs math io.servers.connection ;
+USING: help.markup help.syntax io.streams.string quotations strings urls http vocabs.refresh math io.servers.connection ;
IN: http.server
HELP: trivial-responder
-! Copyright (C) 2003, 2008 Slava Pestov.
+! Copyright (C) 2003, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors sequences arrays namespaces splitting
vocabs.loader destructors assocs debugger continuations
-combinators tools.vocabs tools.time math math.parser present
+combinators vocabs.refresh tools.time math math.parser present
io vectors
io.sockets
io.sockets.secure
IN: present.tests
-USING: tools.test present math vocabs tools.vocabs sequences kernel ;
+USING: tools.test present math vocabs sequences kernel ;
[ "3" ] [ 3 present ] unit-test
[ "Hi" ] [ "Hi" present ] unit-test
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel arrays sequences math namespaces
-strings io fry vectors words assocs combinators sorting
-unicode.case unicode.categories math.order vocabs
-tools.vocabs unicode.data locals ;
+USING: accessors kernel arrays sequences math namespaces strings io
+fry vectors words assocs combinators sorting unicode.case
+unicode.categories math.order vocabs vocabs.hierarchy unicode.data
+locals ;
IN: tools.completion
:: (fuzzy) ( accum i full ch -- accum i full ? )
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs io.pathnames kernel parser prettyprint sequences
-splitting tools.deploy.config tools.vocabs vocabs.loader ;
+splitting tools.deploy.config vocabs.loader vocabs.metadata ;
IN: tools.deploy.config.editor
: deploy-config-path ( vocab -- string )
] when
strip-dictionary? [
"compiler.units" init-hooks get delete-at
- "tools.vocabs" init-hooks get delete-at
+ "vocabs.cache" init-hooks get delete-at
] when ;
: strip-debugger ( -- )
continuations debugger effects fry generalizations io io.files
io.styles kernel lexer locals macros math.parser namespaces
parser prettyprint quotations sequences source-files splitting
-stack-checker summary unicode.case vectors vocabs vocabs.loader words
-tools.vocabs tools.errors source-files.errors io.streams.string make
-compiler.errors ;
+stack-checker summary unicode.case vectors vocabs vocabs.loader
+vocabs.files words tools.errors source-files.errors
+io.streams.string make compiler.errors ;
IN: tools.test
TUPLE: test-failure < source-file-error continuation ;
+++ /dev/null
-Slava Pestov
+++ /dev/null
-USING: tools.test tools.vocabs.monitor io.pathnames ;
-IN: tools.vocabs.monitor.tests
-
-[ "kernel" ] [ "core/kernel/kernel.factor" path>vocab ] unit-test
-[ "kernel" ] [ "core/kernel/" path>vocab ] unit-test
-[ "kernel" ] [ "core/kernel/" resource-path path>vocab ] unit-test
+++ /dev/null
-! Copyright (C) 2008, 2009 Slava Pestov.\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: threads io.files io.pathnames io.monitors init kernel\r
-vocabs vocabs.loader tools.vocabs namespaces continuations\r
-sequences splitting assocs command-line concurrency.messaging\r
-io.backend sets tr accessors ;\r
-IN: tools.vocabs.monitor\r
-\r
-TR: convert-separators "/\\" ".." ;\r
-\r
-: vocab-dir>vocab-name ( path -- vocab )\r
- trim-head-separators\r
- trim-tail-separators\r
- convert-separators ;\r
-\r
-: path>vocab-name ( path -- vocab )\r
- dup ".factor" tail? [ parent-directory ] when ;\r
-\r
-: chop-vocab-root ( path -- path' )\r
- "resource:" prepend-path normalize-path\r
- dup vocab-roots get\r
- [ normalize-path ] map\r
- [ head? ] with find nip\r
- ?head drop ;\r
-\r
-: path>vocab ( path -- vocab )\r
- chop-vocab-root path>vocab-name vocab-dir>vocab-name ;\r
-\r
-: monitor-loop ( -- )\r
- #! On OS X, monitors give us the full path, so we chop it\r
- #! off if its there.\r
- receive path>> path>vocab changed-vocab\r
- reset-cache\r
- monitor-loop ;\r
-\r
-: add-monitor-for-path ( path -- )\r
- dup exists? [ t my-mailbox (monitor) ] when drop ;\r
-\r
-: monitor-thread ( -- )\r
- [\r
- [\r
- vocab-roots get prune [ add-monitor-for-path ] each\r
-\r
- H{ } clone changed-vocabs set-global\r
- vocabs [ changed-vocab ] each\r
-\r
- monitor-loop\r
- ] with-monitors\r
- ] ignore-errors ;\r
-\r
-: start-monitor-thread ( -- )\r
- #! Silently ignore errors during monitor creation since\r
- #! monitors are not supported on all platforms.\r
- [ monitor-thread ] "Vocabulary monitor" spawn drop ;\r
-\r
-[\r
- "-no-monitors" (command-line) member?\r
- [ start-monitor-thread ] unless\r
-] "tools.vocabs.monitor" add-init-hook\r
+++ /dev/null
-Use io.monitors to clear tools.browser authors/tags/summary cache
+++ /dev/null
-Reloading vocabularies and cross-referencing vocabularies
+++ /dev/null
-USING: help.markup help.syntax strings ;\r
-IN: tools.vocabs\r
-\r
-ARTICLE: "tools.vocabs" "Vocabulary tools"\r
-"Reloading source files changed on disk:"\r
-{ $subsection refresh }\r
-{ $subsection refresh-all }\r
-"Vocabulary summaries:"\r
-{ $subsection vocab-summary }\r
-{ $subsection set-vocab-summary }\r
-"Vocabulary tags:"\r
-{ $subsection vocab-tags }\r
-{ $subsection set-vocab-tags }\r
-{ $subsection add-vocab-tags }\r
-"Getting and setting vocabulary meta-data:"\r
-{ $subsection vocab-file-contents }\r
-{ $subsection set-vocab-file-contents }\r
-"Global meta-data:"\r
-{ $subsection all-vocabs }\r
-{ $subsection all-vocabs-seq }\r
-{ $subsection all-tags }\r
-{ $subsection all-authors }\r
-"Because loading the above data is expensive, it is cached. The cache is flushed by the " { $vocab-link "tools.vocabs.monitor" } " vocabulary. It can also be flushed manually when file system change monitors are not available:"\r
-{ $subsection reset-cache } ;\r
-\r
-ABOUT: "tools.vocabs"\r
-\r
-HELP: vocab-files\r
-{ $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of pathname strings" } }\r
-{ $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." } ;\r
-\r
-HELP: vocab-tests\r
-{ $values { "vocab" "a vocabulary specifier" } { "tests" "a sequence of pathname strings" } }\r
-{ $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." } ;\r
-\r
-HELP: source-modified?\r
-{ $values { "path" "a pathname string" } { "?" "a boolean" } }\r
-{ $description "Tests if the source file has been modified since it was last loaded. This compares the file's CRC32 checksum of the file's contents against the previously-recorded value." } ;\r
-\r
-HELP: refresh\r
-{ $values { "prefix" string } }\r
-{ $description "Reloads source files and documentation belonging to loaded vocabularies whose names are prefixed by " { $snippet "prefix" } " which have been modified on disk." } ;\r
-\r
-HELP: refresh-all\r
-{ $description "Reloads source files and documentation for all loaded vocabularies which have been modified on disk." } ;\r
-\r
-{ refresh refresh-all } related-words\r
-\r
-HELP: vocab-file-contents\r
-{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "seq" "a sequence of lines, or " { $link f } } }\r
-{ $description "Outputs the contents of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ;\r
-\r
-HELP: set-vocab-file-contents\r
-{ $values { "seq" "a sequence of lines" } { "vocab" "a vocabulary specifier" } { "name" string } }\r
-{ $description "Stores a sequence of lines to the file named " { $snippet "name" } " from the vocabulary's directory." } ;\r
-\r
-HELP: vocab-summary\r
-{ $values { "vocab" "a vocabulary specifier" } { "summary" "a string or " { $link f } } }\r
-{ $description "Outputs a one-line string description of the vocabulary's intended purpose from the " { $snippet "summary.txt" } " file in the vocabulary's directory. Outputs " { $link f } " if the file does not exist." } ;\r
-\r
-HELP: set-vocab-summary\r
-{ $values { "string" "a string or " { $link f } } { "vocab" "a vocabulary specifier" } }\r
-{ $description "Stores a one-line string description of the vocabulary to the " { $snippet "summary.txt" } " file in the vocabulary's directory." } ;\r
-\r
-HELP: vocab-tags\r
-{ $values { "vocab" "a vocabulary specifier" } { "tags" "a sequence of strings" } }\r
-{ $description "Outputs a list of short tags classifying the vocabulary from the " { $snippet "tags.txt" } " file in the vocabulary's directory. Outputs " { $link f } " if the file does not exist." } ;\r
-\r
-HELP: set-vocab-tags\r
-{ $values { "tags" "a sequence of strings" } { "vocab" "a vocabulary specifier" } }\r
-{ $description "Stores a list of short tags classifying the vocabulary to the " { $snippet "tags.txt" } " file in the vocabulary's directory." } ;\r
-\r
-HELP: all-vocabs\r
-{ $values { "assoc" "an association list mapping vocabulary roots to sequences of vocabulary specifiers" } }\r
-{ $description "Outputs an association list of all vocabularies which have been loaded or are available for loading." } ;\r
-\r
-HELP: load-all-under\r
-{ $values { "prefix" string } }\r
-{ $description "Load all vocabularies that match the provided prefix." } ;\r
-\r
-HELP: all-vocabs-under\r
-{ $values { "prefix" string } }\r
-{ $description "Return a sequence of vocab or vocab-links for each vocab matching the provided prefix. Unlike " { $link all-child-vocabs } " this word will return both loaded and unloaded vocabularies." } ;\r
+++ /dev/null
-IN: tools.vocabs.tests
-USING: continuations namespaces tools.test tools.vocabs tools.vocabs.private ;
-
-[ ] [
- changed-vocabs get-global
- f changed-vocabs set-global
- [ t ] [ "kernel" changed-vocab? ] unit-test
- [ "kernel" changed-vocab ] [ changed-vocabs set-global ] [ ] cleanup
-] unit-test
-
-[ t ] [ "some-vocab" valid-vocab-dirname ] unit-test
-[ f ] [ ".git" valid-vocab-dirname ] unit-test
+++ /dev/null
-! Copyright (C) 2007, 2008 Slava Pestov.\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel io io.styles io.files io.files.info io.directories\r
-io.pathnames io.encodings.utf8 vocabs.loader vocabs sequences\r
-namespaces make math.parser arrays hashtables assocs memoize\r
-summary sorting splitting combinators source-files debugger\r
-continuations compiler.errors init checksums checksums.crc32\r
-sets accessors generic definitions words ;\r
-IN: tools.vocabs\r
-\r
-: vocab-tests-file ( vocab -- path )\r
- dup "-tests.factor" vocab-dir+ vocab-append-path dup\r
- [ dup exists? [ drop f ] unless ] [ drop f ] if ;\r
-\r
-: vocab-tests-dir ( vocab -- paths )\r
- dup vocab-dir "tests" append-path vocab-append-path dup [\r
- dup exists? [\r
- dup directory-files [ ".factor" tail? ] filter\r
- [ append-path ] with map\r
- ] [ drop f ] if\r
- ] [ drop f ] if ;\r
-\r
-: vocab-tests ( vocab -- tests )\r
- [\r
- [ vocab-tests-file [ , ] when* ]\r
- [ vocab-tests-dir [ % ] when* ] bi\r
- ] { } make ;\r
-\r
-: vocab-files ( vocab -- seq )\r
- [\r
- [ vocab-source-path [ , ] when* ]\r
- [ vocab-docs-path [ , ] when* ]\r
- [ vocab-tests % ] tri\r
- ] { } make ;\r
-\r
-: vocab-heading. ( vocab -- )\r
- nl\r
- "==== " write\r
- [ vocab-name ] [ vocab write-object ] bi ":" print\r
- nl ;\r
-\r
-: load-error. ( triple -- )\r
- [ first vocab-heading. ] [ second print-error ] bi ;\r
-\r
-: load-failures. ( failures -- )\r
- [ load-error. nl ] each ;\r
-\r
-SYMBOL: failures\r
-\r
-: require-all ( vocabs -- failures )\r
- [\r
- V{ } clone blacklist set\r
- V{ } clone failures set\r
- [\r
- [ require ]\r
- [ swap vocab-name failures get set-at ]\r
- recover\r
- ] each\r
- failures get\r
- ] with-scope ;\r
-\r
-: source-modified? ( path -- ? )\r
- dup source-files get at [\r
- dup path>>\r
- dup exists? [\r
- utf8 file-lines crc32 checksum-lines\r
- swap checksum>> = not\r
- ] [\r
- 2drop f\r
- ] if\r
- ] [\r
- exists?\r
- ] ?if ;\r
-\r
-SYMBOL: changed-vocabs\r
-\r
-: changed-vocab ( vocab -- )\r
- dup vocab changed-vocabs get and\r
- [ dup changed-vocabs get set-at ] [ drop ] if ;\r
-\r
-: unchanged-vocab ( vocab -- )\r
- changed-vocabs get delete-at ;\r
-\r
-: unchanged-vocabs ( vocabs -- )\r
- [ unchanged-vocab ] each ;\r
-\r
-: changed-vocab? ( vocab -- ? )\r
- changed-vocabs get dup [ key? ] [ 2drop t ] if ;\r
-\r
-: filter-changed ( vocabs -- vocabs' )\r
- [ changed-vocab? ] filter ;\r
-\r
-SYMBOL: modified-sources\r
-SYMBOL: modified-docs\r
-\r
-: (to-refresh) ( vocab variable loaded? path -- )\r
- dup [\r
- swap [\r
- pick changed-vocab? [\r
- source-modified? [ get push ] [ 2drop ] if\r
- ] [ 3drop ] if\r
- ] [ drop get push ] if\r
- ] [ 2drop 2drop ] if ;\r
-\r
-: to-refresh ( prefix -- modified-sources modified-docs unchanged )\r
- [\r
- V{ } clone modified-sources set\r
- V{ } clone modified-docs set\r
-\r
- child-vocabs [\r
- [\r
- [\r
- [ modified-sources ]\r
- [ vocab source-loaded?>> ]\r
- [ vocab-source-path ]\r
- tri (to-refresh)\r
- ] [\r
- [ modified-docs ]\r
- [ vocab docs-loaded?>> ]\r
- [ vocab-docs-path ]\r
- tri (to-refresh)\r
- ] bi\r
- ] each\r
-\r
- modified-sources get\r
- modified-docs get\r
- ]\r
- [ modified-docs get modified-sources get append diff ] bi\r
- ] with-scope ;\r
-\r
-: do-refresh ( modified-sources modified-docs unchanged -- )\r
- unchanged-vocabs\r
- [\r
- [ [ vocab f >>source-loaded? drop ] each ]\r
- [ [ vocab f >>docs-loaded? drop ] each ] bi*\r
- ]\r
- [\r
- append prune\r
- [ unchanged-vocabs ]\r
- [ require-all load-failures. ] bi\r
- ] 2bi ;\r
-\r
-: refresh ( prefix -- ) to-refresh do-refresh ;\r
-\r
-: refresh-all ( -- ) "" refresh ;\r
-\r
-MEMO: vocab-file-contents ( vocab name -- seq )\r
- vocab-append-path dup\r
- [ dup exists? [ utf8 file-lines ] [ drop f ] if ] when ;\r
-\r
-: set-vocab-file-contents ( seq vocab name -- )\r
- dupd vocab-append-path [\r
- utf8 set-file-lines\r
- \ vocab-file-contents reset-memoized\r
- ] [\r
- "The " swap vocab-name\r
- " vocabulary was not loaded from the file system"\r
- 3append throw\r
- ] ?if ;\r
-\r
-: vocab-summary-path ( vocab -- string )\r
- vocab-dir "summary.txt" append-path ;\r
-\r
-: vocab-summary ( vocab -- summary )\r
- dup dup vocab-summary-path vocab-file-contents\r
- [\r
- vocab-name " vocabulary" append\r
- ] [\r
- nip first\r
- ] if-empty ;\r
-\r
-M: vocab summary\r
- [\r
- dup vocab-summary %\r
- " (" %\r
- words>> assoc-size #\r
- " words)" %\r
- ] "" make ;\r
-\r
-M: vocab-link summary vocab-summary ;\r
-\r
-: set-vocab-summary ( string vocab -- )\r
- [ 1array ] dip\r
- dup vocab-summary-path\r
- set-vocab-file-contents ;\r
-\r
-: vocab-tags-path ( vocab -- string )\r
- vocab-dir "tags.txt" append-path ;\r
-\r
-: vocab-tags ( vocab -- tags )\r
- dup vocab-tags-path vocab-file-contents harvest ;\r
-\r
-: set-vocab-tags ( tags vocab -- )\r
- dup vocab-tags-path set-vocab-file-contents ;\r
-\r
-: add-vocab-tags ( tags vocab -- )\r
- [ vocab-tags append prune ] keep set-vocab-tags ;\r
-\r
-: vocab-authors-path ( vocab -- string )\r
- vocab-dir "authors.txt" append-path ;\r
-\r
-: vocab-authors ( vocab -- authors )\r
- dup vocab-authors-path vocab-file-contents harvest ;\r
-\r
-: set-vocab-authors ( authors vocab -- )\r
- dup vocab-authors-path set-vocab-file-contents ;\r
-\r
-\r
-<PRIVATE\r
-: valid-vocab-dirname ( dirname -- ? )\r
- dup empty? [ drop f ] [ first CHAR: . = not ] if ;\r
-PRIVATE>\r
-\r
-: vocab-subdirs ( dir -- dirs )\r
- [\r
- [ [ link-info directory? ] [ valid-vocab-dirname ] bi and ] filter\r
- ] with-directory-files natural-sort ;\r
-\r
-: (all-child-vocabs) ( root name -- vocabs )\r
- [\r
- vocab-dir append-path dup exists?\r
- [ vocab-subdirs ] [ drop { } ] if\r
- ] keep [\r
- swap [ "." glue ] with map\r
- ] unless-empty ;\r
-\r
-: vocab-dir? ( root name -- ? )\r
- over\r
- [ ".factor" vocab-dir+ append-path exists? ]\r
- [ 2drop f ]\r
- if ;\r
-\r
-: vocabs-in-dir ( root name -- )\r
- dupd (all-child-vocabs) [\r
- 2dup vocab-dir? [ dup >vocab-link , ] when\r
- vocabs-in-dir\r
- ] with each ;\r
-\r
-: all-vocabs ( -- assoc )\r
- vocab-roots get [\r
- dup [ "" vocabs-in-dir ] { } make\r
- ] { } map>assoc ;\r
-\r
-: all-vocabs-under ( prefix -- vocabs )\r
- [\r
- vocab-roots get [ over vocabs-in-dir ] each drop\r
- ] { } make ;\r
-\r
-MEMO: all-vocabs-seq ( -- seq )\r
- all-vocabs values concat ;\r
-\r
-: unportable? ( name -- ? )\r
- vocab-tags "unportable" swap member? ;\r
-\r
-: filter-unportable ( seq -- seq' )\r
- [ vocab-name unportable? not ] filter ;\r
-\r
-: try-everything ( -- failures )\r
- all-vocabs-seq\r
- filter-unportable\r
- require-all ;\r
-\r
-: load-everything ( -- )\r
- try-everything load-failures. ;\r
-\r
-: load-all-under ( prefix -- )\r
- all-vocabs-under filter-unportable require-all load-failures. ;\r
-\r
-: unrooted-child-vocabs ( prefix -- seq )\r
- dup empty? [ CHAR: . suffix ] unless\r
- vocabs\r
- [ find-vocab-root not ] filter\r
- [\r
- vocab-name swap ?head CHAR: . rot member? not and\r
- ] with filter\r
- [ vocab ] map ;\r
-\r
-: all-child-vocabs ( prefix -- assoc )\r
- vocab-roots get [\r
- dup pick (all-child-vocabs) [ >vocab-link ] map\r
- ] { } map>assoc\r
- swap unrooted-child-vocabs f swap 2array suffix ;\r
-\r
-: all-child-vocabs-seq ( prefix -- assoc )\r
- vocab-roots get swap [\r
- dupd (all-child-vocabs)\r
- [ vocab-dir? ] with filter\r
- ] curry map concat ;\r
-\r
-MEMO: all-tags ( -- seq )\r
- all-vocabs-seq [ vocab-tags ] gather natural-sort ;\r
-\r
-MEMO: all-authors ( -- seq )\r
- all-vocabs-seq [ vocab-authors ] gather natural-sort ;\r
-\r
-: reset-cache ( -- )\r
- root-cache get-global clear-assoc\r
- \ vocab-file-contents reset-memoized\r
- \ all-vocabs-seq reset-memoized\r
- \ all-authors reset-memoized\r
- \ all-tags reset-memoized ;\r
-\r
-SINGLETON: cache-observer\r
-\r
-M: cache-observer vocabs-changed drop reset-cache ;\r
-\r
-[\r
- f changed-vocabs set-global\r
- cache-observer add-vocab-observer\r
-] "tools.vocabs" add-init-hook
\ No newline at end of file
cocoa.classes cocoa.dialogs cocoa.pasteboard cocoa.subclassing
core-foundation core-foundation.strings help.topics kernel
memory namespaces parser system ui ui.tools.browser
-ui.tools.listener ui.backend.cocoa eval locals tools.vocabs ;
+ui.tools.listener ui.backend.cocoa eval locals
+vocabs.refresh ;
IN: ui.backend.cocoa.tools
: finder-run-files ( alien -- )
USING: help.markup help.syntax ui.commands ui.operations
ui.gadgets.editors ui.gadgets.panes listener io words
ui.tools.listener.completion ui.tools.common help.tips
-tools.vocabs vocabs ;
+vocabs vocabs.refresh ;
IN: ui.tools.listener
HELP: interactor
continuations destructors documents documents.elements fry hashtables
help help.markup io io.styles kernel lexer listener math models sets
models.delay models.arrow namespaces parser prettyprint quotations
-sequences strings threads tools.vocabs vocabs vocabs.loader
+sequences strings threads vocabs vocabs.refresh vocabs.loader
vocabs.parser words debugger ui ui.commands ui.pens.solid ui.gadgets
ui.gadgets.glass ui.gadgets.buttons ui.gadgets.editors
ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers
ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.borders ui.gestures
ui.operations ui.tools.browser ui.tools.common ui.tools.debugger
ui.tools.listener.completion ui.tools.listener.popups
-ui.tools.listener.history ui.images ui.tools.error-list tools.errors.model ;
+ui.tools.listener.history ui.images ui.tools.error-list
+tools.errors.model ;
FROM: source-files.errors => all-errors ;
IN: ui.tools.listener
stack-checker summary io.pathnames io.styles kernel namespaces parser
prettyprint quotations tools.crossref tools.annotations editors
tools.profiler tools.test tools.time tools.walker vocabs vocabs.loader
-words sequences tools.vocabs classes compiler.errors compiler.units
+words sequences classes compiler.errors compiler.units
accessors vocabs.parser macros.expander ui ui.tools.browser
ui.tools.listener ui.tools.listener.completion ui.tools.profiler
ui.tools.inspector ui.tools.traceback ui.commands ui.gadgets.editors
! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: memory system kernel tools.vocabs ui.tools.operations
+USING: memory system kernel vocabs.refresh ui.tools.operations
ui.tools.listener ui.tools.browser ui.tools.common ui.tools.error-list
ui.tools.walker ui.commands ui.gestures ui ui.private ;
IN: ui.tools
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs kernel namespaces memoize init vocabs
+vocabs.hierarchy vocabs.loader vocabs.metadata vocabs.refresh ;
+IN: vocabs.cache
+
+: reset-cache ( -- )
+ root-cache get-global clear-assoc
+ \ vocab-file-contents reset-memoized
+ \ all-vocabs-seq reset-memoized
+ \ all-authors reset-memoized
+ \ all-tags reset-memoized ;
+
+SINGLETON: cache-observer
+
+M: cache-observer vocabs-changed drop reset-cache ;
+
+[
+ f changed-vocabs set-global
+ cache-observer add-vocab-observer
+] "vocabs.cache" add-init-hook
\ No newline at end of file
--- /dev/null
+Caching vocabulary data from disk
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs continuations debugger io io.styles kernel
+namespaces sequences vocabs vocabs.loader ;
+IN: vocabs.errors
+
+<PRIVATE
+
+: vocab-heading. ( vocab -- )
+ nl
+ "==== " write
+ [ vocab-name ] [ vocab write-object ] bi ":" print
+ nl ;
+
+: load-error. ( triple -- )
+ [ first vocab-heading. ] [ second print-error ] bi ;
+
+SYMBOL: failures
+
+PRIVATE>
+
+: load-failures. ( failures -- )
+ [ load-error. nl ] each ;
+
+: require-all ( vocabs -- failures )
+ [
+ V{ } clone blacklist set
+ V{ } clone failures set
+ [
+ [ require ]
+ [ swap vocab-name failures get set-at ]
+ recover
+ ] each
+ failures get
+ ] with-scope ;
\ No newline at end of file
--- /dev/null
+Loading vocabularies and batching errors
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+USING: help.markup help.syntax strings ;
+IN: vocabs.files
+
+HELP: vocab-files
+{ $values { "vocab" "a vocabulary specifier" } { "seq" "a sequence of pathname strings" } }
+{ $description "Outputs a sequence of files comprising this vocabulary, or " { $link f } " if the vocabulary does not have a directory on disk." } ;
+
+HELP: vocab-tests
+{ $values { "vocab" "a vocabulary specifier" } { "tests" "a sequence of pathname strings" } }
+{ $description "Outputs a sequence of pathnames where the unit tests for " { $snippet "vocab" } " are located." } ;
+
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.directories io.files io.pathnames kernel make
+sequences vocabs.loader ;
+IN: vocabs.files
+
+<PRIVATE
+
+: vocab-tests-file ( vocab -- path )
+ dup "-tests.factor" vocab-dir+ vocab-append-path dup
+ [ dup exists? [ drop f ] unless ] [ drop f ] if ;
+
+: vocab-tests-dir ( vocab -- paths )
+ dup vocab-dir "tests" append-path vocab-append-path dup [
+ dup exists? [
+ dup directory-files [ ".factor" tail? ] filter
+ [ append-path ] with map
+ ] [ drop f ] if
+ ] [ drop f ] if ;
+
+PRIVATE>
+
+: vocab-tests ( vocab -- tests )
+ [
+ [ vocab-tests-file [ , ] when* ]
+ [ vocab-tests-dir [ % ] when* ] bi
+ ] { } make ;
+
+: vocab-files ( vocab -- seq )
+ [
+ [ vocab-source-path [ , ] when* ]
+ [ vocab-docs-path [ , ] when* ]
+ [ vocab-tests % ] tri
+ ] { } make ;
\ No newline at end of file
--- /dev/null
+Getting a list of files in a vocabulary
--- /dev/null
+USING: help.markup help.syntax strings vocabs.loader ;\r
+IN: vocabs.hierarchy\r
+\r
+ARTICLE: "vocabs.hierarchy" "Vocabulary hierarchy tools"\r
+"These tools operate on all vocabularies found in the current set of " { $link vocab-roots } ", loaded or not."\r
+$nl\r
+"Loading vocabulary hierarchies:"\r
+{ $subsection load }\r
+{ $subsection load-all }\r
+"Getting all vocabularies on disk:"\r
+{ $subsection all-vocabs }\r
+{ $subsection all-vocabs-seq }\r
+"Getting " { $link "vocabs.metadata" } " for all vocabularies on disk:"\r
+{ $subsection all-tags }\r
+{ $subsection all-authors } ;\r
+\r
+ABOUT: "vocabs.hierarchy"\r
+\r
+HELP: all-vocabs\r
+{ $values { "assoc" "an association list mapping vocabulary roots to sequences of vocabulary specifiers" } }\r
+{ $description "Outputs an association list of all vocabularies which have been loaded or are available for loading." } ;\r
+\r
+HELP: load\r
+{ $values { "prefix" string } }\r
+{ $description "Load all vocabularies that match the provided prefix." }\r
+{ $notes "This word differs from " { $link require } " in that it loads all subvocabularies, not just the given one." } ;\r
+\r
+HELP: load-all\r
+{ $description "Load all vocabularies in the source tree." } ;\r
+\r
+HELP: all-vocabs-under\r
+{ $values { "prefix" string } }\r
+{ $description "Return a sequence of vocab or vocab-links for each vocab matching the provided prefix. Unlike " { $link all-child-vocabs } " this word will return both loaded and unloaded vocabularies." } ;\r
--- /dev/null
+IN: vocabs.hierarchy.tests
+USING: continuations namespaces tools.test vocabs.hierarchy vocabs.hierarchy.private ;
+
+[ ] [
+ changed-vocabs get-global
+ f changed-vocabs set-global
+ [ t ] [ "kernel" changed-vocab? ] unit-test
+ [ "kernel" changed-vocab ] [ changed-vocabs set-global ] [ ] cleanup
+] unit-test
+
+[ t ] [ "some-vocab" valid-vocab-dirname ] unit-test
+[ f ] [ ".git" valid-vocab-dirname ] unit-test
--- /dev/null
+! Copyright (C) 2007, 2009 Slava Pestov.\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: arrays assocs combinators.short-circuit fry\r
+io.directories io.files io.files.info io.pathnames kernel make\r
+memoize namespaces sequences sorting splitting vocabs sets\r
+vocabs.loader vocabs.metadata vocabs.errors ;\r
+IN: vocabs.hierarchy\r
+\r
+<PRIVATE\r
+\r
+: vocab-subdirs ( dir -- dirs )\r
+ [\r
+ [\r
+ { [ link-info directory? ] [ "." head? not ] } 1&&\r
+ ] filter\r
+ ] with-directory-files natural-sort ;\r
+\r
+: (all-child-vocabs) ( root name -- vocabs )\r
+ [\r
+ vocab-dir append-path dup exists?\r
+ [ vocab-subdirs ] [ drop { } ] if\r
+ ] keep\r
+ [ '[ [ _ "." ] dip 3append ] map ] unless-empty ;\r
+\r
+: vocab-dir? ( root name -- ? )\r
+ over\r
+ [ ".factor" vocab-dir+ append-path exists? ]\r
+ [ 2drop f ]\r
+ if ;\r
+\r
+: vocabs-in-dir ( root name -- )\r
+ dupd (all-child-vocabs) [\r
+ 2dup vocab-dir? [ dup >vocab-link , ] when\r
+ vocabs-in-dir\r
+ ] with each ;\r
+\r
+PRIVATE>\r
+\r
+: all-vocabs ( -- assoc )\r
+ vocab-roots get [\r
+ dup [ "" vocabs-in-dir ] { } make\r
+ ] { } map>assoc ;\r
+\r
+: all-vocabs-under ( prefix -- vocabs )\r
+ [\r
+ [ vocab-roots get ] dip '[ _ vocabs-in-dir ] each\r
+ ] { } make ;\r
+\r
+MEMO: all-vocabs-seq ( -- seq )\r
+ "" all-vocabs-under ;\r
+\r
+<PRIVATE\r
+\r
+: unrooted-child-vocabs ( prefix -- seq )\r
+ dup empty? [ CHAR: . suffix ] unless\r
+ vocabs\r
+ [ find-vocab-root not ] filter\r
+ [\r
+ vocab-name swap ?head CHAR: . rot member? not and\r
+ ] with filter\r
+ [ vocab ] map ;\r
+\r
+PRIVATE>\r
+\r
+: all-child-vocabs ( prefix -- assoc )\r
+ vocab-roots get [\r
+ dup pick (all-child-vocabs) [ >vocab-link ] map\r
+ ] { } map>assoc\r
+ swap unrooted-child-vocabs f swap 2array suffix ;\r
+\r
+: all-child-vocabs-seq ( prefix -- assoc )\r
+ vocab-roots get swap '[\r
+ dup _ (all-child-vocabs)\r
+ [ vocab-dir? ] with filter\r
+ ] map concat ;\r
+\r
+<PRIVATE\r
+\r
+: filter-unportable ( seq -- seq' )\r
+ [ vocab-name unportable? not ] filter ;\r
+\r
+PRIVATE>\r
+\r
+: (load) ( prefix -- failures )\r
+ all-vocabs-under\r
+ filter-unportable\r
+ require-all ;\r
+\r
+: load ( prefix -- )\r
+ (load) load-failures. ;\r
+\r
+: load-all ( -- )\r
+ "" load ;\r
+\r
+MEMO: all-tags ( -- seq )\r
+ all-vocabs-seq [ vocab-tags ] gather natural-sort ;\r
+\r
+MEMO: all-authors ( -- seq )\r
+ all-vocabs-seq [ vocab-authors ] gather natural-sort ;
\ No newline at end of file
--- /dev/null
+Searching for vocabularies on disk
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+USING: help.markup help.syntax strings ;
+IN: vocabs.metadata
+
+ARTICLE: "vocabs.metadata" "Vocabulary metadata"
+"Vocabulary summaries:"
+{ $subsection vocab-summary }
+{ $subsection set-vocab-summary }
+"Vocabulary authors:"
+{ $subsection vocab-authors }
+{ $subsection set-vocab-authors }
+"Vocabulary tags:"
+{ $subsection vocab-tags }
+{ $subsection set-vocab-tags }
+{ $subsection add-vocab-tags }
+"Getting and setting arbitrary vocabulary metadata:"
+{ $subsection vocab-file-contents }
+{ $subsection set-vocab-file-contents } ;
+
+ABOUT: "vocabs.metadata"
+
+HELP: vocab-file-contents
+{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "seq" "a sequence of lines, or " { $link f } } }
+{ $description "Outputs the contents of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ;
+
+HELP: set-vocab-file-contents
+{ $values { "seq" "a sequence of lines" } { "vocab" "a vocabulary specifier" } { "name" string } }
+{ $description "Stores a sequence of lines to the file named " { $snippet "name" } " from the vocabulary's directory." } ;
+
+HELP: vocab-summary
+{ $values { "vocab" "a vocabulary specifier" } { "summary" "a string or " { $link f } } }
+{ $description "Outputs a one-line string description of the vocabulary's intended purpose from the " { $snippet "summary.txt" } " file in the vocabulary's directory. Outputs " { $link f } " if the file does not exist." } ;
+
+HELP: set-vocab-summary
+{ $values { "string" "a string or " { $link f } } { "vocab" "a vocabulary specifier" } }
+{ $description "Stores a one-line string description of the vocabulary to the " { $snippet "summary.txt" } " file in the vocabulary's directory." } ;
+
+HELP: vocab-tags
+{ $values { "vocab" "a vocabulary specifier" } { "tags" "a sequence of strings" } }
+{ $description "Outputs a list of short tags classifying the vocabulary from the " { $snippet "tags.txt" } " file in the vocabulary's directory. Outputs " { $link f } " if the file does not exist." } ;
+
+HELP: set-vocab-tags
+{ $values { "tags" "a sequence of strings" } { "vocab" "a vocabulary specifier" } }
+{ $description "Stores a list of short tags classifying the vocabulary to the " { $snippet "tags.txt" } " file in the vocabulary's directory." } ;
+
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors arrays assocs io.encodings.utf8 io.files
+io.pathnames kernel make math.parser memoize sequences sets
+sorting summary vocabs vocabs.loader ;
+IN: vocabs.metadata
+
+MEMO: vocab-file-contents ( vocab name -- seq )
+ vocab-append-path dup
+ [ dup exists? [ utf8 file-lines ] [ drop f ] if ] when ;
+
+: set-vocab-file-contents ( seq vocab name -- )
+ dupd vocab-append-path [
+ utf8 set-file-lines
+ \ vocab-file-contents reset-memoized
+ ] [
+ "The " swap vocab-name
+ " vocabulary was not loaded from the file system"
+ 3append throw
+ ] ?if ;
+
+: vocab-summary-path ( vocab -- string )
+ vocab-dir "summary.txt" append-path ;
+
+: vocab-summary ( vocab -- summary )
+ dup dup vocab-summary-path vocab-file-contents
+ [
+ vocab-name " vocabulary" append
+ ] [
+ nip first
+ ] if-empty ;
+
+M: vocab summary
+ [
+ dup vocab-summary %
+ " (" %
+ words>> assoc-size #
+ " words)" %
+ ] "" make ;
+
+M: vocab-link summary vocab-summary ;
+
+: set-vocab-summary ( string vocab -- )
+ [ 1array ] dip
+ dup vocab-summary-path
+ set-vocab-file-contents ;
+
+: vocab-tags-path ( vocab -- string )
+ vocab-dir "tags.txt" append-path ;
+
+: vocab-tags ( vocab -- tags )
+ dup vocab-tags-path vocab-file-contents harvest ;
+
+: set-vocab-tags ( tags vocab -- )
+ dup vocab-tags-path set-vocab-file-contents ;
+
+: add-vocab-tags ( tags vocab -- )
+ [ vocab-tags append prune ] keep set-vocab-tags ;
+
+: vocab-authors-path ( vocab -- string )
+ vocab-dir "authors.txt" append-path ;
+
+: vocab-authors ( vocab -- authors )
+ dup vocab-authors-path vocab-file-contents harvest ;
+
+: set-vocab-authors ( authors vocab -- )
+ dup vocab-authors-path set-vocab-file-contents ;
+
+: unportable? ( vocab -- ? )
+ vocab-tags "unportable" swap member? ;
\ No newline at end of file
--- /dev/null
+Managing vocabulary author, tag and summary information
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+Slava Pestov
--- /dev/null
+USING: tools.test vocabs.refresh.monitor io.pathnames ;
+IN: vocabs.refresh.monitor.tests
+
+[ "kernel" ] [ "core/kernel/kernel.factor" path>vocab ] unit-test
+[ "kernel" ] [ "core/kernel/" path>vocab ] unit-test
+[ "kernel" ] [ "core/kernel/" resource-path path>vocab ] unit-test
--- /dev/null
+! Copyright (C) 2008, 2009 Slava Pestov.\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: accessors assocs command-line concurrency.messaging\r
+continuations init io.backend io.files io.monitors io.pathnames\r
+kernel namespaces sequences sets splitting threads\r
+tr vocabs vocabs.loader vocabs.refresh vocabs.cache ;\r
+IN: vocabs.refresh.monitor\r
+\r
+TR: convert-separators "/\\" ".." ;\r
+\r
+: vocab-dir>vocab-name ( path -- vocab )\r
+ trim-head-separators\r
+ trim-tail-separators\r
+ convert-separators ;\r
+\r
+: path>vocab-name ( path -- vocab )\r
+ dup ".factor" tail? [ parent-directory ] when ;\r
+\r
+: chop-vocab-root ( path -- path' )\r
+ "resource:" prepend-path normalize-path\r
+ dup vocab-roots get\r
+ [ normalize-path ] map\r
+ [ head? ] with find nip\r
+ ?head drop ;\r
+\r
+: path>vocab ( path -- vocab )\r
+ chop-vocab-root path>vocab-name vocab-dir>vocab-name ;\r
+\r
+: monitor-loop ( -- )\r
+ #! On OS X, monitors give us the full path, so we chop it\r
+ #! off if its there.\r
+ receive path>> path>vocab changed-vocab\r
+ reset-cache\r
+ monitor-loop ;\r
+\r
+: add-monitor-for-path ( path -- )\r
+ dup exists? [ t my-mailbox (monitor) ] when drop ;\r
+\r
+: monitor-thread ( -- )\r
+ [\r
+ [\r
+ vocab-roots get prune [ add-monitor-for-path ] each\r
+\r
+ H{ } clone changed-vocabs set-global\r
+ vocabs [ changed-vocab ] each\r
+\r
+ monitor-loop\r
+ ] with-monitors\r
+ ] ignore-errors ;\r
+\r
+: start-monitor-thread ( -- )\r
+ #! Silently ignore errors during monitor creation since\r
+ #! monitors are not supported on all platforms.\r
+ [ monitor-thread ] "Vocabulary monitor" spawn drop ;\r
+\r
+[\r
+ "-no-monitors" (command-line) member?\r
+ [ start-monitor-thread ] unless\r
+] "vocabs.refresh.monitor" add-init-hook\r
--- /dev/null
+Use io.monitors to clear tools.browser authors/tags/summary cache
--- /dev/null
+USING: help.markup help.syntax strings ;
+IN: vocabs.refresh
+
+HELP: source-modified?
+{ $values { "path" "a pathname string" } { "?" "a boolean" } }
+{ $description "Tests if the source file has been modified since it was last loaded. This compares the file's CRC32 checksum of the file's contents against the previously-recorded value." } ;
+
+HELP: refresh
+{ $values { "prefix" string } }
+{ $description "Reloads source files and documentation belonging to loaded vocabularies whose names are prefixed by " { $snippet "prefix" } " which have been modified on disk." } ;
+
+HELP: refresh-all
+{ $description "Reloads source files and documentation for all loaded vocabularies which have been modified on disk." } ;
+
+{ refresh refresh-all } related-words
+
+ARTICLE: "vocabs.refresh" "Runtime code reloading"
+"Reloading source files changed on disk:"
+{ $subsection refresh }
+{ $subsection refresh-all } ;
+
+ABOUT: "vocabs.refresh"
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors assocs checksums checksums.crc32
+io.encodings.utf8 io.files kernel namespaces sequences sets
+source-files vocabs vocabs.errors vocabs.loader ;
+IN: vocabs.refresh
+
+: source-modified? ( path -- ? )
+ dup source-files get at [
+ dup path>>
+ dup exists? [
+ utf8 file-lines crc32 checksum-lines
+ swap checksum>> = not
+ ] [
+ 2drop f
+ ] if
+ ] [
+ exists?
+ ] ?if ;
+
+SYMBOL: changed-vocabs
+
+: changed-vocab ( vocab -- )
+ dup vocab changed-vocabs get and
+ [ dup changed-vocabs get set-at ] [ drop ] if ;
+
+: unchanged-vocab ( vocab -- )
+ changed-vocabs get delete-at ;
+
+: unchanged-vocabs ( vocabs -- )
+ [ unchanged-vocab ] each ;
+
+: changed-vocab? ( vocab -- ? )
+ changed-vocabs get dup [ key? ] [ 2drop t ] if ;
+
+: filter-changed ( vocabs -- vocabs' )
+ [ changed-vocab? ] filter ;
+
+SYMBOL: modified-sources
+SYMBOL: modified-docs
+
+: (to-refresh) ( vocab variable loaded? path -- )
+ dup [
+ swap [
+ pick changed-vocab? [
+ source-modified? [ get push ] [ 2drop ] if
+ ] [ 3drop ] if
+ ] [ drop get push ] if
+ ] [ 2drop 2drop ] if ;
+
+: to-refresh ( prefix -- modified-sources modified-docs unchanged )
+ [
+ V{ } clone modified-sources set
+ V{ } clone modified-docs set
+
+ child-vocabs [
+ [
+ [
+ [ modified-sources ]
+ [ vocab source-loaded?>> ]
+ [ vocab-source-path ]
+ tri (to-refresh)
+ ] [
+ [ modified-docs ]
+ [ vocab docs-loaded?>> ]
+ [ vocab-docs-path ]
+ tri (to-refresh)
+ ] bi
+ ] each
+
+ modified-sources get
+ modified-docs get
+ ]
+ [ modified-docs get modified-sources get append diff ] bi
+ ] with-scope ;
+
+: do-refresh ( modified-sources modified-docs unchanged -- )
+ unchanged-vocabs
+ [
+ [ [ vocab f >>source-loaded? drop ] each ]
+ [ [ vocab f >>docs-loaded? drop ] each ] bi*
+ ]
+ [
+ append prune
+ [ unchanged-vocabs ]
+ [ require-all load-failures. ] bi
+ ] 2bi ;
+
+: refresh ( prefix -- ) to-refresh do-refresh ;
+
+: refresh-all ( -- ) "" refresh ;
\ No newline at end of file
--- /dev/null
+Reloading changed vocabularies from disk
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: ;
+IN: alien.dlls
"tools.test"
"tools.threads"
"tools.time"
- "tools.vocabs"
"vocabs"
"vocabs.loader"
+ "vocabs.refresh"
+ "vocabs.hierarchy"
"words"
"scratchpad"
} interactive-vocabs set-global
IN: source-files
ARTICLE: "source-files" "Source files"
-"Words in the " { $vocab-link "source-files" } " vocabulary are used to keep track of loaded source files. This is used to implement " { $link "tools.vocabs" } "."
+"Words in the " { $vocab-link "source-files" } " vocabulary are used to keep track of loaded source files. This is used to implement " { $link "vocabs.refresh" } "."
$nl
"The source file database:"
{ $subsection source-files }
$low-level-note ;
HELP: reset-checksums
-{ $description "Resets recorded modification times and CRC32 checksums for all loaded source files, creating a checkpoint for " { $link "tools.vocabs" } "." } ;
+{ $description "Resets recorded modification times and CRC32 checksums for all loaded source files, creating a checkpoint for " { $link "vocabs.refresh" } "." } ;
HELP: forget-source
{ $values { "path" "a pathname string" } }
HELP: require
{ $values { "vocab" "a vocabulary specifier" } }
{ $description "Loads a vocabulary if it has not already been loaded." }
-{ $notes "To unconditionally reload a vocabulary, use " { $link reload } ". To reload changed source files only, use the words in " { $link "tools.vocabs" } "." } ;
+{ $notes "To unconditionally reload a vocabulary, use " { $link reload } ". To reload changed source files only, use the words in " { $link "vocabs.refresh" } "." } ;
HELP: run
{ $values { "vocab" "a vocabulary specifier" } }
-IN: vocabs.loader.tests
USING: vocabs.loader tools.test continuations vocabs math
kernel arrays sequences namespaces io.streams.string
parser source-files words assocs classes.tuple definitions
-debugger compiler.units tools.vocabs accessors eval
+debugger compiler.units accessors eval
combinators vocabs.parser grouping ;
+IN: vocabs.loader.tests
! This vocab should not exist, but just in case...
[ ] [
! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: kernel vocabs vocabs.loader tools.time tools.vocabs
+USING: kernel vocabs vocabs.loader tools.time vocabs.hierarchy
arrays assocs io.styles io help.markup prettyprint sequences
continuations debugger math namespaces memory ;
IN: benchmark
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays kernel math ;
+IN: benchmark.gc0
+
+: allocate ( -- obj ) 10 f <array> ;
+: gc0 ( -- ) f 60000000 [ allocate nip ] times drop ;
+
+MAIN: gc0
\ No newline at end of file
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays byte-arrays kernel namespaces sequences math memory ;
+IN: benchmark.gc2
+
+! Runs slowly if clean cards are not unmarked.
+SYMBOL: oldies
+
+: make-old-objects ( -- )
+ 1000000 [ 1 f <array> ] replicate oldies set gc
+ oldies get [ "HI" swap set-first ] each ;
+
+: allocate ( -- x ) 20000 (byte-array) ;
+
+: age ( -- )
+ 1000 [ allocate drop ] times ;
+
+: gc2 ( -- )
+ [
+ make-old-objects
+ 50000 [ age ] times
+ ] with-scope ;
+
+MAIN: gc2
\ No newline at end of file
USING: accessors arrays assocs combinators help help.crossref
help.markup help.topics io io.streams.string kernel make namespaces
-parser prettyprint sequences summary tools.vocabs help.vocabs
-vocabs vocabs.loader words see ;
+parser prettyprint sequences summary help.vocabs
+vocabs vocabs.loader vocabs.hierarchy vocabs.metadata words see ;
IN: fuel.help
[ see ] with-string-writer ; inline
: fuel-methods-str ( word -- str )
- methods dup empty? not [
+ methods [ f ] [
[ [ see nl ] each ] with-string-writer
- ] [ drop f ] if ; inline
+ ] if-empty ; inline
: fuel-related-words ( word -- seq )
dup "related" word-prop remove ; inline
USING: accessors arrays assocs definitions help.topics io.pathnames
kernel math math.order memoize namespaces sequences sets sorting
-tools.completion tools.crossref tools.vocabs vocabs vocabs.parser
+tools.completion tools.crossref vocabs vocabs.parser vocabs.hierarchy
words ;
IN: fuel.xref
USING: slides help.markup math arrays hashtables namespaces
sequences kernel sequences parser memoize io.encodings.binary
locals kernel.private help.vocabs assocs quotations
-urls peg.ebnf tools.vocabs tools.annotations tools.crossref
+urls peg.ebnf tools.annotations tools.crossref
help.topics math.functions compiler.tree.optimizer
compiler.cfg.optimizer fry ;
IN: galois-talk
USING: slides help.markup math arrays hashtables namespaces
sequences kernel sequences parser memoize io.encodings.binary
locals kernel.private help.vocabs assocs quotations
-urls peg.ebnf tools.vocabs tools.annotations tools.crossref
+urls peg.ebnf tools.annotations tools.crossref
help.topics math.functions compiler.tree.optimizer
compiler.cfg.optimizer fry ;
IN: google-tech-talk
: ?prepare-build-machine ( -- )
builds/factor exists? [ prepare-build-machine ] unless ;
-CONSTANT: load-everything-vocabs-file "load-everything-vocabs"
-CONSTANT: load-everything-errors-file "load-everything-errors"
+CONSTANT: load-all-vocabs-file "load-everything-vocabs"
+CONSTANT: load-all-errors-file "load-everything-errors"
CONSTANT: test-all-vocabs-file "test-all-vocabs"
CONSTANT: test-all-errors-file "test-all-errors"
timings-table
"Load failures"
- load-everything-vocabs-file
- load-everything-errors-file
+ load-all-vocabs-file
+ load-all-errors-file
error-dump
"Compiler errors"
: build-clean? ( -- ? )
{
- [ load-everything-vocabs-file eval-file empty? ]
+ [ load-all-vocabs-file eval-file empty? ]
[ test-all-vocabs-file eval-file empty? ]
[ help-lint-vocabs-file eval-file empty? ]
[ compiler-errors-file eval-file empty? ]
USING: accessors assocs benchmark bootstrap.stage2 compiler.errors
source-files.errors generic help.html help.lint io.directories
io.encodings.utf8 io.files kernel mason.common math namespaces
-prettyprint sequences sets sorting tools.test tools.time tools.vocabs
-words system io tools.errors locals ;
+prettyprint sequences sets sorting tools.test tools.time
+words system io tools.errors vocabs.hierarchy vocabs.errors
+vocabs.refresh locals ;
IN: mason.test
: do-load ( -- )
- try-everything
- [ keys load-everything-vocabs-file to-file ]
- [ load-everything-errors-file utf8 [ load-failures. ] with-file-writer ]
+ "" (load)
+ [ keys load-all-vocabs-file to-file ]
+ [ load-all-errors-file utf8 [ load-failures. ] with-file-writer ]
bi ;
GENERIC: word-vocabulary ( word -- vocabulary )
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: slides help.markup math arrays hashtables namespaces sequences
-kernel sequences parser memoize io.encodings.binary locals
-kernel.private help.vocabs assocs quotations tools.vocabs
+USING: slides help.markup math arrays hashtables namespaces
+sequences kernel sequences parser memoize io.encodings.binary
+locals kernel.private help.vocabs assocs quotations
tools.annotations tools.crossref help.topics math.functions
-compiler.tree.optimizer compiler.cfg.optimizer fry ui.gadgets.panes
-tetris tetris.game combinators generalizations multiline
-sequences.private ;
+compiler.tree.optimizer compiler.cfg.optimizer fry
+ui.gadgets.panes tetris tetris.game combinators generalizations
+multiline sequences.private ;
IN: otug-talk
: $tetris ( element -- )
! See http://factorcode.org/license.txt for BSD license.
USING: slides help.markup math arrays hashtables namespaces
sequences kernel sequences parser memoize io.encodings.binary
-locals kernel.private help.vocabs assocs quotations
-urls peg.ebnf tools.vocabs tools.annotations tools.crossref
-help.topics math.functions compiler.tree.optimizer
-compiler.cfg.optimizer fry ;
+locals kernel.private help.vocabs assocs quotations urls
+peg.ebnf tools.annotations tools.crossref help.topics
+math.functions compiler.tree.optimizer compiler.cfg.optimizer
+fry ;
IN: vpri-talk
CONSTANT: vpri-slides