Simply core: don't call directory? and file-modified until after bootstrap

db4
Slava Pestov 2008-03-13 04:54:33 -05:00
parent 96c4aaf94a
commit 3cddca95ae
7 changed files with 53 additions and 68 deletions

View File

@ -484,7 +484,6 @@ SYMBOL: interactive-vocabs
: finish-parsing ( lines quot -- ) : finish-parsing ( lines quot -- )
file get file get
[ record-form ] keep [ record-form ] keep
[ record-modified ] keep
[ record-definitions ] keep [ record-definitions ] keep
record-checksum ; record-checksum ;

View File

@ -9,10 +9,7 @@ $nl
{ $subsection source-files } { $subsection source-files }
"The class of source files:" "The class of source files:"
{ $subsection source-file } { $subsection source-file }
"Testing if a source file has been changed on disk:"
{ $subsection source-modified? }
"Words intended for the parser:" "Words intended for the parser:"
{ $subsection record-modified }
{ $subsection record-checksum } { $subsection record-checksum }
{ $subsection record-form } { $subsection record-form }
{ $subsection xref-source } { $subsection xref-source }
@ -41,15 +38,6 @@ HELP: source-file
} }
} ; } ;
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 modification time and CRC32 checksum of the file's contents against previously-recorded values." } ;
HELP: record-modified
{ $values { "source-file" source-file } }
{ $description "Records the modification time of the source file." }
$low-level-note ;
HELP: record-checksum HELP: record-checksum
{ $values { "source-file" source-file } { "lines" "a sequence of strings" } } { $values { "source-file" source-file } { "lines" "a sequence of strings" } }
{ $description "Records the CRC32 checksm of the source file's contents." } { $description "Records the CRC32 checksm of the source file's contents." }

View File

@ -1,44 +1,25 @@
! Copyright (C) 2007 Slava Pestov. ! Copyright (C) 2007, 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays definitions generic assocs kernel math USING: arrays definitions generic assocs kernel math namespaces
namespaces prettyprint sequences strings vectors words prettyprint sequences strings vectors words quotations inspector
quotations inspector io.styles io combinators sorting io.styles io combinators sorting splitting math.parser effects
splitting math.parser effects continuations debugger continuations debugger io.files io.crc32 vocabs hashtables
io.files io.crc32 io.streams.string vocabs graphs compiler.units io.encodings.utf8 ;
hashtables graphs compiler.units io.encodings.utf8 ;
IN: source-files IN: source-files
SYMBOL: source-files SYMBOL: source-files
TUPLE: source-file TUPLE: source-file
path path
modified checksum checksum
uses definitions ; uses definitions ;
: (source-modified?) ( path modified checksum -- ? )
pick file-modified rot [ 0 or ] 2apply >
[ swap utf8 file-lines lines-crc32 = not ] [ 2drop f ] if ;
: source-modified? ( path -- ? )
dup source-files get at [
dup source-file-path ?resource-path
over source-file-modified
rot source-file-checksum
(source-modified?)
] [
resource-exists?
] ?if ;
: record-modified ( source-file -- )
dup source-file-path ?resource-path file-modified
swap set-source-file-modified ;
: record-checksum ( lines source-file -- ) : record-checksum ( lines source-file -- )
swap lines-crc32 swap set-source-file-checksum ; >r lines-crc32 r> set-source-file-checksum ;
: (xref-source) ( source-file -- pathname uses ) : (xref-source) ( source-file -- pathname uses )
dup source-file-path <pathname> swap source-file-uses dup source-file-path <pathname>
[ crossref? ] subset ; swap source-file-uses [ crossref? ] subset ;
: xref-source ( source-file -- ) : xref-source ( source-file -- )
(xref-source) crossref get add-vertex ; (xref-source) crossref get add-vertex ;
@ -67,9 +48,7 @@ uses definitions ;
: reset-checksums ( -- ) : reset-checksums ( -- )
source-files get [ source-files get [
swap ?resource-path dup exists? swap ?resource-path dup exists? [
[
over record-modified
utf8 file-lines swap record-checksum utf8 file-lines swap record-checksum
] [ 2drop ] if ] [ 2drop ] if
] assoc-each ; ] assoc-each ;

View File

@ -3,7 +3,7 @@ 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 tuples definitions parser source-files words assocs tuples definitions
debugger compiler.units ; debugger compiler.units tools.vocabs ;
! This vocab should not exist, but just in case... ! This vocab should not exist, but just in case...
[ ] [ [ ] [

View File

@ -48,27 +48,6 @@ M: string vocab-root
M: vocab-link vocab-root M: vocab-link vocab-root
vocab-link-root ; vocab-link-root ;
: vocab-tests ( vocab -- tests )
dup vocab-root [
[
f >vocab-link dup
dup "-tests.factor" vocab-dir+ vocab-path+
dup resource-exists? [ , ] [ drop ] if
dup vocab-dir "tests" path+ vocab-path+ dup
?resource-path directory keys [ ".factor" tail? ] subset
[ path+ , ] with each
] { } make
] [ drop f ] if ;
: vocab-files ( vocab -- seq )
f >vocab-link [
dup vocab-source-path [ , ] when*
dup vocab-docs-path [ , ] when*
vocab-tests %
] { } make ;
SYMBOL: load-help? SYMBOL: load-help?
: source-was-loaded t swap set-vocab-source-loaded? ; : source-was-loaded t swap set-vocab-source-loaded? ;

View File

@ -25,6 +25,10 @@ ARTICLE: "tools.vocabs" "Vocabulary tools"
ABOUT: "tools.vocabs" ABOUT: "tools.vocabs"
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 HELP: refresh
{ $values { "prefix" string } } { $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." } ; { $description "Reloads source files and documentation belonging to loaded vocabularies whose names are prefixed by " { $snippet "prefix" } " which have been modified on disk." } ;

View File

@ -3,9 +3,45 @@
USING: io.files kernel io.encodings.utf8 vocabs.loader vocabs USING: io.files kernel io.encodings.utf8 vocabs.loader vocabs
sequences namespaces math.parser arrays hashtables assocs sequences namespaces math.parser arrays hashtables assocs
memoize inspector sorting splitting combinators source-files memoize inspector sorting splitting combinators source-files
io debugger continuations compiler.errors init ; io debugger continuations compiler.errors init io.crc32 ;
IN: tools.vocabs IN: tools.vocabs
: vocab-tests-file, ( vocab -- )
dup "-tests.factor" vocab-dir+ vocab-path+
dup resource-exists? [ , ] [ drop ] if ;
: vocab-tests-dir, ( vocab -- )
dup vocab-dir "tests" path+ vocab-path+
dup resource-exists? [
dup ?resource-path directory keys
[ ".factor" tail? ] subset
[ path+ , ] with each
] [ drop ] if ;
: vocab-tests ( vocab -- tests )
dup vocab-root [
[
f >vocab-link dup
vocab-tests-file,
vocab-tests-dir,
] { } make
] [ drop f ] if ;
: vocab-files ( vocab -- seq )
f >vocab-link [
dup vocab-source-path [ , ] when*
dup vocab-docs-path [ , ] when*
vocab-tests %
] { } make ;
: source-modified? ( path -- ? )
dup source-files get at [
dup source-file-path ?resource-path utf8 file-lines lines-crc32
swap source-file-checksum = not
] [
resource-exists?
] ?if ;
: modified ( seq quot -- seq ) : modified ( seq quot -- seq )
[ dup ] swap compose { } map>assoc [ dup ] swap compose { } map>assoc
[ nip ] assoc-subset [ nip ] assoc-subset