diff --git a/core/source-files/source-files-docs.factor b/core/source-files/source-files-docs.factor index 2f2f8fd0c0..89ffbfd795 100755 --- a/core/source-files/source-files-docs.factor +++ b/core/source-files/source-files-docs.factor @@ -30,10 +30,10 @@ HELP: source-file { $description "Outputs the source file associated to a path name, creating the source file first if it doesn't exist. Source files are retained in the " { $link source-files } " variable." } { $class-description "Instances retain information about loaded source files, and have the following slots:" { $list - { { $link source-file-path } " - a pathname string." } - { { $link source-file-checksum } " - the CRC32 checksum of the source file's contents at the time it was most recently loaded." } - { { $link source-file-uses } " - an assoc whose keys are words referenced from this source file's top level form." } - { { $link source-file-definitions } " - a pair of assocs, containing definitions and classes defined in this source file, respectively" } + { { $snippet "path" } " - a pathname string." } + { { $snippet "checksum" } " - the CRC32 checksum of the source file's contents at the time it was most recently loaded." } + { { $snippet "uses" } " - an assoc whose keys are words referenced from this source file's top level form." } + { { $snippet "definitions" } " - a pair of assocs, containing definitions and classes defined in this source file, respectively" } } } ; @@ -78,4 +78,4 @@ HELP: rollback-source-file { $description "Records information to the source file after an incomplete parse which ended with an error." } ; HELP: file -{ $var-description "Stores the " { $link source-file } " being parsed. The " { $link source-file-path } " of this object comes from the input parameter to " { $link with-source-file } "." } ; +{ $var-description "Stores the " { $link source-file } " being parsed. The " { $snippet "path" } " of this object comes from the input parameter to " { $link with-source-file } "." } ; diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 50c79fc2c6..aa2cd563a5 100755 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -15,11 +15,11 @@ checksum uses definitions ; : record-checksum ( lines source-file -- ) - >r crc32 checksum-lines r> set-source-file-checksum ; + [ crc32 checksum-lines ] dip (>>checksum) ; : (xref-source) ( source-file -- pathname uses ) - dup source-file-path - swap source-file-uses [ crossref? ] filter ; + [ path>> ] + [ uses>> [ crossref? ] filter ] bi ; : xref-source ( source-file -- ) (xref-source) crossref get add-vertex ; @@ -31,20 +31,22 @@ uses definitions ; source-files get [ nip xref-source ] assoc-each ; : record-form ( quot source-file -- ) - dup unxref-source - swap quot-uses keys over set-source-file-uses + tuck unxref-source + quot-uses keys >>uses xref-source ; : record-definitions ( file -- ) - new-definitions get swap set-source-file-definitions ; + new-definitions get >>definitions drop ; : ( path -- source-file ) \ source-file new swap >>path >>definitions ; +ERROR: invalid-source-file-path path ; + : source-file ( path -- source-file ) - dup string? [ "Invalid source file path" throw ] unless + dup string? [ invalid-source-file-path ] unless source-files get [ ] cache ; : reset-checksums ( -- ) @@ -70,8 +72,9 @@ M: pathname forget* pathname-string forget-source ; : rollback-source-file ( file -- ) - dup source-file-definitions new-definitions get [ assoc-union ] 2map - swap set-source-file-definitions ; + [ + new-definitions get [ assoc-union ] 2map + ] change-definitions drop ; SYMBOL: file @@ -87,7 +90,7 @@ TUPLE: source-file-error file error ; [ swap source-file dup file set - source-file-definitions old-definitions set + definitions>> old-definitions set [ file get rollback-source-file rethrow