new accessors
parent
11f6bdcafb
commit
582aeaf73a
|
|
@ -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." }
|
{ $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:"
|
{ $class-description "Instances retain information about loaded source files, and have the following slots:"
|
||||||
{ $list
|
{ $list
|
||||||
{ { $link source-file-path } " - a pathname string." }
|
{ { $snippet "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." }
|
{ { $snippet "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." }
|
{ { $snippet "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 "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." } ;
|
{ $description "Records information to the source file after an incomplete parse which ended with an error." } ;
|
||||||
|
|
||||||
HELP: file
|
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 } "." } ;
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ checksum
|
||||||
uses definitions ;
|
uses definitions ;
|
||||||
|
|
||||||
: record-checksum ( lines source-file -- )
|
: 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 )
|
: (xref-source) ( source-file -- pathname uses )
|
||||||
dup source-file-path <pathname>
|
[ path>> <pathname> ]
|
||||||
swap source-file-uses [ crossref? ] filter ;
|
[ uses>> [ crossref? ] filter ] bi ;
|
||||||
|
|
||||||
: xref-source ( source-file -- )
|
: xref-source ( source-file -- )
|
||||||
(xref-source) crossref get add-vertex ;
|
(xref-source) crossref get add-vertex ;
|
||||||
|
|
@ -31,20 +31,22 @@ uses definitions ;
|
||||||
source-files get [ nip xref-source ] assoc-each ;
|
source-files get [ nip xref-source ] assoc-each ;
|
||||||
|
|
||||||
: record-form ( quot source-file -- )
|
: record-form ( quot source-file -- )
|
||||||
dup unxref-source
|
tuck unxref-source
|
||||||
swap quot-uses keys over set-source-file-uses
|
quot-uses keys >>uses
|
||||||
xref-source ;
|
xref-source ;
|
||||||
|
|
||||||
: record-definitions ( file -- )
|
: record-definitions ( file -- )
|
||||||
new-definitions get swap set-source-file-definitions ;
|
new-definitions get >>definitions drop ;
|
||||||
|
|
||||||
: <source-file> ( path -- source-file )
|
: <source-file> ( path -- source-file )
|
||||||
\ source-file new
|
\ source-file new
|
||||||
swap >>path
|
swap >>path
|
||||||
<definitions> >>definitions ;
|
<definitions> >>definitions ;
|
||||||
|
|
||||||
|
ERROR: invalid-source-file-path path ;
|
||||||
|
|
||||||
: source-file ( path -- source-file )
|
: 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 ;
|
source-files get [ <source-file> ] cache ;
|
||||||
|
|
||||||
: reset-checksums ( -- )
|
: reset-checksums ( -- )
|
||||||
|
|
@ -70,8 +72,9 @@ M: pathname forget*
|
||||||
pathname-string forget-source ;
|
pathname-string forget-source ;
|
||||||
|
|
||||||
: rollback-source-file ( file -- )
|
: 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
|
SYMBOL: file
|
||||||
|
|
||||||
|
|
@ -87,7 +90,7 @@ TUPLE: source-file-error file error ;
|
||||||
[
|
[
|
||||||
swap source-file
|
swap source-file
|
||||||
dup file set
|
dup file set
|
||||||
source-file-definitions old-definitions set
|
definitions>> old-definitions set
|
||||||
[
|
[
|
||||||
file get rollback-source-file
|
file get rollback-source-file
|
||||||
<source-file-error> rethrow
|
<source-file-error> rethrow
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue