Rename (load-vocab) to (require), add tags.txt for "p" vocab loader test. Code formatting.

db4
Doug Coleman 2011-11-02 18:07:22 -07:00
parent 69ffe6377a
commit 1eed9203bb
5 changed files with 18 additions and 14 deletions

View File

@ -9,7 +9,7 @@ IN: bootstrap.help
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

View File

@ -1,7 +1,7 @@
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
@ -185,6 +185,8 @@ forget-junk
[ ] [ "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

View File

@ -138,28 +138,29 @@ SYMBOL: blacklist
: 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 ;

View File

@ -0,0 +1 @@
not loaded

View File

@ -140,7 +140,7 @@ GENERIC: require ( object -- )
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.