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
|
T{ bit-set f ?{ f f t f t f } } intersect
|
||||||
] unit-test
|
] 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 f t f f f } } ] [
|
||||||
T{ bit-set f ?{ t t 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
|
T{ bit-set f ?{ f t f f t t } } diff
|
||||||
|
|
|
@ -20,8 +20,8 @@ IN: bootstrap.compiler
|
||||||
"alien.remote-control" require
|
"alien.remote-control" require
|
||||||
] unless
|
] unless
|
||||||
|
|
||||||
"prettyprint" "alien.prettyprint" require-when
|
{ "boostrap.compiler" "prettyprint" } "alien.prettyprint" require-when
|
||||||
"debugger" "alien.debugger" require-when
|
{ "boostrap.compiler" "debugger" } "alien.debugger" require-when
|
||||||
|
|
||||||
"cpu." cpu name>> append require
|
"cpu." cpu name>> append require
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: vocabs.loader vocabs kernel ;
|
USING: vocabs.loader vocabs kernel ;
|
||||||
IN: bootstrap.handbook
|
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 ;
|
compiler.utilities namespaces ;
|
||||||
IN: bootstrap.threads
|
IN: bootstrap.threads
|
||||||
|
|
||||||
"debugger" "debugger.threads" require-when
|
{ "bootstrap.threads" "debugger" } "debugger.threads" require-when
|
||||||
|
|
||||||
[ yield ] yield-hook set-global
|
[ yield ] yield-hook set-global
|
||||||
|
|
|
@ -4,7 +4,7 @@ USING: kernel vocabs vocabs.loader sequences system ;
|
||||||
[ "bootstrap." prepend vocab ] all? [
|
[ "bootstrap." prepend vocab ] all? [
|
||||||
"ui.tools" require
|
"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
|
"ui.tools.walker" require
|
||||||
] when
|
] when
|
||||||
|
|
|
@ -404,4 +404,4 @@ FUNCTOR-SYNTAX: STRUCT:
|
||||||
|
|
||||||
USING: vocabs vocabs.loader ;
|
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 )
|
: http-delete ( url -- response data )
|
||||||
<delete-request> http-request ;
|
<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"
|
"locals.fry"
|
||||||
} [ require ] each
|
} [ require ] each
|
||||||
|
|
||||||
"prettyprint" "locals.definitions" require-when
|
{ "locals" "prettyprint" } "locals.definitions" require-when
|
||||||
"prettyprint" "locals.prettyprint" require-when
|
{ "locals" "prettyprint" } "locals.prettyprint" require-when
|
||||||
|
|
|
@ -64,4 +64,4 @@ M: rect contains-point?
|
||||||
|
|
||||||
USE: vocabs.loader
|
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+
|
M: int-4 v*hs+
|
||||||
int-4-rep [ (simd-v*hs+) ] [ call-next-method ] vv->v-op longlong-2-cast ; inline
|
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!
|
] 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 ;
|
||||||
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:
|
SYNTAX: SPECIALIZED-ARRAY:
|
||||||
scan-c-type define-array-vocab use-vocab ;
|
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 ;
|
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::
|
SYNTAX: TYPED::
|
||||||
(::) define-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
|
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
|
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
|
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 -- )
|
: with-x ( display-string quot -- )
|
||||||
[ init-x ] dip [ close-x ] [ ] cleanup ; inline
|
[ 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
|
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
|
[ 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
|
[ 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 members table>> keys ; inline
|
||||||
M: hash-set set-like drop dup hash-set? [ members <hash-set> ] unless ;
|
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 clone table>> clone hash-set boa ;
|
||||||
|
M: hash-set null? table>> assoc-empty? ;
|
||||||
|
|
||||||
M: sequence fast-set <hash-set> ;
|
M: sequence fast-set <hash-set> ;
|
||||||
M: f fast-set drop H{ } clone hash-set boa ;
|
M: f fast-set drop H{ } clone hash-set boa ;
|
||||||
|
|
|
@ -23,6 +23,8 @@ ARTICLE: "set-operations" "Operations on sets"
|
||||||
adjoin
|
adjoin
|
||||||
delete
|
delete
|
||||||
}
|
}
|
||||||
|
"To test if a set is the empty set:"
|
||||||
|
{ $subsections null? }
|
||||||
"Basic mathematical operations, which any type of set may override for efficiency:"
|
"Basic mathematical operations, which any type of set may override for efficiency:"
|
||||||
{ $subsections
|
{ $subsections
|
||||||
diff
|
diff
|
||||||
|
@ -178,3 +180,7 @@ HELP: within
|
||||||
HELP: without
|
HELP: without
|
||||||
{ $values { "seq" sequence } { "set" set } { "subseq" sequence } }
|
{ $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." } ;
|
{ $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
|
[ 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
|
[ 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: set= ( set1 set2 -- ? )
|
||||||
GENERIC: duplicates ( set -- seq )
|
GENERIC: duplicates ( set -- seq )
|
||||||
GENERIC: all-unique? ( set -- ? )
|
GENERIC: all-unique? ( set -- ? )
|
||||||
|
GENERIC: null? ( set -- ? )
|
||||||
|
|
||||||
! Defaults for some methods.
|
! Defaults for some methods.
|
||||||
! Override them for efficiency
|
! Override them for efficiency
|
||||||
|
|
||||||
|
M: set null? members null? ; inline
|
||||||
|
|
||||||
M: set set-like drop ; inline
|
M: set set-like drop ; inline
|
||||||
|
|
||||||
M: set union
|
M: set union
|
||||||
|
@ -92,6 +95,9 @@ M: sequence set-like
|
||||||
M: sequence members
|
M: sequence members
|
||||||
[ pruned ] keep like ;
|
[ pruned ] keep like ;
|
||||||
|
|
||||||
|
M: sequence null?
|
||||||
|
empty? ; inline
|
||||||
|
|
||||||
: combine ( sets -- set )
|
: combine ( sets -- set )
|
||||||
[ f ]
|
[ f ]
|
||||||
[ [ [ members ] map concat ] [ first ] bi set-like ]
|
[ [ [ members ] map concat ] [ first ] bi set-like ]
|
||||||
|
|
|
@ -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" } "." } ;
|
{ $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
|
HELP: require-when
|
||||||
{ $values { "if" "a vocabulary specifier" } { "then" "a vocabulary specifier" } }
|
{ $values { "if" "a sequence of vocabulary specifiers" } { "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." }
|
{ $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 can be placed in " { $snippet "a" } " in order express the dependency."
|
{ $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 "\"b\" \"c\" require-when" } } ;
|
{ $code "{ \"a\" \"b\" } \"c\" require-when" } } ;
|
||||||
|
|
||||||
HELP: run
|
HELP: run
|
||||||
{ $values { "vocab" "a vocabulary specifier" } }
|
{ $values { "vocab" "a vocabulary specifier" } }
|
||||||
|
|
|
@ -66,10 +66,19 @@ DEFER: require
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: load-conditional-requires ( vocab-name -- )
|
SYMBOL: require-when-vocabs
|
||||||
conditional-requires get
|
require-when-vocabs [ HS{ } clone ] initialize
|
||||||
[ at [ require ] each ]
|
|
||||||
[ delete-at ] 2bi ;
|
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 -- )
|
: load-source ( vocab -- )
|
||||||
dup check-vocab-hook get call( vocab -- )
|
dup check-vocab-hook get call( vocab -- )
|
||||||
|
@ -79,7 +88,7 @@ DEFER: require
|
||||||
[ +parsing+ >>source-loaded? ] dip
|
[ +parsing+ >>source-loaded? ] dip
|
||||||
[ % ] [ call( -- ) ] if-bootstrapping
|
[ % ] [ call( -- ) ] if-bootstrapping
|
||||||
+done+ >>source-loaded?
|
+done+ >>source-loaded?
|
||||||
vocab-name load-conditional-requires
|
load-conditional-requires
|
||||||
] [ ] [ f >>source-loaded? ] cleanup ;
|
] [ ] [ f >>source-loaded? ] cleanup ;
|
||||||
|
|
||||||
: load-docs ( vocab -- )
|
: load-docs ( vocab -- )
|
||||||
|
@ -97,10 +106,12 @@ PRIVATE>
|
||||||
load-vocab drop ;
|
load-vocab drop ;
|
||||||
|
|
||||||
: require-when ( if then -- )
|
: require-when ( if then -- )
|
||||||
over vocab
|
over [ vocab ] all? [
|
||||||
[ nip require ]
|
require drop
|
||||||
[ swap conditional-requires get [ swap suffix ] change-at ]
|
] [
|
||||||
if ;
|
[ drop [ require-when-vocabs get adjoin ] each ]
|
||||||
|
[ 2array require-when-table get push ] 2bi
|
||||||
|
] if ;
|
||||||
|
|
||||||
: reload ( name -- )
|
: reload ( name -- )
|
||||||
dup vocab
|
dup vocab
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
USE: vocabs.loader
|
USE: vocabs.loader
|
||||||
IN: vocabs.loader.test.m
|
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.
|
! Copyright (C) 2007, 2009 Eduardo Cavazos, Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs strings kernel sorting namespaces
|
USING: accessors assocs strings kernel sorting namespaces
|
||||||
sequences definitions sets ;
|
sequences definitions sets combinators ;
|
||||||
IN: vocabs
|
IN: vocabs
|
||||||
|
|
||||||
SYMBOL: dictionary
|
SYMBOL: dictionary
|
||||||
|
@ -83,9 +83,6 @@ ERROR: bad-vocab-name name ;
|
||||||
: check-vocab-name ( name -- name )
|
: check-vocab-name ( name -- name )
|
||||||
dup string? [ bad-vocab-name ] unless ;
|
dup string? [ bad-vocab-name ] unless ;
|
||||||
|
|
||||||
SYMBOL: conditional-requires
|
|
||||||
conditional-requires [ H{ } clone ] initialize
|
|
||||||
|
|
||||||
: create-vocab ( name -- vocab )
|
: create-vocab ( name -- vocab )
|
||||||
check-vocab-name
|
check-vocab-name
|
||||||
dictionary get [ <vocab> ] cache
|
dictionary get [ <vocab> ] cache
|
||||||
|
|
|
@ -112,6 +112,6 @@ PRIVATE>
|
||||||
M: game-loop dispose
|
M: game-loop dispose
|
||||||
stop-loop ;
|
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
|
[ world>> ] [ program>> instances>> ] [ ] tri ?delete-at
|
||||||
reset-memos ;
|
reset-memos ;
|
||||||
|
|
||||||
"prettyprint" "gpu.shaders.prettyprint" require-when
|
{ "gpu.shaders" "prettyprint" } "gpu.shaders.prettyprint" require-when
|
||||||
|
|
Loading…
Reference in New Issue