Merge branch 'master' of git://factorcode.org/git/factor

db4
Slava Pestov 2009-05-04 09:08:46 -04:00
commit f812f70473
73 changed files with 612 additions and 468 deletions

View File

@ -14,7 +14,8 @@ IN: bootstrap.tools
"tools.test" "tools.test"
"tools.time" "tools.time"
"tools.threads" "tools.threads"
"tools.vocabs" "vocabs.hierarchy"
"tools.vocabs.monitor" "vocabs.refresh"
"vocabs.refresh.monitor"
"editors" "editors"
} [ require ] each } [ require ] each

View File

@ -1,10 +1,10 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: parser lexer kernel namespaces sequences definitions io.files USING: parser lexer kernel namespaces sequences definitions
io.backend io.pathnames io summary continuations tools.crossref io.files io.backend io.pathnames io summary continuations
tools.vocabs prettyprint source-files source-files.errors assocs tools.crossref vocabs.hierarchy prettyprint source-files
vocabs vocabs.loader splitting accessors debugger prettyprint source-files.errors assocs vocabs vocabs.loader splitting
help.topics ; accessors debugger prettyprint help.topics ;
IN: editors IN: editors
TUPLE: no-edit-hook ; TUPLE: no-edit-hook ;

View File

@ -1,8 +1,8 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs fry help.markup help.topics io USING: accessors arrays assocs fry help.markup help.topics io
kernel make math math.parser namespaces sequences sorting 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 ; vocabs words unicode.case help ;
IN: help.apropos IN: help.apropos

View File

@ -281,7 +281,7 @@ ARTICLE: "handbook-tools-reference" "Developer tools"
{ $heading "Workflow" } { $heading "Workflow" }
{ $subsection "listener" } { $subsection "listener" }
{ $subsection "editor" } { $subsection "editor" }
{ $subsection "tools.vocabs" } { $subsection "vocabs.refresh" }
{ $subsection "tools.test" } { $subsection "tools.test" }
{ $subsection "help" } { $subsection "help" }
{ $heading "Debugging" } { $heading "Debugging" }
@ -292,6 +292,7 @@ ARTICLE: "handbook-tools-reference" "Developer tools"
{ $heading "Browsing" } { $heading "Browsing" }
{ $subsection "see" } { $subsection "see" }
{ $subsection "tools.crossref" } { $subsection "tools.crossref" }
{ $subsection "vocabs.hierarchy" }
{ $heading "Performance" } { $heading "Performance" }
{ $subsection "timing" } { $subsection "timing" }
{ $subsection "profiling" } { $subsection "profiling" }

View File

@ -3,7 +3,7 @@
USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary
io.files io.files.temp io.directories html.streams help kernel io.files io.files.temp io.directories html.streams help kernel
assocs sequences make words accessors arrays help.topics vocabs 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 vocabs.loader serialize fry memoize ascii unicode.case math.order
sorting debugger html xml.syntax xml.writer math.parser ; sorting debugger html xml.syntax xml.writer math.parser ;
IN: help.html IN: help.html

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: assocs continuations fry help help.lint.checks USING: assocs continuations fry help help.lint.checks
help.topics io kernel namespaces parser sequences 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 ; locals tools.errors ;
FROM: help.lint.checks => all-vocabs ; FROM: help.lint.checks => all-vocabs ;
IN: help.lint IN: help.lint

View File

@ -1,6 +1,6 @@
USING: help.markup help.syntax ui.commands ui.operations USING: help.markup help.syntax ui.commands ui.operations
editors vocabs.loader kernel sequences prettyprint tools.test 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 ; ui.tools.browser ui.tools.common ;
IN: help.tutorial IN: help.tutorial

View File

@ -6,7 +6,8 @@ classes.singleton classes.tuple classes.union combinators
definitions effects fry generic help help.markup help.stylesheet definitions effects fry generic help help.markup help.stylesheet
help.topics io io.files io.pathnames io.styles kernel macros help.topics io io.files io.pathnames io.styles kernel macros
make namespaces prettyprint sequences sets sorting summary 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 IN: help.vocabs
: about ( vocab -- ) : about ( vocab -- )

View File

@ -1,4 +1,4 @@
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 IN: http.server
HELP: trivial-responder HELP: trivial-responder

View File

@ -1,8 +1,8 @@
! Copyright (C) 2003, 2008 Slava Pestov. ! Copyright (C) 2003, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel accessors sequences arrays namespaces splitting USING: kernel accessors sequences arrays namespaces splitting
vocabs.loader destructors assocs debugger continuations 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 vectors
io.sockets io.sockets
io.sockets.secure io.sockets.secure

