Merge branch 'require-when' of git://github.com/littledan/Factor
commit
703ff5385d
|
@ -11,6 +11,9 @@ IN: bit-sets.tests
|
|||
T{ bit-set f ?{ f f t f t f } } intersect
|
||||
] unit-test
|
||||
|
||||
[ f ] [ T{ bit-set f ?{ t f f f t f } } null? ] unit-test
|
||||
[ t ] [ T{ bit-set f ?{ f f f f f f } } null? ] unit-test
|
||||
|
||||
[ T{ bit-set f ?{ t f t f f f } } ] [
|
||||
T{ bit-set f ?{ t t t f f f } }
|
||||
T{ bit-set f ?{ f t f f t t } } diff
|
||||
|
|
|
@ -20,8 +20,8 @@ IN: bootstrap.compiler
|
|||
"alien.remote-control" require
|
||||
] unless
|
||||
|
||||
"prettyprint" "alien.prettyprint" require-when
|
||||
"debugger" "alien.debugger" require-when
|
||||
{ "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when
|
||||
{ "boostrap.compiler" "debugger" } "alien.debugger" require-when
|
||||
|
||||
"cpu." cpu name>> append require
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
USING: vocabs.loader vocabs kernel ;
|
||||
IN: bootstrap.handbook
|
||||
|
||||
"bootstrap.help" "help.handbook" require-when
|
||||
{ "boostrap.handbook" "bootstrap.help" } "help.handbook" require-when
|
||||
|
|
|
@ -4,6 +4,6 @@ USING: vocabs.loader kernel io.thread threads
|
|||
compiler.utilities namespaces ;
|
||||
IN: bootstrap.threads
|
||||
|
||||
"debugger" "debugger.threads" require-when
|
||||
{ "bootstrap.threads" "debugger" } "debugger.threads" require-when
|
||||
|
||||
[ yield ] yield-hook set-global
|
||||
|
|
|
@ -4,7 +4,7 @@ USING: kernel vocabs vocabs.loader sequences system ;
|
|||
[ "bootstrap." prepend vocab ] all? [
|
||||
"ui.tools" require
|
||||
|
||||
"ui.backend.cocoa" "ui.backend.cocoa.tools" require-when
|
||||
{ "ui.backend.cocoa" } "ui.backend.cocoa.tools" require-when
|
||||
|
||||
"ui.tools.walker" require
|
||||
] when
|
||||
|
|
|
@ -404,4 +404,4 @@ FUNCTOR-SYNTAX: STRUCT:
|
|||
|
||||
USING: vocabs vocabs.loader ;
|
||||
|
||||
"prettyprint" "classes.struct.prettyprint" require-when
|
||||
{ "classes.struct" "prettyprint" } "classes.struct.prettyprint" require-when
|
||||
|
|
|
@ -194,6 +194,6 @@ ERROR: download-failed response ;
|
|||
: http-delete ( url -- response data )
|
||||
<delete-request> http-request ;
|
||||
|
||||
USING: vocabs vocabs.loader ;
|
||||
USE: vocabs.loader
|
||||
|
||||
"debugger" "http.client.debugger" require-when
|
||||
{ "http.client" "debugger" } "http.client.debugger" require-when
|
||||
|
|
|
@ -26,5 +26,5 @@ SYNTAX: MEMO:: (::) define-memoized ;
|
|||
"locals.fry"
|
||||
} [ require ] each
|
||||
|
||||
"prettyprint" "locals.definitions" require-when
|
||||
"prettyprint" "locals.prettyprint" require-when
|
||||
{ "locals" "prettyprint" } "locals.definitions" require-when
|
||||
{ "locals" "prettyprint" } "locals.prettyprint" require-when
|
||||
|
|
|
@ -64,4 +64,4 @@ M: rect contains-point?
|
|||
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "math.rectangles.prettyprint" require-when
|
||||
{ "math.rectangles" "prettyprint" } "math.rectangles.prettyprint" require-when
|
||||
|
|
|
@ -339,4 +339,4 @@ M: short-8 v*hs+
|
|||
M: int-4 v*hs+
|
||||
int-4-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op longlong-2-cast ; inline
|
||||
|
||||
"mirrors" "math.vectors.simd.mirrors" require-when
|
||||
{ "math.vectors.simd" "mirrors" } "math.vectors.simd.mirrors" require-when
|
||||
|
|
|
@ -628,6 +628,6 @@ SYNTAX: PEG:
|
|||
] append!
|
||||
] ;
|
||||
|
||||
USING: vocabs vocabs.loader ;
|
||||
USE: vocabs.loader
|
||||
|
||||
"debugger" "peg.debugger" require-when
|
||||
{ "debugger" "peg" } "peg.debugger" require-when
|
||||
|
|
|
@ -216,6 +216,6 @@ SYNTAX: R` CHAR: ` parsing-regexp ;
|
|||
SYNTAX: R{ CHAR: } parsing-regexp ;
|
||||
SYNTAX: R| CHAR: | parsing-regexp ;
|
||||
|
||||
USING: vocabs vocabs.loader ;
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "regexp.prettyprint" require-when
|
||||
{ "prettyprint" "regexp" } "regexp.prettyprint" require-when
|
||||
|
|
|
@ -173,6 +173,6 @@ SYNTAX: SPECIALIZED-ARRAYS:
|
|||
SYNTAX: SPECIALIZED-ARRAY:
|
||||
scan-c-type define-array-vocab use-vocab ;
|
||||
|
||||
"prettyprint" "specialized-arrays.prettyprint" require-when
|
||||
{ "specialized-arrays" "prettyprint" } "specialized-arrays.prettyprint" require-when
|
||||
|
||||
"mirrors" "specialized-arrays.mirrors" require-when
|
||||
{ "specialized-arrays" "mirrors" } "specialized-arrays.mirrors" require-when
|
||||
|
|
|
@ -35,4 +35,4 @@ ERROR: bad-declaration-error < inference-error declaration ;
|
|||
|
||||
ERROR: unbalanced-branches-error < inference-error word quots declareds actuals ;
|
||||
|
||||
"debugger" "stack-checker.errors.prettyprint" require-when
|
||||
{ "stack-checker.errors" "debugger" } "stack-checker.errors.prettyprint" require-when
|
||||
|
|
|
@ -164,6 +164,6 @@ SYNTAX: TYPED:
|
|||
SYNTAX: TYPED::
|
||||
(::) define-typed ;
|
||||
|
||||
USING: vocabs vocabs.loader ;
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "typed.prettyprint" require-when
|
||||
{ "typed" "prettyprint" } "typed.prettyprint" require-when
|
||||
|
|
|
@ -395,4 +395,4 @@ M: f request-focus-on 2drop ;
|
|||
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "ui.gadgets.prettyprint" require-when
|
||||
{ "ui.gadgets" "prettyprint" } "ui.gadgets.prettyprint" require-when
|
||||
|
|
|
@ -72,6 +72,6 @@ M: unix open-file [ open ] unix-system-call ;
|
|||
|
||||
<<
|
||||
|
||||
"debugger" "unix.debugger" require-when
|
||||
{ "unix" "debugger" } "unix.debugger" require-when
|
||||
|
||||
>>
|
||||
|
|
|
@ -185,4 +185,4 @@ SYNTAX: URL" lexer get skip-blank parse-string >url suffix! ;
|
|||
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "urls.prettyprint" require-when
|
||||
{ "urls" "prettyprint" } "urls.prettyprint" require-when
|
||||
|
|
|
@ -96,4 +96,4 @@ SYNTAX: GUID: scan string>guid suffix! ;
|
|||
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "windows.com.prettyprint" require-when
|
||||
{ "windows.com" "prettyprint" } "windows.com.prettyprint" require-when
|
||||
|
|
|
@ -33,4 +33,4 @@ SYMBOL: root
|
|||
: with-x ( display-string quot -- )
|
||||
[ init-x ] dip [ close-x ] [ ] cleanup ; inline
|
||||
|
||||
"io.backend.unix" "x11.io.unix" require-when
|
||||
{ "x11" "io.backend.unix" } "x11.io.unix" require-when
|
||||
|
|
|
@ -177,4 +177,4 @@ SYNTAX: [XML
|
|||
|
||||
USE: vocabs.loader
|
||||
|
||||
"inverse" "xml.syntax.inverse" require-when
|
||||
{ "xml.syntax" "inverse" } "xml.syntax.inverse" require-when
|
||||
|
|
|
@ -31,3 +31,6 @@ IN: hash-sets.tests
|
|||
[ f ] [ HS{ 1 2 3 } HS{ 2 3 } set= ] unit-test
|
||||
|
||||
[ HS{ 1 2 } HS{ 1 2 3 } ] [ HS{ 1 2 } clone dup clone [ 3 swap adjoin ] keep ] unit-test
|
||||
|
||||
[ t ] [ HS{ } null? ] unit-test
|
||||
[ f ] [ HS{ 1 } null? ] unit-test
|
||||
|
|
|
@ -18,6 +18,7 @@ M: hash-set delete table>> delete-at ; inline
|
|||
M: hash-set members table>> keys ; inline
|
||||
M: hash-set set-like drop dup hash-set? [ members <hash-set> ] unless ;
|
||||
M: hash-set clone table>> clone hash-set boa ;
|
||||
M: hash-set null? table>> assoc-empty? ;
|
||||
|
||||
M: sequence fast-set <hash-set> ;
|
||||
M: f fast-set drop H{ } clone hash-set boa ;
|
||||
|
|
|
@ -23,6 +23,8 @@ ARTICLE: "set-operations" "Operations on sets"
|
|||
adjoin
|
||||
delete
|
||||
}
|
||||
"To test if a set is the empty set:"
|
||||
{ $subsections null? }
|
||||
"Basic mathematical operations, which any type of set may override for efficiency:"
|
||||
{ $subsections
|
||||
diff
|
||||
|
@ -178,3 +180,7 @@ HELP: within
|
|||
HELP: without
|
||||
{ $values { "seq" sequence } { "set" set } { "subseq" sequence } }
|
||||
{ $description "Returns the subsequence of the given sequence consisting of things that are not members of the set. This may contain duplicates, if the sequence has duplicates." } ;
|
||||
|
||||
HELP: null?
|
||||
{ $values { "set" set } { "?" "a boolean" } }
|
||||
{ $description "Tests whether the given set is empty. This outputs " { $snippet "t" } " when given a null set of any type." } ;
|
||||
|
|
|
@ -61,3 +61,6 @@ IN: sets.tests
|
|||
[ f ] [ HS{ 1 2 3 1 2 1 } duplicates ] unit-test
|
||||
|
||||
[ H{ { 3 HS{ 1 2 } } } ] [ H{ } clone 1 3 pick adjoin-at 2 3 pick adjoin-at ] unit-test
|
||||
|
||||
[ t ] [ f null? ] unit-test
|
||||
[ f ] [ { 4 } null? ] unit-test
|
||||
|
|
|
@ -21,10 +21,13 @@ GENERIC: subset? ( set1 set2 -- ? )
|
|||
GENERIC: set= ( set1 set2 -- ? )
|
||||
GENERIC: duplicates ( set -- seq )
|
||||
GENERIC: all-unique? ( set -- ? )
|
||||
GENERIC: null? ( set -- ? )
|
||||
|
||||
! Defaults for some methods.
|
||||
! Override them for efficiency
|
||||
|
||||
M: set null? members null? ; inline
|
||||
|
||||
M: set set-like drop ; inline
|
||||
|
||||
M: set union
|
||||
|
@ -91,6 +94,9 @@ M: sequence set-like
|
|||
|
||||
M: sequence members
|
||||
[ pruned ] keep like ;
|
||||
|
||||
M: sequence null?
|
||||
empty? ; inline
|
||||
|
||||
: combine ( sets -- set )
|
||||
[ f ]
|
||||
|
|
|
@ -114,10 +114,10 @@ HELP: require
|
|||
{ $notes "To unconditionally reload a vocabulary, use " { $link reload } ". To reload changed source files only, use the words in " { $link "vocabs.refresh" } "." } ;
|
||||
|
||||
HELP: require-when
|
||||
{ $values { "if" "a vocabulary specifier" } { "then" "a vocabulary specifier" } }
|
||||
{ $description "Loads the " { $snippet "then" } " vocabulary if it is not loaded and the " { $snippet "if" } " vocabulary is. If the " { $snippet "if" } " vocabulary is not loaded now, but it is later, then the " { $snippet "then" } " vocabulary will be loaded along with it at that time." }
|
||||
{ $notes "This is used to express a joint dependency of vocabularies. If vocabularies " { $snippet "a" } " and " { $snippet "b" } " use code in vocabulary " { $snippet "c" } " to interact, then the following line can be placed in " { $snippet "a" } " in order express the dependency."
|
||||
{ $code "\"b\" \"c\" require-when" } } ;
|
||||
{ $values { "if" "a sequence of vocabulary specifiers" } { "then" "a vocabulary specifier" } }
|
||||
{ $description "Loads the " { $snippet "then" } " vocabulary if it is not loaded and all of the " { $snippet "if" } " vocabulary is. If some of the " { $snippet "if" } " vocabularies are not loaded now, but they are later, then the " { $snippet "then" } " vocabulary will be loaded along with the final one." }
|
||||
{ $notes "This is used to express a joint dependency of vocabularies. If vocabularies " { $snippet "a" } " and " { $snippet "b" } " use code in vocabulary " { $snippet "c" } " to interact, then the following line, which can be placed in " { $snippet "a" } " or " { $snippet "b" } ", expresses the dependency."
|
||||
{ $code "{ \"a\" \"b\" } \"c\" require-when" } } ;
|
||||
|
||||
HELP: run
|
||||
{ $values { "vocab" "a vocabulary specifier" } }
|
||||
|
|
|
@ -66,10 +66,19 @@ DEFER: require
|
|||
|
||||
<PRIVATE
|
||||
|
||||
: load-conditional-requires ( vocab-name -- )
|
||||
conditional-requires get
|
||||
[ at [ require ] each ]
|
||||
[ delete-at ] 2bi ;
|
||||
SYMBOL: require-when-vocabs
|
||||
require-when-vocabs [ HS{ } clone ] initialize
|
||||
|
||||
SYMBOL: require-when-table
|
||||
require-when-table [ V{ } clone ] initialize
|
||||
|
||||
: load-conditional-requires ( vocab -- )
|
||||
vocab-name require-when-vocabs get in? [
|
||||
require-when-table get [
|
||||
[ [ vocab ] all? ] dip
|
||||
[ require ] curry when
|
||||
] assoc-each
|
||||
] when ;
|
||||
|
||||
: load-source ( vocab -- )
|
||||
dup check-vocab-hook get call( vocab -- )
|
||||
|
@ -79,7 +88,7 @@ DEFER: require
|
|||
[ +parsing+ >>source-loaded? ] dip
|
||||
[ % ] [ call( -- ) ] if-bootstrapping
|
||||
+done+ >>source-loaded?
|
||||
vocab-name load-conditional-requires
|
||||
load-conditional-requires
|
||||
] [ ] [ f >>source-loaded? ] cleanup ;
|
||||
|
||||
: load-docs ( vocab -- )
|
||||
|
@ -97,10 +106,12 @@ PRIVATE>
|
|||
load-vocab drop ;
|
||||
|
||||
: require-when ( if then -- )
|
||||
over vocab
|
||||
[ nip require ]
|
||||
[ swap conditional-requires get [ swap suffix ] change-at ]
|
||||
if ;
|
||||
over [ vocab ] all? [
|
||||
require drop
|
||||
] [
|
||||
[ drop [ require-when-vocabs get adjoin ] each ]
|
||||
[ 2array require-when-table get push ] 2bi
|
||||
] if ;
|
||||
|
||||
: reload ( name -- )
|
||||
dup vocab
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
USE: vocabs.loader
|
||||
IN: vocabs.loader.test.m
|
||||
|
||||
"vocabs.loader.test.o" "vocabs.loader.test.n" require-when
|
||||
{ "vocabs.loader.test.o" "vocabs.loader.test.m" }
|
||||
"vocabs.loader.test.n" require-when
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors assocs strings kernel sorting namespaces
|
||||
sequences definitions sets ;
|
||||
sequences definitions sets combinators ;
|
||||
IN: vocabs
|
||||
|
||||
SYMBOL: dictionary
|
||||
|
@ -83,9 +83,6 @@ ERROR: bad-vocab-name name ;
|
|||
: check-vocab-name ( name -- name )
|
||||
dup string? [ bad-vocab-name ] unless ;
|
||||
|
||||
SYMBOL: conditional-requires
|
||||
conditional-requires [ H{ } clone ] initialize
|
||||
|
||||
: create-vocab ( name -- vocab )
|
||||
check-vocab-name
|
||||
dictionary get [ <vocab> ] cache
|
||||
|
|
|
@ -112,6 +112,6 @@ PRIVATE>
|
|||
M: game-loop dispose
|
||||
stop-loop ;
|
||||
|
||||
USING: vocabs vocabs.loader ;
|
||||
USE: vocabs.loader
|
||||
|
||||
"prettyprint" "game.loop.prettyprint" require-when
|
||||
{ "game.loop" "prettyprint" } "game.loop.prettyprint" require-when
|
||||
|
|
|
@ -632,4 +632,4 @@ M: program-instance dispose
|
|||
[ world>> ] [ program>> instances>> ] [ ] tri ?delete-at
|
||||
reset-memos ;
|
||||
|
||||
"prettyprint" "gpu.shaders.prettyprint" require-when
|
||||
{ "gpu.shaders" "prettyprint" } "gpu.shaders.prettyprint" require-when
|
||||
|
|
Loading…
Reference in New Issue