new accessors

db4
Doug Coleman 2008-08-30 12:34:37 -05:00
parent 11f6bdcafb
commit 582aeaf73a
2 changed files with 18 additions and 15 deletions

View File

@ -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 } "." } ;

View File

@ -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 <pathname>
swap source-file-uses [ crossref? ] filter ;
[ path>> <pathname> ]
[ 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 ;
: <source-file> ( path -- source-file )
\ source-file new
swap >>path
<definitions> >>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 [ <source-file> ] 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
<source-file-error> rethrow