View File

@ -1,5 +1,5 @@
IN: present.tests 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 [ "3" ] [ 3 present ] unit-test
[ "Hi" ] [ "Hi" present ] unit-test [ "Hi" ] [ "Hi" present ] unit-test

View File

@ -1,9 +1,9 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel arrays sequences math namespaces USING: accessors kernel arrays sequences math namespaces strings io
strings io fry vectors words assocs combinators sorting fry vectors words assocs combinators sorting unicode.case
unicode.case unicode.categories math.order vocabs unicode.categories math.order vocabs vocabs.hierarchy unicode.data
tools.vocabs unicode.data locals ; locals ;
IN: tools.completion IN: tools.completion
:: (fuzzy) ( accum i full ch -- accum i full ? ) :: (fuzzy) ( accum i full ch -- accum i full ? )

View File

@ -1,7 +1,7 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: assocs io.pathnames kernel parser prettyprint sequences 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 IN: tools.deploy.config.editor
: deploy-config-path ( vocab -- string ) : deploy-config-path ( vocab -- string )

View File

@ -37,7 +37,7 @@ IN: tools.deploy.shaker
] when ] when
strip-dictionary? [ strip-dictionary? [
"compiler.units" init-hooks get delete-at "compiler.units" init-hooks get delete-at
"tools.vocabs" init-hooks get delete-at "vocabs.cache" init-hooks get delete-at
] when ; ] when ;
: strip-debugger ( -- ) : strip-debugger ( -- )

View File

@ -4,9 +4,9 @@ USING: accessors arrays assocs combinators compiler.units
continuations debugger effects fry generalizations io io.files continuations debugger effects fry generalizations io io.files
io.styles kernel lexer locals macros math.parser namespaces io.styles kernel lexer locals macros math.parser namespaces
parser prettyprint quotations sequences source-files splitting parser prettyprint quotations sequences source-files splitting
stack-checker summary unicode.case vectors vocabs vocabs.loader words stack-checker summary unicode.case vectors vocabs vocabs.loader
tools.vocabs tools.errors source-files.errors io.streams.string make vocabs.files words tools.errors source-files.errors
compiler.errors ; io.streams.string make compiler.errors ;
IN: tools.test IN: tools.test
TUPLE: test-failure < source-file-error continuation ; TUPLE: test-failure < source-file-error continuation ;

View File

@ -1 +0,0 @@
Reloading vocabularies and cross-referencing vocabularies

View File

@ -1,75 +0,0 @@
USING: help.markup help.syntax strings ;
IN: tools.vocabs
ARTICLE: "tools.vocabs" "Vocabulary tools"
"Reloading source files changed on disk:"
{ $subsection refresh }
{ $subsection refresh-all }
"Vocabulary summaries:"
{ $subsection vocab-summary }
{ $subsection set-vocab-summary }
"Vocabulary tags:"
{ $subsection vocab-tags }
{ $subsection set-vocab-tags }
{ $subsection add-vocab-tags }
"Getting and setting vocabulary meta-data:"
{ $subsection vocab-file-contents }
{ $subsection set-vocab-file-contents }
"Global meta-data:"
{ $subsection all-vocabs }
{ $subsection all-vocabs-seq }
{ $subsection all-tags }
{ $subsection all-authors }
"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:"
{ $subsection reset-cache } ;
ABOUT: "tools.vocabs"
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." } ;
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
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." } ;
HELP: all-vocabs
{ $values { "assoc" "an association list mapping vocabulary roots to sequences of vocabulary specifiers" } }
{ $description "Outputs an association list of all vocabularies which have been loaded or are available for loading." } ;

View File

