From 3cddca95ae6d09a447411b70bc44d861e800d30f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 13 Mar 2008 04:54:33 -0500 Subject: [PATCH] Simply core: don't call directory? and file-modified until after bootstrap --- core/parser/parser.factor | 1 - core/source-files/source-files-docs.factor | 12 ------ core/source-files/source-files.factor | 43 ++++++---------------- core/vocabs/loader/loader-tests.factor | 2 +- core/vocabs/loader/loader.factor | 21 ----------- extra/tools/vocabs/vocabs-docs.factor | 4 ++ extra/tools/vocabs/vocabs.factor | 38 ++++++++++++++++++- 7 files changed, 53 insertions(+), 68 deletions(-) diff --git a/core/parser/parser.factor b/core/parser/parser.factor index cc28f09855..50f8f582d3 100755 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -484,7 +484,6 @@ SYMBOL: interactive-vocabs : finish-parsing ( lines quot -- ) file get [ record-form ] keep - [ record-modified ] keep [ record-definitions ] keep record-checksum ; diff --git a/core/source-files/source-files-docs.factor b/core/source-files/source-files-docs.factor index 31c2defd19..505ca59425 100755 --- a/core/source-files/source-files-docs.factor +++ b/core/source-files/source-files-docs.factor @@ -9,10 +9,7 @@ $nl { $subsection source-files } "The class of source files:" { $subsection source-file } -"Testing if a source file has been changed on disk:" -{ $subsection source-modified? } "Words intended for the parser:" -{ $subsection record-modified } { $subsection record-checksum } { $subsection record-form } { $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 { $values { "source-file" source-file } { "lines" "a sequence of strings" } } { $description "Records the CRC32 checksm of the source file's contents." } diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 98438b48d8..f4428e4e8b 100755 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -1,44 +1,25 @@ -! Copyright (C) 2007 Slava Pestov. +! Copyright (C) 2007, 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: arrays definitions generic assocs kernel math -namespaces prettyprint sequences strings vectors words -quotations inspector io.styles io combinators sorting -splitting math.parser effects continuations debugger -io.files io.crc32 io.streams.string vocabs -hashtables graphs compiler.units io.encodings.utf8 ; +USING: arrays definitions generic assocs kernel math namespaces +prettyprint sequences strings vectors words quotations inspector +io.styles io combinators sorting splitting math.parser effects +continuations debugger io.files io.crc32 vocabs hashtables +graphs compiler.units io.encodings.utf8 ; IN: source-files SYMBOL: source-files TUPLE: source-file path -modified checksum +checksum 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 -- ) - swap lines-crc32 swap set-source-file-checksum ; + >r lines-crc32 r> set-source-file-checksum ; : (xref-source) ( source-file -- pathname uses ) - dup source-file-path swap source-file-uses - [ crossref? ] subset ; + dup source-file-path + swap source-file-uses [ crossref? ] subset ; : xref-source ( source-file -- ) (xref-source) crossref get add-vertex ; @@ -67,9 +48,7 @@ uses definitions ; : reset-checksums ( -- ) source-files get [ - swap ?resource-path dup exists? - [ - over record-modified + swap ?resource-path dup exists? [ utf8 file-lines swap record-checksum ] [ 2drop ] if ] assoc-each ; diff --git a/core/vocabs/loader/loader-tests.factor b/core/vocabs/loader/loader-tests.factor index f99bf94aa4..514e45f10f 100755 --- a/core/vocabs/loader/loader-tests.factor +++ b/core/vocabs/loader/loader-tests.factor @@ -3,7 +3,7 @@ IN: vocabs.loader.tests USING: vocabs.loader tools.test continuations vocabs math kernel arrays sequences namespaces io.streams.string parser source-files words assocs tuples definitions -debugger compiler.units ; +debugger compiler.units tools.vocabs ; ! This vocab should not exist, but just in case... [ ] [ diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 430aa066a8..fa9ff5b504 100755 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -48,27 +48,6 @@ M: string vocab-root M: vocab-link vocab-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? : source-was-loaded t swap set-vocab-source-loaded? ; diff --git a/extra/tools/vocabs/vocabs-docs.factor b/extra/tools/vocabs/vocabs-docs.factor index bdc3954e2e..ee82134379 100755 --- a/extra/tools/vocabs/vocabs-docs.factor +++ b/extra/tools/vocabs/vocabs-docs.factor @@ -25,6 +25,10 @@ ARTICLE: "tools.vocabs" "Vocabulary tools" 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 { $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." } ; diff --git a/extra/tools/vocabs/vocabs.factor b/extra/tools/vocabs/vocabs.factor index 21b8da8910..675a2e1d6e 100755 --- a/extra/tools/vocabs/vocabs.factor +++ b/extra/tools/vocabs/vocabs.factor @@ -3,9 +3,45 @@ USING: io.files kernel io.encodings.utf8 vocabs.loader vocabs sequences namespaces math.parser arrays hashtables assocs memoize inspector sorting splitting combinators source-files -io debugger continuations compiler.errors init ; +io debugger continuations compiler.errors init io.crc32 ; 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 ) [ dup ] swap compose { } map>assoc [ nip ] assoc-subset