Change require-all for Ed

db4
Slava Pestov 2008-02-05 19:01:19 -06:00
parent 687cd78603
commit 038578939f
3 changed files with 30 additions and 35 deletions

View File

@ -124,15 +124,12 @@ 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." } ;
HELP: refresh-all-error
{ $values { "vocabs" "a sequence of vocabularies" } }
{ $description "Throws a " { $link require-all-error } "." }
{ $error-description "Thrown by " { $link require-all } " if one or more vocabulary failed to load." } ;
HELP: refresh-all
{ $description "Reloads source files and documentation for all loaded vocabularies which have been modified on disk." } ;
{ refresh refresh-all } related-words
HELP: vocab-file-contents
{ $values { "vocab" "a vocabulary specifier" } { "name" string } { "seq" "a sequence of lines, or " { $link f } } }
{ $description "Outputs the contents of the file named " { $snippet "name" } " from the vocabulary's directory, or " { $link f } " if the file does not exist." } ;
HELP: set-vocab-file-contents
{ $values { "seq" "a sequence of lines" } { "vocab" "a vocabulary specifier" } { "name" string } }
{ $description "Stores a sequence of lines to the file named " { $snippet "name" } " from the vocabulary's directory." } ;

View File

@ -148,16 +148,31 @@ SYMBOL: load-help?
dup update-roots
dup modified-sources swap modified-docs ;
: require-restart { { "Ignore this vocabulary" t } } ;
: load-error. ( vocab error -- )
"While loading " swap dup >vocab-link write-object ":" print
print-error ;
: require-all ( seq -- )
[
TUPLE: require-all-error vocabs ;
: require-all-error ( vocabs -- )
\ require-all-error construct-boa throw ;
M: require-all-error summary
drop "The require-all operation failed" ;
: require-all ( vocabs -- )
dup length 1 = [ first require ] [
[
[ require ]
[ require-restart rethrow-restarts 2drop ]
recover
] each
] with-compiler-errors ;
[
[ [ require ] [ 2array , ] recover ] each
] { } make
dup empty? [ drop ] [
"==== LOAD ERRORS:" print
dup [ nl load-error. ] assoc-each
keys require-all-error
] if
] with-compiler-errors
] if ;
: do-refresh ( modified-sources modified-docs -- )
2dup
@ -190,22 +205,3 @@ load-vocab-hook set-global
M: vocab where vocab-where ;
M: vocab-link where vocab-where ;
: vocab-file-contents ( vocab name -- seq )
vocab-path+ dup [
?resource-path dup exists? [
<file-reader> lines
] [
drop f
] if
] when ;
: set-vocab-file-contents ( seq vocab name -- )
dupd vocab-path+ [
?resource-path
<file-writer> [ [ print ] each ] with-stream
] [
"The " swap vocab-name
" vocabulary was not loaded from the file system"
3append throw
] ?if ;

View File

@ -10,3 +10,5 @@ IN: bootstrap.io
{ [ wince? ] [ "windows.ce" ] }
} cond append require
] when
"vocabs.monitor" require