@ -1,9 +0,0 @@
IN: tools.vocabs.tests
USING: tools.test tools.vocabs namespaces continuations ;
[ ] [
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

View File

@ -1,296 +0,0 @@
! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel io io.styles io.files io.files.info io.directories
io.pathnames io.encodings.utf8 vocabs.loader vocabs sequences
namespaces make math.parser arrays hashtables assocs memoize
summary sorting splitting combinators source-files debugger
continuations compiler.errors init checksums checksums.crc32
sets accessors generic definitions words ;
IN: tools.vocabs
: 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 ;
: 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 ;
: vocab-heading. ( vocab -- )
nl
"==== " write
[ vocab-name ] [ vocab write-object ] bi ":" print
nl ;
: load-error. ( triple -- )
[ first vocab-heading. ] [ second print-error ] bi ;
: load-failures. ( failures -- )
[ load-error. nl ] each ;
SYMBOL: failures
: 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 ;
: 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 ;
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 ;
: subdirs ( dir -- dirs )
[
[ link-info directory? ] filter
] with-directory-files natural-sort ;
: (all-child-vocabs) ( root name -- vocabs )
[
vocab-dir append-path dup exists?
[ subdirs ] [ drop { } ] if
] keep [
swap [ "." glue ] with map
] unless-empty ;
: vocab-dir? ( root name -- ? )
over
[ ".factor" vocab-dir+ append-path exists? ]
[ 2drop f ]
if ;
: vocabs-in-dir ( root name -- )
dupd (all-child-vocabs) [
2dup vocab-dir? [ dup >vocab-link , ] when
vocabs-in-dir
] with each ;
: all-vocabs ( -- assoc )
vocab-roots get [
dup [ "" vocabs-in-dir ] { } make
] { } map>assoc ;
MEMO: all-vocabs-seq ( -- seq )
all-vocabs values concat ;
: unportable? ( name -- ? )
vocab-tags "unportable" swap member? ;
: filter-unportable ( seq -- seq' )
[ vocab-name unportable? not ] filter ;
: try-everything ( -- failures )
all-vocabs-seq
filter-unportable
require-all ;
: load-everything ( -- )
try-everything load-failures. ;
: unrooted-child-vocabs ( prefix -- seq )
dup empty? [ CHAR: . suffix ] unless
vocabs
[ find-vocab-root not ] filter
[
vocab-name swap ?head CHAR: . rot member? not and
] with filter
[ vocab ] map ;
: all-child-vocabs ( prefix -- assoc )
vocab-roots get [
dup pick (all-child-vocabs) [ >vocab-link ] map
] { } map>assoc
swap unrooted-child-vocabs f swap 2array suffix ;
: all-child-vocabs-seq ( prefix -- assoc )
vocab-roots get swap [
dupd (all-child-vocabs)
[ vocab-dir? ] with filter
] curry map concat ;
MEMO: all-tags ( -- seq )
all-vocabs-seq [ vocab-tags ] gather natural-sort ;
MEMO: all-authors ( -- seq )
all-vocabs-seq [ vocab-authors ] gather natural-sort ;
: 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
] "tools.vocabs" add-init-hook

View File

@ -4,7 +4,8 @@ USING: alien.syntax cocoa cocoa.nibs cocoa.application
cocoa.classes cocoa.dialogs cocoa.pasteboard cocoa.subclassing cocoa.classes cocoa.dialogs cocoa.pasteboard cocoa.subclassing
core-foundation core-foundation.strings help.topics kernel core-foundation core-foundation.strings help.topics kernel
memory namespaces parser system ui ui.tools.browser 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 IN: ui.backend.cocoa.tools
: finder-run-files ( alien -- ) : finder-run-files ( alien -- )

View File

@ -1,7 +1,7 @@
USING: help.markup help.syntax ui.commands ui.operations USING: help.markup help.syntax ui.commands ui.operations
ui.gadgets.editors ui.gadgets.panes listener io words ui.gadgets.editors ui.gadgets.panes listener io words
ui.tools.listener.completion ui.tools.common help.tips ui.tools.listener.completion ui.tools.common help.tips
tools.vocabs vocabs ; vocabs vocabs.refresh ;
IN: ui.tools.listener IN: ui.tools.listener
HELP: interactor HELP: interactor

View File

@ -6,14 +6,15 @@ compiler.units help.tips concurrency.flags concurrency.mailboxes
continuations destructors documents documents.elements fry hashtables continuations destructors documents documents.elements fry hashtables
help help.markup io io.styles kernel lexer listener math models sets help help.markup io io.styles kernel lexer listener math models sets
models.delay models.arrow namespaces parser prettyprint quotations 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 vocabs.parser words debugger ui ui.commands ui.pens.solid ui.gadgets
ui.gadgets.glass ui.gadgets.buttons ui.gadgets.editors ui.gadgets.glass ui.gadgets.buttons ui.gadgets.editors
ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.labeled ui.gadgets.panes ui.gadgets.scrollers
ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.borders ui.gestures ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.borders ui.gestures
ui.operations ui.tools.browser ui.tools.common ui.tools.debugger ui.operations ui.tools.browser ui.tools.common ui.tools.debugger
ui.tools.listener.completion ui.tools.listener.popups 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 ; FROM: source-files.errors => all-errors ;
IN: ui.tools.listener IN: ui.tools.listener

View File

@ -4,7 +4,7 @@ USING: continuations definitions generic help.topics threads
stack-checker summary io.pathnames io.styles kernel namespaces parser stack-checker summary io.pathnames io.styles kernel namespaces parser
prettyprint quotations tools.crossref tools.annotations editors prettyprint quotations tools.crossref tools.annotations editors
tools.profiler tools.test tools.time tools.walker vocabs vocabs.loader 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 accessors vocabs.parser macros.expander ui ui.tools.browser
ui.tools.listener ui.tools.listener.completion ui.tools.profiler ui.tools.listener ui.tools.listener.completion ui.tools.profiler
ui.tools.inspector ui.tools.traceback ui.commands ui.gadgets.editors ui.tools.inspector ui.tools.traceback ui.commands ui.gadgets.editors

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006, 2009 Slava Pestov. ! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! 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.listener ui.tools.browser ui.tools.common ui.tools.error-list
ui.tools.walker ui.commands ui.gestures ui ui.private ; ui.tools.walker ui.commands ui.gestures ui ui.private ;
IN: ui.tools IN: ui.tools

1
basis/vocabs/cache/authors.txt vendored Normal file
View File

@ -0,0 +1 @@
Slava Pestov

21
basis/vocabs/cache/cache.factor vendored Normal file
View File

@ -0,0 +1,21 @@
! 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

1
basis/vocabs/cache/summary.txt vendored Normal file
View File

@ -0,0 +1 @@
Caching vocabulary data from disk

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,35 @@
! 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 ;

View File

@ -0,0 +1 @@
Loading vocabularies and batching errors

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,11 @@
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." } ;

View File

@ -0,0 +1,34 @@
! 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 ;

View File

@ -0,0 +1 @@
Getting a list of files in a vocabulary

View File

@ -0,0 +1,33 @@
USING: help.markup help.syntax strings vocabs.loader ;
IN: vocabs.hierarchy
ARTICLE: "vocabs.hierarchy" "Vocabulary hierarchy tools"
"These tools operate on all vocabularies found in the current set of " { $link vocab-roots } ", loaded or not."
$nl
"Loading vocabulary hierarchies:"
{ $subsection load }
{ $subsection load-all }
"Getting all vocabularies on disk:"
{ $subsection all-vocabs }
{ $subsection all-vocabs-seq }
"Getting " { $link "vocabs.metadata" } " for all vocabularies on disk:"
{ $subsection all-tags }
{ $subsection all-authors } ;
ABOUT: "vocabs.hierarchy"
HELP: all-vocabs
{ $values { "assoc" "an association list mapping vocabulary roots to sequences of vocabulary specifiers" } }
{ $description "Outputs an association list of all vocabularies which have been loaded or are available for loading." } ;
HELP: load
{ $values { "prefix" string } }
{ $description "Load all vocabularies that match the provided prefix." }
{ $notes "This word differs from " { $link require } " in that it loads all subvocabularies, not just the given one." } ;
HELP: load-all
{ $description "Load all vocabularies in the source tree." } ;
HELP: all-vocabs-under
{ $values { "prefix" string } }
{ $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." } ;

View File

@ -0,0 +1,12 @@
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

View File

@ -0,0 +1,99 @@
! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs combinators.short-circuit fry
io.directories io.files io.files.info io.pathnames kernel make
memoize namespaces sequences sorting splitting vocabs sets
vocabs.loader vocabs.metadata vocabs.errors ;
IN: vocabs.hierarchy
<PRIVATE
: vocab-subdirs ( dir -- dirs )
[
[
{ [ link-info directory? ] [ "." head? not ] } 1&&
] filter
] with-directory-files natural-sort ;
: (all-child-vocabs) ( root name -- vocabs )
[
vocab-dir append-path dup exists?
[ vocab-subdirs ] [ drop { } ] if
] keep
[ '[ [ _ "." ] dip 3append ] map ] unless-empty ;
: vocab-dir? ( root name -- ? )
over
[ ".factor" vocab-dir+ append-path exists? ]
[ 2drop f ]
if ;
: vocabs-in-dir ( root name -- )
dupd (all-child-vocabs) [
2dup vocab-dir? [ dup >vocab-link , ] when
vocabs-in-dir
] with each ;
PRIVATE>
: all-vocabs ( -- assoc )
vocab-roots get [
dup [ "" vocabs-in-dir ] { } make
] { } map>assoc ;
: all-vocabs-under ( prefix -- vocabs )
[
[ vocab-roots get ] dip '[ _ vocabs-in-dir ] each
] { } make ;
MEMO: all-vocabs-seq ( -- seq )
"" all-vocabs-under ;
<PRIVATE
: unrooted-child-vocabs ( prefix -- seq )
dup empty? [ CHAR: . suffix ] unless
vocabs
[ find-vocab-root not ] filter
[
vocab-name swap ?head CHAR: . rot member? not and
] with filter
[ vocab ] map ;
PRIVATE>
: all-child-vocabs ( prefix -- assoc )
vocab-roots get [
dup pick (all-child-vocabs) [ >vocab-link ] map
] { } map>assoc
swap unrooted-child-vocabs f swap 2array suffix ;
: all-child-vocabs-seq ( prefix -- assoc )
vocab-roots get swap '[
dup _ (all-child-vocabs)
[ vocab-dir? ] with filter
] map concat ;
<PRIVATE
: filter-unportable ( seq -- seq' )
[ vocab-name unportable? not ] filter ;
PRIVATE>
: (load) ( prefix -- failures )
all-vocabs-under
filter-unportable
require-all ;
: load ( prefix -- )
(load) load-failures. ;
: load-all ( -- )
"" load ;
MEMO: all-tags ( -- seq )
all-vocabs-seq [ vocab-tags ] gather natural-sort ;
MEMO: all-authors ( -- seq )
all-vocabs-seq [ vocab-authors ] gather natural-sort ;

View File

@ -0,0 +1 @@
Searching for vocabularies on disk

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,44 @@
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." } ;

View File

@ -0,0 +1,70 @@
! 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? ;

View File

@ -0,0 +1 @@
Managing vocabulary author, tag and summary information

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -1,5 +1,5 @@
USING: tools.test tools.vocabs.monitor io.pathnames ; USING: tools.test vocabs.refresh.monitor io.pathnames ;
IN: tools.vocabs.monitor.tests IN: vocabs.refresh.monitor.tests
[ "kernel" ] [ "core/kernel/kernel.factor" path>vocab ] unit-test [ "kernel" ] [ "core/kernel/kernel.factor" path>vocab ] unit-test
[ "kernel" ] [ "core/kernel/" path>vocab ] unit-test [ "kernel" ] [ "core/kernel/" path>vocab ] unit-test

View File

@ -1,10 +1,10 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: threads io.files io.pathnames io.monitors init kernel USING: accessors assocs command-line concurrency.messaging
vocabs vocabs.loader tools.vocabs namespaces continuations continuations init io.backend io.files io.monitors io.pathnames
sequences splitting assocs command-line concurrency.messaging kernel namespaces sequences sets splitting threads
io.backend sets tr accessors ; tr vocabs vocabs.loader vocabs.refresh vocabs.cache ;
IN: tools.vocabs.monitor IN: vocabs.refresh.monitor
TR: convert-separators "/\\" ".." ; TR: convert-separators "/\\" ".." ;
@ -56,4 +56,4 @@ TR: convert-separators "/\\" ".." ;
[ [
"-no-monitors" (command-line) member? "-no-monitors" (command-line) member?
[ start-monitor-thread ] unless [ start-monitor-thread ] unless
] "tools.vocabs.monitor" add-init-hook ] "vocabs.refresh.monitor" add-init-hook

View File

@ -0,0 +1,22 @@
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"

View File

@ -0,0 +1,91 @@
! 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 ;

View File

@ -0,0 +1 @@
Reloading changed vocabularies from disk

View File

@ -198,9 +198,10 @@ SYMBOL: interactive-vocabs
"tools.test" "tools.test"
"tools.threads" "tools.threads"
"tools.time" "tools.time"
"tools.vocabs"
"vocabs" "vocabs"
"vocabs.loader" "vocabs.loader"
"vocabs.refresh"
"vocabs.hierarchy"
"words" "words"
"scratchpad" "scratchpad"
} interactive-vocabs set-global } interactive-vocabs set-global

View File

@ -3,7 +3,7 @@ definitions quotations compiler.units ;
IN: source-files IN: source-files
ARTICLE: "source-files" "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 $nl
"The source file database:" "The source file database:"
{ $subsection source-files } { $subsection source-files }
@ -41,7 +41,7 @@ HELP: record-checksum
$low-level-note ; $low-level-note ;
HELP: reset-checksums 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 HELP: forget-source
{ $values { "path" "a pathname string" } } { $values { "path" "a pathname string" } }

View File

@ -106,7 +106,7 @@ HELP: reload
HELP: require HELP: require
{ $values { "vocab" "a vocabulary specifier" } } { $values { "vocab" "a vocabulary specifier" } }
{ $description "Loads a vocabulary if it has not already been loaded." } { $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 HELP: run
{ $values { "vocab" "a vocabulary specifier" } } { $values { "vocab" "a vocabulary specifier" } }

View File

@ -1,9 +1,9 @@
IN: vocabs.loader.tests
USING: vocabs.loader tools.test continuations vocabs math USING: vocabs.loader tools.test continuations vocabs math
kernel arrays sequences namespaces io.streams.string kernel arrays sequences namespaces io.streams.string
parser source-files words assocs classes.tuple definitions parser source-files words assocs classes.tuple definitions
debugger compiler.units tools.vocabs accessors eval debugger compiler.units accessors eval
combinators vocabs.parser grouping ; combinators vocabs.parser grouping ;
IN: vocabs.loader.tests
! This vocab should not exist, but just in case... ! This vocab should not exist, but just in case...
[ ] [ [ ] [

View File

@ -1,6 +1,6 @@
! Copyright (C) 2007, 2009 Slava Pestov. ! Copyright (C) 2007, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! 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 arrays assocs io.styles io help.markup prettyprint sequences
continuations debugger math namespaces memory ; continuations debugger math namespaces memory ;
IN: benchmark IN: benchmark

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,9 @@
! 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

View File

@ -0,0 +1 @@
Slava Pestov

View File

@ -0,0 +1,24 @@
! 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

View File

@ -3,8 +3,8 @@
USING: accessors arrays assocs combinators help help.crossref USING: accessors arrays assocs combinators help help.crossref
help.markup help.topics io io.streams.string kernel make namespaces help.markup help.topics io io.streams.string kernel make namespaces
parser prettyprint sequences summary tools.vocabs help.vocabs parser prettyprint sequences summary help.vocabs
vocabs vocabs.loader words see ; vocabs vocabs.loader vocabs.hierarchy vocabs.metadata words see ;
IN: fuel.help IN: fuel.help
@ -21,9 +21,9 @@ IN: fuel.help
[ see ] with-string-writer ; inline [ see ] with-string-writer ; inline
: fuel-methods-str ( word -- str ) : fuel-methods-str ( word -- str )
methods dup empty? not [ methods [ f ] [
[ [ see nl ] each ] with-string-writer [ [ see nl ] each ] with-string-writer
] [ drop f ] if ; inline ] if-empty ; inline
: fuel-related-words ( word -- seq ) : fuel-related-words ( word -- seq )
dup "related" word-prop remove ; inline dup "related" word-prop remove ; inline

View File

@ -3,7 +3,7 @@
USING: accessors arrays assocs definitions help.topics io.pathnames USING: accessors arrays assocs definitions help.topics io.pathnames
kernel math math.order memoize namespaces sequences sets sorting 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 ; words ;
IN: fuel.xref IN: fuel.xref

View File

@ -3,7 +3,7 @@
USING: slides help.markup math arrays hashtables namespaces USING: slides help.markup math arrays hashtables namespaces
sequences kernel sequences parser memoize io.encodings.binary sequences kernel sequences parser memoize io.encodings.binary
locals kernel.private help.vocabs assocs quotations 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 help.topics math.functions compiler.tree.optimizer
compiler.cfg.optimizer fry ; compiler.cfg.optimizer fry ;
IN: galois-talk IN: galois-talk

View File

@ -3,7 +3,7 @@
USING: slides help.markup math arrays hashtables namespaces USING: slides help.markup math arrays hashtables namespaces
sequences kernel sequences parser memoize io.encodings.binary sequences kernel sequences parser memoize io.encodings.binary
locals kernel.private help.vocabs assocs quotations 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 help.topics math.functions compiler.tree.optimizer
compiler.cfg.optimizer fry ; compiler.cfg.optimizer fry ;
IN: google-tech-talk IN: google-tech-talk

View File

@ -90,8 +90,8 @@ SYMBOL: stamp
: ?prepare-build-machine ( -- ) : ?prepare-build-machine ( -- )
builds/factor exists? [ prepare-build-machine ] unless ; builds/factor exists? [ prepare-build-machine ] unless ;
CONSTANT: load-everything-vocabs-file "load-everything-vocabs" CONSTANT: load-all-vocabs-file "load-everything-vocabs"
CONSTANT: load-everything-errors-file "load-everything-errors" CONSTANT: load-all-errors-file "load-everything-errors"
CONSTANT: test-all-vocabs-file "test-all-vocabs" CONSTANT: test-all-vocabs-file "test-all-vocabs"
CONSTANT: test-all-errors-file "test-all-errors" CONSTANT: test-all-errors-file "test-all-errors"

View File

@ -89,8 +89,8 @@ IN: mason.report
timings-table timings-table
"Load failures" "Load failures"
load-everything-vocabs-file load-all-vocabs-file
load-everything-errors-file load-all-errors-file
error-dump error-dump
"Compiler errors" "Compiler errors"
@ -120,7 +120,7 @@ IN: mason.report
: build-clean? ( -- ? ) : build-clean? ( -- ? )
{ {
[ load-everything-vocabs-file eval-file empty? ] [ load-all-vocabs-file eval-file empty? ]
[ test-all-vocabs-file eval-file empty? ] [ test-all-vocabs-file eval-file empty? ]
[ help-lint-vocabs-file eval-file empty? ] [ help-lint-vocabs-file eval-file empty? ]
[ compiler-errors-file eval-file empty? ] [ compiler-errors-file eval-file empty? ]

View File

@ -3,14 +3,15 @@
USING: accessors assocs benchmark bootstrap.stage2 compiler.errors USING: accessors assocs benchmark bootstrap.stage2 compiler.errors
source-files.errors generic help.html help.lint io.directories source-files.errors generic help.html help.lint io.directories
io.encodings.utf8 io.files kernel mason.common math namespaces io.encodings.utf8 io.files kernel mason.common math namespaces
prettyprint sequences sets sorting tools.test tools.time tools.vocabs prettyprint sequences sets sorting tools.test tools.time
words system io tools.errors locals ; words system io tools.errors vocabs.hierarchy vocabs.errors
vocabs.refresh locals ;
IN: mason.test IN: mason.test
: do-load ( -- ) : do-load ( -- )
try-everything "" (load)
[ keys load-everything-vocabs-file to-file ] [ keys load-all-vocabs-file to-file ]
[ load-everything-errors-file utf8 [ load-failures. ] with-file-writer ] [ load-all-errors-file utf8 [ load-failures. ] with-file-writer ]
bi ; bi ;
GENERIC: word-vocabulary ( word -- vocabulary ) GENERIC: word-vocabulary ( word -- vocabulary )

View File

@ -15,9 +15,9 @@ ARTICLE: "mongodb" "MongoDB factor integration"
{ $heading "Highlevel tuple integration" } { $heading "Highlevel tuple integration" }
"The " { $vocab-link "mongodb.tuple" } " vocabulary lets you define persistent tuples that can be stored to and retrieved from a MongoDB database" "The " { $vocab-link "mongodb.tuple" } " vocabulary lets you define persistent tuples that can be stored to and retrieved from a MongoDB database"
{ $unchecked-example { $unchecked-example
"USING: mongodb.driver mongodb.tuple fry ;" "USING: mongodb.driver mongodb.tuple fry literals ;"
"MDBTUPLE: person name age ; " "MDBTUPLE: person name age ; "
"person \"persons\" { { \"age\" +fieldindex+ } } define-persistent " "person \"persons\" { } { $[ \"ageIdx\" [ \"age\" asc ] key-spec <tuple-index> ] } define-persistent "
"\"db\" \"127.0.0.1\" 27017 <mdb>" "\"db\" \"127.0.0.1\" 27017 <mdb>"
"person new \"Alfred\" >>name 57 >>age" "person new \"Alfred\" >>name 57 >>age"
"'[ _ save-tuple person new 57 >>age select-tuple ] with-db" "'[ _ save-tuple person new 57 >>age select-tuple ] with-db"

View File

@ -1,6 +1,6 @@
USING: accessors assocs classes.mixin classes.tuple USING: accessors assocs classes.mixin classes.tuple
classes.tuple.parser compiler.units fry kernel sequences mongodb.driver classes.tuple.parser compiler.units fry kernel sequences mongodb.driver
mongodb.msg mongodb.tuple.collection mongodb.tuple.index mongodb.msg mongodb.tuple.collection
mongodb.tuple.persistent mongodb.tuple.state strings ; mongodb.tuple.persistent mongodb.tuple.state strings ;
IN: mongodb.tuple IN: mongodb.tuple

View File

@ -1,12 +1,12 @@
! Copyright (C) 2008 Slava Pestov. ! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: slides help.markup math arrays hashtables namespaces sequences USING: slides help.markup math arrays hashtables namespaces
kernel sequences parser memoize io.encodings.binary locals sequences kernel sequences parser memoize io.encodings.binary
kernel.private help.vocabs assocs quotations tools.vocabs locals kernel.private help.vocabs assocs quotations
tools.annotations tools.crossref help.topics math.functions tools.annotations tools.crossref help.topics math.functions
compiler.tree.optimizer compiler.cfg.optimizer fry ui.gadgets.panes compiler.tree.optimizer compiler.cfg.optimizer fry
tetris tetris.game combinators generalizations multiline ui.gadgets.panes tetris tetris.game combinators generalizations
sequences.private ; multiline sequences.private ;
IN: otug-talk IN: otug-talk
: $tetris ( element -- ) : $tetris ( element -- )

View File

@ -2,10 +2,10 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: slides help.markup math arrays hashtables namespaces USING: slides help.markup math arrays hashtables namespaces
sequences kernel sequences parser memoize io.encodings.binary sequences kernel sequences parser memoize io.encodings.binary
locals kernel.private help.vocabs assocs quotations locals kernel.private help.vocabs assocs quotations urls
urls peg.ebnf tools.vocabs tools.annotations tools.crossref peg.ebnf tools.annotations tools.crossref help.topics
help.topics math.functions compiler.tree.optimizer math.functions compiler.tree.optimizer compiler.cfg.optimizer
compiler.cfg.optimizer fry ; fry ;
IN: vpri-talk IN: vpri-talk
CONSTANT: vpri-slides CONSTANT: vpri-slides

View File

@ -1,4 +1,4 @@
include vmpp/Config.unix include vm/Config.unix
PLAF_DLL_OBJS += vmpp/os-genunix.o vmpp/os-freebsd.o PLAF_DLL_OBJS += vm/os-genunix.o vm/os-freebsd.o
CFLAGS += -export-dynamic CFLAGS += -export-dynamic
LIBS = -L/usr/local/lib/ -lm $(X11_UI_LIBS) LIBS = -L/usr/local/lib/ -lm $(X11_UI_LIBS)

View File

@ -48,21 +48,21 @@ void iterate_relocations(code_block *compiled, relocation_iterator iter)
} }
/* Store a 32-bit value into a PowerPC LIS/ORI sequence */ /* Store a 32-bit value into a PowerPC LIS/ORI sequence */
static void store_address_2_2(cell *cell, cell value) static void store_address_2_2(cell *ptr, cell value)
{ {
cell[-1] = ((cell[-1] & ~0xffff) | ((value >> 16) & 0xffff)); ptr[-1] = ((ptr[-1] & ~0xffff) | ((value >> 16) & 0xffff));
cell[ 0] = ((cell[ 0] & ~0xffff) | (value & 0xffff)); ptr[ 0] = ((ptr[ 0] & ~0xffff) | (value & 0xffff));
} }
/* Store a value into a bitfield of a PowerPC instruction */ /* Store a value into a bitfield of a PowerPC instruction */
static void store_address_masked(cell *cell, fixnum value, cell mask, fixnum shift) static void store_address_masked(cell *ptr, fixnum value, cell mask, fixnum shift)
{ {
/* This is unaccurate but good enough */ /* This is unaccurate but good enough */
fixnum test = (fixnum)mask >> 1; fixnum test = (fixnum)mask >> 1;
if(value <= -test || value >= test) if(value <= -test || value >= test)
critical_error("Value does not fit inside relocation",0); critical_error("Value does not fit inside relocation",0);
*cell = ((*cell & ~mask) | ((value >> shift) & mask)); *ptr = ((*ptr & ~mask) | ((value >> shift) & mask));
} }
/* Perform a fixup on a code block */ /* Perform a fixup on a code block */

View File

@ -3,13 +3,13 @@
namespace factor namespace factor
{ {
extern int main(); extern "C" int main();
const char *vm_executable_path(void) const char *vm_executable_path(void)
{ {
static Dl_info info = {0}; static Dl_info info = {0};
if (!info.dli_fname) if (!info.dli_fname)
dladdr(main, &info); dladdr((void *)main, &info);
return info.dli_fname; return info.dli_fname;
} }