]> gitweb.factorcode.org Git - factor.git/commitdiff
Clean up formatting, rename load-vocab-hook to require-hook. Add a unit test for...
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 2 Nov 2011 23:30:00 +0000 (16:30 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 2 Nov 2011 23:31:42 +0000 (16:31 -0700)
basis/bootstrap/help/help.factor
basis/tools/deploy/shaker/shaker.factor
core/vocabs/loader/loader-tests.factor
core/vocabs/loader/loader.factor
core/vocabs/vocabs-docs.factor
core/vocabs/vocabs.factor

index 9004d556f69d0849e2708f1618da3f85212b528f..0b85468b08598f7baff56791df871232753894db 100644 (file)
@@ -9,7 +9,7 @@ IN: bootstrap.help
 
     t load-help? set-global
 
-    [ dup lookup-vocab [ ] [ no-vocab ] ?if ] load-vocab-hook [
+    [ dup lookup-vocab [ ] [ no-vocab ] ?if ] require-hook [
         dictionary get values
         [ docs-loaded?>> not ] filter
         [ load-docs ] each
index 38109cd10d46e5e24f24556a1b32a5dc70aab8c0..05234e544b38db14592349f100e118f0b5c0e3d7 100755 (executable)
@@ -371,7 +371,7 @@ IN: tools.deploy.shaker
                 source-files.errors:error-types
                 source-files.errors:error-observers
                 vocabs:dictionary
-                vocabs:load-vocab-hook
+                vocabs:require-hook
                 vocabs:vocab-observers
                 vocabs.loader:add-vocab-root-hook
                 word
index d5fbacf5f1f45103803e45b8ca9e8ed6713de127..dd0bc493d9acac56ffbe93564ec8fa354ba84e3e 100644 (file)
@@ -185,6 +185,9 @@ forget-junk
 [ ] [ "vocabs.loader.test.m" require ] unit-test
 [ t ] [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
 
+[ ] [ "vocabs.loader.test.p.private" require ] unit-test
+[ { "foo" } ] [ "vocabs.loader.test.p" words [ name>> ] map ] unit-test
+
 [
-    "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each
+    "mnop" [ "vocabs.loader.test." swap suffix forget-vocab ] each
 ] with-compilation-unit
index 5e6a3259e54d0a4a74a6969f119e15891d505a43..d5a344f6bd2ddcff78a0f5871877a2520786d826 100644 (file)
@@ -159,7 +159,7 @@ PRIVATE>
     dup vocab-name blacklist get at* [ rethrow ] [
         drop dup find-vocab-root
         [ (load-vocab) ] [ dup lookup-vocab [ ] [ no-vocab ] ?if ] if
-    ] if
-] load-vocab-hook set-global
+    ] if drop
+] require-hook set-global
 
 M: vocab-spec where vocab-source-path dup [ 1 2array ] when ;
index c67cdb450856b317319ee6c223260047849c7449..301b4b838b645ae2f484f3f8ce1f8dea40b03c1c 100644 (file)
@@ -76,8 +76,8 @@ HELP: forget-vocab
 { $description "Removes a vocabulary. All words in the vocabulary are forgotten." }
 { $notes "This word must be called from inside " { $link with-compilation-unit } "." } ;
 
-HELP: load-vocab-hook
-{ $var-description { $quotation "( name -- vocab )" } " which loads a vocabulary. This quotation is called by " { $link load-vocab } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
+HELP: require-hook
+{ $var-description { $quotation "( name -- )" } " which loads a vocabulary. This quotation is called by " { $link require } ". The default value should not need to be changed; this functionality is implemented via a hook stored in a variable to break a circular dependency which would otherwise exist from " { $vocab-link "vocabs" } " to " { $vocab-link "vocabs.loader" } " to " { $vocab-link "parser" } " back to " { $vocab-link "vocabs" } "." } ;
 
 HELP: words-named
 { $values { "str" string } { "seq" "a sequence of words" } }
index 7f1200ea70c436aea85bfc62eb61dfc710af0220..1b3c15a9b4cd9e21ab8ef637617830b897ad477f 100644 (file)
@@ -125,34 +125,33 @@ M: object >vocab-link dup lookup-vocab [ ] [ <vocab-link> ] ?if ;
 
 M: vocab-spec forget* forget-vocab ;
 
-SYMBOL: load-vocab-hook ! ( name -- vocab )
+SYMBOL: require-hook
 
 PREDICATE: runnable-vocab < vocab
     vocab-main >boolean ;
 
 INSTANCE: vocab-spec definition
 
-: call-load-vocab-hook ( name -- )
-    load-vocab-hook get call( name -- vocab ) drop ;
+: call-require-hook ( name -- )
+    require-hook get call( name -- ) ;
 
 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 "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.
+! 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.
 M: string require ( vocab -- )
     dup ".private" ?tail [
-        over lookup-vocab [
-            2drop
-        ] [
-            nip call-load-vocab-hook
-        ] if
+        over lookup-vocab
+        [ 2drop ]
+        [ nip call-require-hook ]
+        if
     ] [
-        nip call-load-vocab-hook
+        nip call-require-hook
     ] if ;
 
 : load-vocab ( name -- vocab )