]> gitweb.factorcode.org Git - factor.git/commitdiff
vocabs.loader: make require-all throw restarts.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 21 Jul 2015 00:34:24 +0000 (17:34 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 21 Jul 2015 00:35:22 +0000 (17:35 -0700)
We only want to catch the restarts in mason, so make a special
load-no-restarts that will catch the failures and print them out
the same way it worked before.

basis/vocabs/errors/authors.txt [deleted file]
basis/vocabs/errors/errors.factor [deleted file]
basis/vocabs/errors/summary.txt [deleted file]
basis/vocabs/hierarchy/hierarchy.factor
basis/vocabs/refresh/refresh.factor
core/source-files/errors/errors.factor
core/vocabs/loader/loader.factor
extra/mason/test/test.factor

diff --git a/basis/vocabs/errors/authors.txt b/basis/vocabs/errors/authors.txt
deleted file mode 100644 (file)
index d4f5d6b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
\ No newline at end of file
diff --git a/basis/vocabs/errors/errors.factor b/basis/vocabs/errors/errors.factor
deleted file mode 100644 (file)
index 454ed52..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: assocs continuations debugger io io.styles kernel
-namespaces sequences vocabs vocabs.loader ;
-IN: vocabs.errors
-
-<PRIVATE
-
-: vocab-heading. ( vocab -- )
-    nl
-    "==== " write
-    [ vocab-name ] [ lookup-vocab write-object ] bi ":" print
-    nl ;
-
-: load-error. ( triple -- )
-    [ first vocab-heading. ] [ second print-error ] bi ;
-
-SYMBOL: failures
-
-PRIVATE>
-
-: load-failures. ( failures -- )
-    [ load-error. nl ] each ;
-
-: require-all ( vocabs -- failures )
-    [
-        V{ } clone blacklist set
-        V{ } clone failures set
-        [
-            [ require ]
-            [ swap vocab-name failures get set-at ]
-            recover
-        ] each
-        failures get
-    ] with-scope ;
diff --git a/basis/vocabs/errors/summary.txt b/basis/vocabs/errors/summary.txt
deleted file mode 100644 (file)
index b7e7040..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Loading vocabularies and batching errors
index 5e0cbd6f95b49e48d87bd215458078077c537344..e4316710226765ade284ec35647aa66d140c279c 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays assocs combinators.short-circuit fry
 io.directories io.files io.files.types io.pathnames kernel make
 memoize namespaces sequences sorting splitting vocabs sets
-vocabs.loader vocabs.metadata vocabs.errors ;
+vocabs.loader vocabs.metadata ;
 IN: vocabs.hierarchy
 
 TUPLE: vocab-prefix name ;
@@ -133,22 +133,22 @@ PRIVATE>
 : disk-vocabs-in-root ( root -- seq )
     "" disk-vocabs-in-root/prefix ;
 
-: (load-from-root) ( root prefix -- failures )
+<PRIVATE
+
+: vocabs-to-load ( root prefix -- seq )
     disk-vocabs-in-root/prefix
-    [ don't-load? ] reject no-prefixes
-    require-all ;
+    [ don't-load? ] reject no-prefixes ;
+
+PRIVATE>
 
 : load-from-root ( root prefix -- )
-    (load-from-root) load-failures. ;
+    vocabs-to-load require-all ;
 
 : load-root ( root -- )
     "" load-from-root ;
 
-: (load) ( prefix -- failures )
-    [ vocab-roots get ] dip '[ _ (load-from-root) ] map concat ;
-
 : load ( prefix -- )
-    (load) load-failures. ;
+    [ vocab-roots get ] dip '[ _ load-from-root ] each ;
 
 : load-all ( -- )
     "" load ;
index 3106bdc82b719cf9424f86aa39f7ad21cab44f23..8faaac7f7d0bb3f24a94c648c4fa1df224ecbbda 100644 (file)
@@ -2,8 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs checksums checksums.crc32
 combinators.short-circuit io.encodings.utf8 io.files kernel
-namespaces sequences sets source-files vocabs vocabs.errors
-vocabs.loader ;
+namespaces sequences sets source-files vocabs vocabs.loader ;
 FROM: namespaces => set ;
 IN: vocabs.refresh
 
@@ -72,10 +71,9 @@ SYMBOL: changed-vocabs
     [
         union
         [ mark-unchanged-vocabs ]
-        [ require-all load-failures. ] bi
+        [ require-all ] bi
     ] 2bi ;
 
-
 : refresh ( prefix -- ) to-refresh do-refresh ;
 
 : refresh-all ( -- ) "" refresh ;
index 7336e4434ea76694f1a724f5ab4765848cfd04b4..7580c04b4300f467d0a4745b86919efb0bd8cc1b 100644 (file)
@@ -68,13 +68,18 @@ GENERIC: errors-changed ( observer -- )
 
 SYMBOL: error-observers
 
-[ V{ } clone error-observers set-global ] "source-files.errors" add-startup-hook
+[
+    V{ } clone error-observers set-global
+] "source-files.errors" add-startup-hook
 
-: add-error-observer ( observer -- ) error-observers get push ;
+: add-error-observer ( observer -- )
+    error-observers get push ;
 
-: remove-error-observer ( observer -- ) error-observers get remove-eq! drop ;
+: remove-error-observer ( observer -- )
+    error-observers get remove-eq! drop ;
 
-: notify-error-observers ( -- ) error-observers get [ errors-changed ] each ;
+: notify-error-observers ( -- )
+    error-observers get [ errors-changed ] each ;
 
 : delete-file-errors ( seq file type -- )
     [
index 1e663d668cbe5a386ad8358e6413586292181e61..a024655b214d7eddae83606db0e6159020bc1363 100644 (file)
@@ -133,6 +133,9 @@ PRIVATE>
 
 SYMBOL: blacklist
 
+: require-all ( vocabs -- )
+    V{ } clone blacklist [ [ require ] each ] with-variable ;
+
 <PRIVATE
 
 : add-to-blacklist ( error vocab -- )
index 465dd68ffa74021782b7dc1287fbf8a552c9d923..5959d4e5ab86b5695c81c3c330aa8700ffc537fc 100644 (file)
@@ -1,15 +1,44 @@
 ! Copyright (C) 2008, 2010 Eduardo Cavazos, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs benchmark bootstrap.stage2 command-line
-compiler.errors generic help.html help.lint io io.directories
-io.encodings.utf8 io.files kernel locals mason.common namespaces
-parser.notes sequences sets sorting source-files.errors system
-tools.errors tools.test tools.time vocabs.errors
-vocabs.hierarchy vocabs.refresh words ;
+compiler.errors continuations debugger fry generic help.html
+help.lint io io.directories io.encodings.utf8 io.files io.styles
+kernel locals mason.common namespaces parser.notes sequences
+sets sorting source-files.errors system tools.errors tools.test
+tools.time vocabs vocabs.hierarchy.private vocabs.loader
+vocabs.refresh words ;
 IN: mason.test
 
+: vocab-heading. ( vocab -- )
+    nl
+    "==== " write
+    [ vocab-name ] [ lookup-vocab write-object ] bi ":" print
+    nl ;
+
+: load-error. ( triple -- )
+    [ first vocab-heading. ] [ second print-error ] bi ;
+
+: load-failures. ( failures -- ) [ load-error. nl ] each ;
+
+: require-all-no-restarts ( vocabs -- failures )
+    V{ } clone blacklist [
+        V{ } clone [
+            '[
+                [ require ]
+                [ swap vocab-name _ set-at ] recover
+            ] each
+        ] keep
+    ] with-variable ;
+
+: load-from-root-no-restarts ( root prefix -- failures )
+    vocabs-to-load require-all-no-restarts ;
+
+: load-no-restarts ( prefix -- failures )
+    [ vocab-roots get ] dip
+    '[ _ load-from-root-no-restarts ] map concat ;
+
 : do-load ( -- )
-    "" (load)
+    "" load-no-restarts
     [ keys load-all-vocabs-file to-file ]
     [ load-all-errors-file utf8 [ load-failures. ] with-file-writer ]
     bi ;