t load-help? set-global
- [ dup lookup-vocab [ ] [ no-vocab ] ?if drop ] require-hook [
+ [ dup lookup-vocab [ drop ] [ no-vocab ] if ] require-hook [
dictionary get values
[ docs-loaded?>> not ] filter
[ load-docs ] each
USING: vocabs.loader tools.test continuations vocabs math
kernel arrays sequences namespaces io.streams.string
parser source-files words assocs classes.tuple definitions
-debugger compiler.units accessors eval
+debugger compiler.units accessors eval vocabs.hierarchy
combinators vocabs.parser grouping vocabs.files vocabs.refresh ;
IN: vocabs.loader.tests
[ ] [ "vocabs.loader.test.m" require ] unit-test
[ t ] [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
+[ ] [ "vocabs" load ] unit-test
+[ f ] [ "vocabs.loader.test.p" lookup-vocab ] unit-test
[ ] [ "vocabs.loader.test.p.private" require ] unit-test
[ { "foo" } ] [ "vocabs.loader.test.p" words [ name>> ] map ] unit-test
: add-to-blacklist ( error vocab -- )
vocab-name blacklist get dup [ set-at ] [ 3drop ] if ;
-GENERIC: (load-vocab) ( name -- vocab )
+GENERIC: (require) ( name -- )
-M: vocab (load-vocab)
+M: vocab (require)
[
- dup source-loaded?>> +parsing+ eq? [
+ dup source-loaded?>> +parsing+ eq? [ drop ] [
dup source-loaded?>> [ dup load-source ] unless
dup docs-loaded?>> [ dup load-docs ] unless
- ] unless
+ drop
+ ] if
] [ [ swap add-to-blacklist ] keep rethrow ] recover ;
-M: vocab-link (load-vocab)
- vocab-name (load-vocab) ;
+M: vocab-link (require)
+ vocab-name (require) ;
-M: string (load-vocab) create-vocab (load-vocab) ;
+M: string (require) create-vocab (require) ;
PRIVATE>
[
- dup vocab-name blacklist get at* [ rethrow ] [
- drop dup find-vocab-root
- [ (load-vocab) ] [ dup lookup-vocab [ ] [ no-vocab ] ?if ] if
- ] if drop
+ dup vocab-name blacklist get at*
+ [ rethrow ]
+ [ drop dup find-vocab-root [ (require) ] [ drop ] if ]
+ if
] require-hook set-global
M: vocab-spec where vocab-source-path dup [ 1 2array ] when ;
--- /dev/null
+not loaded
M: vocab require name>> require ;
M: vocab-link require name>> require ;
-! When calling "foo.private" require, load "foo" instead, ! but only when
+! When calling "foo.private" require, load "foo" instead, but only when
! "foo.private" does not exist. The reason for this is that stage1 bootstrap
! starts out with some .private vocabs that contain primitives, and
! loading the public vocabs would cause circularity issues.