From 7327b8bdd49af79cf48a12875a2183d4ee8b03a6 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 20 Jul 2015 17:34:24 -0700 Subject: [PATCH] vocabs.loader: make require-all throw restarts. 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 | 1 - basis/vocabs/errors/errors.factor | 35 --------------------- basis/vocabs/errors/summary.txt | 1 - basis/vocabs/hierarchy/hierarchy.factor | 18 +++++------ basis/vocabs/refresh/refresh.factor | 6 ++-- core/source-files/errors/errors.factor | 13 +++++--- core/vocabs/loader/loader.factor | 3 ++ extra/mason/test/test.factor | 41 +++++++++++++++++++++---- 8 files changed, 58 insertions(+), 60 deletions(-) delete mode 100644 basis/vocabs/errors/authors.txt delete mode 100644 basis/vocabs/errors/errors.factor delete mode 100644 basis/vocabs/errors/summary.txt diff --git a/basis/vocabs/errors/authors.txt b/basis/vocabs/errors/authors.txt deleted file mode 100644 index d4f5d6b3ae..0000000000 --- a/basis/vocabs/errors/authors.txt +++ /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 index 454ed52b30..0000000000 --- a/basis/vocabs/errors/errors.factor +++ /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 - - - -: 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 index b7e7040366..0000000000 --- a/basis/vocabs/errors/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Loading vocabularies and batching errors diff --git a/basis/vocabs/hierarchy/hierarchy.factor b/basis/vocabs/hierarchy/hierarchy.factor index 5e0cbd6f95..e431671022 100644 --- a/basis/vocabs/hierarchy/hierarchy.factor +++ b/basis/vocabs/hierarchy/hierarchy.factor @@ -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 ) + : 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 ; diff --git a/basis/vocabs/refresh/refresh.factor b/basis/vocabs/refresh/refresh.factor index 3106bdc82b..8faaac7f7d 100644 --- a/basis/vocabs/refresh/refresh.factor +++ b/basis/vocabs/refresh/refresh.factor @@ -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 ; diff --git a/core/source-files/errors/errors.factor b/core/source-files/errors/errors.factor index 7336e4434e..7580c04b43 100644 --- a/core/source-files/errors/errors.factor +++ b/core/source-files/errors/errors.factor @@ -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 -- ) [ diff --git a/core/vocabs/loader/loader.factor b/core/vocabs/loader/loader.factor index 1e663d668c..a024655b21 100644 --- a/core/vocabs/loader/loader.factor +++ b/core/vocabs/loader/loader.factor @@ -133,6 +133,9 @@ PRIVATE> SYMBOL: blacklist +: require-all ( vocabs -- ) + V{ } clone blacklist [ [ require ] each ] with-variable ; +