]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' into microseconds
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 23 Nov 2008 09:06:32 +0000 (03:06 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sun, 23 Nov 2008 09:06:32 +0000 (03:06 -0600)
243 files changed:
.gitignore
Makefile
basis/alarms/alarms.factor
basis/bootstrap/help/help.factor
basis/bootstrap/image/image.factor
basis/bootstrap/stage2.factor
basis/cocoa/dialogs/dialogs.factor
basis/combinators/short-circuit/short-circuit-docs.factor
basis/combinators/short-circuit/short-circuit.factor
basis/combinators/short-circuit/smart/smart.factor
basis/compiler/compiler.factor
basis/compiler/tests/redefine13.factor [new file with mode: 0644]
basis/compiler/tests/redefine14.factor [new file with mode: 0644]
basis/compiler/tree/propagation/info/info.factor
basis/compiler/tree/propagation/known-words/known-words.factor
basis/concurrency/combinators/combinators-docs.factor
basis/concurrency/combinators/combinators-tests.factor
basis/concurrency/combinators/combinators.factor
basis/cpu/ppc/bootstrap.factor
basis/cpu/x86/32/bootstrap.factor
basis/cpu/x86/64/unix/bootstrap.factor
basis/cpu/x86/64/winnt/bootstrap.factor
basis/cpu/x86/bootstrap.factor
basis/debugger/debugger.factor
basis/documents/documents.factor
basis/editors/notepad2/authors.txt [new file with mode: 0644]
basis/editors/notepad2/notepad2.factor [new file with mode: 0644]
basis/editors/notepad2/summary.txt [new file with mode: 0644]
basis/editors/notepad2/tags.txt [new file with mode: 0644]
basis/farkup/farkup.factor
basis/fry/fry-docs.factor
basis/fry/fry-tests.factor
basis/fry/fry.factor
basis/generalizations/generalizations-tests.factor
basis/generalizations/generalizations.factor
basis/help/cookbook/cookbook.factor
basis/help/definitions/definitions-tests.factor
basis/help/handbook/handbook-tests.factor
basis/help/handbook/handbook.factor
basis/help/help-docs.factor
basis/help/help.factor
basis/help/lint/lint.factor
basis/help/markup/markup-tests.factor
basis/help/markup/markup.factor
basis/html/templates/fhtml/fhtml-tests.factor
basis/http/server/static/static.factor
basis/io/encodings/utf16/.utf16.factor.swo [deleted file]
basis/io/files/listing/unix/unix.factor
basis/io/sockets/secure/openssl/openssl.factor [new file with mode: 0644]
basis/io/unix/files/files.factor
basis/io/unix/sockets/secure/secure.factor
basis/io/windows/files/files.factor
basis/listener/listener-docs.factor
basis/listener/listener.factor
basis/locals/locals-docs.factor
basis/locals/locals-tests.factor
basis/locals/locals.factor
basis/macros/expander/expander.factor
basis/math/bitwise/bitwise-docs.factor
basis/math/geometry/rect/rect-docs.factor
basis/math/partial-dispatch/partial-dispatch.factor
basis/mime-types/authors.txt [deleted file]
basis/mime-types/mime-types-docs.factor [deleted file]
basis/mime-types/mime-types-tests.factor [deleted file]
basis/mime-types/mime-types.factor [deleted file]
basis/mime-types/mime.types [deleted file]
basis/mime/multipart/authors.txt [new file with mode: 0644]
basis/mime/multipart/multipart-tests.factor [new file with mode: 0644]
basis/mime/multipart/multipart.factor [new file with mode: 0644]
basis/mime/types/authors.txt [new file with mode: 0755]
basis/mime/types/mime.types [new file with mode: 0644]
basis/mime/types/types-docs.factor [new file with mode: 0644]
basis/mime/types/types-tests.factor [new file with mode: 0644]
basis/mime/types/types.factor [new file with mode: 0644]
basis/openssl/openssl.factor
basis/peg/parsers/parsers.factor
basis/peg/peg.factor
basis/prettyprint/backend/backend.factor
basis/prettyprint/prettyprint-docs.factor
basis/prettyprint/prettyprint-tests.factor
basis/prettyprint/prettyprint.factor
basis/qualified/qualified.factor
basis/regexp/classes/classes.factor
basis/regexp/parser/parser.factor
basis/regexp/regexp-tests.factor
basis/regexp/regexp.factor
basis/regexp/traversal/traversal.factor
basis/smtp/smtp.factor
basis/stack-checker/known-words/known-words.factor
basis/stack-checker/transforms/transforms.factor
basis/tools/completion/completion.factor
basis/tools/deploy/backend/backend.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/shaker/next-methods.factor [new file with mode: 0644]
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/shaker/strip-debugger.factor
basis/tools/deploy/test/7/7.factor [new file with mode: 0644]
basis/tools/deploy/test/7/deploy.factor [new file with mode: 0644]
basis/tools/test/test.factor
basis/tools/vocabs/browser/authors.txt
basis/tools/vocabs/browser/browser-docs.factor
basis/tools/vocabs/browser/browser.factor
basis/tools/vocabs/vocabs.factor
basis/tools/walker/walker.factor
basis/ui/cocoa/cocoa.factor
basis/ui/cocoa/views/views.factor
basis/ui/commands/commands-docs.factor
basis/ui/gadgets/buttons/buttons.factor
basis/ui/gadgets/editors/editors.factor
basis/ui/gadgets/frames/frames.factor
basis/ui/gadgets/gadgets.factor
basis/ui/gadgets/labels/labels-tests.factor [new file with mode: 0644]
basis/ui/gadgets/panes/panes-tests.factor
basis/ui/gadgets/panes/panes.factor
basis/ui/gadgets/scrollers/scrollers-tests.factor
basis/ui/gadgets/scrollers/scrollers.factor
basis/ui/gadgets/slots/slots.factor
basis/ui/gadgets/tracks/tracks-tests.factor
basis/ui/gadgets/tracks/tracks.factor
basis/ui/gadgets/viewports/viewports.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/gestures/gestures-docs.factor
basis/ui/gestures/gestures.factor
basis/ui/tools/browser/browser.factor
basis/ui/tools/debugger/debugger-docs.factor
basis/ui/tools/debugger/debugger.factor
basis/ui/tools/deploy/deploy.factor
basis/ui/tools/inspector/inspector.factor
basis/ui/tools/interactor/interactor.factor
basis/ui/tools/listener/listener.factor
basis/ui/tools/profiler/profiler.factor
basis/ui/tools/search/search.factor
basis/ui/tools/tools-docs.factor
basis/ui/tools/tools.factor
basis/ui/tools/traceback/traceback.factor
basis/ui/tools/walker/walker.factor
basis/ui/tools/workspace/workspace.factor
basis/ui/ui-docs.factor
basis/ui/ui-tests.factor [new file with mode: 0644]
basis/ui/ui.factor
basis/ui/windows/windows.factor [changed mode: 0644->0755]
basis/ui/x11/x11.factor
basis/unix/bsd/bsd.factor
basis/unix/stat/stat.factor
basis/unix/unix.factor
basis/urls/urls.factor
basis/values/values-docs.factor
build-support/factor.sh
core/arrays/arrays.factor
core/assocs/assocs.factor
core/bootstrap/primitives.factor
core/checksums/checksums.factor
core/checksums/crc32/crc32.factor
core/classes/algebra/algebra-tests.factor
core/classes/algebra/algebra.factor
core/classes/tuple/tuple-tests.factor
core/classes/tuple/tuple.factor
core/combinators/combinators-docs.factor
core/combinators/combinators.factor
core/compiler/errors/errors.factor
core/continuations/continuations.factor
core/generic/generic-docs.factor
core/generic/generic.factor
core/generic/math/math.factor
core/generic/parser/parser.factor
core/generic/standard/engines/engines.factor
core/generic/standard/engines/predicate/predicate.factor
core/generic/standard/engines/tag/tag.factor
core/generic/standard/standard.factor
core/growable/growable.factor
core/hashtables/hashtables-tests.factor
core/hashtables/hashtables.factor
core/io/encodings/encodings.factor
core/io/files/files.factor
core/io/io.factor
core/io/streams/byte-array/byte-array.factor
core/io/streams/c/c.factor [changed mode: 0644->0755]
core/io/streams/nested/nested.factor
core/io/streams/string/string.factor
core/kernel/kernel-docs.factor
core/kernel/kernel-tests.factor
core/kernel/kernel.factor
core/lexer/lexer.factor
core/math/integers/integers.factor
core/math/math-docs.factor
core/math/math.factor
core/math/parser/parser.factor
core/namespaces/namespaces.factor
core/parser/parser-docs.factor
core/parser/parser-tests.factor
core/parser/parser.factor
core/quotations/quotations-tests.factor
core/quotations/quotations.factor
core/sequences/sequences.factor
core/slots/slots.factor
core/sorting/sorting.factor
core/splitting/splitting-docs.factor
core/splitting/splitting-tests.factor
core/splitting/splitting.factor
core/strings/parser/parser.factor
core/strings/strings.factor
core/syntax/syntax.factor
core/vectors/vectors-tests.factor
core/vocabs/loader/loader-docs.factor
core/vocabs/loader/loader-tests.factor
core/vocabs/loader/loader.factor
core/vocabs/loader/test/f/f.factor [new file with mode: 0644]
core/vocabs/loader/test/f/tags.txt [new file with mode: 0644]
core/vocabs/loader/test/g/g.factor [new file with mode: 0644]
core/vocabs/loader/test/g/tags.txt [new file with mode: 0644]
core/vocabs/loader/test/h/h.factor [new file with mode: 0644]
core/vocabs/loader/test/h/tags.txt [new file with mode: 0644]
core/vocabs/loader/test/i/i.factor [new file with mode: 0644]
core/vocabs/loader/test/i/tags.txt [new file with mode: 0644]
core/vocabs/vocabs-docs.factor
core/vocabs/vocabs.factor
core/words/words.factor
extra/bake/fry/fry.factor
extra/benchmark/fib6/fib6.factor
extra/benchmark/regex-dna/regex-dna-tests.factor
extra/boids/boids.factor
extra/cairo/gadgets/gadgets.factor
extra/cfdg/cfdg.factor
extra/display-stack/display-stack.factor [deleted file]
extra/opengl/gadgets/gadgets.factor
extra/spheres/spheres.factor
extra/ui/gadgets/broken/broken.factor [new file with mode: 0644]
misc/factor.el
unfinished/vocab-browser/vocab-browser.factor [deleted file]
unmaintained/io/load.factor [deleted file]
unmaintained/io/os-unix-shell.factor [deleted file]
unmaintained/io/os-unix.factor [deleted file]
unmaintained/io/os-winnt-shell.factor [deleted file]
unmaintained/io/os-winnt.factor [deleted file]
unmaintained/io/shell.factor [deleted file]
unmaintained/io/test/io.factor [deleted file]
unmaintained/io/test/mmap.factor [deleted file]
vm/debug.c
vm/math.c
vm/os-netbsd.h
vm/quotations.c
vm/run.c
vm/run.h

index 290f075aae67d3add4bfbf0da1b906b3a535bcac..f4334f37278ce8cfb2aa838fc2eda20635f93e9b 100644 (file)
@@ -20,3 +20,4 @@ temp
 logs
 work
 build-support/wordsize
+*.bak
index 973ba1f3d4034eb91b8afb9f313a984fc22ac999..ffcbf6364c2544f1a4a4be579a0ed984faf2e41d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -161,7 +161,7 @@ factor: $(DLL_OBJS) $(EXE_OBJS)
 
 clean:
        rm -f vm/*.o
-       rm -f factor*.dll libfactor*.*
+       rm -f factor*.dll libfactor.{a,so,dylib}
 
 vm/resources.o:
        $(WINDRES) vm/factor.rs vm/resources.o
index 7fdeca9ae6cc39e5bb8bcf5ced6cd65196aed3a0..ad1838b3df4421afcbf4b34c7b2b29fd5912c694 100644 (file)
@@ -35,7 +35,7 @@ ERROR: bad-alarm-frequency frequency ;
     [ time>> ] dip before=? ;
 
 : reschedule-alarm ( alarm -- )
-    dup [ swap interval>> time+ ] change-time register-alarm ;
+    dup [ swap interval>> time+ now max ] change-time register-alarm ;
 
 : call-alarm ( alarm -- )
     [ entry>> box> drop ]
index e2a2288988f6f79ac161b4a118dbd0a7e0f68579..5b49ce28021a0a6722416bdc2aec7265e22bd0f8 100644 (file)
@@ -1,6 +1,6 @@
 USING: help help.topics help.syntax help.crossref
 help.definitions io io.files kernel namespaces vocabs sequences
-parser vocabs.loader ;
+parser vocabs.loader vocabs.loader.private accessors assocs ;
 IN: bootstrap.help
 
 : load-help ( -- )
@@ -10,8 +10,8 @@ IN: bootstrap.help
     t load-help? set-global
 
     [ drop ] load-vocab-hook [
-        vocabs
-        [ vocab-docs-loaded? not ] filter
+        dictionary get values
+        [ docs-loaded?>> not ] filter
         [ load-docs ] each
     ] with-variable ;
 
index c0fafdc0f53ac0b7d2b624b45cd368d86bc5ee5f..d5f36db776335c94bfa4ea872aa1c7cddf75fdc6 100644 (file)
@@ -130,6 +130,12 @@ SYMBOL: jit-if-word
 SYMBOL: jit-if-jump
 SYMBOL: jit-dispatch-word
 SYMBOL: jit-dispatch
+SYMBOL: jit-dip-word
+SYMBOL: jit-dip
+SYMBOL: jit-2dip-word
+SYMBOL: jit-2dip
+SYMBOL: jit-3dip-word
+SYMBOL: jit-3dip
 SYMBOL: jit-epilog
 SYMBOL: jit-return
 SYMBOL: jit-profiling
@@ -139,8 +145,8 @@ SYMBOL: jit-save-stack
 ! Default definition for undefined words
 SYMBOL: undefined-quot
 
-: userenv-offset ( symbol -- n )
-    {
+: userenvs ( -- assoc )
+    H{
         { bootstrap-boot-quot 20 }
         { bootstrap-global 21 }
         { jit-code-format 22 }
@@ -160,8 +166,17 @@ SYMBOL: undefined-quot
         { jit-push-immediate 36 }
         { jit-declare-word 42 }
         { jit-save-stack 43 }
+        { jit-dip-word 44 }
+        { jit-dip 45 }
+        { jit-2dip-word 46 }
+        { jit-2dip 47 }
+        { jit-3dip-word 48 }
+        { jit-3dip 49 }
         { undefined-quot 60 }
-    } at header-size + ;
+    } ; inline
+
+: userenv-offset ( symbol -- n )
+    userenvs at header-size + ;
 
 : emit ( cell -- ) image get push ;
 
@@ -443,6 +458,9 @@ M: quotation '
     \ dispatch jit-dispatch-word set
     \ do-primitive jit-primitive-word set
     \ declare jit-declare-word set
+    \ dip jit-dip-word set
+    \ 2dip jit-2dip-word set
+    \ 3dip jit-3dip-word set
     [ undefined ] undefined-quot set
     {
         jit-code-format
@@ -457,6 +475,12 @@ M: quotation '
         jit-if-jump
         jit-dispatch-word
         jit-dispatch
+        jit-dip-word
+        jit-dip
+        jit-2dip-word
+        jit-2dip
+        jit-3dip-word
+        jit-3dip
         jit-epilog
         jit-return
         jit-profiling
index 78d555fe92f054ee3311720aa9548c0dabc41e1c..ac8e5343e1eb4c94ca0383f5632cb0810c7ce415 100644 (file)
@@ -67,7 +67,7 @@ SYMBOL: bootstrap-time
     os wince? [ "windows.ce" require ] when
     os winnt? [ "windows.nt" require ] when
 
-    "deploy-vocab" get [
+    "staging" get "deploy-vocab" get or [
         "stage2: deployment mode" print
     ] [
         "listener" require
index 606526a240fafa48b6ae6d03c110f2d648c1ef09..662b4a7bae784f481dd92e5cf94434318185e87c 100644 (file)
@@ -26,7 +26,7 @@ IN: cocoa.dialogs
     [ -> filenames CF>string-array ] [ drop f ] if ;
 
 : split-path ( path -- dir file )
-    "/" last-split1 [ <NSString> ] bi@ ;
+    "/" split1-last [ <NSString> ] bi@ ;
 
 : save-panel ( path -- paths )
     <NSSavePanel> dup
index 54fc3aac432261c7dc2e9eab7148d3c5e38a4711..6cd18201feb170e01030391292a0b9e78d400830 100644 (file)
@@ -52,17 +52,17 @@ HELP: 3||
      { "quot" quotation } }
 { $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same three elements from the datastack and must return a boolean." } ;
 
-HELP: n&&-rewrite
+HELP: n&&
 { $values
      { "quots" "a sequence of quotations" } { "N" integer }
      { "quot" quotation } }
-{ $description "A macro that reqrites the code to pass " { $snippet "N" } " parameters from the stack to each AND quotation." } ;
+{ $description "A macro that rewrites the code to pass " { $snippet "n" } " parameters from the stack to each AND quotation." } ;
 
-HELP: n||-rewrite
+HELP: n||
 { $values
-     { "quots" "a sequence of quotations" } { "N" integer }
+     { "quots" "a sequence of quotations" } { "n" integer }
      { "quot" quotation } }
-{ $description "A macro that reqrites the code to pass " { $snippet "N" } " parameters from the stack to each OR quotation." } ;
+{ $description "A macro that rewrites the code to pass " { $snippet "n" } " parameters from the stack to each OR quotation." } ;
 
 ARTICLE: "combinators.short-circuit" "Short-circuit combinators"
 "The " { $vocab-link "combinators.short-circuit" } " vocabulary stops a computation early once a condition is met." $nl
@@ -77,8 +77,8 @@ ARTICLE: "combinators.short-circuit" "Short-circuit combinators"
 { $subsection 2|| }
 { $subsection 3|| }
 "Generalized combinators:"
-{ $subsection n&&-rewrite }
-{ $subsection n||-rewrite }
+{ $subsection n&& }
+{ $subsection n|| }
 ;
 
 ABOUT: "combinators.short-circuit"
index 7b6c1d126da8fadc4c1fad0cb9d48b2599dc64eb..2b4e522789f2cc4d1102c8b960d541c5fb779c35 100644 (file)
@@ -1,35 +1,26 @@
-
 USING: kernel combinators quotations arrays sequences assocs
-       locals generalizations macros fry ;
-
+locals generalizations macros fry ;
 IN: combinators.short-circuit
 
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: n&&-rewrite ( quots N -- quot )
-   quots
-     [ '[ drop N ndup @ dup not ] [ drop N ndrop f ] 2array ]
-   map
-   [ t ] [ N nnip ] 2array suffix
-   '[ f _ cond ] ;
-
-MACRO: 0&& ( quots -- quot ) 0 n&&-rewrite ;
-MACRO: 1&& ( quots -- quot ) 1 n&&-rewrite ;
-MACRO: 2&& ( quots -- quot ) 2 n&&-rewrite ;
-MACRO: 3&& ( quots -- quot ) 3 n&&-rewrite ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-:: n||-rewrite ( quots N -- quot )
-   quots
-     [ '[ drop N ndup @ dup ] [ N nnip ] 2array ]
-   map
-   [ drop N ndrop t ] [ f ] 2array suffix
-   '[ f _ cond ] ;
-
-MACRO: 0|| ( quots -- quot ) 0 n||-rewrite ;
-MACRO: 1|| ( quots -- quot ) 1 n||-rewrite ;
-MACRO: 2|| ( quots -- quot ) 2 n||-rewrite ;
-MACRO: 3|| ( quots -- quot ) 3 n||-rewrite ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+MACRO:: n&& ( quots n -- quot )
+    [ f ]
+    quots [| q | { [ drop n ndup q call dup not ] [ drop n ndrop f ] } ] map
+    [ n nnip ] suffix 1array
+    [ cond ] 3append ;
+
+MACRO: 0&& ( quots -- quot ) '[ _ 0 n&& ] ;
+MACRO: 1&& ( quots -- quot ) '[ _ 1 n&& ] ;
+MACRO: 2&& ( quots -- quot ) '[ _ 2 n&& ] ;
+MACRO: 3&& ( quots -- quot ) '[ _ 3 n&& ] ;
+
+MACRO:: n|| ( quots n -- quot )
+    [ f ]
+    quots
+    [| q | { [ drop n ndup q call dup ] [ n nnip ] } ] map
+    { [ drop n ndrop t ] [ f ] } suffix 1array
+    [ cond ] 3append ;
+
+MACRO: 0|| ( quots -- quot ) '[ _ 0 n|| ] ;
+MACRO: 1|| ( quots -- quot ) '[ _ 1 n|| ] ;
+MACRO: 2|| ( quots -- quot ) '[ _ 2 n|| ] ;
+MACRO: 3|| ( quots -- quot ) '[ _ 3 n|| ] ;
index ca659cacbef83ad0d68ea36b8028c54a2f230c76..b80e7294d15e064c926a36a09ff732c2cb1eaebe 100644 (file)
@@ -1,7 +1,5 @@
-
 USING: kernel sequences math stack-checker effects accessors macros
-       combinators.short-circuit ;
-
+fry combinators.short-circuit ;
 IN: combinators.short-circuit.smart
 
 <PRIVATE
@@ -13,6 +11,6 @@ IN: combinators.short-circuit.smart
 
 PRIVATE>
 
-MACRO: && ( quots -- quot ) dup arity n&&-rewrite ;
+MACRO: && ( quots -- quot ) dup arity '[ _ _ n&& ] ;
 
-MACRO: || ( quots -- quot ) dup arity n||-rewrite ;
+MACRO: || ( quots -- quot ) dup arity '[ _ _ n|| ] ;
index a6afc4b243af077ff2d4cbdfed3bb8eacebcb198..e5cbd888d94f0ddc93127ce810380103882a2255 100644 (file)
@@ -91,8 +91,8 @@ t compile-dependencies? set-global
     [
         dup crossref?
         [
-            dependencies get >alist
-            generic-dependencies get >alist
+            dependencies get
+            generic-dependencies get
             compiled-xref
         ] [ drop ] if
     ] tri ;
diff --git a/basis/compiler/tests/redefine13.factor b/basis/compiler/tests/redefine13.factor
new file mode 100644 (file)
index 0000000..d092cd4
--- /dev/null
@@ -0,0 +1,14 @@
+USING: math fry macros eval tools.test ;
+IN: compiler.tests.redefine13
+
+: breakage-word ( a b -- c ) + ;
+
+MACRO: breakage-macro ( a -- ) '[ _ breakage-word ] ;
+
+GENERIC: breakage-caller ( a -- c )
+
+M: fixnum breakage-caller 2 breakage-macro ;
+
+: breakage ( -- obj ) 2 breakage-caller ;
+
+! [ ] [ "IN: compiler.tests.redefine13 : breakage-word ( a b -- c ) ;" eval ] unit-test
diff --git a/basis/compiler/tests/redefine14.factor b/basis/compiler/tests/redefine14.factor
new file mode 100644 (file)
index 0000000..807f3ed
--- /dev/null
@@ -0,0 +1,8 @@
+USING: compiler.units definitions tools.test sequences ;
+IN: compiler.tests.redefine14
+
+! TUPLE: bad ;
+! 
+! M: bad length 1 2 3 ;
+! 
+! [ ] [ [ { bad length } forget ] with-compilation-unit ] unit-test
index e89a9c62118a83b3d155456b61a372479a03efe2..771d3800df6780007e15708a6e5c997c8d0f947c 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs classes classes.algebra classes.tuple
 classes.tuple.private kernel accessors math math.intervals
-namespaces sequences words combinators combinators.short-circuit
+namespaces sequences words combinators
 arrays compiler.tree.propagation.copy ;
 IN: compiler.tree.propagation.info
 
@@ -253,12 +253,13 @@ DEFER: (value-info-union)
         { [ over not ] [ 2drop f ] }
         [
             {
-                [ [ class>> ] bi@ class<= ]
-                [ [ interval>> ] bi@ interval-subset? ]
-                [ literals<= ]
-                [ [ length>> ] bi@ value-info<= ]
-                [ [ slots>> ] bi@ [ value-info<= ] 2all? ]
-            } 2&&
+                { [ 2dup [ class>> ] bi@ class<= not ] [ f ] }
+                { [ 2dup [ interval>> ] bi@ interval-subset? not ] [ f ] }
+                { [ 2dup literals<= not ] [ f ] }
+                { [ 2dup [ length>> ] bi@ value-info<= not ] [ f ] }
+                { [ 2dup [ slots>> ] bi@ [ value-info<= ] 2all? not ] [ f ] }
+                [ t ]
+            } cond 2nip
         ]
     } cond ;
 
index 3b698e000168a7a3cddeaee4644298e1372520a5..f6e2bc0940867861881231267658199c8f94347c 100644 (file)
@@ -138,6 +138,12 @@ most-negative-fixnum most-positive-fixnum [a,b]
 \ mod [ [ interval-mod ] [ real-valued ] binary-op ] each-derived-op
 \ rem [ [ interval-rem ] [ may-overflow real-valued ] binary-op ] each-derived-op
 
+{ /mod fixnum/mod } [
+    \ /i \ mod
+    [ "outputs" word-prop ] bi@
+    '[ _ _ 2bi ] "outputs" set-word-prop
+] each
+
 \ shift [ [ interval-shift-safe ] [ may-overflow integer-valued ] binary-op ] each-derived-op
 \ shift [ [ interval-shift-safe ] [ integer-valued ] binary-op ] each-fast-derived-op
 
index cb07e5a8d6e148e65c7ec6aad162232e968c899a..c61967fc8a0a2b91b34ba5a6d051b50a89b4608a 100644 (file)
@@ -27,11 +27,17 @@ HELP: parallel-filter
 { $errors "Throws an error if one of the iterations throws an error." } ;\r
 \r
 ARTICLE: "concurrency.combinators" "Concurrent combinators"\r
-"The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of " { $link each } ", " { $link map } " and " { $link filter } ":"\r
+"The " { $vocab-link "concurrency.combinators" } " vocabulary provides concurrent variants of various combinators."\r
+$nl\r
+"Concurrent sequence combinators:"\r
 { $subsection parallel-each }\r
 { $subsection 2parallel-each }\r
 { $subsection parallel-map }\r
 { $subsection 2parallel-map }\r
-{ $subsection parallel-filter } ;\r
+{ $subsection parallel-filter }\r
+"Concurrent cleave combinators:"\r
+{ $subsection parallel-cleave }\r
+{ $subsection parallel-spread }\r
+{ $subsection parallel-napply } ;\r
 \r
 ABOUT: "concurrency.combinators"\r
index 440a6766c55a80ae43ce72242708d2bfb41088bc..1c2dea2d79ce62305457be3cb4b306316eb5591c 100644 (file)
@@ -1,6 +1,7 @@
 IN: concurrency.combinators.tests\r
 USING: concurrency.combinators tools.test random kernel math \r
-concurrency.mailboxes threads sequences accessors arrays ;\r
+concurrency.mailboxes threads sequences accessors arrays\r
+math.parser ;\r
 \r
 [ [ drop ] parallel-each ] must-infer\r
 { 2 0 } [ [ 2drop ] 2parallel-each ] must-infer-as\r
@@ -45,3 +46,10 @@ concurrency.mailboxes threads sequences accessors arrays ;
 ] unit-test\r
 \r
 [ { f } [ "OOPS" throw ] parallel-each ] must-fail\r
+\r
+[ "1a" "4b" "3c" ] [\r
+    2\r
+    { [ 1- ] [ sq ] [ 1+ ] } parallel-cleave\r
+    [ number>string ] 3 parallel-napply\r
+    { [ "a" append ] [ "b" append ] [ "c" append ] } parallel-spread\r
+] unit-test\r
index ab3ca7ed4a27ffc175703ec4c51e29b77d13ba12..4608faf79ba572231422a5864a05f92cb3d99562 100644 (file)
@@ -1,34 +1,58 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: concurrency.futures concurrency.count-downs sequences\r
-kernel ;\r
+kernel macros fry combinators generalizations ;\r
 IN: concurrency.combinators\r
 \r
 <PRIVATE\r
+\r
 : (parallel-each) ( n quot -- )\r
-    >r <count-down> r> keep await ; inline\r
+    [ <count-down> ] dip keep await ; inline\r
+\r
 PRIVATE>\r
 \r
 : parallel-each ( seq quot -- )\r
     over length [\r
-        [ >r curry r> spawn-stage ] 2curry each\r
+        '[ _ curry _ spawn-stage ] each\r
     ] (parallel-each) ; inline\r
 \r
 : 2parallel-each ( seq1 seq2 quot -- )\r
     2over min-length [\r
-        [ >r 2curry r> spawn-stage ] 2curry 2each\r
+        '[ _ 2curry _ spawn-stage ] 2each\r
     ] (parallel-each) ; inline\r
 \r
 : parallel-filter ( seq quot -- newseq )\r
-    over >r pusher >r each r> r> like ; inline\r
+    over [ pusher [ each ] dip ] dip like ; inline\r
 \r
 <PRIVATE\r
+\r
+: [future] ( quot -- quot' ) '[ _ curry future ] ; inline\r
+\r
 : future-values dup [ ?future ] change-each ; inline\r
+\r
 PRIVATE>\r
 \r
 : parallel-map ( seq quot -- newseq )\r
-    [ curry future ] curry map future-values ;\r
-    inline\r
+    [future] map future-values ; inline\r
 \r
 : 2parallel-map ( seq1 seq2 quot -- newseq )\r
-    [ 2curry future ] curry 2map future-values ;\r
+    '[ _ 2curry future ] 2map future-values ;\r
+\r
+<PRIVATE\r
+\r
+: (parallel-spread) ( n -- spread-array )\r
+    [ ?future ] <repetition> ; inline\r
+\r
+: (parallel-cleave) ( quots -- quot-array spread-array )\r
+    [ [future] ] map dup length (parallel-spread) ; inline\r
+\r
+PRIVATE>\r
+\r
+MACRO: parallel-cleave ( quots -- )\r
+    (parallel-cleave) '[ _ cleave _ spread ] ;\r
+\r
+MACRO: parallel-spread ( quots -- )\r
+    (parallel-cleave) '[ _ spread _ spread ] ;\r
+\r
+MACRO: parallel-napply ( quot n -- )\r
+    [ [future] ] dip dup (parallel-spread) '[ _ _ napply _ spread ] ;\r
index aee0f3f4f38c66f6c2f603846e11e02f975b2e31..56ef89884c87031196b0e41ee72a5347212f2cbd 100644 (file)
@@ -71,11 +71,16 @@ big-endian on
 \r
 [ 0 B ] rc-relative-ppc-3 rt-xt 0 jit-word-jump jit-define\r
 \r
-: jit-call-quot ( -- )\r
+: jit-jump-quot ( -- )\r
     4 3 quot-xt-offset LWZ\r
     4 MTCTR\r
     BCTR ;\r
 \r
+: jit-call-quot ( -- )\r
+    4 3 quot-xt-offset LWZ\r
+    4 MTLR\r
+    BLR ;\r
+\r
 [\r
     0 3 LOAD32\r
     6 ds-reg 0 LWZ\r
@@ -84,7 +89,7 @@ big-endian on
     3 3 4 ADDI\r
     3 3 0 LWZ\r
     ds-reg dup 4 SUBI\r
-    jit-call-quot\r
+    jit-jump-quot\r
 ] rc-absolute-ppc-2/2 rt-literal 1 jit-if-jump jit-define\r
 \r
 [\r
@@ -95,9 +100,83 @@ big-endian on
     3 3 6 ADD\r
     3 3 array-start-offset LWZ\r
     ds-reg dup 4 SUBI\r
-    jit-call-quot\r
+    jit-jump-quot\r
 ] rc-absolute-ppc-2/2 rt-literal 1 jit-dispatch jit-define\r
 \r
+! These should not clobber r3 since we store a quotation in there\r
+! in jit-dip\r
+\r
+: jit->r ( -- )\r
+    4 ds-reg 0 LWZ\r
+    ds-reg dup 4 SUBI\r
+    4 rs-reg 4 STWU ;\r
+\r
+: jit-2>r ( -- )\r
+    4 ds-reg 0 LWZ\r
+    5 ds-reg -4 LWZ\r
+    ds-reg dup 8 SUBI\r
+    rs-reg dup 8 ADDI\r
+    4 rs-reg 0 STW\r
+    5 rs-reg -4 STW ;\r
+\r
+: jit-3>r ( -- )\r
+    4 ds-reg 0 LWZ\r
+    5 ds-reg -4 LWZ\r
+    6 ds-reg -8 LWZ\r
+    ds-reg dup 12 SUBI\r
+    rs-reg dup 12 ADDI\r
+    4 rs-reg 0 STW\r
+    5 rs-reg -4 STW\r
+    6 rs-reg -8 STW ;\r
+\r
+: jit-r> ( -- )\r
+    4 ds-reg 0 LWZ\r
+    ds-reg dup 4 SUBI\r
+    4 rs-reg 4 STWU ;\r
+\r
+: jit-2r> ( -- )\r
+    4 rs-reg 0 LWZ\r
+    5 rs-reg -4 LWZ\r
+    rs-reg dup 8 SUBI\r
+    ds-reg dup 8 ADDI\r
+    4 ds-reg 0 STW\r
+    5 ds-reg -4 STW ;\r
+\r
+: jit-3r> ( -- )\r
+    4 rs-reg 0 LWZ\r
+    5 rs-reg -4 LWZ\r
+    6 rs-reg -8 LWZ\r
+    rs-reg dup 12 SUBI\r
+    ds-reg dup 12 ADDI\r
+    4 ds-reg 0 STW\r
+    5 ds-reg -4 STW\r
+    6 ds-reg -8 STW ;\r
+\r
+: prepare-dip ( -- )\r
+    0 3 LOAD32\r
+    3 3 0 LWZ ;\r
+\r
+[\r
+    prepare-dip\r
+    jit->r\r
+    jit-call-quot\r
+    jit-r>\r
+] rc-absolute-ppc-2/2 rt-literal 1 jit-dip jit-define\r
+\r
+[\r
+    prepare-dip\r
+    jit-2>r\r
+    jit-call-quot\r
+    jit-2r>\r
+] rc-absolute-ppc-2/2 rt-literal 1 jit-2dip jit-define\r
+\r
+[\r
+    prepare-dip\r
+    jit-3>r\r
+    jit-call-quot\r
+    jit-3r>\r
+] rc-absolute-ppc-2/2 rt-literal 1 jit-3dip jit-define\r
+\r
 [\r
     0 1 lr-save stack-frame + LWZ\r
     1 1 stack-frame ADDI\r
@@ -112,7 +191,7 @@ big-endian on
 [\r
     3 ds-reg 0 LWZ\r
     ds-reg dup 4 SUBI\r
-    jit-call-quot\r
+    jit-jump-quot\r
 ] f f f \ (call) define-sub-primitive\r
 \r
 [\r
@@ -245,17 +324,9 @@ big-endian on
     4 ds-reg 0 STW\r
 ] f f f \ -rot define-sub-primitive\r
 \r
-[\r
-    3 ds-reg 0 LWZ\r
-    ds-reg dup 4 SUBI\r
-    3 rs-reg 4 STWU\r
-] f f f \ >r define-sub-primitive\r
+[ jit->r ] f f f \ >r define-sub-primitive\r
 \r
-[\r
-    3 rs-reg 0 LWZ\r
-    rs-reg dup 4 SUBI\r
-    3 ds-reg 4 STWU\r
-] f f f \ r> define-sub-primitive\r
+[ jit-r> ] f f f \ r> define-sub-primitive\r
 \r
 ! Comparisons\r
 : jit-compare ( insn -- )\r
@@ -335,6 +406,24 @@ big-endian on
     7 ds-reg 0 STW\r
 ] f f f \ fixnum-mod define-sub-primitive\r
 \r
+[\r
+    3 ds-reg 0 LWZ\r
+    ds-reg ds-reg 4 SUBI\r
+    4 ds-reg 0 LWZ\r
+    5 4 3 DIVW\r
+    5 ds-reg 0 STW\r
+] f f f \ fixnum/i-fast define-sub-primitive\r
+\r
+[\r
+    3 ds-reg 0 LWZ\r
+    4 ds-reg -4 LWZ\r
+    5 4 3 DIVW\r
+    6 5 3 MULLW\r
+    7 6 4 SUBF\r
+    5 ds-reg -4 STW\r
+    7 ds-reg 0 STW\r
+] f f f \ fixnum/mod-fast define-sub-primitive\r
+\r
 [\r
     3 ds-reg 0 LWZ\r
     3 3 1 SRAWI\r
index ba963ab477d2f087df299394f8fb1319255558f9..04bdcca68b8498f392623d5212b33b8182cdaf78 100644 (file)
@@ -12,6 +12,7 @@ IN: bootstrap.x86
 : mod-arg ( -- reg ) EDX ;
 : arg0 ( -- reg ) EAX ;
 : arg1 ( -- reg ) EDX ;
+: arg2 ( -- reg ) ECX ;
 : temp-reg ( -- reg ) EBX ;
 : stack-reg ( -- reg ) ESP ;
 : ds-reg ( -- reg ) ESI ;
index 29d48bd7944b41b6241ab0f46c02764b018fca3c..f0ca56da1472bda5f28b42bf614c30b7cf3fe221 100644 (file)
@@ -7,6 +7,7 @@ IN: bootstrap.x86
 : stack-frame-size ( -- n ) 4 bootstrap-cells ;
 : arg0 ( -- reg ) RDI ;
 : arg1 ( -- reg ) RSI ;
+: arg2 ( -- reg ) RDX ;
 
 << "resource:basis/cpu/x86/64/bootstrap.factor" parse-file parsed >>
 call
index a62b946e83981782b8eff07d9142b34b3aec9886..459945d82e4d9715c6ede20b493dd9b6165c8aff 100644 (file)
@@ -7,6 +7,7 @@ IN: bootstrap.x86
 : stack-frame-size ( -- n ) 8 bootstrap-cells ;
 : arg0 ( -- reg ) RCX ;
 : arg1 ( -- reg ) RDX ;
+: arg2 ( -- reg ) R8 ;
 
 << "resource:basis/cpu/x86/64/bootstrap.factor" parse-file parsed >>
 call
index 1ee74a434b0bc611aeb82399ab53325dfc17d46f..af7c9e2f0f8222fb01fcf4eaffdb33f33a92f031 100644 (file)
@@ -73,6 +73,80 @@ big-endian off
     arg0 quot-xt-offset [+] JMP                ! execute branch
 ] rc-absolute-cell rt-literal 1 rex-length + jit-dispatch jit-define
 
+! The jit->r words cannot clobber arg0
+
+: jit->r ( -- )
+    rs-reg bootstrap-cell ADD
+    temp-reg ds-reg [] MOV
+    ds-reg bootstrap-cell SUB
+    rs-reg [] temp-reg MOV ;
+
+: jit-2>r ( -- )
+    rs-reg 2 bootstrap-cells ADD
+    temp-reg ds-reg [] MOV
+    arg1 ds-reg -1 bootstrap-cells [+] MOV
+    ds-reg 2 bootstrap-cells SUB
+    rs-reg [] temp-reg MOV
+    rs-reg -1 bootstrap-cells [+] arg1 MOV ;
+
+: jit-3>r ( -- )
+    rs-reg 3 bootstrap-cells ADD
+    temp-reg ds-reg [] MOV
+    arg1 ds-reg -1 bootstrap-cells [+] MOV
+    arg2 ds-reg -2 bootstrap-cells [+] MOV
+    ds-reg 3 bootstrap-cells SUB
+    rs-reg [] temp-reg MOV
+    rs-reg -1 bootstrap-cells [+] arg1 MOV
+    rs-reg -2 bootstrap-cells [+] arg2 MOV ;
+
+: jit-r> ( -- )
+    ds-reg bootstrap-cell ADD
+    temp-reg rs-reg [] MOV
+    rs-reg bootstrap-cell SUB
+    ds-reg [] temp-reg MOV ;
+
+: jit-2r> ( -- )
+    ds-reg 2 bootstrap-cells ADD
+    temp-reg rs-reg [] MOV
+    arg1 rs-reg -1 bootstrap-cells [+] MOV
+    rs-reg 2 bootstrap-cells SUB
+    ds-reg [] temp-reg MOV
+    ds-reg -1 bootstrap-cells [+] arg1 MOV ;
+
+: jit-3r> ( -- )
+    ds-reg 3 bootstrap-cells ADD
+    temp-reg rs-reg [] MOV
+    arg1 rs-reg -1 bootstrap-cells [+] MOV
+    arg2 rs-reg -2 bootstrap-cells [+] MOV
+    rs-reg 3 bootstrap-cells SUB
+    ds-reg [] temp-reg MOV
+    ds-reg -1 bootstrap-cells [+] arg1 MOV
+    ds-reg -2 bootstrap-cells [+] arg2 MOV ;
+
+[
+    arg0 0 MOV                                 ! load quotation addr
+    arg0 arg0 [] MOV                           ! load quotation
+    jit->r
+    arg0 quot-xt-offset [+] CALL               ! call quotation
+    jit-r>
+] rc-absolute-cell rt-literal 1 rex-length + jit-dip jit-define
+
+[
+    arg0 0 MOV                                 ! load quotation addr
+    arg0 arg0 [] MOV                           ! load quotation
+    jit-2>r
+    arg0 quot-xt-offset [+] CALL               ! call quotation
+    jit-2r>
+] rc-absolute-cell rt-literal 1 rex-length + jit-2dip jit-define
+
+[
+    arg0 0 MOV                                 ! load quotation addr
+    arg0 arg0 [] MOV                           ! load quotation
+    jit-3>r                                    
+    arg0 quot-xt-offset [+] CALL               ! call quotation
+    jit-3r>
+] rc-absolute-cell rt-literal 1 rex-length + jit-3dip jit-define
+
 [
     stack-reg stack-frame-size bootstrap-cell - ADD ! unwind stack frame
 ] f f f jit-epilog jit-define
@@ -223,19 +297,9 @@ big-endian off
     ds-reg [] arg1 MOV
 ] f f f \ -rot define-sub-primitive
 
-[
-    rs-reg bootstrap-cell ADD
-    arg0 ds-reg [] MOV
-    ds-reg bootstrap-cell SUB
-    rs-reg [] arg0 MOV
-] f f f \ >r define-sub-primitive
+[ jit->r ] f f f \ >r define-sub-primitive
 
-[
-    ds-reg bootstrap-cell ADD
-    arg0 rs-reg [] MOV
-    rs-reg bootstrap-cell SUB
-    ds-reg [] arg0 MOV
-] f f f \ r> define-sub-primitive
+[ jit-r> ] f f f \ r> define-sub-primitive
 
 ! Comparisons
 : jit-compare ( insn -- )
@@ -305,16 +369,33 @@ big-endian off
     ds-reg [] arg1 MOV                         ! push to stack
 ] f f f \ fixnum-shift-fast define-sub-primitive
 
-[
+: jit-fixnum-/mod ( -- )
     temp-reg ds-reg [] MOV                     ! load second parameter
-    ds-reg bootstrap-cell SUB                  ! adjust stack pointer
-    div-arg ds-reg [] MOV                      ! load first parameter
+    div-arg ds-reg bootstrap-cell neg [+] MOV  ! load first parameter
     mod-arg div-arg MOV                        ! make a copy
     mod-arg bootstrap-cell-bits 1- SAR         ! sign-extend
-    temp-reg IDIV                              ! divide
+    temp-reg IDIV ;                            ! divide
+
+[
+    jit-fixnum-/mod
+    ds-reg bootstrap-cell SUB                  ! adjust stack pointer
     ds-reg [] mod-arg MOV                      ! push to stack
 ] f f f \ fixnum-mod define-sub-primitive
 
+[
+    jit-fixnum-/mod
+    ds-reg bootstrap-cell SUB                  ! adjust stack pointer
+    div-arg tag-bits get SHL                   ! tag it
+    ds-reg [] div-arg MOV                      ! push to stack
+] f f f \ fixnum/i-fast define-sub-primitive
+
+[
+    jit-fixnum-/mod
+    div-arg tag-bits get SHL                   ! tag it
+    ds-reg [] mod-arg MOV                      ! push to stack
+    ds-reg bootstrap-cell neg [+] div-arg MOV
+] f f f \ fixnum/mod-fast define-sub-primitive
+
 [
     arg0 ds-reg [] MOV                         ! load local number
     fixnum>slot@                               ! turn local number into offset
index ec93a01c19af449d65125cd574a01242955dae4b..0e7a56ee5f471cdef17e0332e7fac74d70fed825 100644 (file)
@@ -206,9 +206,8 @@ M: no-cond summary
 M: no-case summary
     drop "Fall-through in case" ;
 
-M: slice-error error.
-    "Cannot create slice because " write
-    reason>> print ;
+M: slice-error summary
+    drop "Cannot create slice" ;
 
 M: bounds-error summary drop "Sequence index out of bounds" ;
 
index 54bc85284a14bfb22e6cfa96f6c48e5a6dc72d4b..a82437ba40bcec2767b1237ae7969a8ef51fe359 100644 (file)
@@ -5,9 +5,9 @@ sequences strings splitting combinators unicode.categories
 math.order ;
 IN: documents
 
-: +col ( loc n -- newloc ) >r first2 r> + 2array ;
+: +col ( loc n -- newloc ) [ first2 ] dip + 2array ;
 
-: +line ( loc n -- newloc ) >r first2 swap r> + swap 2array ;
+: +line ( loc n -- newloc ) [ first2 swap ] dip + swap 2array ;
 
 : =col ( n loc -- newloc ) first swap 2array ;
 
@@ -31,10 +31,10 @@ TUPLE: document < model locs ;
 : doc-line ( n document -- string ) value>> nth ;
 
 : doc-lines ( from to document -- slice )
-    >r 1+ r> value>> <slice> ;
+    [ 1+ ] dip value>> <slice> ;
 
 : start-on-line ( document from line# -- n1 )
-    >r dup first r> = [ nip second ] [ 2drop 0 ] if ;
+    [ dup first ] dip = [ nip second ] [ 2drop 0 ] if ;
 
 : end-on-line ( document to line# -- n2 )
     over first over = [
@@ -47,12 +47,14 @@ TUPLE: document < model locs ;
     2over = [
         3drop
     ] [
-        >r [ first ] bi@ 1+ dup <slice> r> each
+        [ [ first ] bi@ 1+ dup <slice> ] dip each
     ] if ; inline
 
 : start/end-on-line ( from to line# -- n1 n2 )
-    tuck >r >r document get -rot start-on-line r> r>
-    document get -rot end-on-line ;
+    tuck
+    [ [ document get ] 2dip start-on-line ]
+    [ [ document get ] 2dip end-on-line ]
+    2bi* ;
 
 : (doc-range) ( from to line# -- )
     [ start/end-on-line ] keep document get doc-line <slice> , ;
@@ -60,16 +62,18 @@ TUPLE: document < model locs ;
 : doc-range ( from to document -- string )
     [
         document set 2dup [
-            >r 2dup r> (doc-range)
+            [ 2dup ] dip (doc-range)
         ] each-line 2drop
     ] { } make "\n" join ;
 
 : text+loc ( lines loc -- loc )
-    over >r over length 1 = [
-        nip first2
-    ] [
-        first swap length 1- + 0
-    ] if r> peek length + 2array ;
+    over [
+        over length 1 = [
+            nip first2
+        ] [
+            first swap length 1- + 0
+        ] if
+    ] dip peek length + 2array ;
 
 : prepend-first ( str seq -- )
     0 swap [ append ] change-nth ;
@@ -78,25 +82,25 @@ TUPLE: document < model locs ;
     [ length 1- ] keep [ prepend ] change-nth ;
 
 : loc-col/str ( loc document -- str col )
-    >r first2 swap r> nth swap ;
+    [ first2 swap ] dip nth swap ;
 
 : prepare-insert ( newinput from to lines -- newinput )
-    tuck loc-col/str tail-slice >r loc-col/str head-slice r>
+    tuck [ loc-col/str head-slice ] [ loc-col/str tail-slice ] 2bi*
     pick append-last over prepend-first ;
 
 : (set-doc-range) ( newlines from to lines -- )
     [ prepare-insert ] 3keep
-    >r [ first ] bi@ 1+ r>
+    [ [ first ] bi@ 1+ ] dip
     replace-slice ;
 
 : set-doc-range ( string from to document -- )
     [
-        >r >r >r string-lines r> [ text+loc ] 2keep r> r>
+        [ [ string-lines ] dip [ text+loc ] 2keep ] 2dip
         [ [ (set-doc-range) ] keep ] change-model
     ] keep update-locs ;
 
 : remove-doc-range ( from to document -- )
-    >r >r >r "" r> r> r> set-doc-range ;
+    [ "" ] 3dip set-doc-range ;
 
 : last-line# ( document -- line )
     value>> length 1- ;
@@ -111,7 +115,7 @@ TUPLE: document < model locs ;
     dupd doc-line length 2array ;
 
 : line-end? ( loc document -- ? )
-    >r first2 swap r> doc-line length = ;
+    [ first2 swap ] dip doc-line length = ;
 
 : doc-end ( document -- loc )
     [ last-line# ] keep line-end ;
@@ -123,7 +127,7 @@ TUPLE: document < model locs ;
         over first 0 < [
             2drop { 0 0 }
         ] [
-            >r first2 swap tuck r> validate-col 2array
+            [ first2 swap tuck ] dip validate-col 2array
         ] if
     ] if ;
 
@@ -131,7 +135,7 @@ TUPLE: document < model locs ;
     value>> "\n" join ;
 
 : set-doc-string ( string document -- )
-    >r string-lines V{ } like r> [ set-model ] keep
+    [ string-lines V{ } like ] dip [ set-model ] keep
     [ doc-end ] [ update-locs ] bi ;
 
 : clear-doc ( document -- )
@@ -141,17 +145,17 @@ GENERIC: prev-elt ( loc document elt -- newloc )
 GENERIC: next-elt ( loc document elt -- newloc )
 
 : prev/next-elt ( loc document elt -- start end )
-    3dup next-elt >r prev-elt r> ;
+    [ prev-elt ] [ next-elt ] 3bi ;
 
 : elt-string ( loc document elt -- string )
-    over >r prev/next-elt r> doc-range ;
+    [ prev/next-elt ] [ drop ] 2bi doc-range ;
 
 TUPLE: char-elt ;
 
 : (prev-char) ( loc document quot -- loc )
     -rot {
         { [ over { 0 0 } = ] [ drop ] }
-        { [ over second zero? ] [ >r first 1- r> line-end ] }
+        { [ over second zero? ] [ [ first 1- ] dip line-end ] }
         [ pick call ]
     } cond nip ; inline
 
@@ -175,14 +179,14 @@ M: one-char-elt prev-elt 2drop ;
 M: one-char-elt next-elt 2drop ;
 
 : (word-elt) ( loc document quot -- loc )
-    pick >r
-    >r >r first2 swap r> doc-line r> call
-    r> =col ; inline
+    pick [
+        [ [ first2 swap ] dip doc-line ] dip call
+    ] dip =col ; inline
 
 : ((word-elt)) ( n seq -- ? n seq ) [ ?nth blank? ] 2keep ;
 
 : break-detector ( ? -- quot )
-    [ >r blank? r> xor ] curry ; inline
+    [ [ blank? ] dip xor ] curry ; inline
 
 : (prev-word) ( ? col str -- col )
     rot break-detector find-last-from drop ?1+ ;
@@ -195,17 +199,17 @@ TUPLE: one-word-elt ;
 
 M: one-word-elt prev-elt
     drop
-    [ f -rot >r 1- r> (prev-word) ] (word-elt) ;
+    [ [ [ f ] dip 1- ] dip (prev-word) ] (word-elt) ;
 
 M: one-word-elt next-elt
     drop
-    [ f -rot (next-word) ] (word-elt) ;
+    [ [ f ] 2dip (next-word) ] (word-elt) ;
 
 TUPLE: word-elt ;
 
 M: word-elt prev-elt
     drop
-    [ [ >r 1- r> ((word-elt)) (prev-word) ] (word-elt) ]
+    [ [ [ 1- ] dip ((word-elt)) (prev-word) ] (word-elt) ]
     (prev-char) ;
 
 M: word-elt next-elt
@@ -219,7 +223,7 @@ M: one-line-elt prev-elt
     2drop first 0 2array ;
 
 M: one-line-elt next-elt
-    drop >r first dup r> doc-line length 2array ;
+    drop [ first dup ] dip doc-line length 2array ;
 
 TUPLE: line-elt ;
 
diff --git a/basis/editors/notepad2/authors.txt b/basis/editors/notepad2/authors.txt
new file mode 100644 (file)
index 0000000..7852139
--- /dev/null
@@ -0,0 +1 @@
+Marc Fauconneau
diff --git a/basis/editors/notepad2/notepad2.factor b/basis/editors/notepad2/notepad2.factor
new file mode 100644 (file)
index 0000000..4d333e4
--- /dev/null
@@ -0,0 +1,16 @@
+USING: editors io.files io.launcher kernel math.parser
+namespaces sequences windows.shell32 make ;
+IN: editors.notepad2
+
+: notepad2-path ( -- str )
+    \ notepad2-path get-global [
+        program-files "C:\\Windows\\system32\\notepad.exe" append-path
+   ] unless* ;
+
+: notepad2 ( file line -- )
+    [
+        notepad2-path ,
+        "/g" , number>string , ,
+    ] { } make run-detached drop ;
+
+[ notepad2 ] edit-hook set-global
\ No newline at end of file
diff --git a/basis/editors/notepad2/summary.txt b/basis/editors/notepad2/summary.txt
new file mode 100644 (file)
index 0000000..ab4a8ce
--- /dev/null
@@ -0,0 +1 @@
+Notepad2 editor integration
diff --git a/basis/editors/notepad2/tags.txt b/basis/editors/notepad2/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index 21e3c05d041bae54a89e9ea5bb6c403134ce9f9c..77a9038cd990aec6d3ec462d8d15a0ff4c5c73ac 100644 (file)
@@ -36,7 +36,7 @@ TUPLE: line-break ;
     { "http://" "https://" "ftp://" } [ head? ] with contains? ;
 
 : simple-link-title ( string -- string' )
-    dup absolute-url? [ "/" last-split1 swap or ] unless ;
+    dup absolute-url? [ "/" split1-last swap or ] unless ;
 
 EBNF: parse-farkup
 nl               = ("\r\n" | "\r" | "\n") => [[ drop "\n" ]]
index 286dbb469ef98eded169bab8b8ca981a1e6e06e2..b5d1b8d8d21708fcdfd8c91d6d15d6c82e44b1a2 100644 (file)
@@ -15,10 +15,13 @@ HELP: fry
 } ;\r
 \r
 HELP: '[\r
-{ $syntax "code... ]" }\r
+{ $syntax "'[ code... ]" }\r
 { $description "Literal fried quotation. Expands into code which takes values from the stack and substitutes them in place of the fry specifiers " { $link _ } " and " { $link @ } "." }\r
 { $examples "See " { $link "fry.examples" } "." } ;\r
 \r
+HELP: >r/r>-in-fry-error\r
+{ $error-description "Thrown by " { $link POSTPONE: '[ } " if the fried quotation contains calls to " { $link >r } " or " { $link r> } ". Explicit retain stack manipulation of this form does not work with fry; use " { $link dip } " instead." } ;\r
+\r
 ARTICLE: "fry.examples" "Examples of fried quotations"\r
 "The easiest way to understand fried quotations is to look at some examples."\r
 $nl\r
@@ -49,6 +52,8 @@ $nl
     "{ 8 13 14 27 } [ even? ] 5 [ dup ] swap [ ? ] curry 3compose map"\r
     "{ 8 13 14 27 } [ even? dup 5 ? ] map"\r
 }\r
+"The following is a no-op:"\r
+{ $code "'[ @ ]" }\r
 "Here are some built-in combinators rewritten in terms of fried quotations:"\r
 { $table\r
     { { $link literalize } { $snippet ": literalize '[ _ ] ;" } }\r
@@ -71,21 +76,27 @@ ARTICLE: "fry.philosophy" "Fried quotation philosophy"
 } ;\r
 \r
 ARTICLE: "fry.limitations" "Fried quotation limitations"\r
-"As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". This is not a real limitation in practice, since " { $link dip } " can be used instead." ;\r
+"As with " { $vocab-link "locals" } ", fried quotations cannot contain " { $link >r } " and " { $link r> } ". This is not a real limitation in practice, since " { $link dip } " can be used instead."\r
+$nl\r
+"An error thrown if a fried quotation contains calls to " { $link >r } " and " { $link r> } ":"\r
+{ $subsection >r/r>-in-fry-error } ;\r
 \r
 ARTICLE: "fry" "Fried quotations"\r
-"A " { $emphasis "fried quotation" } " differs from a literal quotation in that when it is evaluated, instead of just pushing itself on the stack, it consumes zero or more stack values and inserts them into the quotation."\r
+"The " { $vocab-link "fry" } " vocabulary implements " { $emphasis "fried quotation" } ". Conceptually, fried quotations are quotations with ``holes'' (more formally, " { $emphasis "fry specifiers" } "), and the holes are filled in when the fried quotation is pushed on the stack."\r
 $nl\r
-"Fried quotations are denoted with a special parsing word:"\r
+"Fried quotations are started by a special parsing word:"\r
 { $subsection POSTPONE: '[ }\r
-"Fried quotations contain zero or more " { $emphasis "fry specifiers" } ":"\r
+"There are two types of fry specifiers; the first can hold a value, and the second ``splices'' a quotation, as if it were inserted without surrounding brackets:"\r
 { $subsection _ }\r
 { $subsection @ }\r
-"When a fried quotation is being evaluated, values are consumed from the stack and spliced into the quotation from right to left."\r
+"The holes are filled in with the top of stack going in the rightmost hole, the second item on the stack going in the second hole from the right, and so on."\r
 { $subsection "fry.examples" }\r
 { $subsection "fry.philosophy" }\r
 { $subsection "fry.limitations" }\r
-"Quotations can also be fried without using a parsing word:"\r
-{ $subsection fry } ;\r
+"Fry is implemented as a parsing word which reads a quotation and scans for occurrences of " { $link _ } " and " { $link @ } "; these words are not actually executed, and doing so raises an error (this can happen if they're accidentally used outside of a fry)."\r
+$nl\r
+"Fried quotations can also be constructed without using a parsing word; this is useful when meta-programming:"\r
+{ $subsection fry }\r
+"Fried quotations are an abstraction on top of the " { $link "compositional-combinators" } "; their use is encouraged over the combinators, because often the fry form is shorter and clearer than the combinator form." ;\r
 \r
 ABOUT: "fry"\r
index d4a3b8b734a13e29ba4dbd43aa01c218ac7c8d69..0137e8be22b7d159aef81da677225a751f30cac4 100644 (file)
@@ -1,23 +1,20 @@
 IN: fry.tests
 USING: fry tools.test math prettyprint kernel io arrays
-sequences ;
+sequences eval accessors ;
 
 [ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
 
 [ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test
 
-[ [ 1 + ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
+[ [ 1 [ + ] call ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
 
-[ [ 1 + . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
+[ [ 1 [ + ] call . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
 
-[ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
+[ [ [ + ] [ - ] [ call ] dip call ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
 
-[ [ "a" write "b" print ] ]
+[ [ "a" "b" [ write ] dip print ] ]
 [ "a" "b" '[ _ write _ print ] ] unit-test
 
-[ [ 1 2 + 3 4 - ] ]
-[ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test
-
 [ 1/2 ] [
     1 '[ [ _ ] dip / ] 2 swap call
 ] unit-test
@@ -58,3 +55,10 @@ sequences ;
 [ { { { 3 } } } ] [
     3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
 ] unit-test
+
+[ "USING: fry kernel ; f '[ >r _ r> ]" eval ]
+[ error>> >r/r>-in-fry-error? ] must-fail-with
+
+[ { { "a" 1 } { "b" 2 } { "c" 3 } { "d" 4 } } ] [
+    1 2 3 4 '[ "a" _ 2array "b" _ 2array "c" _ 2array "d" _ 2array 4array ] call
+] unit-test
index 87c59e18a083b976238ac7300775abc54be32abb..ac036f58ad261ad45cc5b5979d3f3c3d994e73d1 100644 (file)
@@ -1,33 +1,37 @@
 ! Copyright (C) 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences combinators parser splitting math
-quotations arrays make words ;
+quotations arrays make words locals.backend summary sets ;
 IN: fry
 
 : _ ( -- * ) "Only valid inside a fry" throw ;
 : @ ( -- * ) "Only valid inside a fry" throw ;
 
+ERROR: >r/r>-in-fry-error ;
+
 <PRIVATE
 
-DEFER: (shallow-fry)
-DEFER: shallow-fry
-
-: ((shallow-fry)) ( accum quot adder -- result )
-    >r shallow-fry r>
-    append swap [
-        [ prepose ] curry append
-    ] unless-empty ; inline
-
-: (shallow-fry) ( accum quot -- result )
-    [ 1quotation ] [
-        unclip {
-            { \ _ [ [ curry ] ((shallow-fry)) ] }
-            { \ @ [ [ compose ] ((shallow-fry)) ] }
-            [ swap >r suffix r> (shallow-fry) ]
-        } case
-    ] if-empty ;
-
-: shallow-fry ( quot -- quot' ) [ ] swap (shallow-fry) ;
+: [ncurry] ( n -- quot )
+    {
+        { 0 [ [ ] ] }
+        { 1 [ [ curry ] ] }
+        { 2 [ [ 2curry ] ] }
+        { 3 [ [ 3curry ] ] }
+        [ \ curry <repetition> ]
+    } case ;
+
+M: >r/r>-in-fry-error summary
+    drop
+    "Explicit retain stack manipulation is not permitted in fried quotations" ;
+
+: check-fry ( quot -- quot )
+    dup { >r r> load-locals get-local drop-locals } intersect
+    empty? [ >r/r>-in-fry-error ] unless ;
+
+: shallow-fry ( quot -- quot' )
+    check-fry
+    [ dup \ @ = [ drop [ _ call ] ] [ 1array ] if ] map concat
+    { _ } split [ length 1- [ncurry] ] [ spread>quot ] bi prefix ;
 
 PREDICATE: fry-specifier < word { _ @ } memq? ;
 
index 75985c936892c74b92bcd009eab187057134811a..1ebe528f35c2a0971301277b32b2d0fba77f6fee 100644 (file)
@@ -36,3 +36,5 @@ IN: generalizations.tests
 [ 1 2 3 4 ] [ { 1 2 3 4 } 4 firstn ] unit-test\r
 [ ] [ { } 0 firstn ] unit-test\r
 [ "a" ] [ { "a" } 1 firstn ] unit-test\r
+\r
+[ [ 1 2 ] ] [ 1 2 2 [ ] nsequence ] unit-test\r
index 069d59cee192a9ba2b60f7baa6fdcb702213abe2..c63c2b66caa1b42cc97650cdb89dc104d2cb3b10 100644 (file)
@@ -6,8 +6,11 @@ math.ranges combinators macros quotations fry arrays ;
 IN: generalizations\r
 \r
 MACRO: nsequence ( n seq -- quot )\r
-    [ drop <reversed> ] [ '[ _ _ new-sequence ] ] 2bi\r
-    [ '[ @ [ _ swap set-nth-unsafe ] keep ] ] reduce ;\r
+    [\r
+        [ drop <reversed> ] [ '[ _ _ new-sequence ] ] 2bi\r
+        [ '[ @ [ _ swap set-nth-unsafe ] keep ] ] reduce\r
+    ] keep\r
+    '[ @ _ like ] ;\r
 \r
 MACRO: narray ( n -- quot )\r
     '[ _ { } nsequence ] ;\r
index 9fb837a8735955f56ac80fc64074969faf8ba2e3..6e27bd9256c678885b1f91468533c8a9028ffd82 100644 (file)
@@ -1,5 +1,6 @@
 USING: help.markup help.syntax io kernel math namespaces parser
-prettyprint sequences vocabs.loader namespaces stack-checker ;
+prettyprint sequences vocabs.loader namespaces stack-checker
+help ;
 IN: help.cookbook
 
 ARTICLE: "cookbook-syntax" "Basic syntax cookbook"
@@ -324,6 +325,19 @@ ARTICLE: "cookbook-pitfalls" "Pitfalls to avoid"
     { "If " { $link run-file } " throws a stack depth assertion, it means that the top-level form in the file left behind values on the stack. The stack depth is compared before and after loading a source file, since this type of situation is almost always an error. If you have a legitimate need to load a source file which returns data in some manner, define a word in the source file which produces this data on the stack and call the word after loading the file." }
 } ;
 
+ARTICLE: "cookbook-next" "Next steps"
+"Once you have read through " { $link "first-program" } " and " { $link "cookbook" } ", the best way to keep learning Factor is to start looking at some simple example programs. Here are a few particularly nice vocabularies which should keep you busy for a little while:"
+{ $list
+    { $vocab-link "base64" }
+    { $vocab-link "roman" }
+    { $vocab-link "rot13" }
+    { $vocab-link "smtp" }
+    { $vocab-link "time-server" }
+    { $vocab-link "tools.hexdump" }
+    { $vocab-link "webapps.counter" }
+}
+"If you see code in there that you do not understand, use " { $link see } " and " { $link help } " to explore." ;
+
 ARTICLE: "cookbook" "Factor cookbook"
 "The Factor cookbook is a high-level overview of the most important concepts required to program in Factor."
 { $subsection "cookbook-syntax" }
@@ -336,6 +350,7 @@ ARTICLE: "cookbook" "Factor cookbook"
 { $subsection "cookbook-scripts" }
 { $subsection "cookbook-compiler" }
 { $subsection "cookbook-philosophy" }
-{ $subsection "cookbook-pitfalls" } ;
+{ $subsection "cookbook-pitfalls" }
+{ $subsection "cookbook-next" } ;
 
 ABOUT: "cookbook"
index 1b8bcccce7e18851e2e507dfbbe6a7addc420942..d95f6988a208f71392e7f4fa26e0b769d0944431 100644 (file)
@@ -34,7 +34,7 @@ IN: help.definitions.tests
 
     [ ] [ "IN: help.definitions.tests USING: help.syntax ; : xxx ; HELP: xxx ;" eval ] unit-test
 
-    [ ] [ "xxx" "help.definitions.tests" lookup help ] unit-test
+    [ ] [ "xxx" "help.definitions.tests" lookup print-topic ] unit-test
 
     [ ] [ "xxx" "help.definitions.tests" lookup >link synopsis print ] unit-test
 ] with-file-vocabs
index ae6c7d55f41c3cc470b65b103508b9e4ffeb68f3..240ce672400d3a0bd451546d88d576674638625f 100644 (file)
@@ -1,8 +1,8 @@
 IN: help.handbook.tests
 USING: help tools.test ;
 
-[ ] [ "article-index" help ] unit-test
-[ ] [ "primitive-index" help ] unit-test
-[ ] [ "error-index" help ] unit-test
-[ ] [ "type-index" help ] unit-test
-[ ] [ "class-index" help ] unit-test
+[ ] [ "article-index" print-topic ] unit-test
+[ ] [ "primitive-index" print-topic ] unit-test
+[ ] [ "error-index" print-topic ] unit-test
+[ ] [ "type-index" print-topic ] unit-test
+[ ] [ "class-index" print-topic ] unit-test
index d1d9ca049a2708ed5bd6e3523ed0ab9d265a2d01..2ed86a0a19b5f68c0bdc081b9b729715778c6897 100644 (file)
@@ -65,6 +65,11 @@ $nl
     { "word"                  { "the basic unit of code, analogous to a function or procedure in other programming languages. See " { $link "words" } } }
 } ;
 
+ARTICLE: "tail-call-opt" "Tail-call optimization"
+"If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $emphasis "tail-call optimization" } " and the Factor implementation guarantees that it will be performed."
+$nl
+"Tail-call optimization allows iterative algorithms to be implemented in an efficient manner using recursion, without the need for any kind of primitive looping construct in the language. However, in practice, most iteration is performed via combinators such as " { $link while } ", " { $link each } ", " { $link map } ", " { $link assoc-each } ", and so on. The definitions of these combinators do bottom-out in recursive words, however." ;
+
 ARTICLE: "evaluator" "Evaluation semantics"
 { $link "quotations" } " are evaluated sequentially from beginning to end. When the end is reached, the quotation returns to its caller. As each object in the quotation is evaluated in turn, an action is taken based on its type:"
 { $list
@@ -72,7 +77,7 @@ ARTICLE: "evaluator" "Evaluation semantics"
     { "a " { $link wrapper } " - the wrapped object is pushed on the data stack. Wrappers are used to push word objects directly on the stack when they would otherwise execute. See the " { $link POSTPONE: \ } " parsing word." }
     { "All other types of objects are pushed on the data stack." }
 }
-"If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as " { $snippet "tail-recursion" } " and allows iterative algorithms to execute without incurring unbounded call stack usage."
+{ $subsection "tail-call-opt" }
 { $see-also "compiler" } ;
 
 ARTICLE: "objects" "Objects"
index 277d965e390b735306fed7ebb8a33b1de57fb55e..4a06235c691507ca669e3e1c29c3671773f0b5b9 100644 (file)
@@ -129,12 +129,17 @@ HELP: $title
 { $values { "topic" "a help article name or a word" } }
 { $description "Prints a help article's title, or a word's " { $link summary } ", depending on the type of " { $snippet "topic" } "." } ;
 
-HELP: help
+HELP: print-topic
 { $values { "topic" "an article name or a word" } }
 { $description
-    "Displays a help article or documentation associated to a word on " { $link output-stream } "."
+    "Displays a help topic on " { $link output-stream } "."
 } ;
 
+HELP: help
+{ $values { "topic" "an article name or a word" } }
+{ $description
+    "Displays a help topic."
+} ;
 HELP: about
 { $values { "vocab" "a vocabulary specifier" } }
 { $description
index 686578f1b61e31343f527c7be5d0d9a5aac39d6b..a3e38906871819ffcdce9353ba15c000608fc835 100644 (file)
@@ -19,7 +19,7 @@ GENERIC: word-help* ( word -- content )
     { { "object" object } { "?" "a boolean" } } $values
     [
         "Tests if the object is an instance of the " ,
-        first "predicating" word-prop \ $link swap 2array ,
+        first "predicating" word-prop <$link> ,
         " class." ,
     ] { } make $description ;
 
@@ -58,15 +58,36 @@ M: word article-title
         append
     ] if ;
 
-M: word article-content
+<PRIVATE
+
+: (word-help) ( word -- element )
     [
-        \ $vocabulary over 2array ,
-        dup word-help %
-        \ $related over 2array ,
-        dup get-global [ \ $value swap 2array , ] when*
-        \ $definition swap 2array ,
+        {
+            [ \ $vocabulary swap 2array , ]
+            [ word-help % ]
+            [ \ $related swap 2array , ]
+            [ get-global [ \ $value swap 2array , ] when* ]
+            [ \ $definition swap 2array , ]
+        } cleave
     ] { } make ;
 
+M: word article-content (word-help) ;
+
+<PRIVATE
+
+: word-with-methods ( word -- elements )
+    [
+        [ (word-help) % ]
+        [ \ $methods swap 2array , ]
+        bi
+    ] { } make ;
+
+PRIVATE>
+
+M: generic article-content word-with-methods ;
+
+M: class article-content word-with-methods ;
+
 M: word article-parent "help-parent" word-prop ;
 
 M: word set-article-parent swap "help-parent" set-word-prop ;
@@ -89,10 +110,17 @@ M: word set-article-parent swap "help-parent" set-word-prop ;
         ] with-nesting
     ] with-style nl ;
 
-: help ( topic -- )
+: print-topic ( topic -- )
     last-element off dup $title
     article-content print-content nl ;
 
+SYMBOL: help-hook
+
+help-hook global [ [ print-topic ] or ] change-at
+
+: help ( topic -- )
+    help-hook get call ;
+
 : about ( vocab -- )
     dup require
     dup vocab [ ] [
index be6206f59ca8b7a1bea6c1ec1ac12894c7040145..c7d505d86afbe24a08ed3a1c5dc5756c4340953f 100644 (file)
@@ -68,7 +68,7 @@ IN: help.lint
     ] each ;
 
 : check-rendering ( word element -- )
-    [ help ] with-string-writer drop ;
+    [ print-topic ] with-string-writer drop ;
 
 : all-word-help ( words -- seq )
     [ word-help ] filter ;
index 222c4e7d3f8655df2d4df4cbc235d765a7c33e71..b9ec34a831314da1827b5a40bcddff964aa601e4 100644 (file)
@@ -6,12 +6,12 @@ TUPLE: blahblah quux ;
 
 [ "an int" ] [ [ { "int" } $instance ] with-string-writer ] unit-test
 
-[ ] [ \ quux>> help ] unit-test
-[ ] [ \ >>quux help ] unit-test
-[ ] [ \ blahblah? help ] unit-test
+[ ] [ \ quux>> print-topic ] unit-test
+[ ] [ \ >>quux print-topic ] unit-test
+[ ] [ \ blahblah? print-topic ] unit-test
 
 : fooey "fooey" throw ;
 
-[ ] [ \ fooey help ] unit-test
+[ ] [ \ fooey print-topic ] unit-test
 
-[ ] [ gensym help ] unit-test
+[ ] [ gensym print-topic ] unit-test
index a3078333387ba76a93be7c2fae420395537ad4b5..899cad24042763dc227febd43edd2d9bd61008b6 100644 (file)
@@ -285,11 +285,16 @@ M: f ($instance)
 
 : $see ( element -- ) first [ see ] ($see) ;
 
+: $see-methods ( element -- ) first [ see-methods ] ($see) ;
+
 : $synopsis ( element -- ) first [ synopsis write ] ($see) ;
 
 : $definition ( element -- )
     "Definition" $heading $see ;
 
+: $methods ( element -- )
+    "Methods" $heading $see-methods ;
+
 : $value ( object -- )
     "Variable value" $heading
     "Current value in global namespace:" print-element
@@ -348,3 +353,6 @@ M: array elements*
             ] each
         ] curry each
     ] H{ } make-assoc keys ;
+
+: <$link> ( topic -- element )
+    \ $link swap 2array ;
index d314a60124a534c4e219e43a80641804909f401b..6cebb55688127bf5c1c68d73a934fc8df49535b1 100644 (file)
@@ -6,11 +6,8 @@ IN: html.templates.fhtml.tests
 : test-template ( path -- ? )
     "resource:basis/html/templates/fhtml/test/"
     prepend
-    [
-        ".fhtml" append <fhtml> [ call-template ] with-string-writer
-        <string-reader> lines
-    ] keep
-    ".html" append utf8 file-lines
+    [ ".fhtml" append <fhtml> [ call-template ] with-string-writer ]
+    [ ".html" append utf8 file-contents ] bi
     [ . . ] [ = ] 2bi ;
 
 [ t ] [ "example" test-template ] unit-test
index 208273364c127368e4dee99d0df8b51e36d79581..0bc644d019dc109b22bbd38bb4f3dd02614b8895 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: calendar io io.files kernel math math.order\r
 math.parser namespaces parser sequences strings\r
-assocs hashtables debugger mime-types sorting logging\r
+assocs hashtables debugger mime.types sorting logging\r
 calendar.format accessors splitting\r
 io.encodings.binary fry xml.entities destructors urls\r
 html.elements html.templates.fhtml\r
diff --git a/basis/io/encodings/utf16/.utf16.factor.swo b/basis/io/encodings/utf16/.utf16.factor.swo
deleted file mode 100644 (file)
index 01be8fd..0000000
Binary files a/basis/io/encodings/utf16/.utf16.factor.swo and /dev/null differ
index 313ce1f79af20c3ea9a4bc6deb7076ab442cbf8b..bef8d3dc569233f142854f51cd204fcfc36c7291 100755 (executable)
@@ -3,7 +3,7 @@
 USING: accessors combinators kernel system unicode.case
 io.unix.files io.files.listing generalizations strings
 arrays sequences io.files math.parser unix.groups unix.users
-io.files.listing.private ;
+io.files.listing.private unix.stat math ;
 IN: io.files.listing.unix
 
 <PRIVATE
@@ -30,6 +30,18 @@ IN: io.files.listing.unix
         [ [ sticky? ] [ other-execute? ] bi 2array "t" unix-execute>string ]
     } cleave 10 narray concat ;
 
+: mode>symbol ( mode -- ch )
+    S_IFMT bitand
+    {
+        { [ dup S_IFDIR = ] [ drop "/" ] }
+        { [ dup S_IFIFO = ] [ drop "|" ] }
+        { [ dup any-execute? ] [ drop "*" ] }
+        { [ dup S_IFLNK = ] [ drop "@" ] }
+        { [ dup S_IFWHT = ] [ drop "%" ] }
+        { [ dup S_IFSOCK = ] [ drop "=" ] }
+        { [ t ] [ drop "" ] }
+    } cond ;
+
 M: unix (directory.) ( path -- lines )
     [ [
         [
diff --git a/basis/io/sockets/secure/openssl/openssl.factor b/basis/io/sockets/secure/openssl/openssl.factor
new file mode 100644 (file)
index 0000000..83d7763
--- /dev/null
@@ -0,0 +1,197 @@
+! Copyright (C) 2007, 2008, Slava Pestov, Elie CHAFTARI.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors byte-arrays kernel debugger sequences namespaces math
+math.order combinators init alien alien.c-types alien.strings libc
+continuations destructors debugger summary splitting assocs
+random math.parser locals unicode.case
+openssl.libcrypto openssl.libssl
+io.backend io.ports io.files io.encodings.8-bit
+io.timeouts ;
+IN: io.sockets.secure.openssl
+
+GENERIC: ssl-method ( symbol -- method )
+
+M: SSLv2  ssl-method drop SSLv2_client_method ;
+M: SSLv23 ssl-method drop SSLv23_method ;
+M: SSLv3  ssl-method drop SSLv3_method ;
+M: TLSv1  ssl-method drop TLSv1_method ;
+
+TUPLE: openssl-context < secure-context aliens sessions ;
+
+: set-session-cache ( ctx -- )
+    handle>>
+    [ SSL_SESS_CACHE_BOTH SSL_CTX_set_session_cache_mode ssl-error ]
+    [ 32 random-bits >hex dup length SSL_CTX_set_session_id_context ssl-error ]
+    bi ;
+
+: load-certificate-chain ( ctx -- )
+    dup config>> key-file>> [
+        [ handle>> ] [ config>> key-file>> (normalize-path) ] bi
+        SSL_CTX_use_certificate_chain_file
+        ssl-error
+    ] [ drop ] if ;
+
+: password-callback ( -- alien )
+    "int" { "void*" "int" "bool" "void*" } "cdecl"
+    [| buf size rwflag password! |
+        password [ B{ 0 } password! ] unless
+
+        [let | len [ password strlen ] |
+            buf password len 1+ size min memcpy
+            len
+        ]
+    ] alien-callback ;
+
+: default-pasword ( ctx -- alien )
+    [ config>> password>> latin1 malloc-string ] [ aliens>> ] bi
+    [ push ] [ drop ] 2bi ;
+
+: set-default-password ( ctx -- )
+    [ handle>> password-callback SSL_CTX_set_default_passwd_cb ]
+    [
+        [ handle>> ] [ default-pasword ] bi
+        SSL_CTX_set_default_passwd_cb_userdata
+    ] bi ;
+
+: use-private-key-file ( ctx -- )
+    dup config>> key-file>> [
+        [ handle>> ] [ config>> key-file>> (normalize-path) ] bi
+        SSL_FILETYPE_PEM SSL_CTX_use_PrivateKey_file
+        ssl-error
+    ] [ drop ] if ;
+
+: load-verify-locations ( ctx -- )
+    dup config>> [ ca-file>> ] [ ca-path>> ] bi or [
+        [ handle>> ]
+        [
+            config>>
+            [ ca-file>> dup [ (normalize-path) ] when ]
+            [ ca-path>> dup [ (normalize-path) ] when ] bi
+        ] bi
+        SSL_CTX_load_verify_locations
+    ] [ handle>> SSL_CTX_set_default_verify_paths ] if ssl-error ;
+
+: set-verify-depth ( ctx -- )
+    dup config>> verify-depth>> [
+        [ handle>> ] [ config>> verify-depth>> ] bi
+        SSL_CTX_set_verify_depth
+    ] [ drop ] if ;
+
+TUPLE: bio handle disposed ;
+
+: <bio> ( handle -- bio ) f bio boa ;
+
+M: bio dispose* handle>> BIO_free ssl-error ;
+
+: <file-bio> ( path -- bio )
+    normalize-path "r" BIO_new_file dup ssl-error <bio> ;
+
+: load-dh-params ( ctx -- )
+    dup config>> dh-file>> [
+        [ handle>> ] [ config>> dh-file>> ] bi <file-bio> &dispose
+        handle>> f f f PEM_read_bio_DHparams dup ssl-error
+        SSL_CTX_set_tmp_dh ssl-error
+    ] [ drop ] if ;
+
+TUPLE: rsa handle disposed ;
+
+: <rsa> ( handle -- rsa ) f rsa boa ;
+
+M: rsa dispose* handle>> RSA_free ;
+
+: generate-eph-rsa-key ( ctx -- )
+    [ handle>> ]
+    [
+        config>> ephemeral-key-bits>> RSA_F4 f f RSA_generate_key
+        dup ssl-error <rsa> &dispose handle>>
+    ] bi
+    SSL_CTX_set_tmp_rsa ssl-error ;
+
+: <openssl-context> ( config ctx -- context )
+    openssl-context new
+        swap >>handle
+        swap >>config
+        V{ } clone >>aliens
+        H{ } clone >>sessions ;
+
+M: openssl <secure-context> ( config -- context )
+    maybe-init-ssl
+    [
+        dup method>> ssl-method SSL_CTX_new
+        dup ssl-error <openssl-context> |dispose
+        {
+            [ set-session-cache ]
+            [ load-certificate-chain ]
+            [ set-default-password ]
+            [ use-private-key-file ]
+            [ load-verify-locations ]
+            [ set-verify-depth ]
+            [ load-dh-params ]
+            [ generate-eph-rsa-key ]
+            [ ]
+        } cleave
+    ] with-destructors ;
+
+M: openssl-context dispose*
+    [ aliens>> [ free ] each ]
+    [ sessions>> values [ SSL_SESSION_free ] each ]
+    [ handle>> SSL_CTX_free ]
+    tri ;
+
+TUPLE: ssl-handle file handle connected disposed ;
+
+SYMBOL: default-secure-context
+
+: context-expired? ( context -- ? )
+    dup [ handle>> expired? ] [ drop t ] if ;
+
+: current-secure-context ( -- ctx )
+    secure-context get [
+        default-secure-context get dup context-expired? [
+            drop
+            <secure-config> <secure-context> default-secure-context set-global
+            current-secure-context
+        ] when
+    ] unless* ;
+
+: <ssl-handle> ( fd -- ssl )
+    current-secure-context handle>> SSL_new dup ssl-error
+    f f ssl-handle boa ;
+
+M: ssl-handle dispose*
+    [ handle>> SSL_free ] [ file>> dispose ] bi ;
+
+: check-verify-result ( ssl-handle -- )
+    SSL_get_verify_result dup X509_V_OK =
+    [ drop ] [ verify-message certificate-verify-error ] if ;
+
+: common-name ( certificate -- host )
+    X509_get_subject_name
+    NID_commonName 256 <byte-array>
+    [ 256 X509_NAME_get_text_by_NID ] keep
+    swap -1 = [ drop f ] [ latin1 alien>string ] if ;
+
+: common-names-match? ( expected actual -- ? )
+    [ >lower ] bi@ "*." ?head [ tail? ] [ = ] if ;
+
+: check-common-name ( host ssl-handle -- )
+    SSL_get_peer_certificate common-name
+    2dup common-names-match?
+    [ 2drop ] [ common-name-verify-error ] if ;
+
+M: openssl check-certificate ( host ssl -- )
+    current-secure-context config>> verify>> [
+        handle>>
+        [ nip check-verify-result ]
+        [ check-common-name ]
+        2bi
+    ] [ 2drop ] if ;
+
+: get-session ( addrspec -- session/f )
+    current-secure-context sessions>> at
+    dup expired? [ drop f ] when ;
+
+: save-session ( session addrspec -- )
+    current-secure-context sessions>> set-at ;
+
+openssl secure-socket-backend set-global
index fb8615c47b5338f05cac03ed4dde13dfbba22818..9fa1727e16c241dadd46f9b40e2e46a381dfdea5 100644 (file)
@@ -6,7 +6,8 @@ math.bitwise byte-arrays alien combinators calendar
 io.encodings.binary accessors sequences strings system
 io.files.private destructors vocabs.loader calendar.unix
 unix.stat alien.c-types arrays unix.users unix.groups
-environment fry io.encodings.utf8 alien.strings unix.statfs ;
+environment fry io.encodings.utf8 alien.strings unix.statfs
+combinators.short-circuit ;
 IN: io.unix.files
 
 M: unix cwd ( -- path )
@@ -117,8 +118,8 @@ M: unix stat>file-info ( stat -- file-info )
         [ stat-st_blksize >>blocksize ]
     } cleave ;
 
-M: unix stat>type ( stat -- type )
-    stat-st_mode S_IFMT bitand {
+: n>file-type ( n -- type )
+    S_IFMT bitand {
         { S_IFREG [ +regular-file+ ] }
         { S_IFDIR [ +directory+ ] }
         { S_IFCHR [ +character-device+ ] }
@@ -129,6 +130,9 @@ M: unix stat>type ( stat -- type )
         [ drop +unknown+ ]
     } case ;
 
+M: unix stat>type ( stat -- type )
+    stat-st_mode n>file-type ;
+
 ! Linux has no extra fields in its stat struct
 os {
     { macosx  [ "io.unix.files.bsd" require ] }
@@ -150,7 +154,7 @@ os {
 
 M: unix >directory-entry ( byte-array -- directory-entry )
     [ dirent-d_name utf8 alien>string ]
-    [ dirent-d_type ] bi directory-entry boa ;
+    [ dirent-d_type dirent-type>file-type ] bi directory-entry boa ;
 
 M: unix (directory-entries) ( path -- seq )
     [
@@ -225,6 +229,15 @@ GENERIC: other-read? ( obj -- ? )
 GENERIC: other-write? ( obj -- ? )
 GENERIC: other-execute? ( obj -- ? )
 
+: any-read? ( obj -- ? )
+    { [ user-read? ] [ group-read? ] [ other-read? ] } 1|| ;
+
+: any-write? ( obj -- ? )
+    { [ user-write? ] [ group-write? ] [ other-write? ] } 1|| ;
+
+: any-execute? ( obj -- ? )
+    { [ user-execute? ] [ group-execute? ] [ other-execute? ] } 1|| ;
+
 M: integer uid? ( integer -- ? ) UID mask? ;
 M: integer gid? ( integer -- ? ) GID mask? ;
 M: integer sticky? ( integer -- ? ) STICKY mask? ;
index 649c68673fe4c34679e8fc48da0d0b5cbfdaff82..fb5ed939781a3b7868a98ccfa7ad6557dfbefb36 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2007, 2008, Slava Pestov, Elie CHAFTARI.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors unix byte-arrays kernel debugger sequences namespaces math
-math.order combinators init alien alien.c-types alien.strings libc
-continuations destructors
-openssl openssl.libcrypto openssl.libssl
-io.files io.ports io.unix.backend io.unix.sockets
-io.encodings.ascii io.buffers io.sockets io.sockets.secure
+USING: accessors unix byte-arrays kernel debugger sequences
+namespaces math math.order combinators init alien alien.c-types
+alien.strings libc continuations destructors openssl
+openssl.libcrypto openssl.libssl io.files io.ports
+io.unix.backend io.unix.sockets io.encodings.ascii io.buffers
+io.sockets io.sockets.secure io.sockets.secure.openssl
 io.timeouts system summary ;
 IN: io.unix.sockets.secure
 
index d0409ce59a10f754ab6019be8a25fb586a6daa78..7f84b9d9e54b01e96a03fb12760687f3e944bd53 100755 (executable)
@@ -114,11 +114,6 @@ M: windows delete-directory ( path -- )
     normalize-path
     RemoveDirectory win32-error=0/f ;
 
-M: windows >directory-entry ( byte-array -- directory-entry )
-    [ WIN32_FIND_DATA-cFileName utf16n alien>string ]
-    [ WIN32_FIND_DATA-dwFileAttributes ]
-    bi directory-entry boa ;
-
 : find-first-file ( path -- WIN32_FIND_DATA handle )
     "WIN32_FIND_DATA" <c-object> tuck
     FindFirstFile
@@ -177,6 +172,15 @@ TUPLE: windows-file-info < file-info attributes ;
 : win32-file-type ( n -- symbol )
     FILE_ATTRIBUTE_DIRECTORY mask? +directory+ +regular-file+ ? ;
 
+TUPLE: windows-directory-entry < directory-entry attributes ;
+
+M: windows >directory-entry ( byte-array -- directory-entry )
+    [ WIN32_FIND_DATA-cFileName utf16n alien>string ]
+    [ WIN32_FIND_DATA-dwFileAttributes win32-file-type ]
+    [ WIN32_FIND_DATA-dwFileAttributes win32-file-attributes ]
+    tri
+    dupd remove windows-directory-entry boa ;
+
 : WIN32_FIND_DATA>file-info ( WIN32_FIND_DATA -- file-info )
     [ \ windows-file-info new ] dip
     {
index beea9005b4c440d1f63e47fcdf83f2cdbcd12bdf..014e096b1db41107fb68258536bb127521b6ecc1 100644 (file)
@@ -1,34 +1,60 @@
 USING: help.markup help.syntax kernel io system prettyprint ;
 IN: listener
 
+ARTICLE: "listener-watch" "Watching variables in the listener"
+"The listener prints the concepts of the data and retain stacks after every expression. It can also print values of dynamic variables which are added to a watch list:"
+{ $subsection visible-vars }
+"To add or remove a single variable:"
+{ $subsection show-var }
+{ $subsection hide-var }
+"To add and remove multiple variables:"
+{ $subsection show-vars }
+{ $subsection hide-vars }
+"Hiding all visible variables:"
+{ $subsection hide-all-vars } ;
+
+HELP: show-var
+{ $values { "var" "a variable name" } }
+{ $description "Adds a variable to the watch list; its value will be printed by the listener after every expression." } ;
+
+HELP: show-vars
+{ $values { "seq" "a sequence of variable names" } }
+{ $description "Adds a sequence of variables to the watch list; their values will be printed by the listener after every expression." } ;
+
+HELP: hide-var
+{ $values { "var" "a variable name" } }
+{ $description "Removes a variable from the watch list." } ;
+
+HELP: hide-vars
+{ $values { "seq" "a sequence of variable names" } }
+{ $description "Removes a sequence of variables from the watch list." } ;
+
+HELP: hide-all-vars
+{ $description "Removes all variables from the watch list." } ;
+
 ARTICLE: "listener" "The listener"
 "The listener evaluates Factor expressions read from a stream. The listener is the primary interface to the Factor runtime. Typically, you write Factor code in a text editor, then load it using the listener and test it."
 $nl
 "The classical first program can be run in the listener:"
 { $example "\"Hello, world\" print" "Hello, world" }
-"Multi-line phrases are supported:"
+"Multi-line expressions are supported:"
 { $example "{ 1 2 3 } [\n    .\n] each" "1\n2\n3" }
 "The listener knows when to expect more input by looking at the height of the stack. Parsing words such as " { $link POSTPONE: { } " leave elements on the parser stack, and corresponding words such as " { $link POSTPONE: } } " pop them."
-$nl
-"A very common operation is to inspect the contents of the data stack in the listener:"
-{ $subsection .s }
-"Note that calls to " { $link .s } " can also be included inside words as a debugging aid, however a more convenient way to achieve this is to use the annotation facility. See " { $link "tools.annotations" } "."
-$nl
+{ $subsection "listener-watch" }
 "You can start a nested listener or exit a listener using the following words:"
 { $subsection listener }
 { $subsection bye }
-"The following variables can be rebound inside a nested scope to customize the behavior of a listener; this can be done to create a development tool with a custom interaction loop:"
-{ $subsection listener-hook }
 "Finally, the multi-line expression reading word can be used independently of the rest of the listener:"
 { $subsection read-quot } ;
 
 ABOUT: "listener"
 
+<PRIVATE
+
 HELP: quit-flag
 { $var-description "Variable set to true by " { $link bye } " word; it forces the next iteration of the " { $link listener } " loop to end." } ;
 
-HELP: listener-hook
-{ $var-description "Variable holding a quotation called by the listener before reading an input expression. The UI sets this variable to a quotation which updates the stack display in a listener gadget." } ;
+PRIVATE>
 
 HELP: read-quot
 { $values { "quot/f" "a parsed quotation, or " { $link f } " indicating end of file" } }
index feddbdc042b9bb96ca3152f559e79e3b019803e6..95ad2640002031a72a556f472fb305677d7fa2a6 100644 (file)
@@ -3,16 +3,10 @@
 USING: arrays hashtables io kernel math math.parser memory
 namespaces parser lexer sequences strings io.styles
 vectors words generic system combinators continuations debugger
-definitions compiler.units accessors colors ;
-
+definitions compiler.units accessors colors prettyprint fry
+sets ;
 IN: listener
 
-SYMBOL: quit-flag
-
-SYMBOL: listener-hook
-
-[ ] listener-hook set-global
-
 GENERIC: stream-read-quot ( stream -- quot/f )
 
 : parse-lines-interactive ( lines -- quot/f )
@@ -38,18 +32,65 @@ M: object stream-read-quot
 
 : read-quot ( -- quot/f ) input-stream get stream-read-quot ;
 
+<PRIVATE
+
+SYMBOL: quit-flag
+
+PRIVATE>
+
 : bye ( -- ) quit-flag on ;
 
-: prompt. ( -- )
-    "( " in get " )" 3append
-    H{ { background T{ rgba f 1 0.7 0.7 1 } } } format bl flush ;
+SYMBOL: visible-vars
+
+: show-var ( var -- ) visible-vars  [ swap suffix ] change ;
+
+: show-vars ( seq -- ) visible-vars [ swap union ] change ;
+
+: hide-var ( var -- ) visible-vars [ remove ] change ;
+
+: hide-vars ( seq -- ) visible-vars [ swap diff ] change ;
+
+: hide-all-vars ( -- ) visible-vars off ;
 
 SYMBOL: error-hook
 
 [ print-error-and-restarts ] error-hook set-global
 
+<PRIVATE
+
+: title. ( string -- )
+    H{ { foreground T{ rgba f 0.3 0.3 0.3 1 } } } format nl ;
+
+: visible-vars. ( -- )
+    visible-vars get [
+        nl "--- Watched variables:" title.
+        standard-table-style [
+            [
+                [
+                    [ [ short. ] with-cell ]
+                    [ [ get short. ] with-cell ]
+                    bi
+                ] with-row
+            ] each
+        ] tabular-output
+    ] unless-empty ;
+
+SYMBOL: display-stacks?
+
+t display-stacks? set-global
+
+: stacks. ( -- )
+    display-stacks? get [
+        datastack [ nl "--- Data stack:" title. stack. ] unless-empty
+        retainstack [ nl "--- Retain stack:" title. stack. ] unless-empty
+    ] when ;
+
+: prompt. ( -- )
+    "( " in get auto-use? get [ " - auto" append ] when " )" 3append
+    H{ { background T{ rgba f 1 0.7 0.7 1 } } } format bl flush ;
+
 : listen ( -- )
-    listener-hook get call prompt.
+    visible-vars. stacks. prompt.
     [ read-quot [ [ error-hook get call ] recover ] [ bye ] if* ]
     [
         dup lexer-error? [
@@ -62,6 +103,8 @@ SYMBOL: error-hook
 : until-quit ( -- )
     quit-flag get [ quit-flag off ] [ listen until-quit ] if ;
 
+PRIVATE>
+
 : listener ( -- )
     [ until-quit ] with-interactive-vocabs ;
 
index 35e0536530a19b2b38501b05d1e5328a1b985f47..18488ed1ddd4c204c56e9e4effff076c5dfcbc6f 100644 (file)
@@ -132,8 +132,8 @@ $nl
 "Unlike some languages such as Python and Java, writing to mutable locals in outer scopes is fully supported and has the expected semantics." ;
 
 ARTICLE: "locals-limitations" "Limitations of locals"
-"The first limitation is that the " { $link >r } " and " { $link r> } " words may not be used together with locals. Instead, use the " { $link dip } " combinator."
-$nl
+"The first limitation is also shared by " { $vocab-link "fry" } ": the " { $link >r } " and " { $link r> } " words may not be used together with locals. Instead, use the " { $link dip } " combinator. An error is thrown at parse time if an attempt is made to use " { $link >r } " and " { $link r> } " inside a lambda body:"
+{ $subsection >r/r>-in-lambda-error }
 "Another limitation concerns combinators implemented as macros. Locals can only be used with such combinators if the input array immediately precedes the combinator call. For example, the following will work:"
 { $code
     ":: good-cond-usage ( a -- ... )"
index ca6697be1cdd5198956d878c8d574b185f16b187..44c04da1a14dade304009ad1409483b488f2eb16 100644 (file)
@@ -2,7 +2,7 @@ USING: locals math sequences tools.test hashtables words kernel
 namespaces arrays strings prettyprint io.streams.string parser
 accessors generic eval combinators combinators.short-circuit
 combinators.short-circuit.smart math.order math.functions
-definitions compiler.units ;
+definitions compiler.units fry lexer ;
 IN: locals.tests
 
 :: foo ( a b -- a a ) a a ;
@@ -286,6 +286,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
         { [ a b > ] [ 5 ] }
     } cond ;
 
+\ cond-test must-infer
+
 [ 3 ] [ 1 2 cond-test ] unit-test
 [ 4 ] [ 2 2 cond-test ] unit-test
 [ 5 ] [ 3 2 cond-test ] unit-test
@@ -293,6 +295,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
 :: 0&&-test ( a -- ? )
     { [ a integer? ] [ a even? ] [ a 10 > ] } 0&& ;
 
+\ 0&&-test must-infer
+
 [ f ] [ 1.5 0&&-test ] unit-test
 [ f ] [ 3 0&&-test ] unit-test
 [ f ] [ 8 0&&-test ] unit-test
@@ -301,6 +305,8 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
 :: &&-test ( a -- ? )
     { [ a integer? ] [ a even? ] [ a 10 > ] } && ;
 
+\ &&-test must-infer
+
 [ f ] [ 1.5 &&-test ] unit-test
 [ f ] [ 3 &&-test ] unit-test
 [ f ] [ 8 &&-test ] unit-test
@@ -346,6 +352,10 @@ M:: sequence method-with-locals ( a -- y ) a reverse ;
 
 { 3 1 } [| from to seq | T{ slice f from to seq } ] must-infer-as
 
+ERROR: punned-class x ;
+
+[ T{ punned-class f 3 } ] [ 3 [| a | T{ punned-class f a } ] call ] unit-test
+
 :: literal-identity-test ( -- a b )
     { } V{ } ;
 
@@ -388,6 +398,26 @@ M:: integer lambda-method-forget-test ( a -- b ) ;
 
 [ ] [ [ { integer lambda-method-forget-test } forget ] with-compilation-unit ] unit-test
 
+[ { [ 10 ] } ] [ 10 [| A | { [ A ] } ] call ] unit-test
+
+[
+    "USING: locals fry math ; [ 0 '[ [let | A [ 10 ] | A _ + ] ] ]" eval
+] [ error>> >r/r>-in-fry-error? ] must-fail-with
+
+:: (funny-macro-test) ( obj quot -- ? ) obj { quot } 1&& ; inline
+: funny-macro-test ( n -- ? ) [ odd? ] (funny-macro-test) ;
+
+\ funny-macro-test must-infer
+
+[ t ] [ 3 funny-macro-test ] unit-test
+[ f ] [ 2 funny-macro-test ] unit-test
+
+! Some odd parser corner cases
+[ "USE: locals [let" eval ] [ error>> unexpected-eof? ] must-fail-with
+[ "USE: locals [let |" eval ] [ error>> unexpected-eof? ] must-fail-with
+[ "USE: locals [let | a" eval ] [ error>> unexpected-eof? ] must-fail-with
+[ "USE: locals [|" eval ] [ error>> unexpected-eof? ] must-fail-with
+
 ! :: wlet-&&-test ( a -- ? )
 !     [wlet | is-integer? [ a integer? ]
 !             is-even? [ a even? ]
index 7de9d10436088cbabbe19c4120b0ccd934447fce..e66b1531d206c7dfafdabfa8f64986ffb9a00d47 100644 (file)
@@ -6,12 +6,18 @@ quotations debugger macros arrays macros splitting combinators
 prettyprint.backend definitions prettyprint hashtables
 prettyprint.sections sets sequences.private effects
 effects.parser generic generic.parser compiler.units accessors
-locals.backend memoize macros.expander lexer classes ;
+locals.backend memoize macros.expander lexer classes summary ;
 IN: locals
 
 ! Inspired by
 ! http://cat-language.googlecode.com/svn/trunk/CatPointFreeForm.cs
 
+ERROR: >r/r>-in-lambda-error ;
+
+M: >r/r>-in-lambda-error summary
+    drop
+    "Explicit retain stack manipulation is not permitted in lambda bodies" ;
+
 <PRIVATE
 
 TUPLE: lambda vars body ;
@@ -141,20 +147,17 @@ GENERIC: free-vars* ( form -- )
 : free-vars ( form -- vars )
     [ free-vars* ] { } make prune ;
 
-: add-if-free ( object -- )
-    {
-        { [ dup local-writer? ] [ "local-reader" word-prop , ] }
-        { [ dup lexical? ] [ , ] }
-        { [ dup quote? ] [ local>> , ] }
-        { [ t ] [ free-vars* ] }
-    } cond ;
+M: local-writer free-vars* "local-reader" word-prop , ;
+
+M: lexical free-vars* , ;
+
+M: quote free-vars* , ;
 
 M: object free-vars* drop ;
 
-M: quotation free-vars* [ add-if-free ] each ;
+M: quotation free-vars* [ free-vars* ] each ;
 
-M: lambda free-vars*
-    [ vars>> ] [ body>> ] bi free-vars swap diff % ;
+M: lambda free-vars* [ vars>> ] [ body>> ] bi free-vars swap diff % ;
 
 GENERIC: lambda-rewrite* ( obj -- )
 
@@ -201,6 +204,8 @@ M: special rewrite-literal? drop t ;
 
 M: array rewrite-literal? [ rewrite-literal? ] contains? ;
 
+M: quotation rewrite-literal? [ rewrite-literal? ] contains? ;
+
 M: hashtable rewrite-literal? drop t ;
 
 M: vector rewrite-literal? drop t ;
@@ -215,17 +220,20 @@ GENERIC: rewrite-element ( obj -- )
     [ rewrite-element ] each ;
 
 : rewrite-sequence ( seq -- )
-    [ rewrite-elements ] [ length , ] [ , ] tri \ nsequence , ;
+    [ rewrite-elements ] [ length , ] [ 0 head , ] tri \ nsequence , ;
 
 M: array rewrite-element
     dup rewrite-literal? [ rewrite-sequence ] [ , ] if ;
 
+M: quotation rewrite-element
+    dup rewrite-literal? [ rewrite-sequence ] [ , ] if ;
+
 M: vector rewrite-element rewrite-sequence ;
 
 M: hashtable rewrite-element >alist rewrite-sequence \ >hashtable , ;
 
 M: tuple rewrite-element
-    [ tuple-slots rewrite-elements ] [ class , ] bi \ boa , ;
+    [ tuple-slots rewrite-elements ] [ class literalize , ] bi \ boa , ;
 
 M: local rewrite-element , ;
 
@@ -243,6 +251,10 @@ M: tuple local-rewrite* rewrite-element ;
 
 M: hashtable local-rewrite* rewrite-element ;
 
+M: word local-rewrite*
+    dup { >r r> } memq?
+    [ >r/r>-in-lambda-error ] [ call-next-method ] if ;
+
 M: object lambda-rewrite* , ;
 
 M: object local-rewrite* , ;
@@ -277,18 +289,16 @@ SYMBOL: in-lambda?
     \ ] (parse-lambda) <lambda> ;
 
 : parse-binding ( -- pair/f )
-    scan dup "|" = [
-        drop f
-    ] [
-        scan {
-            { "[" [ \ ] parse-until >quotation ] }
-            { "[|" [ parse-lambda ] }
-        } case 2array
-    ] if ;
+    scan {
+        { [ dup not ] [ unexpected-eof ] }
+        { [ dup "|" = ] [ drop f ] }
+        { [ dup "!" = ] [ drop POSTPONE: ! parse-binding ] }
+        [ scan-object 2array ]
+    } cond ;
 
 : (parse-bindings) ( -- )
     parse-binding [
-        first2 >r make-local r> 2array ,
+        first2 [ make-local ] dip 2array ,
         (parse-bindings)
     ] when* ;
 
@@ -341,7 +351,7 @@ M: wlet local-rewrite*
     in>> [ dup pair? [ first ] when ] map make-locals dup push-locals ;
 
 : parse-locals-definition ( word -- word quot )
-    scan "(" assert= parse-locals \ ; (parse-lambda) <lambda>
+    "(" expect parse-locals \ ; (parse-lambda) <lambda>
     2dup "lambda" set-word-prop
     lambda-rewrite first ;
 
@@ -359,15 +369,15 @@ PRIVATE>
 : [| parse-lambda parsed-lambda ; parsing
 
 : [let
-    scan "|" assert= parse-bindings
+    "|" expect parse-bindings
     \ ] (parse-lambda) <let> parsed-lambda ; parsing
 
 : [let*
-    scan "|" assert= parse-bindings*
+    "|" expect parse-bindings*
     \ ] (parse-lambda) <let*> parsed-lambda ; parsing
 
 : [wlet
-    scan "|" assert= parse-wbindings
+    "|" expect parse-wbindings
     \ ] (parse-lambda) <wlet> parsed-lambda ; parsing
 
 : :: (::) define ; parsing
index 3666fa2423c7e2d579ae772caaeeacd17a57e183..cdd2b49d9cd656f738835b3dd66466959f498d89 100644 (file)
@@ -37,9 +37,17 @@ M: wrapper expand-macros* wrapped>> literal ;
         [ '[ _ ndrop _ nnip call ] [ ] like ] 2map , \ dispatch ,
     ] bi ;
 
-: expand-macro ( quot -- )
-    stack [ swap with-datastack >vector ] change
-    stack get pop >quotation end (expand-macros) ;
+: word, ( word -- ) end , ;
+
+: expand-macro ( word quot -- )
+    '[
+        drop
+        stack [ _ with-datastack >vector ] change
+        stack get pop >quotation end (expand-macros)
+    ] [
+        drop
+        word,
+    ] recover ;
 
 : expand-macro? ( word -- quot ? )
     dup [ "transform-quot" word-prop ] [ "macro" word-prop ] bi or dup [
@@ -47,11 +55,9 @@ M: wrapper expand-macros* wrapped>> literal ;
         stack get length <=
     ] [ 2drop f f ] if ;
 
-: word, ( word -- ) end , ;
-
 M: word expand-macros*
     dup expand-dispatch? [ drop expand-dispatch ] [
-        dup expand-macro? [ nip expand-macro ] [
+        dup expand-macro? [ expand-macro ] [
             drop word,
         ] if
     ] if ;
index 4f2606bda0ef8540cb6f6fdc7a43186d92ced564..9ed164330bcd3edfc6fa3cfe6f14fa4deb4e267d 100644 (file)
@@ -310,8 +310,9 @@ ARTICLE: "math-bitfields" "Constructing bit fields"
 "Some applications, such as binary communication protocols and assemblers, need to construct integers from elaborate bit field specifications. Hand-coding this using " { $link shift } " and " { $link bitor } " results in repetitive code. A higher-level facility exists to factor out this repetition:"
 { $subsection bitfield } ;
 
-ARTICLE: "math.bitwise" "Bitwise arithmetic"
-"The " { $vocab-link "math.bitwise" } " vocabulary can implements bitwise arithmetic words that are useful for efficiency, low-level programming, and interfacing with C libraries." $nl
+ARTICLE: "math.bitwise" "Additional bitwise arithmetic"
+"The " { $vocab-link "math.bitwise" } " vocabulary provides bitwise arithmetic words extending " { $link "bitwise-arithmetic" } ". They are useful for efficiency, low-level programming, and interfacing with C libraries."
+$nl
 "Setting and clearing bits:"
 { $subsection set-bit }
 { $subsection clear-bit }
index a892940363f47e4631961e03ee6521b6446abaeb..31c9e44b1d3337979ceeafe9dc035092850bee78 100644 (file)
@@ -47,3 +47,21 @@ HELP: <zero-rect>
 { $values { "rect" "a new " { $link rect } } }
 { $description "Creates a rectangle located at the origin with zero dimensions." } ;
 
+ARTICLE: "math.geometry.rect" "Rectangles"
+"The " { $vocab-link "math.geometry.rect" } " vocabulary defines a rectangle data type and operations on them."
+{ $subsection rect }
+"Rectangles can be taken apart:"
+{ $subsection rect-loc }
+{ $subsection rect-dim }
+{ $subsection rect-bounds }
+{ $subsection rect-extent }
+"New rectangles can be created:"
+{ $subsection <zero-rect> }
+{ $subsection <rect> }
+{ $subsection <extent-rect> }
+"More utility words for working with rectangles:"
+{ $subsection offset-rect }
+{ $subsection rect-intersect }
+{ $subsection intersects? } ;
+
+ABOUT: "math.geometry.rect"
index 6874b79d2ed52bb24914d5a58538dc677f61190f..ddde4e124498ae1a7b590b9c9d69085aa7de2ae5 100644 (file)
@@ -29,6 +29,8 @@ M: word integer-op-input-classes
         { fixnum- fixnum-fast }
         { fixnum* fixnum*fast }
         { fixnum-shift fixnum-shift-fast }
+        { fixnum/i fixnum/i-fast }
+        { fixnum/mod fixnum/mod-fast }
     } at ;
 
 : modular-variant ( op -- fast-op )
diff --git a/basis/mime-types/authors.txt b/basis/mime-types/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/basis/mime-types/mime-types-docs.factor b/basis/mime-types/mime-types-docs.factor
deleted file mode 100644 (file)
index b7fa46d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-! Copyright (C) 2008 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: assocs help.markup help.syntax io.streams.string sequences ;
-IN: mime-types
-
-HELP: mime-db
-{ $values
-    
-     { "seq" sequence } }
-{ $description "Outputs an array where the first element is a MIME type and the rest of the array is file extensions that have that MIME type." } ;
-
-HELP: mime-type
-{ $values
-    { "filename" "a filename" }
-    { "mime-type" "a MIME type string" } }
-{ $description "Outputs the MIME type associtated with a path by parsing the path's file extension and looking it up in the table returned by " { $link mime-types } "." } ;
-
-HELP: mime-types
-{ $values
-    
-     { "assoc" assoc } }
-{ $description "Outputs an " { $snippet "assoc" } " made from the data in the " { $link mime-db } " word where the keys are file extensions and the values are the corresponding MIME types." } ;
-
-HELP: nonstandard-mime-types
-{ $values
-    
-     { "assoc" assoc } }
-{ $description "A list of Factor-specific MIME types that are added to the MIME database loaded from disk." } ;
-
-ARTICLE: "mime-types" "MIME types"
-"The " { $vocab-link "mime-types" } " vocabulary loads a file of MIME types and provides a word to look up the MIME type based on a file extension." $nl
-"Looking up a MIME type:"
-{ $subsection mime-type } ;
-
-ABOUT: "mime-types"
diff --git a/basis/mime-types/mime-types-tests.factor b/basis/mime-types/mime-types-tests.factor
deleted file mode 100644 (file)
index 925eca2..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-IN: mime-types.tests
-USING: mime-types tools.test ;
-
-[ "application/postscript" ] [ "foo.ps" mime-type ] unit-test
-[ "application/octet-stream" ] [ "foo.ps.gz" mime-type ] unit-test
-[ "text/plain" ] [ "foo.factor" mime-type ] unit-test
diff --git a/basis/mime-types/mime-types.factor b/basis/mime-types/mime-types.factor
deleted file mode 100644 (file)
index 909f762..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-! Copyright (C) 2004, 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: io.files io.encodings.ascii assocs sequences splitting
-kernel namespaces fry memoize ;
-IN: mime-types
-
-MEMO: mime-db ( -- seq )
-    "resource:basis/mime-types/mime.types" ascii file-lines
-    [ "#" head? not ] filter [ " \t" split harvest ] map harvest ;
-
-: nonstandard-mime-types ( -- assoc )
-    H{
-        { "factor" "text/plain"                       }
-        { "cgi"    "application/x-cgi-script"         }
-        { "fhtml"  "application/x-factor-server-page" }
-    } ;
-
-MEMO: mime-types ( -- assoc )
-    [
-        mime-db [ unclip '[ [ _ ] dip set ] each ] each
-    ] H{ } make-assoc
-    nonstandard-mime-types assoc-union ;
-
-: mime-type ( filename -- mime-type )
-    file-extension mime-types at "application/octet-stream" or ;
diff --git a/basis/mime-types/mime.types b/basis/mime-types/mime.types
deleted file mode 100644 (file)
index b602e9d..0000000
+++ /dev/null
@@ -1,988 +0,0 @@
-# This is a comment. I love comments.
-
-# This file controls what Internet media types are sent to the client for
-# given file extension(s).  Sending the correct media type to the client
-# is important so they know how to handle the content of the file.
-# Extra types can either be added here or by using an AddType directive
-# in your config files. For more information about Internet media types,
-# please read RFC 2045, 2046, 2047, 2048, and 2077.  The Internet media type
-# registry is at <http://www.iana.org/assignments/media-types/>.
-
-# MIME type                                    Extensions
-application/activemessage
-application/andrew-inset                       ez
-application/applefile
-application/atom+xml                           atom
-application/atomcat+xml                                atomcat
-application/atomicmail
-application/atomsvc+xml                                atomsvc
-application/auth-policy+xml
-application/batch-smtp
-application/beep+xml
-application/cals-1840
-application/ccxml+xml                          ccxml
-application/cellml+xml
-application/cnrp+xml
-application/commonground
-application/conference-info+xml
-application/cpl+xml
-application/csta+xml
-application/cstadata+xml
-application/cybercash
-application/davmount+xml                       davmount
-application/dca-rft
-application/dec-dx
-application/dialog-info+xml
-application/dicom
-application/dns
-application/dvcs
-application/ecmascript                         ecma
-application/edi-consent
-application/edi-x12
-application/edifact
-application/epp+xml
-application/eshop
-application/fastinfoset
-application/fastsoap
-application/fits
-application/font-tdpfr                         pfr
-application/h224
-application/http
-application/hyperstudio                                stk
-application/iges
-application/im-iscomposing+xml
-application/index
-application/index.cmd
-application/index.obj
-application/index.response
-application/index.vnd
-application/iotp
-application/ipp
-application/isup
-application/javascript                         js
-application/json                               json
-application/kpml-request+xml
-application/kpml-response+xml
-application/mac-binhex40                       hqx
-application/mac-compactpro                     cpt
-application/macwriteii
-application/marc                               mrc
-application/mathematica                                ma nb mb
-application/mathml+xml                         mathml
-application/mbms-associated-procedure-description+xml
-application/mbms-deregister+xml
-application/mbms-envelope+xml
-application/mbms-msk+xml
-application/mbms-msk-response+xml
-application/mbms-protection-description+xml
-application/mbms-reception-report+xml
-application/mbms-register+xml
-application/mbms-register-response+xml
-application/mbms-user-service-description+xml
-application/mbox                               mbox
-application/mediaservercontrol+xml             mscml
-application/mikey
-application/mp4                                        mp4s
-application/mpeg4-generic
-application/mpeg4-iod
-application/mpeg4-iod-xmt
-application/msword                             doc dot
-application/mxf                                        mxf
-application/nasdata
-application/news-message-id
-application/news-transmission
-application/nss
-application/ocsp-request
-application/ocsp-response
-application/octet-stream bin dms lha lzh class so iso dmg dist distz pkg bpk dump elc scpt
-application/oda                                        oda
-application/oebps-package+xml
-application/ogg                                        ogg
-application/parityfec
-application/pdf                                        pdf
-application/pgp-encrypted                      pgp
-application/pgp-keys
-application/pgp-signature                      asc sig
-application/pics-rules                         prf
-application/pidf+xml
-application/pkcs10                             p10
-application/pkcs7-mime                         p7m p7c
-application/pkcs7-signature                    p7s
-application/pkix-cert                          cer
-application/pkix-crl                           crl
-application/pkix-pkipath                       pkipath
-application/pkixcmp                            pki
-application/pls+xml                            pls
-application/poc-settings+xml
-application/postscript                         ai eps ps
-application/prs.alvestrand.titrax-sheet
-application/prs.cww                            cww
-application/prs.nprend
-application/prs.plucker
-application/qsig
-application/rdf+xml                            rdf
-application/reginfo+xml                                rif
-application/relax-ng-compact-syntax            rnc
-application/remote-printing
-application/resource-lists+xml                 rl
-application/riscos
-application/rlmi+xml
-application/rls-services+xml                   rs
-application/rsd+xml                            rsd
-application/rss+xml                            rss
-application/rtf                                        rtf
-application/rtx
-application/samlassertion+xml
-application/samlmetadata+xml
-application/sbml+xml                           sbml
-application/sdp                                        sdp
-application/set-payment
-application/set-payment-initiation             setpay
-application/set-registration
-application/set-registration-initiation                setreg
-application/sgml
-application/sgml-open-catalog
-application/shf+xml                            shf
-application/sieve
-application/simple-filter+xml
-application/simple-message-summary
-application/simplesymbolcontainer
-application/slate
-application/smil
-application/smil+xml                           smi smil
-application/soap+fastinfoset
-application/soap+xml
-application/spirits-event+xml
-application/srgs                               gram
-application/srgs+xml                           grxml
-application/ssml+xml                           ssml
-application/timestamp-query
-application/timestamp-reply
-application/tve-trigger
-application/vemmi
-application/vividence.scriptfile
-application/vnd.3gpp.bsf+xml
-application/vnd.3gpp.pic-bw-large              plb
-application/vnd.3gpp.pic-bw-small              psb
-application/vnd.3gpp.pic-bw-var                        pvb
-application/vnd.3gpp.sms
-application/vnd.3gpp2.bcmcsinfo+xml
-application/vnd.3gpp2.sms
-application/vnd.3m.post-it-notes               pwn
-application/vnd.accpac.simply.aso              aso
-application/vnd.accpac.simply.imp              imp
-application/vnd.acucobol                       acu
-application/vnd.acucorp                                atc acutc
-application/vnd.adobe.xdp+xml                  xdp
-application/vnd.adobe.xfdf                     xfdf
-application/vnd.aether.imp
-application/vnd.amiga.ami                      ami
-application/vnd.anser-web-certificate-issue-initiation cii
-application/vnd.anser-web-funds-transfer-initiation    fti
-application/vnd.antix.game-component           atx
-application/vnd.apple.installer+xml            mpkg
-application/vnd.audiograph                     aep
-application/vnd.autopackage
-application/vnd.avistar+xml
-application/vnd.blueice.multipass              mpm
-application/vnd.bmi                            bmi
-application/vnd.businessobjects                        rep
-application/vnd.cab-jscript
-application/vnd.canon-cpdl
-application/vnd.canon-lips
-application/vnd.cendio.thinlinc.clientconf
-application/vnd.chemdraw+xml                   cdxml
-application/vnd.chipnuts.karaoke-mmd           mmd
-application/vnd.cinderella                     cdy
-application/vnd.cirpack.isdn-ext
-application/vnd.claymore                       cla
-application/vnd.clonk.c4group                  c4g c4d c4f c4p c4u
-application/vnd.commerce-battelle
-application/vnd.commonspace                    csp cst
-application/vnd.contact.cmsg                   cdbcmsg
-application/vnd.cosmocaller                    cmc
-application/vnd.crick.clicker                  clkx
-application/vnd.crick.clicker.keyboard         clkk
-application/vnd.crick.clicker.palette          clkp
-application/vnd.crick.clicker.template         clkt
-application/vnd.crick.clicker.wordbank         clkw
-application/vnd.criticaltools.wbs+xml          wbs
-application/vnd.ctc-posml                      pml
-application/vnd.cups-pdf
-application/vnd.cups-postscript
-application/vnd.cups-ppd                       ppd
-application/vnd.cups-raster
-application/vnd.cups-raw
-application/vnd.curl                           curl
-application/vnd.cybank
-application/vnd.data-vision.rdz                        rdz
-application/vnd.denovo.fcselayout-link         fe_launch
-application/vnd.dna                            dna
-application/vnd.dolby.mlp                      mlp
-application/vnd.dpgraph                                dpg
-application/vnd.dreamfactory                   dfac
-application/vnd.dvb.esgcontainer
-application/vnd.dvb.ipdcesgaccess
-application/vnd.dxr
-application/vnd.ecdis-update
-application/vnd.ecowin.chart                   mag
-application/vnd.ecowin.filerequest
-application/vnd.ecowin.fileupdate
-application/vnd.ecowin.series
-application/vnd.ecowin.seriesrequest
-application/vnd.ecowin.seriesupdate
-application/vnd.enliven                                nml
-application/vnd.epson.esf                      esf
-application/vnd.epson.msf                      msf
-application/vnd.epson.quickanime               qam
-application/vnd.epson.salt                     slt
-application/vnd.epson.ssf                      ssf
-application/vnd.ericsson.quickcall
-application/vnd.eszigno3+xml                   es3 et3
-application/vnd.eudora.data
-application/vnd.ezpix-album                    ez2
-application/vnd.ezpix-package                  ez3
-application/vnd.fdf                            fdf
-application/vnd.ffsns
-application/vnd.fints
-application/vnd.flographit                     gph
-application/vnd.fluxtime.clip                  ftc
-application/vnd.framemaker                     fm frame maker
-application/vnd.frogans.fnc                    fnc
-application/vnd.frogans.ltf                    ltf
-application/vnd.fsc.weblaunch                  fsc
-application/vnd.fujitsu.oasys                  oas
-application/vnd.fujitsu.oasys2                 oa2
-application/vnd.fujitsu.oasys3                 oa3
-application/vnd.fujitsu.oasysgp                        fg5
-application/vnd.fujitsu.oasysprs               bh2
-application/vnd.fujixerox.art-ex
-application/vnd.fujixerox.art4
-application/vnd.fujixerox.hbpl
-application/vnd.fujixerox.ddd                  ddd
-application/vnd.fujixerox.docuworks            xdw
-application/vnd.fujixerox.docuworks.binder     xbd
-application/vnd.fut-misnet
-application/vnd.fuzzysheet                     fzs
-application/vnd.genomatix.tuxedo               txd
-application/vnd.google-earth.kml+xml           kml
-application/vnd.google-earth.kmz               kmz
-application/vnd.grafeq                         gqf gqs
-application/vnd.gridmp
-application/vnd.groove-account                 gac
-application/vnd.groove-help                    ghf
-application/vnd.groove-identity-message                gim
-application/vnd.groove-injector                        grv
-application/vnd.groove-tool-message            gtm
-application/vnd.groove-tool-template           tpl
-application/vnd.groove-vcard                   vcg
-application/vnd.handheld-entertainment+xml     zmm
-application/vnd.hbci                           hbci
-application/vnd.hcl-bireports
-application/vnd.hhe.lesson-player              les
-application/vnd.hp-hpgl                                hpgl
-application/vnd.hp-hpid                                hpid
-application/vnd.hp-hps                         hps
-application/vnd.hp-jlyt                                jlt
-application/vnd.hp-pcl                         pcl
-application/vnd.hp-pclxl                       pclxl
-application/vnd.httphone
-application/vnd.hzn-3d-crossword               x3d
-application/vnd.ibm.afplinedata
-application/vnd.ibm.electronic-media
-application/vnd.ibm.minipay                    mpy
-application/vnd.ibm.modcap                     afp listafp list3820
-application/vnd.ibm.rights-management          irm
-application/vnd.ibm.secure-container           sc
-application/vnd.igloader                       igl
-application/vnd.immervision-ivp                        ivp
-application/vnd.immervision-ivu                        ivu
-application/vnd.informedcontrol.rms+xml
-application/vnd.intercon.formnet               xpw xpx
-application/vnd.intertrust.digibox
-application/vnd.intertrust.nncp
-application/vnd.intu.qbo                       qbo
-application/vnd.intu.qfx                       qfx
-application/vnd.ipunplugged.rcprofile          rcprofile
-application/vnd.irepository.package+xml                irp
-application/vnd.is-xpr                         xpr
-application/vnd.jam                            jam
-application/vnd.japannet-directory-service
-application/vnd.japannet-jpnstore-wakeup
-application/vnd.japannet-payment-wakeup
-application/vnd.japannet-registration
-application/vnd.japannet-registration-wakeup
-application/vnd.japannet-setstore-wakeup
-application/vnd.japannet-verification
-application/vnd.japannet-verification-wakeup
-application/vnd.jcp.javame.midlet-rms          rms
-application/vnd.jisp                           jisp
-application/vnd.kahootz                                ktz ktr
-application/vnd.kde.karbon                     karbon
-application/vnd.kde.kchart                     chrt
-application/vnd.kde.kformula                   kfo
-application/vnd.kde.kivio                      flw
-application/vnd.kde.kontour                    kon
-application/vnd.kde.kpresenter                 kpr kpt
-application/vnd.kde.kspread                    ksp
-application/vnd.kde.kword                      kwd kwt
-application/vnd.kenameaapp                     htke
-application/vnd.kidspiration                   kia
-application/vnd.kinar                          kne knp
-application/vnd.koan                           skp skd skt skm
-application/vnd.liberty-request+xml
-application/vnd.llamagraphics.life-balance.desktop     lbd
-application/vnd.llamagraphics.life-balance.exchange+xml        lbe
-application/vnd.lotus-1-2-3                    123
-application/vnd.lotus-approach                 apr
-application/vnd.lotus-freelance                        pre
-application/vnd.lotus-notes                    nsf
-application/vnd.lotus-organizer                        org
-application/vnd.lotus-screencam                        scm
-application/vnd.lotus-wordpro                  lwp
-application/vnd.macports.portpkg               portpkg
-application/vnd.marlin.drm.actiontoken+xml
-application/vnd.marlin.drm.conftoken+xml
-application/vnd.marlin.drm.mdcf
-application/vnd.mcd                            mcd
-application/vnd.medcalcdata                    mc1
-application/vnd.mediastation.cdkey             cdkey
-application/vnd.meridian-slingshot
-application/vnd.mfer                           mwf
-application/vnd.mfmp                           mfm
-application/vnd.micrografx.flo                 flo
-application/vnd.micrografx.igx                 igx
-application/vnd.mif                            mif
-application/vnd.minisoft-hp3000-save
-application/vnd.mitsubishi.misty-guard.trustweb
-application/vnd.mobius.daf                     daf
-application/vnd.mobius.dis                     dis
-application/vnd.mobius.mbk                     mbk
-application/vnd.mobius.mqy                     mqy
-application/vnd.mobius.msl                     msl
-application/vnd.mobius.plc                     plc
-application/vnd.mobius.txf                     txf
-application/vnd.mophun.application             mpn
-application/vnd.mophun.certificate             mpc
-application/vnd.motorola.flexsuite
-application/vnd.motorola.flexsuite.adsi
-application/vnd.motorola.flexsuite.fis
-application/vnd.motorola.flexsuite.gotap
-application/vnd.motorola.flexsuite.kmr
-application/vnd.motorola.flexsuite.ttc
-application/vnd.motorola.flexsuite.wem
-application/vnd.mozilla.xul+xml        xul
-application/vnd.ms-artgalry                    cil
-application/vnd.ms-asf                         asf
-application/vnd.ms-cab-compressed              cab
-application/vnd.ms-excel                       xls xlm xla xlc xlt xlw
-application/vnd.ms-fontobject                  eot
-application/vnd.ms-htmlhelp                    chm
-application/vnd.ms-ims                         ims
-application/vnd.ms-lrm                         lrm
-application/vnd.ms-playready.initiator+xml
-application/vnd.ms-powerpoint                  ppt pps pot
-application/vnd.ms-project                     mpp mpt
-application/vnd.ms-tnef
-application/vnd.ms-wmdrm.lic-chlg-req
-application/vnd.ms-wmdrm.lic-resp
-application/vnd.ms-wmdrm.meter-chlg-req
-application/vnd.ms-wmdrm.meter-resp
-application/vnd.ms-works                       wps wks wcm wdb
-application/vnd.ms-wpl                         wpl
-application/vnd.ms-xpsdocument                 xps
-application/vnd.mseq                           mseq
-application/vnd.msign
-application/vnd.music-niff
-application/vnd.musician                       mus
-application/vnd.ncd.control
-application/vnd.nervana
-application/vnd.netfpx
-application/vnd.neurolanguage.nlu              nlu
-application/vnd.noblenet-directory             nnd
-application/vnd.noblenet-sealer                        nns
-application/vnd.noblenet-web                   nnw
-application/vnd.nokia.catalogs
-application/vnd.nokia.conml+wbxml
-application/vnd.nokia.conml+xml
-application/vnd.nokia.isds-radio-presets
-application/vnd.nokia.iptv.config+xml
-application/vnd.nokia.landmark+wbxml
-application/vnd.nokia.landmark+xml
-application/vnd.nokia.landmarkcollection+xml
-application/vnd.nokia.n-gage.ac+xml
-application/vnd.nokia.n-gage.data              ngdat
-application/vnd.nokia.n-gage.symbian.install   n-gage
-application/vnd.nokia.ncd
-application/vnd.nokia.pcd+wbxml
-application/vnd.nokia.pcd+xml
-application/vnd.nokia.radio-preset             rpst
-application/vnd.nokia.radio-presets            rpss
-application/vnd.novadigm.edm                   edm
-application/vnd.novadigm.edx                   edx
-application/vnd.novadigm.ext                   ext
-application/vnd.oasis.opendocument.chart               odc
-application/vnd.oasis.opendocument.chart-template      otc
-application/vnd.oasis.opendocument.formula             odf
-application/vnd.oasis.opendocument.formula-template    otf
-application/vnd.oasis.opendocument.graphics            odg
-application/vnd.oasis.opendocument.graphics-template   otg
-application/vnd.oasis.opendocument.image               odi
-application/vnd.oasis.opendocument.image-template      oti
-application/vnd.oasis.opendocument.presentation                odp
-application/vnd.oasis.opendocument.presentation-template otp
-application/vnd.oasis.opendocument.spreadsheet         ods
-application/vnd.oasis.opendocument.spreadsheet-template        ots
-application/vnd.oasis.opendocument.text                        odt
-application/vnd.oasis.opendocument.text-master         otm
-application/vnd.oasis.opendocument.text-template       ott
-application/vnd.oasis.opendocument.text-web            oth
-application/vnd.obn
-application/vnd.olpc-sugar                     xo
-application/vnd.oma-scws-config
-application/vnd.oma-scws-http-request
-application/vnd.oma-scws-http-response
-application/vnd.oma.bcast.associated-procedure-parameter+xml
-application/vnd.oma.bcast.drm-trigger+xml
-application/vnd.oma.bcast.imd+xml
-application/vnd.oma.bcast.notification+xml
-application/vnd.oma.bcast.sgboot
-application/vnd.oma.bcast.sgdd+xml
-application/vnd.oma.bcast.sgdu
-application/vnd.oma.bcast.simple-symbol-container
-application/vnd.oma.bcast.smartcard-trigger+xml
-application/vnd.oma.bcast.sprov+xml
-application/vnd.oma.dd2+xml                    dd2
-application/vnd.oma.drm.risd+xml
-application/vnd.oma.group-usage-list+xml
-application/vnd.oma.poc.groups+xml
-application/vnd.oma.xcap-directory+xml
-application/vnd.omads-email+xml
-application/vnd.omads-file+xml
-application/vnd.omads-folder+xml
-application/vnd.omaloc-supl-init
-application/vnd.openofficeorg.extension                oxt
-application/vnd.osa.netdeploy
-application/vnd.osgi.dp                                dp
-application/vnd.otps.ct-kip+xml
-application/vnd.palm                           prc pdb pqa oprc
-application/vnd.paos.xml
-application/vnd.pg.format                      str
-application/vnd.pg.osasli                      ei6
-application/vnd.piaccess.application-licence
-application/vnd.picsel                         efif
-application/vnd.poc.group-advertisement+xml
-application/vnd.pocketlearn                    plf
-application/vnd.powerbuilder6                  pbd
-application/vnd.powerbuilder6-s
-application/vnd.powerbuilder7
-application/vnd.powerbuilder7-s
-application/vnd.powerbuilder75
-application/vnd.powerbuilder75-s
-application/vnd.preminet
-application/vnd.previewsystems.box             box
-application/vnd.proteus.magazine               mgz
-application/vnd.publishare-delta-tree          qps
-application/vnd.pvi.ptid1                      ptid
-application/vnd.pwg-multiplexed
-application/vnd.pwg-xhtml-print+xml
-application/vnd.qualcomm.brew-app-res
-application/vnd.quark.quarkxpress              qxd qxt qwd qwt qxl qxb
-application/vnd.rapid
-application/vnd.recordare.musicxml             mxl
-application/vnd.recordare.musicxml+xml
-application/vnd.renlearn.rlprint
-application/vnd.rn-realmedia                   rm
-application/vnd.ruckus.download
-application/vnd.s3sms
-application/vnd.scribus
-application/vnd.sealed.3df
-application/vnd.sealed.csf
-application/vnd.sealed.doc
-application/vnd.sealed.eml
-application/vnd.sealed.mht
-application/vnd.sealed.net
-application/vnd.sealed.ppt
-application/vnd.sealed.tiff
-application/vnd.sealed.xls
-application/vnd.sealedmedia.softseal.html
-application/vnd.sealedmedia.softseal.pdf
-application/vnd.seemail                                see
-application/vnd.sema                           sema
-application/vnd.semd                           semd
-application/vnd.semf                           semf
-application/vnd.shana.informed.formdata                ifm
-application/vnd.shana.informed.formtemplate    itp
-application/vnd.shana.informed.interchange     iif
-application/vnd.shana.informed.package         ipk
-application/vnd.simtech-mindmapper             twd twds
-application/vnd.smaf                           mmf
-application/vnd.solent.sdkm+xml                        sdkm sdkd
-application/vnd.spotfire.dxp                   dxp
-application/vnd.spotfire.sfs                   sfs
-application/vnd.sss-cod
-application/vnd.sss-dtf
-application/vnd.sss-ntf
-application/vnd.street-stream
-application/vnd.sun.wadl+xml
-application/vnd.sus-calendar                   sus susp
-application/vnd.svd                            svd
-application/vnd.swiftview-ics
-application/vnd.syncml+xml                     xsm
-application/vnd.syncml.dm+wbxml                        bdm
-application/vnd.syncml.dm+xml                  xdm
-application/vnd.syncml.ds.notification
-application/vnd.tao.intent-module-archive      tao
-application/vnd.tmobile-livetv                 tmo
-application/vnd.trid.tpt                       tpt
-application/vnd.triscape.mxs                   mxs
-application/vnd.trueapp                                tra
-application/vnd.truedoc
-application/vnd.ufdl                           ufd ufdl
-application/vnd.uiq.theme                      utz
-application/vnd.umajin                         umj
-application/vnd.unity                          unityweb
-application/vnd.uoml+xml                       uoml
-application/vnd.uplanet.alert
-application/vnd.uplanet.alert-wbxml
-application/vnd.uplanet.bearer-choice
-application/vnd.uplanet.bearer-choice-wbxml
-application/vnd.uplanet.cacheop
-application/vnd.uplanet.cacheop-wbxml
-application/vnd.uplanet.channel
-application/vnd.uplanet.channel-wbxml
-application/vnd.uplanet.list
-application/vnd.uplanet.list-wbxml
-application/vnd.uplanet.listcmd
-application/vnd.uplanet.listcmd-wbxml
-application/vnd.uplanet.signal
-application/vnd.vcx                            vcx
-application/vnd.vd-study
-application/vnd.vectorworks
-application/vnd.vidsoft.vidconference
-application/vnd.visio                          vsd vst vss vsw
-application/vnd.visionary                      vis
-application/vnd.vividence.scriptfile
-application/vnd.vsf                            vsf
-application/vnd.wap.sic
-application/vnd.wap.slc
-application/vnd.wap.wbxml                      wbxml
-application/vnd.wap.wmlc                       wmlc
-application/vnd.wap.wmlscriptc                 wmlsc
-application/vnd.webturbo                       wtb
-application/vnd.wfa.wsc
-application/vnd.wordperfect                    wpd
-application/vnd.wqd                            wqd
-application/vnd.wrq-hp3000-labelled
-application/vnd.wt.stf                         stf
-application/vnd.wv.csp+wbxml
-application/vnd.wv.csp+xml
-application/vnd.wv.ssp+xml
-application/vnd.xara                           xar
-application/vnd.xfdl                           xfdl
-application/vnd.xmpie.cpkg
-application/vnd.xmpie.dpkg
-application/vnd.xmpie.plan
-application/vnd.xmpie.ppkg
-application/vnd.xmpie.xlim
-application/vnd.yamaha.hv-dic                  hvd
-application/vnd.yamaha.hv-script               hvs
-application/vnd.yamaha.hv-voice                        hvp
-application/vnd.yamaha.smaf-audio              saf
-application/vnd.yamaha.smaf-phrase             spf
-application/vnd.yellowriver-custom-menu                cmp
-application/vnd.zzazz.deck+xml                 zaz
-application/voicexml+xml                       vxml
-application/watcherinfo+xml
-application/whoispp-query
-application/whoispp-response
-application/winhlp                             hlp
-application/wita
-application/wordperfect5.1
-application/wsdl+xml                           wsdl
-application/wspolicy+xml                       wspolicy
-application/x-ace-compressed                   ace
-application/x-bcpio                            bcpio
-application/x-bittorrent                       torrent
-application/x-bzip                             bz
-application/x-bzip2                            bz2 boz
-application/x-cdlink                           vcd
-application/x-chat                             chat
-application/x-chess-pgn                                pgn
-application/x-compress
-application/x-cpio                             cpio
-application/x-csh                              csh
-application/x-director                         dcr dir dxr fgd
-application/x-dvi                              dvi
-application/x-futuresplash                     spl
-application/x-gtar                             gtar
-application/x-gzip
-application/x-hdf                              hdf
-application/x-java-jnlp-file   jnlp
-application/x-latex                            latex
-application/x-ms-wmd                           wmd
-application/x-ms-wmz                           wmz
-application/x-msaccess                         mdb
-application/x-msbinder                         obd
-application/x-mscardfile                       crd
-application/x-msclip                           clp
-application/x-msdownload                       exe dll com bat msi
-application/x-msmediaview                      mvb m13 m14
-application/x-msmetafile                       wmf
-application/x-msmoney                          mny
-application/x-mspublisher                      pub
-application/x-msschedule                       scd
-application/x-msterminal                       trm
-application/x-mswrite                          wri
-application/x-netcdf                           nc cdf
-application/x-pkcs12                           p12 pfx
-application/x-pkcs7-certificates               p7b spc
-application/x-pkcs7-certreqresp                        p7r
-application/x-rar-compressed                   rar
-application/x-sh                               sh
-application/x-shar                             shar
-application/x-shockwave-flash                  swf
-application/x-stuffit                          sit
-application/x-stuffitx                         sitx
-application/x-sv4cpio                          sv4cpio
-application/x-sv4crc                           sv4crc
-application/x-tar                              tar
-application/x-tcl                              tcl
-application/x-tex                              tex
-application/x-texinfo                          texinfo texi
-application/x-ustar                            ustar
-application/x-wais-source                      src
-application/x-x509-ca-cert                     der crt
-application/x400-bp
-application/xcap-att+xml
-application/xcap-caps+xml
-application/xcap-el+xml
-application/xcap-error+xml
-application/xcap-ns+xml
-application/xenc+xml                           xenc
-application/xhtml+xml                          xhtml xht
-application/xml                                        xml xsl
-application/xml-dtd                            dtd
-application/xml-external-parsed-entity
-application/xmpp+xml
-application/xop+xml                            xop
-application/xslt+xml                           xslt
-application/xspf+xml                           xspf
-application/xv+xml                             mxml xhvml xvml xvm
-application/zip                                        zip
-audio/32kadpcm
-audio/3gpp
-audio/3gpp2
-audio/ac3
-audio/amr
-audio/amr-wb
-audio/amr-wb+
-audio/asc
-audio/basic                                    au snd
-audio/bv16
-audio/bv32
-audio/clearmode
-audio/cn
-audio/dat12
-audio/dls
-audio/dsr-es201108
-audio/dsr-es202050
-audio/dsr-es202211
-audio/dsr-es202212
-audio/dvi4
-audio/eac3
-audio/evrc
-audio/evrc-qcp
-audio/evrc0
-audio/evrc1
-audio/evrcb
-audio/evrcb0
-audio/evrcb1
-audio/g722
-audio/g7221
-audio/g723
-audio/g726-16
-audio/g726-24
-audio/g726-32
-audio/g726-40
-audio/g728
-audio/g729
-audio/g7291
-audio/g729d
-audio/g729e
-audio/gsm
-audio/gsm-efr
-audio/ilbc
-audio/l16
-audio/l20
-audio/l24
-audio/l8
-audio/lpc
-audio/midi                                     mid midi kar rmi
-audio/mobile-xmf
-audio/mp4                                      mp4a
-audio/mp4a-latm                        m4a m4p
-audio/mpa
-audio/mpa-robust
-audio/mpeg                                     mpga mp2 mp2a mp3 m2a m3a
-audio/mpeg4-generic
-audio/parityfec
-audio/pcma
-audio/pcmu
-audio/prs.sid
-audio/qcelp
-audio/red
-audio/rtp-enc-aescm128
-audio/rtp-midi
-audio/rtx
-audio/smv
-audio/smv0
-audio/smv-qcp
-audio/sp-midi
-audio/t140c
-audio/t38
-audio/telephone-event
-audio/tone
-audio/vdvi
-audio/vmr-wb
-audio/vnd.3gpp.iufp
-audio/vnd.4sb
-audio/vnd.audiokoz
-audio/vnd.celp
-audio/vnd.cisco.nse
-audio/vnd.cmles.radio-events
-audio/vnd.cns.anp1
-audio/vnd.cns.inf1
-audio/vnd.digital-winds                                eol
-audio/vnd.dlna.adts
-audio/vnd.dolby.mlp
-audio/vnd.everad.plj
-audio/vnd.hns.audio
-audio/vnd.lucent.voice                         lvp
-audio/vnd.nokia.mobile-xmf
-audio/vnd.nortel.vbk
-audio/vnd.nuera.ecelp4800                      ecelp4800
-audio/vnd.nuera.ecelp7470                      ecelp7470
-audio/vnd.nuera.ecelp9600                      ecelp9600
-audio/vnd.octel.sbc
-audio/vnd.qcelp
-audio/vnd.rhetorex.32kadpcm
-audio/vnd.sealedmedia.softseal.mpeg
-audio/vnd.vmx.cvsd
-audio/wav                                      wav
-audio/x-aiff                                   aif aiff aifc
-audio/x-mpegurl                                        m3u
-audio/x-ms-wax                                 wax
-audio/x-ms-wma                                 wma
-audio/x-pn-realaudio                           ram ra
-audio/x-pn-realaudio-plugin                    rmp
-audio/x-wav                                    wav
-chemical/x-cdx                                 cdx
-chemical/x-cif                                 cif
-chemical/x-cmdf                                        cmdf
-chemical/x-cml                                 cml
-chemical/x-csml                                        csml
-chemical/x-pdb                                 pdb
-chemical/x-xyz                                 xyz
-image/bmp                                      bmp
-image/cgm                                      cgm
-image/fits
-image/g3fax                                    g3
-image/gif                                      gif
-image/ief                                      ief
-image/jp2                      jp2
-image/jpeg                                     jpeg jpg jpe
-image/jpm
-image/jpx
-image/naplps
-image/pict                     pict pic pct
-image/png                                      png
-image/prs.btif                                 btif
-image/prs.pti
-image/svg+xml                                  svg svgz
-image/t38
-image/tiff                                     tiff tif
-image/tiff-fx
-image/vnd.adobe.photoshop                      psd
-image/vnd.cns.inf2
-image/vnd.djvu                                 djvu djv
-image/vnd.dwg                                  dwg
-image/vnd.dxf                                  dxf
-image/vnd.fastbidsheet                         fbs
-image/vnd.fpx                                  fpx
-image/vnd.fst                                  fst
-image/vnd.fujixerox.edmics-mmr                 mmr
-image/vnd.fujixerox.edmics-rlc                 rlc
-image/vnd.globalgraphics.pgb
-image/vnd.microsoft.icon                       ico
-image/vnd.mix
-image/vnd.ms-modi                              mdi
-image/vnd.net-fpx                              npx
-image/vnd.sealed.png
-image/vnd.sealedmedia.softseal.gif
-image/vnd.sealedmedia.softseal.jpg
-image/vnd.svf
-image/vnd.wap.wbmp                             wbmp
-image/vnd.xiff                                 xif
-image/x-cmu-raster                             ras
-image/x-cmx                                    cmx
-image/x-icon
-image/x-macpaint               pntg pnt mac
-image/x-pcx                                    pcx
-image/x-pict                                   pic pct
-image/x-portable-anymap                                pnm
-image/x-portable-bitmap                                pbm
-image/x-portable-graymap                       pgm
-image/x-portable-pixmap                                ppm
-image/x-quicktime              qtif qti
-image/x-rgb                                    rgb
-image/x-xbitmap                                        xbm
-image/x-xpixmap                                        xpm
-image/x-xwindowdump                            xwd
-message/cpim
-message/delivery-status
-message/disposition-notification
-message/external-body
-message/http
-message/news
-message/partial
-message/rfc822                                 eml mime
-message/s-http
-message/sip
-message/sipfrag
-message/tracking-status
-model/iges                                     igs iges
-model/mesh                                     msh mesh silo
-model/vnd.dwf                                  dwf
-model/vnd.flatland.3dml
-model/vnd.gdl                                  gdl
-model/vnd.gs.gdl
-model/vnd.gtw                                  gtw
-model/vnd.moml+xml
-model/vnd.mts                                  mts
-model/vnd.parasolid.transmit.binary
-model/vnd.parasolid.transmit.text
-model/vnd.vtu                                  vtu
-model/vrml                                     wrl vrml
-multipart/alternative
-multipart/appledouble
-multipart/byteranges
-multipart/digest
-multipart/encrypted
-multipart/form-data
-multipart/header-set
-multipart/mixed
-multipart/parallel
-multipart/related
-multipart/report
-multipart/signed
-multipart/voice-message
-text/calendar                                  ics ifb
-text/css                                       css
-text/csv                                       csv
-text/directory
-text/dns
-text/enriched
-text/html                                      html htm
-text/parityfec
-text/plain                                     txt text conf def list log in
-text/prs.fallenstein.rst
-text/prs.lines.tag                             dsc
-text/red
-text/rfc822-headers
-text/richtext                                  rtx
-text/rtf
-text/rtp-enc-aescm128
-text/rtx
-text/sgml                                      sgml sgm
-text/t140
-text/tab-separated-values                      tsv
-text/troff                                     t tr roff man me ms
-text/uri-list                                  uri uris urls
-text/vnd.abc
-text/vnd.curl
-text/vnd.dmclientscript
-text/vnd.esmertec.theme-descriptor
-text/vnd.fly                                   fly
-text/vnd.fmi.flexstor                          flx
-text/vnd.in3d.3dml                             3dml
-text/vnd.in3d.spot                             spot
-text/vnd.iptc.newsml
-text/vnd.iptc.nitf
-text/vnd.latex-z
-text/vnd.motorola.reflex
-text/vnd.ms-mediapackage
-text/vnd.net2phone.commcenter.command
-text/vnd.sun.j2me.app-descriptor               jad
-text/vnd.trolltech.linguist
-text/vnd.wap.si
-text/vnd.wap.sl
-text/vnd.wap.wml                               wml
-text/vnd.wap.wmlscript                         wmls
-text/x-asm                                     s asm
-text/x-c                                       c cc cxx cpp h hh dic
-text/x-fortran                                 f for f77 f90
-text/x-pascal                                  p pas
-text/x-java-source                             java
-text/x-setext                                  etx
-text/x-uuencode                                        uu
-text/x-vcalendar                               vcs
-text/x-vcard                                   vcf
-text/xml
-text/xml-external-parsed-entity
-video/3gpp                                     3gp
-video/3gpp-tt
-video/3gpp2                                    3g2
-video/bmpeg
-video/bt656
-video/celb
-video/dv
-video/h261                                     h261
-video/h263                                     h263
-video/h263-1998
-video/h263-2000
-video/h264                                     h264
-video/jpeg                                     jpgv
-video/jpm                                      jpm jpgm
-video/mj2                                      mj2 mjp2
-video/mp1s
-video/mp2p
-video/mp2t
-video/mp4                                      mp4 mp4v mpg4 m4v
-video/mp4v-es
-video/mpeg                                     mpeg mpg mpe m1v m2v
-video/mpeg4-generic
-video/mpv
-video/nv
-video/parityfec
-video/pointer
-video/quicktime                                        qt mov
-video/raw
-video/rtp-enc-aescm128
-video/rtx
-video/smpte292m
-video/vc1
-video/vnd.dlna.mpeg-tts
-video/vnd.fvt                                  fvt
-video/vnd.hns.video
-video/vnd.motorola.video
-video/vnd.motorola.videop
-video/vnd.mpegurl                              mxu m4u
-video/vnd.nokia.interleaved-multimedia
-video/vnd.nokia.videovoip
-video/vnd.objectvideo
-video/vnd.sealed.mpeg1
-video/vnd.sealed.mpeg4
-video/vnd.sealed.swf
-video/vnd.sealedmedia.softseal.mov
-video/vnd.vivo                                 viv
-video/x-dv                     dv dif
-video/x-fli                                    fli
-video/x-ms-asf                                 asf asx
-video/x-ms-wm                                  wm
-video/x-ms-wmv                                 wmv
-video/x-ms-wmx                                 wmx
-video/x-ms-wvx                                 wvx
-video/x-msvideo                                        avi
-video/x-sgi-movie                              movie
-x-conference/x-cooltalk                                ice
diff --git a/basis/mime/multipart/authors.txt b/basis/mime/multipart/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/mime/multipart/multipart-tests.factor b/basis/mime/multipart/multipart-tests.factor
new file mode 100644 (file)
index 0000000..68b4bff
--- /dev/null
@@ -0,0 +1,1485 @@
+USING: accessors io io.streams.string kernel mime.multipart
+tools.test make multiline strings ;
+IN: mime.multipart.tests
+
+[ { "a" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 2 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 3 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 4 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 5 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+
+[ { "a" "a" f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "aa" f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 2 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "aa" f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 3 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "aa" f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 4 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "aa" f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 5 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+
+
+[ { "a" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "zz" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" "z" "z" "b" "z" "z" "c" "z" "z" "d" "zz" } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "zzz" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" "z" "z" "b" "z" "z" "c" "z" "z" "d" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "az" "zb" "zz" "cz" "zd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 2 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "a" "zzb" "zzc" "zzd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 3 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "az" "zbzz" "czzd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 4 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+[ { "azz" "bzzcz" "zd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 5 >>n
+        [ , ] [ ] multipart-step-loop drop
+    ] { } make
+] unit-test
+
+
+[ { "a" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 2 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 3 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 4 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "z" <multipart-stream> 5 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+
+[ { "a" "a" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "aa" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 2 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "aa" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 3 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "aa" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 4 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "aa" f f "b" f f "c" f f "d" f f } ] [
+    [
+        "aazzbzzczzdzz" <string-reader> "z" <multipart-stream> 5 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+
+
+[ { "a" f "b" f "c" f "d" f } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "zz" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" "z" "z" "b" "z" "z" "c" "z" "z" "d" "zz" } ] [
+    [
+        "azzbzzczzdzz" <string-reader> "zzz" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" "z" "z" "b" "z" "z" "c" "z" "z" "d" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 1 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "az" "zb" "zz" "cz" "zd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 2 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "a" "zzb" "zzc" "zzd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 3 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "az" "zbzz" "czzd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 4 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+[ { "azz" "bzzcz" "zd" f } ] [
+    [
+        "azzbzzczzdzzz" <string-reader> "zzz" <multipart-stream> 5 >>n
+        [ , ] [ ] multipart-loop-all
+    ] { } make
+] unit-test
+
+
+: dog-upload ( -- string )
+    B{
+        45 45 45 45 45 45 87 101 98 75 105 116 70 111 114 109 66
+        111 117 110 100 97 114 121 115 105 103 113 43 53 113 87 116
+        54 79 114 122 56 76 79 13 10 67 111 110 116 101 110 116 45
+        68 105 115 112 111 115 105 116 105 111 110 58 32 102 111
+        114 109 45 100 97 116 97 59 32 110 97 109 101 61 34 102 105
+        108 101 34 59 32 102 105 108 101 110 97 109 101 61 34 100
+        111 103 46 106 112 103 34 13 10 67 111 110 116 101 110 116
+        45 84 121 112 101 58 32 105 109 97 103 101 47 106 112 101
+        103 13 10 13 10 253 253 253 253 0 16 74 70 73 70 0 1 1 0 0
+        1 0 1 0 0 253 253 0 67 0 5 3 4 4 4 3 5 4 4 4 5 5 5 6 7 12 8
+        7 7 7 7 15 11 11 9 12 17 15 18 18 17 15 17 17 19 22 28 23
+        19 20 26 21 17 17 24 33 24 26 29 29 31 31 31 19 23 34 36 34
+        30 36 28 30 31 30 253 253 0 67 1 5 5 5 7 6 7 14 8 8 14 30
+        20 17 20 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
+        30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
+        30 30 30 30 30 30 30 30 30 30 30 30 30 253 253 0 17 8 1 49
+        1 64 3 1 34 0 2 17 1 3 17 1 253 253 0 29 0 0 2 2 3 1 1 1 0
+        0 0 0 0 0 0 0 0 4 5 6 7 2 3 8 0 1 9 253 253 0 74 16 0 2 1 3
+        3 2 4 4 3 4 5 10 5 3 5 1 1 2 3 0 4 17 5 18 33 6 49 19 34 65
+        81 7 50 97 113 20 35 253 21 51 66 82 36 52 253 253 253 8 53
+        83 98 114 115 253 253 253 253 22 37 67 116 253 99 253 253
+        23 68 84 100 253 253 253 253 0 25 1 0 3 1 1 1 0 0 0 0 0 0 0
+        0 0 0 0 1 2 3 0 4 5 253 253 0 39 17 0 2 2 2 2 3 0 2 1 5 1 0
+        0 0 0 0 0 1 2 17 3 33 18 49 34 50 65 19 81 4 5 20 35 66 97
+        82 253 253 0 12 3 1 0 2 17 3 17 0 63 0 253 253 253 253 253
+        253 253 253 253 68 253 253 112 60 21 45 253 91 253 57 253
+        253 253 75 56 95 111 253 253 51 253 253 11 253 253 14 118
+        253 22 253 253 104 253 118 82 46 253 45 253 98 79 253 102
+        253 38 253 98 253 64 253 253 72 253 49 46 104 11 8 253 111
+        253 253 253 253 70 253 12 253 112 61 253 57 36 253 31 82 7
+        253 253 78 253 253 253 253 0 253 41 100 253 76 15 253 253
+        118 60 31 253 85 253 126 253 253 253 253 253 253 113 253 66
+        253 253 253 82 74 49 45 253 253 42 49 253 253 253 108 253
+        99 21 68 253 88 116 253 83 17 253 253 253 253 109 253 253
+        253 6 253 83 253 109 1 253 115 253 10 253 90 106 23 106 253
+        95 59 73 253 253 77 44 111 89 79 253 24 253 253 253 253 86
+        253 253 71 253 20 52 253 253 253 24 253 253 253 253 61 253
+        66 253 65 253 253 253 64 253 5 253 127 253 45 3 99 42 253
+        42 253 253 79 253 83 253 38 86 92 21 57 20 76 253 253 78
+        253 98 88 31 253 253 125 253 253 45 108 253 253 97 253 0
+        253 44 253 0 253 45 22 253 253 253 253 99 88 74 98 77 99 78
+        253 69 111 14 253 253 23 28 253 48 15 253 253 30 253 21 253
+        105 8 253 253 103 253 253 253 253 121 253 127 253 87 253
+        253 253 253 31 253 253 253 253 253 28 88 253 253 120 99 253
+        52 100 253 0 253 253 253 253 108 109 11 103 253 253 127 253
+        253 118 82 71 253 47 253 253 253 11 253 30 74 81 253 102
+        253 253 35 253 97 104 62 253 46 104 41 45 109 119 127 86
+        253 253 21 48 253 253 9 253 104 105 253 24 118 53 76 77 81
+        253 73 105 109 253 253 253 127 253 21 253 89 253 110 63 253
+        97 253 0 253 69 65 253 110 15 39 253 253 253 253 253 41 6
+        253 102 5 22 54 253 114 109 45 253 123 24 253 53 253 45 44
+        253 253 79 253 253 253 253 253 118 101 112 253 253 253 102
+        253 253 253 35 253 99 95 253 253 119 253 253 253 253 253 21
+        18 253 125 253 92 253 2 253 253 16 253 15 253 253 253 71 46
+        253 253 106 253 78 253 40 253 253 109 83 33 45 253 253 253
+        253 253 253 253 253 30 253 253 69 45 37 253 253 253 253 12
+        253 253 253 253 253 253 253 8 75 123 253 15 69 96 7 253 253
+        253 253 253 31 253 253 253 253 253 102 120 253 0 68 253 253
+        253 253 12 15 253 253 253 253 253 253 253 253 253 253 253
+        253 7 253 123 80 253 253 253 118 253 66 253 253 118 62 253
+        253 253 38 91 55 253 253 253 253 60 253 22 96 14 253 253
+        107 84 253 69 253 253 253 253 100 253 0 65 18 253 43 253 82
+        105 253 253 108 64 253 31 102 253 253 253 253 253 253 253
+        39 253 73 38 50 84 253 253 112 253 19 253 4 118 54 253 253
+        22 33 68 54 253 253 52 96 253 253 253 15 115 16 253 66 253
+        253 77 253 253 40 115 253 90 253 91 73 253 116 253 29 253
+        77 253 253 253 253 46 64 109 253 88 45 253 31 253 253 92
+        127 253 253 19 97 99 253 16 253 125 253 253 63 253 20 100
+        253 56 253 253 253 66 84 253 253 253 253 253 253 253 125 18
+        253 125 253 253 108 72 7 253 125 253 63 253 45 109 253 77
+        253 253 253 111 253 253 0 253 253 68 76 253 253 253 51 253
+        103 43 0 253 253 253 253 72 253 253 54 113 253 5 91 120 50
+        59 253 77 7 120 109 253 48 22 8 1 253 253 98 253 106 253
+        253 253 45 253 253 253 93 41 97 253 253 73 97 253 96 19 253
+        103 253 253 23 253 253 253 71 253 93 253 253 110 117 101 67
+        90 253 253 253 55 253 97 253 253 37 122 124 253 253 48 118
+        253 253 81 66 116 253 82 123 2 253 103 108 55 30 99 31 253
+        253 253 253 63 56 253 253 253 253 26 90 253 253 56 20 109
+        253 253 89 16 253 253 80 253 253 80 49 253 110 253 63 253
+        253 253 107 74 62 44 253 36 253 253 17 253 253 253 253 26
+        253 253 253 253 21 40 253 113 253 253 253 253 253 53 253
+        253 63 253 57 253 253 85 55 253 34 5 87 126 124 253 123 26
+        253 15 253 253 42 253 59 108 123 112 51 27 14 253 90 253 61
+        68 253 253 253 253 58 35 7 253 253 57 253 253 253 91 25 82
+        71 24 253 0 253 44 253 253 21 253 99 16 253 120 253 253 253
+        97 253 253 99 81 253 5 253 74 253 253 29 253 253 253 99 121
+        253 253 80 127 253 253 253 22 253 96 121 19 84 253 253 253
+        253 77 106 61 62 253 25 35 114 253 253 1 253 43 253 253 253
+        72 71 24 56 253 125 107 253 253 253 253 253 253 93 61 253
+        35 76 253 42 43 253 253 253 253 253 58 123 85 253 9 37 67
+        103 63 74 117 39 123 37 253 26 110 253 20 14 64 53 253 253
+        253 253 22 253 21 253 253 111 83 69 22 80 72 253 89 253 103
+        61 253 253 117 60 253 121 15 253 253 253 253 8 23 253 253
+        253 253 253 253 36 253 11 253 253 28 85 123 253 253 93 64
+        253 57 52 99 32 253 45 89 253 15 253 253 253 46 253 253 60
+        253 253 48 43 69 253 253 24 253 109 253 61 253 21 57 118 96
+        253 57 92 253 52 43 253 253 253 126 253 68 18 3 88 253 253
+        253 253 108 253 253 8 107 64 62 65 253 253 253 253 91 25
+        253 253 39 38 253 253 99 253 122 253 112 253 118 59 253 83
+        253 114 54 59 46 253 253 89 39 253 90 93 89 88 115 253 110
+        64 74 113 83 253 253 5 59 62 253 35 253 253 16 253 253 124
+        109 253 123 253 253 19 13 253 35 38 253 253 69 62 253 105
+        253 253 0 253 253 85 253 253 82 253 253 253 60 103 253 77
+        253 253 253 66 253 98 253 253 82 253 73 24 253 45 34 81 253
+        253 75 44 253 253 7 114 72 110 253 253 36 73 12 42 253 253
+        253 253 73 52 253 253 253 253 253 253 253 253 113 253 253
+        49 253 90 253 124 40 253 122 110 253 253 253 65 66 12 48
+        253 253 253 94 54 253 61 253 253 94 28 123 10 253 10 78 59
+        253 253 109 253 58 253 8 253 253 253 253 19 73 53 253 86 80
+        253 253 253 1 253 107 253 253 77 101 105 103 51 253 253 36
+        253 24 25 39 253 0 253 93 18 253 253 18 253 253 253 30 253
+        253 85 253 253 109 39 253 253 253 253 110 8 253 253 253 253
+        253 253 253 14 253 253 27 66 253 60 46 54 110 5 72 31 253
+        82 253 57 253 72 253 253 253 64 253 70 127 253 13 253 253
+        107 253 253 253 5 253 91 253 253 253 58 75 253 253 48 72 36
+        47 117 253 71 39 113 4 23 253 253 253 253 96 100 114 107 24
+        253 253 126 62 253 253 101 57 253 253 89 70 6 7 2 253 253
+        35 253 71 102 253 84 40 253 253 110 57 38 253 253 3 253 86
+        19 1 253 253 253 253 253 34 253 253 253 253 100 253 253 253
+        52 121 77 253 253 253 67 117 253 253 253 253 253 17 253 81
+        253 253 116 52 72 253 253 253 253 21 253 253 126 30 79 76
+        46 253 62 253 16 27 253 7 34 55 253 55 63 253 116 253 253
+        118 253 117 253 253 127 253 253 253 253 15 13 127 253 253
+        16 10 253 253 253 69 43 253 253 253 88 23 253 71 70 32 110
+        253 253 253 253 25 99 99 253 78 127 253 253 253 253 253 253
+        253 253 86 35 253 253 42 253 253 253 253 50 65 253 253 53 9
+        89 253 253 253 253 253 253 253 253 54 61 100 68 118 253 86
+        253 89 253 253 121 253 72 1 2 253 253 253 253 253 253 70
+        253 253 28 253 253 253 253 253 253 92 253 253 253 87 23 253
+        92 253 253 253 253 253 121 253 253 107 253 253 103 253 253
+        35 253 253 253 253 84 6 99 253 85 36 253 34 253 98 253 34
+        100 89 89 253 43 6 97 253 35 253 253 95 94 86 17 2 253 56
+        253 105 119 253 253 253 253 253 39 253 253 27 253 16 95 113
+        79 95 253 16 253 30 253 253 253 11 253 60 253 59 253 75 253
+        103 77 91 253 58 101 253 253 253 253 253 253 253 253 78 97
+        253 253 253 253 253 10 31 65 253 253 253 100 253 21 253 253
+        253 29 253 5 87 253 253 110 253 109 31 80 253 36 111 32 39
+        57 253 57 253 77 253 253 92 69 253 253 49 253 126 253 105
+        124 86 253 27 125 70 22 253 253 253 9 2 253 253 253 53 76
+        66 38 253 253 65 109 48 111 8 253 18 123 81 253 20 253 253
+        101 253 253 253 253 94 253 14 253 105 27 253 106 253 253 20
+        11 253 125 51 253 253 253 70 253 253 104 253 87 28 85 117
+        117 253 117 253 253 253 84 87 253 253 26 253 108 253 5 3
+        253 77 253 78 253 74 253 253 253 7 253 115 18 253 253 253
+        253 33 27 48 253 64 24 26 253 126 13 108 253 253 253 253 9
+        253 79 106 26 92 253 253 253 253 253 93 253 124 253 48 107
+        34 253 39 253 253 253 0 253 122 253 253 253 253 253 65 253
+        253 27 253 24 253 101 253 40 253 253 253 49 253 90 109 85
+        29 124 253 253 253 253 19 28 98 253 123 253 253 64 46 253
+        13 122 22 253 39 28 253 253 86 253 253 4 19 90 1 253 253 50
+        28 253 253 52 91 253 253 55 253 62 253 56 91 68 253 88 110
+        253 30 253 37 253 49 253 253 106 58 253 51 73 253 253 119
+        19 253 253 253 253 61 253 253 253 12 253 253 79 253 57 32
+        253 253 51 253 253 90 253 65 253 253 253 8 253 0 51 104 46
+        125 106 115 253 78 253 124 17 113 253 253 37 26 85 253 122
+        109 253 113 68 253 96 49 253 253 125 253 253 85 59 90 64
+        119 124 253 253 253 43 5 43 253 31 79 253 10 253 36 44 26
+        70 253 253 253 30 253 253 253 253 253 253 253 10 253 98 253
+        253 253 253 253 253 253 28 253 253 88 122 253 253 253 253
+        253 52 253 253 88 98 253 253 253 253 36 46 112 15 53 253 56
+        253 253 65 253 0 253 77 253 253 69 253 118 253 253 253 54
+        118 253 253 253 116 73 72 253 253 253 253 253 253 253 31
+        253 22 18 253 26 36 253 2 72 21 60 253 64 253 253 253 106
+        253 253 67 38 253 37 36 253 253 51 90 91 253 253 104 253 13
+        18 253 253 253 253 127 46 43 5 253 253 253 253 55 127 253
+        253 253 43 85 253 100 253 253 253 94 71 20 253 253 103 23
+        43 253 125 253 84 253 253 253 253 253 253 43 100 253 40 253
+        9 22 253 253 45 253 253 253 253 253 253 40 93 79 253 67 62
+        253 253 22 253 253 1 253 96 53 98 253 253 12 253 253 253
+        253 3 253 102 81 253 71 82 41 99 12 59 253 74 117 91 114 45
+        253 117 31 253 103 253 253 253 253 253 45 55 44 17 99 253
+        29 23 12 253 28 6 3 20 20 19 127 71 253 253 253 42 253 28
+        253 253 7 253 253 103 253 253 0 253 253 253 253 120 253 3
+        12 12 253 69 111 253 253 253 253 66 253 36 253 90 253 253
+        253 253 253 253 74 253 89 253 67 123 11 6 57 253 21 63 253
+        253 253 68 253 253 110 253 102 253 253 253 253 253 253 60
+        253 253 253 253 253 253 253 253 253 253 253 15 25 253 253
+        253 39 253 43 63 15 79 19 76 7 253 253 253 253 253 30 253
+        50 253 43 42 253 48 253 253 253 253 253 55 253 71 253 253
+        97 253 253 28 99 253 253 69 117 30 253 31 105 30 253 253 46
+        253 253 75 253 253 253 253 253 253 60 253 70 253 253 80 253
+        253 75 253 34 253 101 253 54 253 25 102 253 55 70 35 3 253
+        118 253 108 39 87 253 66 253 108 61 253 253 253 253 253 119
+        82 49 253 253 253 123 10 253 253 82 89 36 88 253 253 38 253
+        121 37 76 253 253 253 123 36 253 253 253 253 253 20 253 60
+        61 253 253 72 253 253 127 253 23 70 253 253 253 253 253 253
+        107 103 253 253 253 253 70 86 253 66 28 253 3 253 26 58 253
+        253 43 253 66 92 66 253 79 253 115 253 108 56 253 253 105
+        253 115 105 60 253 253 253 23 80 253 253 71 5 253 122 253
+        253 253 253 29 253 42 253 22 253 253 253 253 253 253 253
+        253 70 253 45 21 81 253 253 253 10 253 253 253 71 253 253
+        77 253 49 8 253 84 253 253 35 253 93 112 253 253 253 253 60
+        93 253 116 37 253 39 10 0 126 41 253 119 81 1 253 253 22
+        120 253 35 92 253 253 253 253 253 253 33 253 253 65 87 253
+        253 13 50 87 253 253 253 253 126 253 253 253 253 253 253 10
+        253 46 253 253 115 253 72 253 253 253 41 253 253 253 67 253
+        9 51 12 253 253 114 253 82 120 106 56 113 80 253 253 72 88
+        5 76 31 253 20 253 253 253 253 253 253 253 50 102 37 118
+        253 253 253 253 253 253 253 18 71 253 253 253 253 84 119
+        253 1 73 253 49 253 253 253 253 110 253 253 106 253 253 104
+        253 74 29 253 253 253 253 29 253 89 253 58 77 253 253 253
+        253 20 112 253 253 125 253 6 253 253 253 75 253 253 65 36
+        113 253 253 9 0 253 253 15 253 253 19 79 253 253 79 42 25
+        253 253 253 31 74 76 253 253 71 84 49 253 253 253 253 68
+        253 253 253 253 253 6 253 56 86 28 253 253 45 253 253 253
+        253 66 253 30 61 253 253 253 253 253 253 26 15 40 39 253
+        253 107 253 22 253 253 46 37 36 124 253 127 253 253 83 91
+        118 86 253 253 253 14 253 253 253 103 253 253 253 253 253
+        253 253 48 86 39 253 253 253 253 253 253 253 56 17 91 253
+        253 81 253 17 88 53 253 253 253 28 114 56 92 122 253 253 27
+        253 253 253 253 24 253 253 253 43 85 253 50 253 14 15 36
+        253 87 109 34 253 27 253 121 253 54 108 253 253 12 118 253
+        82 253 253 253 112 253 253 253 253 253 253 77 30 118 120
+        253 253 253 253 122 253 48 107 54 253 103 253 253 253 253
+        253 253 253 253 253 253 253 253 101 109 50 82 253 253 253
+        253 253 115 71 253 11 55 253 253 253 88 253 17 253 253 1
+        253 253 253 253 57 102 253 68 107 48 54 253 27 24 253 68 15
+        114 49 253 253 253 253 19 37 253 253 38 253 253 120 10 253
+        253 86 253 253 108 253 123 9 253 253 253 253 253 253 253
+        253 59 253 253 70 49 253 73 253 253 91 80 99 253 253 62 253
+        253 253 253 111 253 75 253 24 253 253 253 253 90 109 103 31
+        253 97 253 115 84 253 28 253 40 253 253 117 253 100 12 118
+        253 253 253 253 253 92 48 253 34 39 253 253 253 253 14 24
+        253 49 64 253 253 253 78 253 87 253 253 61 43 84 253 253 94
+        55 253 253 253 253 253 61 253 253 89 101 253 16 108 61 253
+        253 253 253 253 253 11 253 253 253 253 91 253 253 253 100
+        86 32 119 253 109 80 30 253 95 79 253 253 30 253 253 253
+        253 127 18 253 0 101 110 253 23 253 43 253 253 107 253 5
+        253 253 30 119 29 253 54 44 125 253 127 253 28 119 253 73
+        72 253 253 40 253 60 31 122 253 253 253 253 38 253 253 3 32
+        253 119 253 21 253 253 253 12 253 67 115 253 84 253 91 253
+        253 97 89 64 253 32 253 84 253 253 119 67 253 253 53 253 38
+        253 30 25 253 112 253 29 69 63 48 253 73 253 65 253 83 13
+        65 48 37 1 124 253 253 253 55 61 253 40 20 109 253 253 90
+        253 253 4 253 78 253 70 24 83 253 253 80 253 253 69 16 253
+        14 14 87 253 104 11 253 104 253 90 118 5 84 253 253 125 253
+        253 126 253 253 21 253 253 69 253 4 103 13 253 253 253 253
+        253 70 55 253 38 88 253 39 253 13 253 253 34 253 33 253 253
+        253 253 253 253 253 253 121 253 85 1 97 253 112 253 90 253
+        90 253 253 253 64 27 45 253 253 127 253 253 253 253 253 98
+        253 253 253 253 77 253 253 99 70 253 253 253 99 253 253 253
+        43 123 77 62 84 37 70 88 253 53 253 253 20 122 253 253 253
+        127 253 100 102 12 71 7 253 253 253 253 80 253 253 123 253
+        93 92 253 90 92 48 253 126 11 3 85 253 253 52 253 72 253 36
+        253 253 253 125 105 253 26 253 253 253 253 253 48 75 253 26
+        50 253 31 253 253 86 253 253 253 120 114 70 67 253 253 253
+        253 123 78 253 253 253 25 60 57 29 36 94 123 112 125 253 77
+        253 116 253 253 253 253 92 70 3 69 253 253 14 72 30 253 94
+        253 253 70 42 93 253 70 127 3 111 32 5 253 28 253 30 253
+        253 13 46 253 253 24 7 253 106 253 253 253 39 253 253 25
+        253 2 253 110 1 253 253 253 45 253 253 253 22 112 6 10 253
+        253 253 253 25 79 253 83 113 90 253 43 253 253 253 253 253
+        253 253 253 253 38 69 97 253 253 90 253 253 253 91 253 253
+        85 253 18 253 103 7 253 253 253 253 253 68 74 253 253 104
+        253 253 253 253 253 51 108 73 97 253 253 2 110 35 93 253
+        253 253 253 253 253 22 253 253 75 253 79 49 253 253 253 76
+        253 253 253 253 30 253 253 253 116 253 113 19 253 19 253
+        253 87 118 253 253 66 253 253 113 253 253 0 84 123 26 253
+        253 17 253 79 253 58 87 253 47 85 90 20 253 99 120 253 253
+        48 253 7 253 253 44 253 72 110 33 115 28 253 253 253 107
+        253 253 73 253 253 13 34 253 43 253 91 253 86 86 253 103
+        253 43 253 253 21 117 253 253 253 253 253 52 253 253 253 42
+        79 57 253 101 253 253 253 89 37 47 253 253 123 62 27 253
+        253 66 253 253 253 253 87 72 253 253 253 253 31 253 253 83
+        11 125 67 253 86 98 67 253 253 92 253 119 20 253 85 253 97
+        108 253 253 253 124 118 253 253 253 7 253 53 253 253 77 253
+        253 8 253 253 106 253 5 122 9 94 253 253 34 253 253 253 119
+        94 29 253 113 253 108 89 253 253 11 127 16 253 111 253 21
+        253 69 35 253 253 253 253 3 253 253 253 253 253 253 253 41
+        253 253 109 86 72 253 253 99 253 32 253 21 50 253 67 51 13
+        253 70 253 253 253 253 91 1 54 253 253 79 106 253 105 49 31
+        46 253 1 253 253 91 125 253 253 253 253 114 253 253 87 253
+        253 253 96 31 253 115 103 253 23 118 253 253 36 82 253 55
+        253 253 90 253 47 253 253 253 39 25 59 121 253 253 109 253
+        0 40 116 120 110 253 253 99 119 97 84 253 253 253 101 253
+        253 88 15 19 77 12 127 74 253 28 124 80 253 50 40 253 253
+        70 70 70 253 125 40 253 124 40 253 106 253 253 253 253 89
+        109 253 34 93 253 253 112 118 10 12 51 23 28 26 253 253 16
+        253 253 253 253 40 253 253 18 63 253 115 121 30 61 253 253
+        253 253 69 44 253 124 253 41 253 253 253 54 253 55 253 49
+        253 27 253 25 253 253 253 105 102 253 24 91 9 253 253 253
+        63 20 253 94 35 253 253 5 253 47 253 9 253 0 253 61 43 70
+        54 253 253 253 253 253 101 33 79 253 35 103 253 253 52 113
+        253 253 253 253 253 37 253 253 253 253 22 253 26 253 108 64
+        22 253 14 253 76 115 74 253 253 76 253 253 253 120 253 253
+        25 116 253 30 253 114 253 253 115 253 253 103 253 2 69 22
+        253 42 253 41 38 15 253 97 253 253 104 253 109 253 253 253
+        70 52 253 253 83 253 253 253 73 253 253 103 65 124 33 253
+        253 253 106 18 99 120 253 121 253 106 253 253 50 253 253
+        103 80 95 24 21 0 253 17 121 29 253 79 253 27 253 253 7 253
+        253 253 45 63 253 253 72 253 83 28 87 61 118 253 253 63 34
+        5 253 47 253 253 113 35 253 123 82 11 253 21 253 11 24 253
+        71 114 106 73 253 90 72 253 253 27 21 253 124 122 253 102
+        253 53 253 253 253 253 0 61 253 37 89 253 29 253 53 75 253
+        111 21 13 253 253 108 112 91 253 253 253 97 109 58 34 253
+        18 253 253 97 253 25 253 253 253 253 126 253 253 82 253 33
+        117 253 253 5 91 253 253 74 81 38 253 119 253 23 253 253 13
+        36 64 111 253 253 120 107 68 253 77 253 59 253 253 99 253
+        253 109 253 253 81 253 121 253 253 253 84 253 253 253 253
+        55 119 18 90 253 253 253 253 253 253 107 253 79 253 32 253
+        253 24 33 253 253 3 253 253 85 253 253 17 253 253 44 253
+        116 39 42 87 253 253 106 253 77 253 83 253 61 31 45 253 253
+        253 1 102 27 100 118 253 29 253 253 21 253 253 253 253 253
+        117 88 99 32 253 102 0 253 79 253 253 253 114 253 253 91
+        253 253 253 31 106 253 62 29 116 253 253 253 14 253 253 253
+        115 253 253 253 79 253 253 85 23 253 253 40 253 116 253 93
+        13 253 253 94 74 18 253 253 114 14 72 92 253 106 253 253 14
+        253 253 253 253 253 49 253 253 72 253 253 253 48 253 30 253
+        253 253 253 47 24 253 253 57 97 253 253 253 253 253 85 253
+        253 100 34 253 253 57 28 122 253 102 253 253 58 97 20 253
+        253 253 253 253 253 253 72 103 253 253 253 253 253 28 17 78
+        83 253 253 253 4 253 96 7 111 126 253 58 253 108 253 90 253
+        40 253 253 253 253 253 253 253 77 253 54 253 110 34 253 253
+        113 123 101 115 115 253 253 253 101 253 253 113 81 253 106
+        35 253 61 46 253 253 44 118 104 3 38 253 253 253 253 253
+        253 253 45 253 101 119 0 9 35 253 41 14 253 104 253 73 101
+        10 253 253 253 119 253 50 253 89 253 253 87 253 48 77 60
+        253 253 110 253 253 253 253 1 253 253 253 253 253 253 253
+        22 253 86 75 117 253 95 31 253 253 114 106 253 69 253 253
+        52 71 111 57 46 113 253 253 253 253 253 253 253 253 110 90
+        253 253 94 253 22 253 253 126 253 253 253 45 253 81 253 253
+        253 253 105 35 253 253 253 41 67 253 122 15 253 253 253 253
+        66 77 47 82 51 89 54 17 78 55 19 253 125 253 253 94 105 253
+        253 253 22 253 16 253 44 124 64 125 90 253 253 253 253 253
+        102 253 70 62 253 31 253 94 124 90 57 84 253 54 116 39 253
+        253 253 253 253 78 253 124 92 52 99 12 24 253 84 253 125 74
+        253 253 22 13 253 35 12 7 253 125 15 253 253 253 65 253 253
+        253 253 253 12 253 253 253 253 253 253 30 253 253 66 253
+        253 114 253 253 253 253 253 253 253 253 104 57 61 253 45
+        253 253 48 52 253 253 253 34 253 37 253 67 26 253 81 253 61
+        253 253 253 49 100 85 253 112 63 90 253 45 253 253 253 253
+        79 82 37 80 253 253 102 253 26 9 253 67 120 253 72 85 91
+        253 72 253 114 59 253 253 18 88 253 116 253 253 253 253 98
+        253 253 66 253 253 253 253 31 74 253 253 253 253 253 35 253
+        253 253 253 253 253 118 253 110 253 97 23 253 49 73 253 253
+        54 253 29 92 253 253 253 109 253 115 253 253 253 87 51 253
+        0 253 20 253 13 253 120 78 253 124 253 253 253 253 253 253
+        27 123 23 50 76 82 69 253 253 253 92 253 253 253 253 253 93
+        84 253 43 29 253 253 55 253 253 253 83 103 14 94 253 60 113
+        50 75 18 253 79 253 253 52 94 253 2 253 253 253 253 84 253
+        50 253 253 253 7 253 253 118 12 253 253 253 18 75 71 56 79
+        253 25 101 81 253 99 253 253 253 253 253 27 253 253 253 74
+        24 253 253 24 112 43 253 32 253 41 253 253 8 253 86 62 48
+        253 253 253 253 93 253 45 3 253 253 253 253 253 90 105 253
+        46 97 24 253 253 72 253 115 253 16 41 253 253 58 253 99 253
+        93 28 124 253 57 31 253 76 253 70 35 253 64 253 8 253 253
+        47 121 253 0 253 253 253 0 45 82 49 253 253 58 116 91 253
+        253 253 253 253 253 253 53 35 105 60 253 253 71 253 59 111
+        253 99 253 253 253 39 120 253 253 115 61 253 58 49 253 62
+        253 27 106 40 253 11 253 253 253 253 90 52 110 112 15 124
+        253 80 253 59 253 60 253 253 93 253 52 5 27 253 123 98 253
+        253 253 253 121 123 23 111 253 253 25 19 253 253 253 25 253
+        25 253 253 253 123 253 253 253 253 6 72 253 55 16 253 253
+        253 253 61 253 253 253 253 253 76 253 12 22 253 253 49 99
+        253 253 253 253 253 253 253 253 82 253 81 253 125 123 87 36
+        253 253 117 253 253 96 58 253 253 253 59 253 253 20 253 253
+        253 253 53 1 253 253 21 253 253 253 253 253 60 253 253 43
+        87 94 253 125 253 253 20 253 73 17 253 118 25 253 253 253
+        253 253 253 253 81 90 253 253 114 253 253 72 253 253 86 253
+        91 253 253 34 253 253 51 253 253 253 253 86 120 81 64 43
+        253 57 253 253 68 253 85 123 61 253 253 95 57 67 253 63 78
+        253 253 26 107 253 12 253 253 253 253 253 61 253 1 113 118
+        253 253 253 253 15 253 118 67 29 253 100 253 253 253 25 125
+        127 253 37 253 253 253 253 253 15 253 39 253 59 88 253 96
+        253 253 90 253 253 36 253 253 253 253 80 71 44 253 42 253
+        253 102 56 81 253 253 253 253 253 87 119 100 253 253 253
+        253 38 253 253 70 24 253 11 24 253 253 253 253 39 253 253
+        253 253 13 253 114 107 91 40 63 18 33 253 114 253 253 72
+        253 253 125 126 253 76 253 0 253 253 253 253 90 253 29 253
+        253 253 92 253 253 253 253 253 118 253 29 253 253 57 31 95
+        253 253 253 67 253 253 19 79 111 28 23 17 253 94 51 253 21
+        253 0 10 253 253 253 253 14 42 253 253 253 51 253 56 253
+        253 253 76 253 253 60 52 109 25 57 253 62 253 253 23 253 18
+        93 21 253 101 66 253 253 253 253 253 253 60 62 42 253 253
+        253 253 253 111 253 253 78 253 253 101 253 253 77 253 91 97
+        53 253 253 56 86 253 19 253 253 253 253 0 253 253 99 253
+        253 88 253 34 253 11 253 253 253 95 72 74 253 253 99 70 54
+        96 118 28 10 87 127 110 100 253 112 118 47 115 77 253 253
+        253 80 119 253 253 253 42 253 15 253 253 253 119 253 104 57
+        39 253 37 117 96 85 253 253 253 51 253 125 105 102 253 253
+        69 54 253 34 253 46 253 253 30 253 0 74 253 93 253 101 253
+        35 47 253 253 33 253 65 253 111 61 253 253 253 253 253 70
+        253 70 253 253 96 43 36 253 253 105 100 109 81 253 253 0 26
+        122 94 253 253 119 19 36 253 69 30 60 253 32 36 253 253 0
+        253 115 30 253 38 253 83 13 253 52 108 59 6 24 56 253 253
+        63 253 253 253 92 105 253 21 253 253 253 19 103 253 21 87
+        43 253 98 73 253 92 75 253 71 69 253 253 122 253 253 253
+        109 253 104 253 35 253 24 32 125 72 253 253 253 253 100 114
+        69 253 22 253 253 253 121 78 1 253 253 253 70 253 115 107
+        34 253 253 98 253 253 122 253 253 6 100 253 253 79 106 253
+        5 253 253 253 47 98 49 85 253 22 46 253 97 69 253 51 92 95
+        253 253 253 253 5 253 99 61 253 253 105 116 253 253 111 113
+        98 30 50 253 84 253 7 61 253 253 115 253 253 253 253 253 88
+        47 253 253 52 108 26 253 253 253 253 253 253 253 11 253 253
+        253 0 253 77 35 253 253 253 253 57 18 253 103 91 253 253
+        253 110 23 116 253 253 102 50 125 13 77 116 75 253 109 109
+        253 33 103 25 253 253 253 253 253 253 253 34 36 253 8 253
+        36 104 253 7 253 253 7 253 253 253 253 77 90 253 253 253 26
+        9 55 2 61 253 253 253 101 253 253 74 107 253 77 121 113 115
+        253 253 253 70 36 253 253 30 99 47 253 253 253 253 62 46 90
+        90 253 253 34 77 104 253 54 253 0 253 253 253 91 253 253
+        253 113 19 96 253 36 253 253 253 253 253 253 51 106 253 86
+        112 70 253 253 253 84 253 53 100 253 105 82 35 18 57 99 90
+        7 253 43 4 253 33 91 253 123 86 107 253 110 253 253 36 101
+        253 19 253 0 253 253 21 253 253 121 39 253 253 253 253 253
+        32 253 71 253 253 253 105 253 253 8 253 253 253 253 253 109
+        253 253 253 253 253 51 253 85 253 253 74 87 253 61 69 29
+        253 253 253 253 253 40 253 57 253 51 103 6 253 253 8 93 58
+        253 60 127 71 127 253 104 253 62 253 22 253 253 253 101 253
+        127 253 253 253 0 45 20 253 24 85 253 73 26 253 65 253 253
+        18 86 70 100 50 253 253 90 89 104 253 253 86 253 253 63 253
+        63 253 253 253 100 253 253 112 253 253 253 69 37 101 99 253
+        116 253 253 253 253 42 253 50 31 8 253 253 253 253 253 127
+        87 0 253 94 9 253 253 253 78 14 51 253 253 253 253 253 253
+        39 127 8 122 253 253 253 253 253 253 253 54 253 253 113 253
+        52 71 92 124 78 253 253 23 253 253 253 28 253 253 253 113
+        253 253 88 253 253 253 253 44 80 253 253 253 253 253 253 38
+        253 253 253 253 121 49 73 253 101 63 253 79 45 253 253 253
+        253 73 78 253 107 253 29 90 253 92 253 101 113 39 253 253
+        253 34 104 102 253 253 253 56 253 104 253 6 61 253 253 253
+        107 11 253 118 253 253 115 52 123 72 253 117 42 253 253 253
+        253 57 35 253 15 24 253 253 253 115 114 14 253 253 253 253
+        18 48 253 23 253 122 253 18 51 72 253 253 253 253 124 253
+        89 253 253 253 82 45 15 253 253 253 253 64 35 253 253 50 60
+        253 253 60 253 253 122 253 34 253 253 253 105 22 52 83 253
+        56 21 119 124 40 253 61 22 11 120 117 14 253 91 71 253 253
+        253 253 253 253 253 253 253 76 253 253 253 63 253 253 18
+        253 18 57 54 253 100 253 253 253 63 253 91 58 253 90 125
+        107 82 253 0 253 61 62 253 253 253 253 253 253 120 253 253
+        82 82 253 69 253 253 253 253 253 253 253 36 253 253 27 253
+        53 90 60 43 62 253 253 253 253 253 253 124 122 30 253 253
+        31 29 52 104 253 253 95 253 32 5 27 100 36 253 45 253 253
+        10 253 253 62 14 116 119 78 253 49 106 29 125 253 253 6 78
+        253 253 253 253 253 253 253 126 25 253 253 0 253 31 253 253
+        111 253 253 253 253 75 11 33 253 58 253 253 253 253 253 111
+        253 253 253 18 253 105 41 253 127 11 55 77 253 253 13 253
+        253 52 253 253 62 32 50 253 253 57 253 253 253 71 253 253
+        253 253 122 253 5 253 105 253 253 57 253 14 11 253 120 253
+        63 253 253 92 19 253 253 53 253 80 253 253 253 253 37 96 36
+        8 112 28 122 30 61 49 87 123 253 75 105 253 99 253 52 253
+        69 118 253 26 0 16 253 253 74 253 104 10 253 71 82 105 125
+        92 253 27 253 253 253 253 253 12 41 37 253 45 253 68 75 253
+        79 115 253 253 5 253 253 253 253 84 103 253 253 253 253 253
+        253 23 49 253 121 21 93 253 36 253 253 253 63 253 90 253
+        115 72 253 28 109 253 86 95 48 30 253 253 46 253 68 253 62
+        253 253 22 88 78 21 253 253 46 120 253 44 126 253 253 253
+        253 72 124 104 253 253 79 13 253 39 0 253 253 253 55 253 64
+        44 102 54 86 40 36 33 28 253 7 21 76 253 62 253 115 253 253
+        253 253 30 37 253 253 49 253 253 253 62 253 88 253 253 253
+        62 34 253 253 58 102 253 2 121 12 14 253 120 80 253 253 253
+        253 253 54 253 253 253 78 253 253 253 253 253 253 110 253
+        253 253 16 253 40 253 253 78 113 253 253 253 17 53 127 253
+        104 253 75 123 253 253 74 17 20 253 253 63 253 253 0 62 253
+        82 116 253 253 253 117 70 253 107 253 253 253 120 253 253
+        79 253 253 253 253 253 253 111 253 28 253 97 20 253 253 253
+        253 253 58 99 87 253 253 253 73 107 36 48 253 16 253 253 70
+        253 253 77 253 62 253 253 253 253 253 63 253 253 13 253 253
+        253 108 253 26 9 253 13 46 253 115 253 3 253 81 85 253 123
+        253 253 79 253 58 54 253 253 253 253 253 96 36 253 110 10
+        253 253 64 253 103 253 70 126 35 124 48 253 253 99 6 253
+        253 253 253 253 253 253 70 253 7 2 253 253 55 41 69 121 116
+        68 62 34 253 106 253 253 253 73 100 253 61 253 253 17 253
+        66 253 253 80 253 253 39 253 253 28 253 253 105 253 105 253
+        87 253 253 26 59 253 253 253 127 13 253 23 253 253 44 14
+        253 253 253 253 68 106 253 61 253 107 110 253 253 30 119 14
+        253 253 253 253 253 120 253 66 253 253 253 33 253 64 42 79
+        57 253 253 253 81 253 67 28 108 18 34 253 27 253 115 75 253
+        13 58 253 253 253 57 253 105 30 253 26 50 253 253 12 253
+        106 111 253 100 253 253 14 110 45 100 30 29 253 108 93 253
+        253 253 253 253 253 253 253 253 46 253 253 65 116 253 253
+        253 253 14 56 39 253 253 253 253 253 253 102 114 65 253 253
+        29 45 253 253 253 253 253 123 82 253 13 253 253 253 111 94
+        253 127 103 35 13 253 89 59 103 253 253 30 253 253 55 253
+        253 253 253 28 253 253 81 14 253 253 46 253 42 253 52 253
+        253 253 3 253 253 253 55 121 253 253 253 253 62 253 62 253
+        119 253 106 33 86 39 253 15 253 81 80 253 28 253 253 102 84
+        57 35 253 81 91 33 60 96 253 253 42 253 253 253 77 253 45
+        72 53 253 65 253 28 253 253 12 110 20 253 253 107 50 253
+        253 253 253 97 14 253 253 100 253 253 253 26 88 99 0 35 253
+        253 253 35 41 253 62 253 126 253 34 253 101 76 115 75 35 4
+        253 124 253 43 70 253 253 253 122 63 253 253 253 0 253 71
+        73 253 87 253 122 7 80 253 0 54 94 253 0 253 253 253 90 41
+        42 48 253 253 253 61 253 13 253 34 76 10 253 4 91 101 25
+        253 253 253 253 95 253 253 253 74 253 13 123 253 40 253 253
+        55 56 253 115 92 253 71 24 253 253 77 103 253 253 29 253
+        253 23 253 3 253 104 29 53 253 69 253 253 28 253 253 32 48
+        31 122 253 253 253 253 253 253 107 253 77 85 253 253 253
+        253 253 253 253 75 20 253 253 253 38 253 253 253 253 95 83
+        57 253 253 0 123 28 253 97 253 253 23 119 6 86 113 253 3 28
+        3 64 73 118 105 253 253 75 253 253 71 96 253 253 62 253 253
+        43 30 253 253 253 90 68 253 253 69 24 253 76 56 253 101 82
+        71 253 84 253 253 253 253 253 117 125 13 253 54 253 253 30
+        253 253 253 253 253 50 61 253 253 17 93 253 253 19 50 253
+        102 24 78 253 253 253 253 29 55 105 99 253 253 253 104 253
+        253 253 253 1 35 253 5 253 253 253 116 95 253 91 125 52 67
+        53 253 253 253 12 22 9 253 126 253 105 253 253 54 58 126
+        253 27 253 253 253 60 253 253 115 253 84 253 100 101 253
+        253 253 253 127 16 35 253 253 54 253 107 253 253 82 253 253
+        102 43 28 64 121 253 253 126 253 253 253 253 253 253 110
+        253 253 59 253 253 55 120 114 253 0 23 124 253 253 253 36
+        90 253 253 253 253 46 104 35 253 4 39 108 253 60 253 253
+        253 253 115 84 102 253 253 253 3 253 253 253 253 253 98 49
+        253 253 65 253 66 253 253 253 86 253 41 73 81 57 253 22 75
+        126 54 92 253 106 253 105 253 45 253 80 253 62 253 253 127
+        20 127 74 19 253 253 253 253 253 253 38 253 113 253 69 121
+        103 125 101 56 253 44 99 102 253 6 60 253 253 103 253 253
+        253 20 253 253 253 253 0 253 55 87 253 253 253 106 38 253
+        29 67 24 253 33 253 7 31 253 253 80 253 42 253 77 253 9 253
+        253 253 34 120 116 93 253 60 253 253 253 253 253 253 253
+        253 36 63 253 253 253 253 122 59 253 253 28 95 253 44 42 62
+        68 123 253 116 253 33 117 253 20 71 109 12 253 51 36 95 253
+        253 253 0 253 51 253 253 73 253 27 253 253 253 253 253 71
+        253 61 253 2 56 253 253 253 253 35 253 77 93 99 94 75 88 99
+        72 253 253 253 253 10 253 9 253 253 122 35 69 253 253 253
+        113 253 112 23 253 91 253 105 61 253 122 116 253 109 253
+        253 253 253 72 253 99 253 44 253 253 253 253 253 253 253
+        253 10 253 84 253 37 105 49 49 72 253 127 253 253 20 253
+        253 253 253 86 107 115 34 253 253 69 108 253 253 21 253 253
+        126 90 40 253 92 115 82 253 253 76 73 253 23 253 253 253
+        253 253 17 77 43 73 110 253 253 66 57 253 36 253 93 26 253
+        253 253 253 3 92 253 253 253 253 253 49 86 11 61 253 253
+        105 20 253 253 253 80 48 43 69 253 253 253 253 253 28 107
+        27 24 253 253 127 95 253 253 253 61 28 253 253 253 253 88
+        253 13 44 253 43 73 31 253 89 253 0 253 253 65 124 52 253
+        253 253 253 253 253 34 253 253 37 253 253 253 253 253 20
+        253 253 10 253 7 106 253 114 1 253 31 253 39 74 253 253 253
+        68 82 126 72 47 253 253 253 253 66 44 253 253 125 107 79 75
+        123 253 253 253 253 36 253 112 14 10 48 253 253 86 253 253
+        9 78 253 253 253 28 253 253 109 253 111 109 253 253 253 6
+        253 45 253 98 253 89 34 13 253 253 253 40 253 253 253 122
+        253 253 253 253 253 253 253 123 92 253 253 15 253 253 253
+        253 253 253 62 94 59 253 85 78 253 253 253 85 253 253 253
+        253 44 253 29 51 80 253 76 59 253 253 253 253 253 110 121
+        253 253 253 111 88 253 86 253 253 253 53 7 76 253 23 253 35
+        72 253 37 121 34 253 50 125 253 8 97 253 95 43 61 95 253
+        253 0 59 22 124 80 253 35 253 82 80 253 51 75 253 253 253
+        253 253 25 31 253 17 253 17 253 111 253 253 253 253 253 253
+        253 109 103 71 253 59 16 253 73 253 91 253 28 99 253 253
+        253 15 58 89 110 253 4 253 253 39 113 32 253 253 93 114 253
+        253 0 82 43 253 253 253 22 253 107 2 253 253 253 253 253
+        253 64 7 253 253 253 35 253 253 103 18 253 111 253 253 126
+        54 253 253 47 253 253 253 253 12 253 253 34 253 75 253 253
+        86 62 11 7 25 253 43 253 58 253 253 44 253 120 36 73 6 253
+        253 99 253 4 19 253 42 253 253 253 253 98 253 253 126 51 78
+        18 73 30 114 253 87 3 253 40 253 253 83 253 78 253 44 103
+        52 253 78 253 253 54 253 253 122 127 47 253 253 119 125 31
+        117 14 253 39 253 60 72 6 74 253 253 253 106 253 9 109 91
+        44 253 253 28 110 20 253 253 253 253 59 253 30 253 253 6 21
+        253 9 253 123 253 117 19 21 253 101 35 253 68 58 114 253 52
+        41 253 253 253 64 253 253 58 253 120 108 253 253 77 35 253
+        22 8 253 253 98 253 16 253 21 112 8 253 15 63 253 253 6 112
+        125 43 253 35 110 253 0 253 0 253 87 23 65 24 66 253 121
+        253 253 109 253 253 21 253 15 42 121 253 28 253 253 59 253
+        253 24 79 253 253 84 253 253 253 253 253 79 253 253 253 253
+        253 253 253 17 253 115 69 105 35 49 45 99 12 253 253 253
+        253 15 253 101 253 253 253 253 0 253 253 101 24 10 253 74
+        11 81 253 77 253 253 0 253 253 253 253 253 66 253 253 253
+        253 253 103 105 253 253 42 253 57 253 117 57 39 253 107 103
+        110 253 253 253 10 63 253 253 126 253 253 98 253 253 20 10
+        253 67 56 253 65 253 16 253 15 122 57 253 253 253 253 115
+        64 88 253 124 49 253 27 28 101 92 253 114 41 253 253 27 43
+        253 253 38 61 66 76 115 253 127 74 253 91 253 102 253 87
+        253 88 253 253 253 253 111 253 6 253 126 253 253 253 253
+        253 253 24 253 2 50 57 62 253 253 253 253 120 253 106 253
+        253 253 59 253 94 38 253 22 253 116 100 87 253 253 80 70 49
+        253 253 58 43 73 68 253 253 253 52 253 253 253 23 35 56 253
+        58 34 72 253 253 58 47 54 253 253 253 24 253 253 253 79 253
+        31 77 16 253 253 253 67 25 6 253 42 13 253 253 253 253 123
+        253 253 253 13 253 26 253 253 253 57 253 0 26 95 253 86 253
+        14 38 0 253 17 253 125 42 75 20 6 20 41 26 253 253 40 253
+        253 253 253 253 24 60 253 78 89 87 253 253 253 253 253 253
+        253 253 253 22 253 60 253 253 253 74 1 34 253 253 253 253
+        253 253 253 253 79 253 47 72 111 89 117 61 99 84 253 253
+        253 103 33 253 253 253 10 253 0 42 253 253 253 253 253 253
+        253 253 50 253 253 77 44 253 253 54 8 65 253 36 253 40 253
+        253 253 253 95 253 253 253 73 17 253 91 253 253 253 253 253
+        253 253 253 253 253 6 253 55 37 118 253 124 253 253 253 253
+        253 253 253 118 253 253 80 74 54 253 1 90 97 253 253 253
+        253 3 81 253 253 253 91 125 63 77 88 108 253 70 21 97 253
+        253 43 253 53 45 120 119 253 253 253 253 253 253 124 24 253
+        10 1 96 59 253 253 116 253 76 253 104 253 253 253 253 4 101
+        253 253 253 94 91 253 253 253 253 11 26 91 253 47 253 253
+        26 52 117 23 55 18 44 253 253 32 253 253 126 253 97 105 253
+        20 118 253 253 120 107 253 2 121 52 253 18 107 253 253 117
+        35 253 17 70 253 66 107 125 253 253 253 253 59 119 1 253
+        253 253 253 106 118 51 105 253 99 27 253 253 20 253 253 85
+        51 253 90 253 253 253 27 36 55 253 253 253 253 253 3 253 57
+        253 253 253 253 253 253 32 253 101 44 253 99 53 59 41 253
+        253 20 253 253 41 119 253 56 253 253 31 105 121 29 253 42
+        253 253 3 253 253 42 253 107 120 2 16 253 100 253 253 253
+        253 253 253 13 20 253 253 253 253 50 86 9 53 123 50 253 11
+        11 107 253 41 253 60 99 35 4 253 0 125 85 253 71 253 82 253
+        87 15 123 4 253 253 49 253 32 28 15 92 253 86 253 120 253
+        40 4 33 253 12 253 54 253 253 253 253 37 253 253 75 253 253
+        70 253 253 38 80 59 12 253 253 19 253 75 253 77 117 119 76
+        253 117 23 78 253 47 253 99 253 253 121 253 253 54 253 3
+        253 253 253 253 253 29 51 253 253 253 122 253 95 27 104 110
+        253 253 76 253 253 83 253 117 43 87 61 253 76 54 253 118
+        253 89 253 81 68 91 43 253 95 113 253 124 253 116 253 59
+        253 54 23 81 253 110 253 253 253 64 54 122 253 39 253 104
+        114 98 73 253 91 253 125 35 253 105 98 107 75 29 66 7 253
+        253 60 253 57 0 59 121 253 39 253 253 253 253 56 45 253 253
+        253 253 36 253 253 44 253 253 253 253 253 253 253 253 106
+        253 111 43 77 19 68 121 253 253 253 253 253 253 79 253 253
+        93 253 253 253 253 253 253 106 253 64 48 87 253 30 253 253
+        40 253 253 253 5 253 77 253 36 102 48 253 7 36 253 253 253
+        253 253 27 70 253 253 41 253 253 253 253 105 253 253 10 22
+        12 253 109 253 253 253 126 253 90 253 119 110 253 6 253 253
+        253 253 253 72 45 253 253 69 253 75 253 125 121 61 253 100
+        5 30 253 253 115 253 253 253 253 253 68 253 253 32 25 253
+        83 253 98 7 34 253 253 88 253 253 79 253 23 253 253 253 253
+        10 253 253 0 253 41 80 99 115 120 253 253 3 253 67 6 253 28
+        253 253 117 84 253 79 253 121 253 253 253 123 26 253 3 253
+        253 81 14 253 253 253 253 253 253 253 253 253 82 253 50 23
+        253 76 253 253 79 253 31 83 253 62 113 253 253 69 69 10 17
+        253 56 253 66 70 253 20 253 115 68 71 56 0 125 120 253 253
+        253 253 253 49 253 253 86 74 25 125 43 253 28 14 56 253 101
+        253 253 84 48 253 89 82 253 46 54 253 253 109 253 253 49
+        125 253 29 96 253 253 121 253 253 253 253 253 71 21 253 53
+        253 253 253 253 29 253 109 70 54 253 253 120 253 253 54 253
+        253 0 45 18 119 46 57 253 253 117 94 116 59 253 253 253 253
+        0 253 107 24 253 89 51 27 24 6 15 253 253 253 253 13 253
+        100 103 53 253 253 15 253 253 253 253 253 253 253 253 253
+        253 110 253 253 99 253 109 59 253 127 253 22 85 73 60 253
+        90 110 68 32 253 122 34 114 253 253 253 253 253 253 117 29
+        89 39 253 16 253 253 54 253 253 6 253 54 101 29 253 54 9
+        253 107 111 65 52 119 55 253 253 14 253 253 253 123 253 120
+        253 111 253 253 253 1 253 76 253 33 253 253 113 71 253 41
+        88 253 0 104 253 36 253 253 253 100 253 253 253 79 84 58
+        126 71 78 253 253 67 253 91 71 31 38 76 42 17 253 86 253 71
+        253 253 40 253 253 253 104 3 30 253 85 116 253 107 47 253
+        253 253 26 121 253 106 253 253 253 68 253 253 253 253 103
+        118 253 253 253 253 253 253 253 52 74 253 101 92 7 94 113
+        81 253 253 253 253 65 45 253 115 0 66 253 253 253 13 253 85
+        253 253 48 60 253 253 253 92 118 253 253 253 253 253 118 96
+        253 253 63 253 253 125 0 253 253 253 107 253 26 41 253 253
+        105 32 81 253 100 67 37 253 104 253 62 253 253 44 37 253
+        253 253 127 253 93 253 253 253 253 34 85 253 107 253 253
+        253 9 27 121 253 56 253 107 55 45 34 253 114 253 253 47 4
+        253 9 253 10 253 253 79 89 253 97 27 94 77 34 253 47 253 51
+        30 13 9 253 253 253 253 253 24 80 18 253 253 253 61 69 71
+        253 253 253 88 253 88 85 21 45 253 60 5 39 253 51 80 253
+        253 65 253 73 37 253 54 253 70 253 4 14 70 59 81 76 106 253
+        253 23 55 253 91 253 127 253 105 253 48 253 48 253 253 3
+        253 0 253 253 58 253 253 6 253 253 253 253 69 253 123 253
+        84 253 253 253 253 11 85 101 253 47 253 53 30 253 253 253
+        40 100 123 125 56 54 253 253 253 111 46 51 253 253 106 53
+        253 253 253 253 253 253 15 253 70 43 253 7 253 100 15 253
+        93 115 122 253 253 111 115 4 1 253 253 98 253 3 253 91 253
+        253 253 253 253 44 117 253 23 112 253 17 66 253 253 253 9
+        253 58 253 253 253 53 93 29 113 253 5 35 43 253 0 253 81
+        127 253 253 68 15 253 0 253 47 253 86 253 118 253 253 76 23
+        253 28 113 253 253 253 124 105 253 91 59 253 253 87 253 253
+        253 253 99 253 35 253 62 253 116 253 76 126 31 253 253 44
+        57 253 253 119 85 253 118 253 253 74 40 12 79 4 253 20 90
+        111 253 27 253 46 253 253 253 253 19 253 253 109 253 253
+        253 253 253 61 253 253 253 79 253 126 253 34 253 21 253 41
+        26 253 253 253 253 8 253 253 253 29 253 253 253 100 253 41
+        36 253 88 253 253 120 253 253 253 253 123 253 253 253 253
+        253 253 253 253 19 76 253 36 253 253 253 253 253 9 253 253
+        253 253 118 253 73 253 93 58 63 80 253 253 35 105 23 253
+        108 253 46 6 253 253 253 253 253 253 253 89 253 65 27 74
+        253 38 253 15 253 253 253 253 253 122 253 253 253 253 55 80
+        253 253 20 253 18 47 253 253 253 253 117 111 253 67 253 253
+        18 5 253 78 3 10 91 12 83 110 253 253 85 253 253 110 90 253
+        68 253 6 95 253 42 60 253 253 79 253 72 253 125 111 38 253
+        53 253 253 253 118 124 253 253 253 26 253 115 253 253 253 0
+        88 253 88 253 85 253 253 68 116 253 253 34 119 253 253 69
+        109 253 113 253 253 108 253 75 31 72 253 120 253 48 25 4
+        253 12 253 43 116 253 253 253 15 13 99 98 8 253 253 105 253
+        91 96 253 253 43 97 253 30 253 253 106 253 253 253 98 253
+        253 253 253 253 253 91 36 253 58 43 253 253 253 72 46 32
+        253 67 253 13 253 253 85 31 25 253 253 253 253 85 253 253
+        21 253 253 253 253 30 61 69 91 253 94 127 21 104 95 4 253
+        121 126 253 89 253 117 253 87 90 116 126 59 253 27 105 92
+        253 64 21 37 26 118 91 253 253 253 253 62 253 253 53 16 253
+        103 28 110 78 73 253 253 47 253 0 253 253 55 253 253 37 253
+        70 61 57 253 29 89 253 92 104 253 253 253 253 253 34 124
+        253 122 99 253 253 253 253 253 74 253 114 64 253 86 82 100
+        253 253 67 34 108 46 115 69 71 38 253 253 41 100 47 253 122
+        54 253 253 253 253 253 253 45 58 24 253 253 253 62 253 253
+        253 103 253 253 68 253 253 94 253 96 20 14 106 253 34 97 0
+        253 121 25 29 253 124 253 37 111 8 253 59 26 253 253 6 77
+        253 253 123 253 122 253 70 253 253 121 253 253 253 253 253
+        21 253 84 35 253 77 253 253 17 57 63 109 253 65 27 87 60 80
+        253 253 253 0 253 111 127 253 253 253 24 253 253 38 21 253
+        253 253 253 253 253 253 127 253 110 4 9 121 25 253 108 37
+        85 253 253 95 85 253 110 253 253 253 253 253 36 7 253 26
+        253 41 30 253 253 25 253 78 71 253 109 253 64 16 253 95 65
+        253 88 90 16 109 253 253 28 86 253 253 119 253 60 253 253
+        107 124 73 253 121 16 253 253 95 26 80 23 253 253 253 253
+        253 9 253 121 253 253 253 253 51 57 39 253 253 253 253 253
+        253 105 82 253 253 253 253 253 11 253 110 53 253 253 23 253
+        253 253 122 44 81 253 48 253 253 0 61 49 74 24 253 14 122
+        66 253 253 94 48 253 253 80 63 253 253 88 90 72 96 253 54
+        56 253 105 7 78 88 253 31 52 253 253 94 88 253 253 79 253
+        74 32 253 75 123 116 253 68 253 118 110 253 253 253 46 253
+        253 58 65 18 253 74 253 253 112 59 84 115 253 46 253 253
+        253 95 121 44 62 81 253 253 253 253 253 119 81 253 108 253
+        253 42 25 253 90 253 253 253 102 93 253 253 119 96 41 253
+        42 253 253 29 253 107 71 253 87 35 253 99 253 106 35 253 90
+        253 78 5 253 253 22 99 253 41 253 253 253 44 26 83 52 101
+        76 44 48 54 118 53 26 253 109 253 253 253 33 253 253 12 12
+        253 25 253 253 47 12 111 76 253 124 53 253 253 16 45 253
+        253 110 64 114 115 253 84 253 253 253 101 78 253 123 102
+        253 26 56 253 253 102 253 123 67 253 75 123 51 101 8 13 253
+        12 127 253 253 92 107 253 253 27 253 126 253 253 98 253 253
+        253 124 253 253 105 253 28 253 253 68 253 52 253 12 48 44
+        118 253 253 253 253 253 37 15 253 62 253 253 53 63 1 253 60
+        39 253 253 84 253 253 46 253 253 253 109 62 253 253 51 92
+        54 12 253 7 253 253 253 87 82 89 54 253 36 87 22 253 253 62
+        94 59 85 34 253 253 253 110 253 97 124 56 253 45 253 8 28
+        253 12 253 253 253 86 5 253 253 253 75 113 12 108 253 77
+        253 110 56 253 35 253 13 253 91 253 38 53 253 253 111 253
+        253 123 253 253 84 91 253 104 17 253 65 24 17 253 15 253
+        116 66 105 253 113 67 109 70 91 88 253 253 118 0 253 5 72
+        81 253 253 78 253 253 56 127 27 45 253 253 253 55 253 49
+        253 253 110 253 253 29 58 101 253 42 5 253 253 66 12 122
+        123 253 62 253 253 253 253 253 0 253 116 60 92 49 253 253
+        253 253 253 55 72 253 80 93 253 253 50 8 253 253 253 253
+        253 110 5 49 253 253 0 253 253 97 24 23 253 28 40 253 253
+        127 253 107 253 253 73 119 50 253 253 253 253 253 114 121
+        253 125 93 62 253 113 253 25 253 29 253 253 65 253 253 253
+        253 12 253 114 253 253 73 69 253 253 95 8 26 253 253 253 54
+        104 253 253 35 68 72 81 253 21 27 253 77 54 125 23 88 18
+        253 253 253 253 69 51 253 0 37 253 27 253 253 253 253 74
+        253 253 66 253 95 114 123 253 253 253 94 253 253 253 253
+        253 42 36 98 114 19 253 126 253 25 253 40 253 50 46 64 61
+        45 117 107 253 89 51 69 38 14 57 7 253 109 253 111 253 253
+        10 13 253 46 60 253 253 25 253 15 76 253 92 88 253 70 5 5
+        73 60 113 253 82 253 253 51 126 253 112 34 19 99 253 253
+        119 30 253 253 0 253 104 116 52 253 79 69 253 109 119 253
+        17 22 66 87 119 13 253 253 35 83 11 253 253 253 253 253 106
+        45 253 253 120 253 36 253 25 253 253 81 75 253 40 88 253
+        253 253 74 253 115 53 253 70 253 253 253 253 117 253 64 253
+        253 53 93 253 253 253 52 253 23 253 62 14 0 95 253 253 90
+        253 253 56 253 49 253 253 253 75 118 6 253 253 253 48 253
+        253 253 105 24 253 48 71 253 253 36 55 39 253 253 127 20 33
+        253 253 253 101 79 6 102 89 24 46 253 62 82 113 253 84 6 88
+        22 44 52 44 253 253 94 253 253 253 253 58 47 253 104 38 253
+        101 253 71 253 81 253 6 83 253 253 83 54 30 42 72 253 253
+        253 3 253 48 253 110 126 253 64 253 104 253 253 253 253 253
+        253 253 64 57 110 107 102 253 110 253 9 253 65 30 253 253
+        253 104 253 35 253 253 42 253 253 253 100 253 46 99 63 253
+        95 39 253 99 253 115 72 34 253 253 253 99 253 253 253 253
+        67 253 106 87 20 253 253 253 253 253 253 30 253 253 253 253
+        253 253 253 253 253 125 253 2 84 253 253 253 100 5 253 253
+        0 53 40 7 253 253 44 80 90 253 253 253 122 114 127 253 61
+        109 253 253 46 87 253 253 26 253 101 109 34 253 253 253 112
+        126 253 253 70 253 253 52 253 111 253 91 253 28 253 253 253
+        118 114 121 253 253 116 253 253 24 71 111 253 253 253 253
+        253 253 5 98 253 253 89 253 253 115 253 253 66 253 99 5 253
+        253 63 253 62 106 105 99 25 48 42 253 253 39 253 104 253
+        253 29 253 253 1 21 83 112 253 253 111 253 253 37 48 14 253
+        253 253 109 107 253 253 253 50 46 253 253 99 253 13 116 78
+        253 56 253 253 20 253 81 253 80 13 253 253 253 85 253 253
+        94 253 59 253 253 99 12 253 253 253 21 108 90 253 253 36 79
+        10 30 0 253 88 253 253 253 253 23 253 253 253 96 253 253
+        126 253 253 253 12 253 34 253 253 253 63 253 35 253 253 88
+        80 35 67 253 79 253 15 253 253 41 253 55 50 71 3 253 253
+        253 63 59 253 253 253 86 20 253 253 9 49 253 253 75 253 7
+        14 59 26 253 122 253 101 253 253 253 253 70 253 79 57 253
+        19 90 253 253 253 253 253 253 253 60 253 85 91 253 91 79
+        121 123 35 126 42 20 85 57 253 253 253 253 39 253 52 59 21
+        95 71 52 120 85 253 253 19 24 253 61 253 253 38 253 109 62
+        56 84 95 120 253 52 253 12 70 23 253 253 253 8 45 33 102 62
+        35 69 113 253 253 43 28 253 253 253 28 253 53 1 12 253 109
+        253 56 69 30 253 90 89 71 253 87 58 90 44 253 253 253 108
+        45 112 24 253 64 59 253 35 39 253 253 63 253 253 253 253
+        110 35 77 90 16 253 253 71 31 253 253 118 63 253 253 0 95
+        253 253 59 76 253 101 45 113 253 67 10 253 253 34 253 253
+        57 253 253 95 116 253 253 253 109 253 19 66 253 32 253 253
+        14 8 253 253 93 81 253 66 253 253 109 253 253 253 253 38
+        253 125 253 92 253 253 82 120 115 253 3 253 253 253 253 81
+        253 253 253 253 114 253 76 253 253 52 253 64 253 253 57 63
+        83 79 253 108 253 58 51 253 102 253 72 93 32 119 36 100 119
+        25 253 72 253 109 109 253 43 253 253 253 253 119 83 253 253
+        81 83 253 116 253 253 43 253 253 253 253 253 53 87 253 109
+        253 20 253 8 29 253 253 253 0 253 117 88 99 253 18 253 121
+        75 253 112 15 253 10 115 253 253 104 253 253 109 253 47 253
+        3 24 253 70 253 34 35 253 50 253 74 253 79 253 253 23 76 95
+        253 68 253 87 253 37 253 253 26 53 97 28 253 253 253 253 0
+        102 42 253 253 253 111 253 101 123 253 50 253 19 253 35 253
+        253 84 253 68 104 4 253 253 98 112 6 125 253 84 82 27 253
+        253 253 253 97 253 253 56 253 253 77 253 113 118 65 83 78
+        253 58 253 253 36 253 253 253 253 121 253 253 253 253 253
+        253 253 253 253 80 253 253 253 253 97 8 253 48 253 253 106
+        253 253 117 11 77 19 76 125 54 253 30 57 82 9 28 3 79 253 0
+        253 253 253 253 253 253 51 253 253 70 35 253 27 10 253 14
+        59 253 253 70 9 253 253 101 20 253 116 253 253 61 10 253 71
+        253 107 107 59 21 100 11 15 253 61 253 253 253 253 71 12 97
+        253 253 253 1 253 253 253 83 13 26 253 43 88 253 75 108 35
+        253 110 253 57 253 253 253 38 253 253 253 253 253 101 253
+        48 253 253 253 253 253 253 98 56 253 253 253 253 75 3 103
+        126 253 13 253 69 253 253 73 253 253 253 67 20 99 253 253
+        253 102 253 13 27 253 253 28 253 18 77 53 253 93 253 253 79
+        106 16 88 52 253 253 111 32 12 253 253 253 253 0 106 253
+        253 59 253 253 97 116 84 108 85 3 72 36 56 253 34 253 80 70
+        253 253 253 81 253 253 24 61 253 253 253 253 253 253 253
+        253 101 45 253 253 253 253 88 253 95 93 44 106 253 81 253
+        31 50 253 253 253 253 253 105 253 108 253 253 31 16 253 253
+        51 27 253 253 253 74 253 94 253 25 253 253 253 22 94 114 87
+        52 253 253 105 35 117 104 83 45 253 27 253 253 119 253 253
+        19 253 62 25 85 110 253 253 52 76 85 253 0 17 253 253 253
+        253 37 253 253 46 20 21 7 110 253 125 253 253 253 79 253 60
+        253 39 32 253 79 253 107 253 122 253 68 253 75 86 253 25 92
+        100 253 59 26 253 253 253 253 38 253 88 253 253 253 119 28
+        30 107 24 253 253 14 253 44 253 253 79 253 253 99 75 110 45
+        85 253 253 83 62 253 253 253 253 108 253 18 253 125 253 34
+        253 110 253 92 253 86 17 253 71 37 253 0 253 253 253 253
+        253 82 48 253 253 124 253 253 37 253 253 92 253 253 253 105
+        253 253 253 19 33 253 127 109 63 253 253 253 253 253 253
+        253 253 253 253 253 85 10 78 40 253 15 8 59 113 253 120 253
+        96 253 253 50 29 253 26 253 253 68 19 72 253 62 253 11 253
+        253 253 253 15 253 253 253 21 253 84 253 0 50 253 55 24 107
+        119 24 253 97 14 253 36 102 253 32 253 253 253 116 253 253
+        253 87 83 253 253 253 81 107 253 253 53 253 18 7 35 253 253
+        253 44 253 37 105 17 119 28 253 253 82 28 253 253 82 253 18
+        49 253 69 79 253 253 75 121 32 92 253 73 28 253 253 68 69
+        253 65 253 106 253 253 253 36 49 253 38 61 87 253 253 253
+        253 253 94 68 253 95 253 66 253 253 253 253 253 253 97 253
+        72 253 106 109 6 103 93 253 253 253 253 253 58 110 253 253
+        2 36 4 1 253 253 253 253 15 253 44 108 253 253 124 25 253
+        127 253 253 71 253 82 107 123 49 34 253 113 253 253 71 253
+        253 65 253 88 87 42 6 22 110 1 253 253 253 92 121 84 253
+        253 253 5 253 253 253 88 253 84 19 253 93 253 65 111 103
+        253 84 253 104 253 253 65 253 253 82 253 42 66 253 41 31
+        253 253 17 253 253 44 28 253 92 253 109 253 253 113 110 253
+        74 253 253 30 253 84 253 253 127 253 253 253 253 3 253 4
+        253 253 253 253 108 253 253 14 114 49 253 95 253 253 127
+        253 72 253 253 53 41 87 12 253 253 253 39 253 83 253 253
+        253 253 253 253 26 253 253 253 11 253 253 16 82 114 78 78
+        106 95 253 253 17 253 253 69 253 253 253 31 253 84 253 106
+        253 253 253 27 98 253 253 102 10 87 29 253 106 99 253 253
+        50 71 253 253 253 253 253 73 253 253 31 90 253 253 100 73
+        45 23 31 79 253 253 253 104 84 253 253 253 120 253 253 71
+        253 83 253 66 55 75 114 253 253 253 43 253 0 25 253 21 16
+        253 253 18 107 104 253 110 11 55 0 15 253 123 84 253 253
+        120 253 253 253 253 253 253 253 8 25 253 118 65 253 60 253
+        253 119 253 253 253 49 253 36 253 253 253 92 253 253 253
+        253 44 85 253 253 253 94 42 253 253 253 90 253 105 253 56
+        253 253 253 253 253 253 253 117 253 253 9 253 123 253 253
+        105 34 104 253 253 253 253 253 127 253 84 31 89 91 253 253
+        253 99 253 30 82 55 40 29 253 253 253 253 23 253 41 112 253
+        253 253 253 103 253 102 123 253 95 57 253 33 24 3 253 42 61
+        253 120 51 36 69 109 119 3 47 253 61 78 15 21 33 253 253
+        253 253 253 9 70 84 15 54 125 253 116 253 253 24 93 253 253
+        253 6 6 59 26 253 17 253 72 253 253 253 98 108 27 117 4 253
+        253 92 253 111 253 65 253 64 98 75 43 87 17 253 253 44 56
+        253 253 253 3 107 110 99 99 52 253 50 253 56 99 253 253 123
+        253 253 77 38 253 37 101 253 31 253 253 70 43 253 110 82 10
+        253 253 253 253 53 253 71 253 87 253 28 253 88 121 125 43
+        253 253 26 253 50 253 22 253 111 253 16 253 42 253 253 253
+        9 253 253 253 253 126 10 253 13 109 253 115 253 31 253 253
+        42 253 253 253 253 11 77 253 25 36 73 90 110 253 15 57 253
+        253 253 25 253 84 55 253 253 97 21 253 74 253 253 15 54 253
+        121 53 5 253 9 86 253 105 118 253 253 119 253 33 253 84 253
+        253 21 253 253 253 253 35 253 253 0 49 253 56 253 253 253
+        110 253 253 253 253 253 253 253 253 90 253 99 253 9 14 253
+        90 57 49 253 253 111 253 87 253 253 79 4 253 52 253 43 253
+        253 253 253 124 12 253 122 253 253 6 253 253 110 1 253 103
+        63 253 253 81 253 94 253 253 25 253 40 87 70 253 127 81 253
+        253 103 45 29 253 28 253 48 253 15 253 27 253 253 18 27 119
+        253 2 63 76 85 253 253 89 253 73 26 42 253 253 28 253 85
+        253 253 29 42 75 253 253 253 253 24 253 253 253 0 15 30 253
+        113 253 253 55 16 253 253 253 253 60 253 123 85 99 253 114
+        253 253 253 1 29 253 9 253 253 87 9 253 253 253 253 253 54
+        73 253 76 253 253 253 121 119 112 64 253 42 68 34 23 10 4
+        109 253 253 76 253 253 54 110 253 87 253 43 32 253 253 7
+        253 253 62 104 253 107 26 118 99 253 253 253 253 14 121 253
+        86 125 99 253 253 253 5 105 110 23 96 62 102 65 87 101 253
+        253 101 30 59 253 121 253 253 51 70 50 13 67 253 253 46 253
+        253 253 253 253 53 253 253 74 7 6 253 253 253 68 117 253 48
+        8 253 72 253 50 38 253 33 116 108 253 253 19 253 253 62 59
+        253 113 87 71 94 253 47 38 253 253 253 253 43 97 86 253 253
+        253 253 34 253 253 48 85 253 253 253 43 2 74 253 253 253
+        103 253 253 101 39 253 25 53 253 253 253 253 253 253 115 85
+        64 52 253 22 80 253 24 56 253 253 78 253 8 0 119 253 23 253
+        253 27 113 253 75 253 10 253 253 2 253 105 253 253 24 105
+        58 110 10 253 74 18 253 0 63 253 110 253 253 253 253 253
+        253 253 99 11 253 72 253 117 31 253 85 253 61 253 78 15 253
+        253 253 253 253 90 253 116 253 76 50 253 253 253 253 21 253
+        8 253 109 253 18 57 24 253 253 124 253 253 109 253 253 253
+        22 253 20 253 253 253 118 253 253 29 253 253 35 253 62 253
+        253 63 253 253 85 109 253 253 253 253 125 253 253 253 87
+        253 98 253 117 42 253 113 253 90 253 253 253 253 77 253 110
+        253 109 253 14 253 253 95 13 253 45 253 81 90 100 44 23 253
+        253 253 127 253 253 253 91 253 68 45 106 253 253 253 24 253
+        253 253 253 253 253 253 93 253 253 253 253 253 253 122 65
+        253 25 253 95 253 253 16 51 253 79 27 105 253 253 253 253
+        121 253 39 60 39 253 105 253 253 13 253 8 84 102 112 4 112
+        253 253 253 52 108 80 71 23 253 253 253 253 253 253 253 32
+        81 253 82 62 253 253 253 80 253 114 126 253 253 253 38 253
+        59 17 121 1 113 253 118 253 253 253 253 107 253 253 36 105
+        253 253 253 253 94 57 82 119 47 253 253 253 253 253 253 6
+        72 31 253 35 253 253 106 253 253 253 5 253 124 86 101 12
+        253 253 253 24 57 253 253 20 253 96 253 62 69 19 13 253 253
+        253 71 253 120 253 102 52 253 253 105 253 253 61 253 253
+        253 253 18 253 50 12 125 90 253 253 19 103 253 120 18 253
+        96 253 0 125 104 103 253 253 101 253 106 253 27 79 111 74
+        253 105 253 119 57 114 90 45 126 253 253 86 253 102 55 40 8
+        253 253 78 253 31 60 86 95 253 107 253 253 253 111 47 36
+        253 253 253 27 253 253 253 253 41 253 253 81 253 112 123
+        253 253 253 253 253 253 253 253 253 253 253 253 56 99 253
+        43 253 30 95 253 253 253 253 253 67 62 253 253 0 22 88 89
+        78 253 89 253 24 85 62 253 68 253 253 20 253 253 120 253 15
+        39 253 253 253 253 253 253 21 100 253 93 81 253 253 253 253
+        121 253 253 27 253 9 24 97 75 253 109 253 123 253 253 118
+        253 72 253 21 59 6 6 11 55 106 253 82 253 57 41 69 21 69
+        253 107 60 253 93 253 253 253 253 75 55 4 26 2 253 55 93
+        253 253 253 91 253 253 253 120 75 253 253 29 253 253 75 118
+        30 253 100 81 28 253 253 253 70 72 253 253 253 0 76 253 124
+        23 81 107 2 253 70 253 7 253 253 253 253 253 253 253 73 100
+        253 253 253 253 35 12 21 253 253 9 253 51 253 105 253 253
+        53 253 47 106 253 55 253 81 38 253 29 253 253 92 253 253
+        253 253 93 2 253 253 253 55 27 253 253 97 253 253 15 253 0
+        253 15 107 253 253 127 107 93 71 0 253 253 253 97 253 253
+        253 113 30 18 114 86 36 253 253 253 253 253 253 253 20 15
+        253 253 27 253 253 253 95 61 33 125 253 253 99 253 94 2 253
+        115 73 32 253 253 253 84 253 253 253 253 253 253 253 253
+        253 253 253 4 253 0 253 253 82 24 253 253 56 253 36 253 253
+        113 253 253 37 253 31 253 36 253 253 26 253 253 53 253 253
+        37 253 47 13 253 65 72 33 253 61 253 253 253 89 253 253 76
+        97 253 43 49 253 10 253 127 253 253 61 253 48 253 93 253
+        124 253 17 253 253 253 253 253 253 253 4 253 253 41 253 39
+        253 253 87 62 73 253 253 98 253 253 77 70 253 105 110 253
+        253 253 50 89 41 253 0 253 31 106 9 108 115 118 253 36 98
+        88 253 253 95 253 13 31 102 253 253 253 253 35 60 253 253
+        253 83 253 253 253 253 253 253 253 253 108 253 253 0 253
+        253 53 72 253 121 20 116 253 19 253 253 253 253 12 107 17
+        119 253 253 253 253 253 0 10 253 253 253 253 253 40 253 253
+        253 81 253 253 253 253 253 253 253 18 40 253 82 0 5 253 253
+        253 22 253 118 253 113 253 59 26 253 253 93 108 253 253 92
+        253 253 53 253 127 253 253 78 87 253 30 253 253 253 253 25
+        253 48 24 118 49 253 113 76 253 89 99 56 253 67 253 20 120
+        253 253 125 13 55 16 8 111 253 76 253 253 37 39 25 253 14
+        253 1 253 117 1 253 101 253 74 96 55 253 88 23 253 19 70
+        253 253 253 253 253 62 253 21 253 72 253 54 253 70 253 84
+        253 253 253 63 253 253 18 253 119 253 253 253 107 253 253
+        101 112 48 74 253 253 253 253 55 253 21 253 101 109 253 118
+        253 49 87 253 253 11 59 89 253 253 253 253 253 86 11 253 86
+        253 253 7 253 41 253 253 253 13 253 119 119 20 253 31 26 4
+        253 53 253 253 114 56 253 35 253 253 99 16 93 253 253 253
+        10 253 253 253 51 11 253 253 253 253 253 253 253 253 253
+        253 97 117 253 31 253 45 253 253 253 87 253 253 82 14 253
+        253 253 65 253 103 253 40 13 74 48 116 253 253 28 253 0 70
+        122 48 73 253 67 52 22 253 253 88 93 253 60 253 56 20 89
+        253 253 253 33 253 253 253 253 253 253 25 98 253 253 55 122
+        253 90 253 99 38 253 253 63 253 253 253 253 10 48 53 33 253
+        253 36 17 76 55 59 253 28 253 86 253 253 253 82 71 253 85
+        253 86 253 253 253 253 253 253 253 73 66 253 253 28 253 253
+        253 57 253 253 253 83 71 253 72 253 97 253 39 106 253 58
+        253 67 121 30 253 68 253 253 34 103 253 57 60 49 253 84 253
+        253 253 59 114 253 42 253 28 253 2 7 97 80 110 253 253 5
+        253 253 18 27 253 57 60 113 253 126 253 55 253 253 253 66
+        38 253 253 253 253 120 57 63 253 89 253 253 57 253 253 35
+        72 23 119 0 253 253 253 35 81 253 253 253 13 8 118 33 253
+        253 253 253 101 253 32 253 253 6 62 50 253 119 99 253 253
+        74 122 253 253 110 253 253 253 11 253 29 253 253 72 253 114
+        71 21 253 48 253 10 253 253 83 253 253 65 253 45 20 253 88
+        253 52 253 91 27 253 104 80 253 18 119 122 253 253 253 11
+        253 123 253 110 31 78 253 93 253 67 253 123 87 79 107 253
+        53 253 253 253 43 75 17 253 253 253 125 253 253 253 253 253
+        73 114 100 84 96 253 253 13 253 126 253 25 70 253 253 253
+        253 253 35 253 116 253 253 253 16 52 253 42 253 253 253 253
+        253 253 253 54 253 253 105 90 253 253 61 253 253 11 28 253
+        83 253 253 253 83 253 253 253 253 253 253 253 100 253 253
+        253 67 96 114 61 253 253 253 52 253 117 253 17 90 56 253
+        253 12 253 35 56 21 60 77 73 253 83 253 253 253 72 253 253
+        45 112 253 253 26 86 59 20 253 4 253 22 253 52 253 98 253
+        253 253 253 253 62 57 253 18 54 253 253 3 253 253 83 78 253
+        253 112 99 253 253 253 45 13 253 32 253 116 125 253 253 121
+        253 104 253 253 101 253 253 0 253 253 253 5 116 62 253 120
+        253 82 123 39 58 253 88 253 117 253 253 253 253 75 124 86
+        253 24 253 253 70 253 253 7 253 53 60 253 253 43 117 253
+        253 75 253 253 253 253 18 89 253 253 44 253 253 253 253 21
+        253 10 123 253 51 253 253 115 253 107 253 36 253 253 253
+        253 253 253 253 253 82 109 7 253 31 89 104 253 71 109 109
+        253 94 4 253 253 253 253 50 8 253 54 253 253 17 253 253 253
+        88 87 253 253 31 253 253 253 126 253 253 43 13 48 94 88 61
+        253 70 63 26 253 88 253 33 125 253 253 51 253 253 106 29
+        253 253 103 253 58 253 253 253 253 253 253 83 35 32 88 253
+        253 32 47 114 126 253 19 253 253 253 253 117 253 33 253 81
+        253 253 253 253 253 12 80 120 253 110 253 253 253 71 253
+        253 66 44 55 19 90 71 253 75 253 253 25 253 115 90 253 73
+        46 253 253 253 53 67 253 78 253 95 20 253 77 253 50 121 253
+        104 253 253 75 253 253 34 253 253 253 253 3 16 253 3 253 47
+        67 253 253 253 64 253 253 253 71 35 253 253 14 253 253 106
+        253 62 27 253 16 253 253 61 253 105 48 253 18 253 96 22 95
+        253 253 253 253 4 253 253 253 7 253 29 47 125 30 253 53 253
+        253 253 253 253 253 253 30 64 253 253 253 253 103 28 123
+        100 253 253 253 120 84 110 253 253 83 126 253 253 253 253
+        253 37 253 253 116 44 56 85 36 55 24 253 253 253 253 83 123
+        118 94 66 67 19 253 106 253 116 253 253 73 18 94 253 253
+        253 83 95 253 76 253 76 46 112 253 31 253 87 31 73 116 253
+        253 253 49 253 253 14 1 253 253 111 253 23 11 20 34 8 35
+        253 253 56 253 3 21 104 90 90 27 93 253 36 126 35 253 253
+        253 79 31 74 253 253 7 86 253 60 253 97 118 253 253 77 253
+        118 253 253 253 91 90 53 253 28 125 253 21 253 60 50 253
+        253 253 253 119 253 253 42 53 58 253 253 51 42 253 253 65
+        253 23 94 12 69 100 253 35 253 123 253 60 253 253 253 20 27
+        253 71 253 253 62 253 90 1 35 253 115 43 40 113 32 253 55
+        124 84 47 253 100 253 49 253 253 253 253 65 253 124 91 253
+        253 85 253 98 253 253 253 103 42 253 121 253 253 253 253
+        253 253 253 253 253 253 253 90 125 253 91 107 253 105 7 253
+        253 253 53 253 68 253 253 47 107 253 95 253 253 49 253 253
+        48 28 73 25 253 253 253 253 87 253 0 253 253 253 51 100 253
+        110 253 87 94 106 67 88 253 55 253 253 253 31 92 113 253 14
+        73 253 85 87 253 82 4 253 253 124 253 253 253 253 253 68 52
+        89 253 73 52 2 253 253 121 253 109 253 50 253 253 253 88 17
+        102 253 253 253 35 253 75 253 27 110 253 76 253 20 96 253
+        253 253 253 85 253 253 14 54 253 253 26 253 253 61 41 102
+        253 41 253 21 253 253 253 39 253 50 253 48 253 253 253 253
+        253 63 5 63 253 253 253 253 17 253 102 122 48 63 253 253
+        253 253 253 43 126 71 253 253 90 253 72 79 253 253 253 253
+        253 36 253 18 45 253 75 17 81 101 253 253 253 253 253 61 77
+        15 111 122 253 87 65 253 118 253 253 30 253 253 253 253 253
+        253 57 253 90 253 253 121 34 110 71 40 7 56 28 253 253 253
+        40 253 47 99 253 126 4 117 253 253 253 253 253 63 253 44
+        253 120 24 253 253 78 253 65 81 253 253 253 118 253 115 28
+        0 107 253 253 28 89 253 253 253 77 54 89 34 32 253 105 56
+        39 253 253 253 253 253 253 253 84 87 102 17 76 253 48 6 9
+        253 253 253 14 60 65 253 51 253 45 102 103 1 100 253 253
+        121 5 78 69 99 253 253 54 253 253 253 253 253 253 253 77 11
+        253 253 39 17 71 112 253 23 28 253 35 253 253 62 253 53 253
+        253 253 253 45 33 253 253 253 0 44 253 98 253 253 19 36 117
+        72 253 253 253 42 72 253 38 120 62 253 112 27 80 5 35 111
+        253 253 118 19 120 253 1 96 253 253 1 253 253 44 253 80 110
+        253 253 253 105 253 64 253 30 253 21 253 25 100 25 82 48 69
+        84 253 0 18 122 82 19 35 253 101 32 253 100 10 253 3 46 56
+        96 104 109 66 253 27 253 253 253 253 253 253 253 40 253 27
+        28 253 253 253 91 253 253 253 91 253 43 63 253 20 71 60 253
+        253 0 74 125 253 93 69 117 98 88 93 253 22 253 92 4 253 253
+        253 91 253 253 76 108 253 72 253 80 51 253 253 106 253 253
+        253 41 68 253 111 29 253 8 253 253 253 253 113 253 124 37
+        103 124 36 253 42 253 44 121 46 108 53 253 253 253 69 253
+        108 253 65 253 253 253 119 253 253 23 253 253 104 37 253
+        253 10 63 253 253 253 253 253 37 253 253 58 253 112 253 253
+        64 253 48 79 253 89 90 93 253 253 253 253 89 253 103 253
+        253 253 123 15 113 253 253 71 43 253 103 52 253 46 52 253
+        27 93 253 99 116 253 253 44 86 253 253 69 253 44 253 253
+        253 84 30 253 64 107 107 253 253 253 56 31 46 7 253 118 253
+        253 253 90 253 253 93 253 54 253 118 57 42 57 253 253 253
+        106 125 33 253 253 120 100 88 86 104 253 96 101 107 253 50
+        253 37 105 28 253 253 253 116 14 253 253 253 253 253 55 51
+        49 253 253 253 253 253 125 55 253 253 54 253 45 253 253 72
+        253 253 70 55 15 122 253 52 46 253 253 253 253 55 253 253
+        20 253 253 99 253 83 253 90 104 253 84 253 97 253 86 49 253
+        36 96 253 53 253 253 253 37 253 253 253 110 253 253 116 79
+        10 253 121 20 253 253 253 4 124 253 107 253 253 253 253 253
+        54 253 105 24 72 253 55 253 253 253 253 53 253 253 253 253
+        109 253 36 253 112 30 68 114 253 253 114 77 87 253 73 121
+        253 91 253 253 87 46 253 121 71 253 253 73 101 116 253 253
+        253 253 51 45 96 106 26 253 253 253 122 253 99 253 45 253 5
+        54 253 30 253 253 253 253 253 253 253 3 20 253 253 253 253
+        253 30 40 253 253 253 253 70 25 253 26 253 253 111 253 99
+        253 253 60 253 70 37 3 253 92 80 79 108 76 253 56 253 25
+        116 63 79 253 253 253 253 253 79 253 125 79 253 74 23 253
+        25 253 28 115 88 253 253 12 33 19 253 119 253 253 58 38 55
+        56 31 90 253 253 253 105 253 99 58 253 46 253 96 253 118
+        253 253 253 52 67 253 102 253 48 253 253 51 69 253 44 126
+        25 60 253 253 14 253 253 253 96 84 253 253 253 5 253 32 253
+        69 103 253 40 114 26 253 15 253 253 81 253 253 253 253 80
+        83 95 73 253 253 33 56 253 0 91 253 253 253 29 68 108 99 48
+        253 9 253 0 124 253 24 63 110 106 11 253 117 110 253 53 253
+        253 253 253 253 253 253 112 114 253 253 88 253 44 46 253
+        253 33 253 79 253 253 73 85 84 16 253 253 253 87 37 124 96
+        253 11 91 253 78 75 11 75 253 21 253 19 253 70 56 253 39 86
+        253 53 253 70 57 32 253 253 82 253 14 28 13 253 87 253 253
+        253 69 253 58 29 253 253 253 42 67 113 123 118 92 253 253 0
+        99 253 107 112 79 253 106 253 45 253 37 253 105 14 112 123
+        31 122 33 253 253 253 60 55 108 125 40 253 99 104 81 97 112
+        253 253 253 253 65 22 96 73 253 253 74 253 253 27 60 53 9
+        253 43 43 104 253 112 57 253 21 253 33 253 253 253 98 253
+        253 13 32 12 253 65 7 253 74 253 253 253 57 253 111 83 253
+        253 73 38 127 24 71 253 60 69 253 25 253 253 49 253 120 253
+        253 103 117 253 253 253 253 113 253 253 253 253 253 31 106
+        22 253 40 253 253 253 253 253 62 105 253 25 253 30 109 42
+        253 113 253 253 253 253 253 57 253 44 44 48 59 119 253 52
+        103 85 253 44 253 253 76 8 127 93 253 85 253 253 253 253 42
+        71 74 116 70 253 2 253 94 14 113 253 97 253 253 87 65 253
+        36 253 253 253 40 253 8 253 47 113 253 253 253 109 253 107
+        253 37 60 253 253 253 83 253 253 253 253 39 87 0 110 35 253
+        253 253 253 253 102 253 253 253 253 253 58 103 253 253 35
+        48 52 114 32 24 253 253 253 253 91 107 253 253 253 5 253 4
+        24 253 56 253 253 77 253 253 89 68 253 55 253 83 253 76 14
+        126 253 52 253 253 55 253 253 76 253 253 126 87 3 253 90 82
+        85 70 74 253 44 116 24 253 253 78 119 103 253 253 48 71 253
+        253 92 104 253 253 253 17 76 111 253 253 253 253 109 38 72
+        100 253 6 253 253 253 118 253 123 253 253 253 11 109 9 28
+        253 253 253 32 100 84 69 110 253 253 253 253 66 253 111 253
+        253 253 47 253 78 114 5 72 45 253 86 253 253 253 114 40 93
+        253 253 57 253 41 93 253 81 253 127 253 15 253 38 120 34
+        253 253 106 64 58 253 28 121 80 57 111 115 72 60 23 253 253
+        29 74 89 38 86 253 45 253 253 253 253 253 253 253 121 8 5
+        253 64 9 253 72 253 253 55 48 253 4 253 253 253 49 30 104
+        253 111 253 253 253 253 253 19 253 253 253 124 39 95 253
+        253 78 76 87 75 253 253 253 113 121 98 20 253 253 57 35 253
+        253 253 93 11 13 253 253 253 54 84 253 253 80 7 38 253 58
+        35 53 253 253 93 253 104 253 253 73 253 1 253 108 253 253
+        253 253 253 253 69 41 253 253 5 253 253 37 253 253 253 253
+        17 59 84 14 253 253 81 253 253 109 67 78 253 253 11 34 253
+        253 253 253 253 253 101 253 253 49 253 253 253 73 253 104
+        253 253 105 253 253 253 253 113 72 253 253 253 253 103 253
+        253 253 253 46 253 253 56 253 78 253 253 253 253 253 101
+        107 253 23 37 89 253 253 70 77 253 78 15 53 53 253 253 108
+        253 253 253 107 120 253 42 253 253 65 65 253 253 104 253 54
+        107 253 253 88 253 36 82 253 253 125 253 111 253 53 101 253
+        127 253 40 122 253 253 253 86 41 3 253 253 15 106 253 125
+        123 253 253 253 253 109 253 54 3 253 253 253 74 253 253 253
+        53 75 253 109 97 70 253 253 253 253 253 105 90 109 253 111
+        253 253 9 253 253 253 41 253 253 105 253 78 253 21 78 253
+        253 55 253 72 253 33 98 31 253 253 253 15 253 75 116 79 253
+        114 8 253 111 35 253 123 118 253 119 31 90 253 52 253 54 27
+        24 253 253 125 253 253 253 113 84 73 62 253 253 253 18 122
+        100 95 253 253 102 29 46 97 253 64 253 23 253 253 253 253
+        253 83 253 28 108 25 253 31 111 122 253 43 108 253 71 253
+        253 253 80 109 253 109 77 253 253 17 30 121 25 253 77 72
+        253 83 126 253 253 23 107 26 253 60 253 253 40 24 111 253
+        253 111 14 8 253 253 78 75 103 253 253 87 50 5 253 253 2 59
+        253 79 21 253 11 103 110 253 18 6 62 253 253 105 28 253 10
+        253 85 123 38 253 45 253 88 253 81 253 67 32 30 253 253 253
+        253 253 80 253 114 253 22 10 253 108 30 62 253 253 79 46 46
+        86 123 98 100 102 253 7 30 94 253 253 26 28 69 253 52 56 95
+        109 253 109 253 108 51 253 253 23 253 104 253 253 25 13 31
+        253 253 253 253 253 27 253 6 56 84 253 253 46 120 12 253 2
+        253 115 20 110 253 110 19 253 253 110 21 62 253 253 253 253
+        52 101 253 43 64 253 253 253 253 104 69 127 74 253 80 253
+        253 253 253 253 51 253 253 14 15 253 106 253 253 253 39 75
+        253 253 253 253 253 21 253 112 126 84 98 23 253 253 39 87
+        253 253 253 49 71 82 114 25 71 106 253 122 253 37 253 40 50
+        77 55 253 64 0 15 253 86 253 53 20 87 81 74 253 253 253 35
+        67 39 101 253 36 99 253 104 9 50 253 54 253 253 35 253 13
+        19 253 45 36 96 65 27 253 253 57 253 253 253 253 253 253 20
+        4 73 253 103 24 253 20 253 122 116 122 47 253 253 253 9 253
+        253 72 253 253 253 32 3 253 122 253 63 53 253 253 253 253
+        34 253 253 60 253 253 61 253 253 253 253 12 102 253 69 26
+        253 253 253 253 253 253 253 92 5 253 253 253 70 253 105 11
+        47 253 253 253 80 87 253 0 253 253 63 253 253 253 86 253
+        253 253 3 253 253 253 99 253 41 253 253 0 253 122 253 17 92
+        253 118 127 253 253 253 1 253 30 18 86 253 51 253 253 253
+        87 253 253 13 50 12 253 64 27 31 253 76 253 253 253 253 253
+        253 120 123 80 41 253 115 253 106 40 253 98 43 123 253 111
+        55 253 253 113 253 253 86 7 70 253 76 253 253 31 253 68 253
+        253 253 253 253 96 62 253 253 253 253 90 28 253 253 99 253
+        253 253 59 253 0 253 15 253 253 83 110 253 253 9 102 253 45
+        253 253 102 253 39 28 253 253 253 98 41 253 253 39 68 253 0
+        253 253 253 253 58 253 253 73 253 253 253 253 73 253 1 30
+        253 97 104 253 253 253 253 253 103 118 253 253 71 253 25
+        253 253 253 63 70 253 253 62 253 253 253 21 253 118 253 70
+        253 253 27 99 71 253 253 253 65 53 34 253 253 77 74 253 47
+        253 114 58 253 68 253 253 31 99 89 253 11 253 253 253 253
+        99 253 30 56 253 54 253 74 253 102 50 61 253 253 253 253
+        120 56 63 32 61 253 78 23 253 53 94 105 26 253 253 253 34
+        65 253 88 253 66 253 253 253 253 253 63 92 122 84 253 253
+        253 75 253 253 68 253 34 253 79 253 1 253 253 74 70 19 118
+        253 11 253 67 44 253 253 18 6 253 253 253 75 253 90 253 71
+        102 253 253 124 253 253 64 253 253 253 253 97 253 253 50
+        253 253 82 7 96 253 253 91 106 39 253 253 253 253 253 253
+        253 253 253 71 253 35 84 253 21 253 253 253 49 34 253 13
+        253 24 253 103 45 29 253 253 82 84 253 253 56 81 69 253 110
+        49 40 48 52 89 28 253 19 253 21 253 253 253 73 253 104 253
+        253 125 8 28 253 253 108 77 38 107 71 120 253 109 66 69 16
+        38 82 253 253 28 253 80 86 73 58 66 99 117 124 253 57 70
+        253 0 253 100 253 60 78 89 81 253 49 253 8 114 63 253 253
+        116 48 99 44 253 63 45 253 123 253 253 253 253 120 253 253
+        97 102 63 253 69 97 52 253 253 253 68 253 253 57 253 109
+        253 0 106 85 253 92 92 253 21 69 112 253 253 32 253 22 253
+        24 41 50 63 253 253 253 253 253 87 118 253 253 73 27 253
+        253 101 126 253 253 122 253 93 117 30 253 38 253 253 94 253
+        253 253 19 253 109 30 48 78 61 8 253 253 253 253 253 92 25
+        97 105 87 253 253 253 253 85 253 17 253 3 72 253 125 66 13
+        98 253 253 253 253 71 112 23 37 99 32 78 61 73 24 253 79 39
+        25 253 120 253 253 253 253 1 253 55 105 253 17 253 253 253
+        253 253 50 253 52 253 253 7 253 23 253 0 253 253 253 253 66
+        253 253 52 253 253 253 253 253 28 253 253 104 115 253 97
+        103 13 253 253 96 253 28 40 253 253 253 253 253 63 253 52
+        253 46 47 253 253 48 50 253 253 253 253 253 71 81 68 114 91
+        118 253 97 253 253 253 85 49 253 102 253 253 67 253 110 96
+        88 253 77 109 119 50 253 253 24 253 45 253 71 109 24 101
+        102 64 253 57 11 253 253 73 253 73 79 253 253 37 253 253
+        253 253 40 14 253 253 115 253 7 253 7 113 54 253 48 253 253
+        85 126 253 253 71 11 42 110 109 253 253 0 253 108 127 253
+        105 72 101 253 253 253 253 88 253 253 2 54 15 253 83 59 253
+        85 5 105 253 55 253 93 253 253 118 52 46 253 34 67 3 253
+        253 93 253 101 3 36 83 68 253 84 92 253 100 125 253 38 253
+        36 253 4 253 253 108 253 30 253 253 253 94 253 253 12 253
+        253 90 253 253 99 86 111 12 54 91 105 253 21 39 253 85 253
+        253 98 82 253 253 6 60 79 253 82 253 46 253 253 253 104 12
+        1 253 78 253 114 104 253 253 253 253 253 57 60 253 6 101
+        253 253 253 253 81 253 62 94 77 44 253 253 83 42 23 253 253
+        253 253 21 29 253 253 34 253 253 253 253 69 1 3 45 52 253
+        103 31 65 253 0 106 47 91 253 45 44 81 253 95 21 253 29 253
+        26 33 44 253 253 21 16 253 126 253 253 8 253 109 13 253 253
+        253 253 253 99 113 253 253 253 41 1 253 62 253 253 104 253
+        69 36 253 49 42 23 253 52 253 253 99 253 61 253 253 253 53
+        253 37 34 253 253 253 253 253 253 60 253 253 76 125 9 253
+        86 14 253 253 114 73 40 253 253 54 109 253 45 253 72 253
+        253 253 253 117 47 253 253 253 253 93 78 253 76 35 253 253
+        253 253 253 253 79 21 253 253 253 253 58 253 253 253 39 253
+        64 253 43 3 253 34 253 253 253 16 253 70 253 253 253 253 69
+        75 117 253 253 253 253 253 253 37 253 253 15 253 253 112
+        253 61 253 71 36 253 44 93 253 85 69 253 253 85 253 3 253
+        253 253 253 96 253 253 253 253 253 63 74 253 29 253 53 253
+        102 73 6 253 253 253 253 253 0 253 106 85 253 253 99 253 79
+        45 253 38 30 253 253 253 253 253 120 253 253 64 8 253 15
+        253 1 253 70 11 124 253 253 253 35 20 253 9 35 116 37 90
+        253 5 253 29 253 65 253 18 253 0 67 253 253 0 116 253 90 41
+        16 1 253 253 253 253 106 24 253 61 253 110 27 253 54 253 61
+        253 78 253 253 110 34 253 47 253 55 253 253 253 253 253 253
+        253 85 253 253 73 118 116 253 253 109 63 253 253 83 53 253
+        253 126 253 253 253 80 80 253 253 253 15 253 122 95 253 253
+        253 122 253 88 253 253 253 253 95 253 253 253 107 86 253
+        253 253 253 253 87 253 31 253 253 77 253 121 253 0 253 253
+        49 127 90 95 253 253 122 253 74 253 253 99 253 253 104 22
+        253 253 125 253 253 253 253 69 126 253 253 253 253 253 79
+        253 253 94 253 80 8 60 253 253 95 253 100 253 253 74 253
+        122 253 253 62 46 253 26 253 253 253 79 253 253 94 253 47
+        30 253 253 126 253 81 253 253 253 253 253 253 100 253 253
+        63 45 125 253 253 253 253 0 109 122 253 80 253 253 51 91
+        253 253 253 253 253 94 253 85 95 253 253 253 253 253 126
+        253 111 253 63 253 94 253 83 46 253 253 253 253 253 253 91
+        117 15 253 253 253 122 253 253 58 253 253 253 111 253 253
+        253 127 253 39 253 85 253 253 17 88 116 253 253 253 253 253
+        253 253 253 87 253 253 16 77 109 253 105 105 76 253 253 253
+        253 94 253 253 253 87 253 0 50 253 0 253 88 71 253 10 253
+        122 253 64 253 253 253 253 253 253 85 253 0 106 253 94 253
+        125 253 35 47 253 58 105 99 253 68 253 0 253 253 87 253 253
+        253 63 253 253 13 10 45 45 45 45 45 45 87 101 98 75 105 116
+        70 111 114 109 66 111 117 110 100 97 114 121 115 105 103
+        113 43 53 113 87 116 54 79 114 122 56 76 79 45 45 13 10
+    } >string ;
+
diff --git a/basis/mime/multipart/multipart.factor b/basis/mime/multipart/multipart.factor
new file mode 100644 (file)
index 0000000..4c7b956
--- /dev/null
@@ -0,0 +1,63 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators io kernel locals math multiline
+sequences splitting prettyprint ;
+IN: mime.multipart
+
+TUPLE: multipart-stream stream n leftover separator ;
+
+: <multipart-stream> ( stream separator -- multipart-stream )
+    multipart-stream new
+        swap >>separator
+        swap >>stream
+        16 2^ >>n ;
+
+<PRIVATE
+
+: ?append ( seq1 seq2 -- newseq/seq2 )
+    over [ append ] [ nip ] if ;
+
+: ?cut* ( seq n -- before after )
+    over length over <= [ drop f swap ] [ cut* ] if ;
+    
+: read-n ( stream -- bytes end-stream? )
+    [ f ] change-leftover
+    [ n>> ] [ stream>> ] bi stream-read [ ?append ] keep not ;
+
+: multipart-split ( bytes separator -- before after seq=? )
+    2dup sequence= [ 2drop f f t ] [ split1 f ] if ;
+
+:: multipart-step-found ( bytes stream quot -- ? )
+    bytes [
+        quot unless-empty
+    ] [
+        stream (>>leftover)
+        quot unless-empty
+    ] if-empty f quot call f ;
+
+:: multipart-step-not-found ( stream end-stream? separator quot -- ? )
+    end-stream? [
+        quot unless-empty f
+    ] [
+        separator length 1- ?cut* stream (>>leftover)
+        quot unless-empty t
+    ] if ;
+
+:: multipart-step ( stream bytes end-stream? separator quot: ( bytes -- ) -- ? end-stream? )
+    #! return t to loop again
+    bytes separator multipart-split
+    [ 2drop f quot call f ]
+    [
+        [ stream quot multipart-step-found ]
+        [ stream end-stream? separator quot multipart-step-not-found ] if*
+    ] if stream leftover>> end-stream? not or ;
+
+PRIVATE>
+
+:: multipart-step-loop ( stream quot1: ( bytes -- ) quot2: ( -- ) -- ? )
+    stream dup [ read-n ] [ separator>> ] bi quot1 multipart-step
+    swap [ drop stream quot1 quot2 multipart-step-loop ] quot2 if ;
+
+: multipart-loop-all ( stream quot1: ( bytes -- ) quot2: ( -- ) -- )
+    3dup multipart-step-loop
+    [ multipart-loop-all ] [ 3drop ] if ;
diff --git a/basis/mime/types/authors.txt b/basis/mime/types/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/mime/types/mime.types b/basis/mime/types/mime.types
new file mode 100644 (file)
index 0000000..b602e9d
--- /dev/null
@@ -0,0 +1,988 @@
+# This is a comment. I love comments.
+
+# This file controls what Internet media types are sent to the client for
+# given file extension(s).  Sending the correct media type to the client
+# is important so they know how to handle the content of the file.
+# Extra types can either be added here or by using an AddType directive
+# in your config files. For more information about Internet media types,
+# please read RFC 2045, 2046, 2047, 2048, and 2077.  The Internet media type
+# registry is at <http://www.iana.org/assignments/media-types/>.
+
+# MIME type                                    Extensions
+application/activemessage
+application/andrew-inset                       ez
+application/applefile
+application/atom+xml                           atom
+application/atomcat+xml                                atomcat
+application/atomicmail
+application/atomsvc+xml                                atomsvc
+application/auth-policy+xml
+application/batch-smtp
+application/beep+xml
+application/cals-1840
+application/ccxml+xml                          ccxml
+application/cellml+xml
+application/cnrp+xml
+application/commonground
+application/conference-info+xml
+application/cpl+xml
+application/csta+xml
+application/cstadata+xml
+application/cybercash
+application/davmount+xml                       davmount
+application/dca-rft
+application/dec-dx
+application/dialog-info+xml
+application/dicom
+application/dns
+application/dvcs
+application/ecmascript                         ecma
+application/edi-consent
+application/edi-x12
+application/edifact
+application/epp+xml
+application/eshop
+application/fastinfoset
+application/fastsoap
+application/fits
+application/font-tdpfr                         pfr
+application/h224
+application/http
+application/hyperstudio                                stk
+application/iges
+application/im-iscomposing+xml
+application/index
+application/index.cmd
+application/index.obj
+application/index.response
+application/index.vnd
+application/iotp
+application/ipp
+application/isup
+application/javascript                         js
+application/json                               json
+application/kpml-request+xml
+application/kpml-response+xml
+application/mac-binhex40                       hqx
+application/mac-compactpro                     cpt
+application/macwriteii
+application/marc                               mrc
+application/mathematica                                ma nb mb
+application/mathml+xml                         mathml
+application/mbms-associated-procedure-description+xml
+application/mbms-deregister+xml
+application/mbms-envelope+xml
+application/mbms-msk+xml
+application/mbms-msk-response+xml
+application/mbms-protection-description+xml
+application/mbms-reception-report+xml
+application/mbms-register+xml
+application/mbms-register-response+xml
+application/mbms-user-service-description+xml
+application/mbox                               mbox
+application/mediaservercontrol+xml             mscml
+application/mikey
+application/mp4                                        mp4s
+application/mpeg4-generic
+application/mpeg4-iod
+application/mpeg4-iod-xmt
+application/msword                             doc dot
+application/mxf                                        mxf
+application/nasdata
+application/news-message-id
+application/news-transmission
+application/nss
+application/ocsp-request
+application/ocsp-response
+application/octet-stream bin dms lha lzh class so iso dmg dist distz pkg bpk dump elc scpt
+application/oda                                        oda
+application/oebps-package+xml
+application/ogg                                        ogg
+application/parityfec
+application/pdf                                        pdf
+application/pgp-encrypted                      pgp
+application/pgp-keys
+application/pgp-signature                      asc sig
+application/pics-rules                         prf
+application/pidf+xml
+application/pkcs10                             p10
+application/pkcs7-mime                         p7m p7c
+application/pkcs7-signature                    p7s
+application/pkix-cert                          cer
+application/pkix-crl                           crl
+application/pkix-pkipath                       pkipath
+application/pkixcmp                            pki
+application/pls+xml                            pls
+application/poc-settings+xml
+application/postscript                         ai eps ps
+application/prs.alvestrand.titrax-sheet
+application/prs.cww                            cww
+application/prs.nprend
+application/prs.plucker
+application/qsig
+application/rdf+xml                            rdf
+application/reginfo+xml                                rif
+application/relax-ng-compact-syntax            rnc
+application/remote-printing
+application/resource-lists+xml                 rl
+application/riscos
+application/rlmi+xml
+application/rls-services+xml                   rs
+application/rsd+xml                            rsd
+application/rss+xml                            rss
+application/rtf                                        rtf
+application/rtx
+application/samlassertion+xml
+application/samlmetadata+xml
+application/sbml+xml                           sbml
+application/sdp                                        sdp
+application/set-payment
+application/set-payment-initiation             setpay
+application/set-registration
+application/set-registration-initiation                setreg
+application/sgml
+application/sgml-open-catalog
+application/shf+xml                            shf
+application/sieve
+application/simple-filter+xml
+application/simple-message-summary
+application/simplesymbolcontainer
+application/slate
+application/smil
+application/smil+xml                           smi smil
+application/soap+fastinfoset
+application/soap+xml
+application/spirits-event+xml
+application/srgs                               gram
+application/srgs+xml                           grxml
+application/ssml+xml                           ssml
+application/timestamp-query
+application/timestamp-reply
+application/tve-trigger
+application/vemmi
+application/vividence.scriptfile
+application/vnd.3gpp.bsf+xml
+application/vnd.3gpp.pic-bw-large              plb
+application/vnd.3gpp.pic-bw-small              psb
+application/vnd.3gpp.pic-bw-var                        pvb
+application/vnd.3gpp.sms
+application/vnd.3gpp2.bcmcsinfo+xml
+application/vnd.3gpp2.sms
+application/vnd.3m.post-it-notes               pwn
+application/vnd.accpac.simply.aso              aso
+application/vnd.accpac.simply.imp              imp
+application/vnd.acucobol                       acu
+application/vnd.acucorp                                atc acutc
+application/vnd.adobe.xdp+xml                  xdp
+application/vnd.adobe.xfdf                     xfdf
+application/vnd.aether.imp
+application/vnd.amiga.ami                      ami
+application/vnd.anser-web-certificate-issue-initiation cii
+application/vnd.anser-web-funds-transfer-initiation    fti
+application/vnd.antix.game-component           atx
+application/vnd.apple.installer+xml            mpkg
+application/vnd.audiograph                     aep
+application/vnd.autopackage
+application/vnd.avistar+xml
+application/vnd.blueice.multipass              mpm
+application/vnd.bmi                            bmi
+application/vnd.businessobjects                        rep
+application/vnd.cab-jscript
+application/vnd.canon-cpdl
+application/vnd.canon-lips
+application/vnd.cendio.thinlinc.clientconf
+application/vnd.chemdraw+xml                   cdxml
+application/vnd.chipnuts.karaoke-mmd           mmd
+application/vnd.cinderella                     cdy
+application/vnd.cirpack.isdn-ext
+application/vnd.claymore                       cla
+application/vnd.clonk.c4group                  c4g c4d c4f c4p c4u
+application/vnd.commerce-battelle
+application/vnd.commonspace                    csp cst
+application/vnd.contact.cmsg                   cdbcmsg
+application/vnd.cosmocaller                    cmc
+application/vnd.crick.clicker                  clkx
+application/vnd.crick.clicker.keyboard         clkk
+application/vnd.crick.clicker.palette          clkp
+application/vnd.crick.clicker.template         clkt
+application/vnd.crick.clicker.wordbank         clkw
+application/vnd.criticaltools.wbs+xml          wbs
+application/vnd.ctc-posml                      pml
+application/vnd.cups-pdf
+application/vnd.cups-postscript
+application/vnd.cups-ppd                       ppd
+application/vnd.cups-raster
+application/vnd.cups-raw
+application/vnd.curl                           curl
+application/vnd.cybank
+application/vnd.data-vision.rdz                        rdz
+application/vnd.denovo.fcselayout-link         fe_launch
+application/vnd.dna                            dna
+application/vnd.dolby.mlp                      mlp
+application/vnd.dpgraph                                dpg
+application/vnd.dreamfactory                   dfac
+application/vnd.dvb.esgcontainer
+application/vnd.dvb.ipdcesgaccess
+application/vnd.dxr
+application/vnd.ecdis-update
+application/vnd.ecowin.chart                   mag
+application/vnd.ecowin.filerequest
+application/vnd.ecowin.fileupdate
+application/vnd.ecowin.series
+application/vnd.ecowin.seriesrequest
+application/vnd.ecowin.seriesupdate
+application/vnd.enliven                                nml
+application/vnd.epson.esf                      esf
+application/vnd.epson.msf                      msf
+application/vnd.epson.quickanime               qam
+application/vnd.epson.salt                     slt
+application/vnd.epson.ssf                      ssf
+application/vnd.ericsson.quickcall
+application/vnd.eszigno3+xml                   es3 et3
+application/vnd.eudora.data
+application/vnd.ezpix-album                    ez2
+application/vnd.ezpix-package                  ez3
+application/vnd.fdf                            fdf
+application/vnd.ffsns
+application/vnd.fints
+application/vnd.flographit                     gph
+application/vnd.fluxtime.clip                  ftc
+application/vnd.framemaker                     fm frame maker
+application/vnd.frogans.fnc                    fnc
+application/vnd.frogans.ltf                    ltf
+application/vnd.fsc.weblaunch                  fsc
+application/vnd.fujitsu.oasys                  oas
+application/vnd.fujitsu.oasys2                 oa2
+application/vnd.fujitsu.oasys3                 oa3
+application/vnd.fujitsu.oasysgp                        fg5
+application/vnd.fujitsu.oasysprs               bh2
+application/vnd.fujixerox.art-ex
+application/vnd.fujixerox.art4
+application/vnd.fujixerox.hbpl
+application/vnd.fujixerox.ddd                  ddd
+application/vnd.fujixerox.docuworks            xdw
+application/vnd.fujixerox.docuworks.binder     xbd
+application/vnd.fut-misnet
+application/vnd.fuzzysheet                     fzs
+application/vnd.genomatix.tuxedo               txd
+application/vnd.google-earth.kml+xml           kml
+application/vnd.google-earth.kmz               kmz
+application/vnd.grafeq                         gqf gqs
+application/vnd.gridmp
+application/vnd.groove-account                 gac
+application/vnd.groove-help                    ghf
+application/vnd.groove-identity-message                gim
+application/vnd.groove-injector                        grv
+application/vnd.groove-tool-message            gtm
+application/vnd.groove-tool-template           tpl
+application/vnd.groove-vcard                   vcg
+application/vnd.handheld-entertainment+xml     zmm
+application/vnd.hbci                           hbci
+application/vnd.hcl-bireports
+application/vnd.hhe.lesson-player              les
+application/vnd.hp-hpgl                                hpgl
+application/vnd.hp-hpid                                hpid
+application/vnd.hp-hps                         hps
+application/vnd.hp-jlyt                                jlt
+application/vnd.hp-pcl                         pcl
+application/vnd.hp-pclxl                       pclxl
+application/vnd.httphone
+application/vnd.hzn-3d-crossword               x3d
+application/vnd.ibm.afplinedata
+application/vnd.ibm.electronic-media
+application/vnd.ibm.minipay                    mpy
+application/vnd.ibm.modcap                     afp listafp list3820
+application/vnd.ibm.rights-management          irm
+application/vnd.ibm.secure-container           sc
+application/vnd.igloader                       igl
+application/vnd.immervision-ivp                        ivp
+application/vnd.immervision-ivu                        ivu
+application/vnd.informedcontrol.rms+xml
+application/vnd.intercon.formnet               xpw xpx
+application/vnd.intertrust.digibox
+application/vnd.intertrust.nncp
+application/vnd.intu.qbo                       qbo
+application/vnd.intu.qfx                       qfx
+application/vnd.ipunplugged.rcprofile          rcprofile
+application/vnd.irepository.package+xml                irp
+application/vnd.is-xpr                         xpr
+application/vnd.jam                            jam
+application/vnd.japannet-directory-service
+application/vnd.japannet-jpnstore-wakeup
+application/vnd.japannet-payment-wakeup
+application/vnd.japannet-registration
+application/vnd.japannet-registration-wakeup
+application/vnd.japannet-setstore-wakeup
+application/vnd.japannet-verification
+application/vnd.japannet-verification-wakeup
+application/vnd.jcp.javame.midlet-rms          rms
+application/vnd.jisp                           jisp
+application/vnd.kahootz                                ktz ktr
+application/vnd.kde.karbon                     karbon
+application/vnd.kde.kchart                     chrt
+application/vnd.kde.kformula                   kfo
+application/vnd.kde.kivio                      flw
+application/vnd.kde.kontour                    kon
+application/vnd.kde.kpresenter                 kpr kpt
+application/vnd.kde.kspread                    ksp
+application/vnd.kde.kword                      kwd kwt
+application/vnd.kenameaapp                     htke
+application/vnd.kidspiration                   kia
+application/vnd.kinar                          kne knp
+application/vnd.koan                           skp skd skt skm
+application/vnd.liberty-request+xml
+application/vnd.llamagraphics.life-balance.desktop     lbd
+application/vnd.llamagraphics.life-balance.exchange+xml        lbe
+application/vnd.lotus-1-2-3                    123
+application/vnd.lotus-approach                 apr
+application/vnd.lotus-freelance                        pre
+application/vnd.lotus-notes                    nsf
+application/vnd.lotus-organizer                        org
+application/vnd.lotus-screencam                        scm
+application/vnd.lotus-wordpro                  lwp
+application/vnd.macports.portpkg               portpkg
+application/vnd.marlin.drm.actiontoken+xml
+application/vnd.marlin.drm.conftoken+xml
+application/vnd.marlin.drm.mdcf
+application/vnd.mcd                            mcd
+application/vnd.medcalcdata                    mc1
+application/vnd.mediastation.cdkey             cdkey
+application/vnd.meridian-slingshot
+application/vnd.mfer                           mwf
+application/vnd.mfmp                           mfm
+application/vnd.micrografx.flo                 flo
+application/vnd.micrografx.igx                 igx
+application/vnd.mif                            mif
+application/vnd.minisoft-hp3000-save
+application/vnd.mitsubishi.misty-guard.trustweb
+application/vnd.mobius.daf                     daf
+application/vnd.mobius.dis                     dis
+application/vnd.mobius.mbk                     mbk
+application/vnd.mobius.mqy                     mqy
+application/vnd.mobius.msl                     msl
+application/vnd.mobius.plc                     plc
+application/vnd.mobius.txf                     txf
+application/vnd.mophun.application             mpn
+application/vnd.mophun.certificate             mpc
+application/vnd.motorola.flexsuite
+application/vnd.motorola.flexsuite.adsi
+application/vnd.motorola.flexsuite.fis
+application/vnd.motorola.flexsuite.gotap
+application/vnd.motorola.flexsuite.kmr
+application/vnd.motorola.flexsuite.ttc
+application/vnd.motorola.flexsuite.wem
+application/vnd.mozilla.xul+xml        xul
+application/vnd.ms-artgalry                    cil
+application/vnd.ms-asf                         asf
+application/vnd.ms-cab-compressed              cab
+application/vnd.ms-excel                       xls xlm xla xlc xlt xlw
+application/vnd.ms-fontobject                  eot
+application/vnd.ms-htmlhelp                    chm
+application/vnd.ms-ims                         ims
+application/vnd.ms-lrm                         lrm
+application/vnd.ms-playready.initiator+xml
+application/vnd.ms-powerpoint                  ppt pps pot
+application/vnd.ms-project                     mpp mpt
+application/vnd.ms-tnef
+application/vnd.ms-wmdrm.lic-chlg-req
+application/vnd.ms-wmdrm.lic-resp
+application/vnd.ms-wmdrm.meter-chlg-req
+application/vnd.ms-wmdrm.meter-resp
+application/vnd.ms-works                       wps wks wcm wdb
+application/vnd.ms-wpl                         wpl
+application/vnd.ms-xpsdocument                 xps
+application/vnd.mseq                           mseq
+application/vnd.msign
+application/vnd.music-niff
+application/vnd.musician                       mus
+application/vnd.ncd.control
+application/vnd.nervana
+application/vnd.netfpx
+application/vnd.neurolanguage.nlu              nlu
+application/vnd.noblenet-directory             nnd
+application/vnd.noblenet-sealer                        nns
+application/vnd.noblenet-web                   nnw
+application/vnd.nokia.catalogs
+application/vnd.nokia.conml+wbxml
+application/vnd.nokia.conml+xml
+application/vnd.nokia.isds-radio-presets
+application/vnd.nokia.iptv.config+xml
+application/vnd.nokia.landmark+wbxml
+application/vnd.nokia.landmark+xml
+application/vnd.nokia.landmarkcollection+xml
+application/vnd.nokia.n-gage.ac+xml
+application/vnd.nokia.n-gage.data              ngdat
+application/vnd.nokia.n-gage.symbian.install   n-gage
+application/vnd.nokia.ncd
+application/vnd.nokia.pcd+wbxml
+application/vnd.nokia.pcd+xml
+application/vnd.nokia.radio-preset             rpst
+application/vnd.nokia.radio-presets            rpss
+application/vnd.novadigm.edm                   edm
+application/vnd.novadigm.edx                   edx
+application/vnd.novadigm.ext                   ext
+application/vnd.oasis.opendocument.chart               odc
+application/vnd.oasis.opendocument.chart-template      otc
+application/vnd.oasis.opendocument.formula             odf
+application/vnd.oasis.opendocument.formula-template    otf
+application/vnd.oasis.opendocument.graphics            odg
+application/vnd.oasis.opendocument.graphics-template   otg
+application/vnd.oasis.opendocument.image               odi
+application/vnd.oasis.opendocument.image-template      oti
+application/vnd.oasis.opendocument.presentation                odp
+application/vnd.oasis.opendocument.presentation-template otp
+application/vnd.oasis.opendocument.spreadsheet         ods
+application/vnd.oasis.opendocument.spreadsheet-template        ots
+application/vnd.oasis.opendocument.text                        odt
+application/vnd.oasis.opendocument.text-master         otm
+application/vnd.oasis.opendocument.text-template       ott
+application/vnd.oasis.opendocument.text-web            oth
+application/vnd.obn
+application/vnd.olpc-sugar                     xo
+application/vnd.oma-scws-config
+application/vnd.oma-scws-http-request
+application/vnd.oma-scws-http-response
+application/vnd.oma.bcast.associated-procedure-parameter+xml
+application/vnd.oma.bcast.drm-trigger+xml
+application/vnd.oma.bcast.imd+xml
+application/vnd.oma.bcast.notification+xml
+application/vnd.oma.bcast.sgboot
+application/vnd.oma.bcast.sgdd+xml
+application/vnd.oma.bcast.sgdu
+application/vnd.oma.bcast.simple-symbol-container
+application/vnd.oma.bcast.smartcard-trigger+xml
+application/vnd.oma.bcast.sprov+xml
+application/vnd.oma.dd2+xml                    dd2
+application/vnd.oma.drm.risd+xml
+application/vnd.oma.group-usage-list+xml
+application/vnd.oma.poc.groups+xml
+application/vnd.oma.xcap-directory+xml
+application/vnd.omads-email+xml
+application/vnd.omads-file+xml
+application/vnd.omads-folder+xml
+application/vnd.omaloc-supl-init
+application/vnd.openofficeorg.extension                oxt
+application/vnd.osa.netdeploy
+application/vnd.osgi.dp                                dp
+application/vnd.otps.ct-kip+xml
+application/vnd.palm                           prc pdb pqa oprc
+application/vnd.paos.xml
+application/vnd.pg.format                      str
+application/vnd.pg.osasli                      ei6
+application/vnd.piaccess.application-licence
+application/vnd.picsel                         efif
+application/vnd.poc.group-advertisement+xml
+application/vnd.pocketlearn                    plf
+application/vnd.powerbuilder6                  pbd
+application/vnd.powerbuilder6-s
+application/vnd.powerbuilder7
+application/vnd.powerbuilder7-s
+application/vnd.powerbuilder75
+application/vnd.powerbuilder75-s
+application/vnd.preminet
+application/vnd.previewsystems.box             box
+application/vnd.proteus.magazine               mgz
+application/vnd.publishare-delta-tree          qps
+application/vnd.pvi.ptid1                      ptid
+application/vnd.pwg-multiplexed
+application/vnd.pwg-xhtml-print+xml
+application/vnd.qualcomm.brew-app-res
+application/vnd.quark.quarkxpress              qxd qxt qwd qwt qxl qxb
+application/vnd.rapid
+application/vnd.recordare.musicxml             mxl
+application/vnd.recordare.musicxml+xml
+application/vnd.renlearn.rlprint
+application/vnd.rn-realmedia                   rm
+application/vnd.ruckus.download
+application/vnd.s3sms
+application/vnd.scribus
+application/vnd.sealed.3df
+application/vnd.sealed.csf
+application/vnd.sealed.doc
+application/vnd.sealed.eml
+application/vnd.sealed.mht
+application/vnd.sealed.net
+application/vnd.sealed.ppt
+application/vnd.sealed.tiff
+application/vnd.sealed.xls
+application/vnd.sealedmedia.softseal.html
+application/vnd.sealedmedia.softseal.pdf
+application/vnd.seemail                                see
+application/vnd.sema                           sema
+application/vnd.semd                           semd
+application/vnd.semf                           semf
+application/vnd.shana.informed.formdata                ifm
+application/vnd.shana.informed.formtemplate    itp
+application/vnd.shana.informed.interchange     iif
+application/vnd.shana.informed.package         ipk
+application/vnd.simtech-mindmapper             twd twds
+application/vnd.smaf                           mmf
+application/vnd.solent.sdkm+xml                        sdkm sdkd
+application/vnd.spotfire.dxp                   dxp
+application/vnd.spotfire.sfs                   sfs
+application/vnd.sss-cod
+application/vnd.sss-dtf
+application/vnd.sss-ntf
+application/vnd.street-stream
+application/vnd.sun.wadl+xml
+application/vnd.sus-calendar                   sus susp
+application/vnd.svd                            svd
+application/vnd.swiftview-ics
+application/vnd.syncml+xml                     xsm
+application/vnd.syncml.dm+wbxml                        bdm
+application/vnd.syncml.dm+xml                  xdm
+application/vnd.syncml.ds.notification
+application/vnd.tao.intent-module-archive      tao
+application/vnd.tmobile-livetv                 tmo
+application/vnd.trid.tpt                       tpt
+application/vnd.triscape.mxs                   mxs
+application/vnd.trueapp                                tra
+application/vnd.truedoc
+application/vnd.ufdl                           ufd ufdl
+application/vnd.uiq.theme                      utz
+application/vnd.umajin                         umj
+application/vnd.unity                          unityweb
+application/vnd.uoml+xml                       uoml
+application/vnd.uplanet.alert
+application/vnd.uplanet.alert-wbxml
+application/vnd.uplanet.bearer-choice
+application/vnd.uplanet.bearer-choice-wbxml
+application/vnd.uplanet.cacheop
+application/vnd.uplanet.cacheop-wbxml
+application/vnd.uplanet.channel
+application/vnd.uplanet.channel-wbxml
+application/vnd.uplanet.list
+application/vnd.uplanet.list-wbxml
+application/vnd.uplanet.listcmd
+application/vnd.uplanet.listcmd-wbxml
+application/vnd.uplanet.signal
+application/vnd.vcx                            vcx
+application/vnd.vd-study
+application/vnd.vectorworks
+application/vnd.vidsoft.vidconference
+application/vnd.visio                          vsd vst vss vsw
+application/vnd.visionary                      vis
+application/vnd.vividence.scriptfile
+application/vnd.vsf                            vsf
+application/vnd.wap.sic
+application/vnd.wap.slc
+application/vnd.wap.wbxml                      wbxml
+application/vnd.wap.wmlc                       wmlc
+application/vnd.wap.wmlscriptc                 wmlsc
+application/vnd.webturbo                       wtb
+application/vnd.wfa.wsc
+application/vnd.wordperfect                    wpd
+application/vnd.wqd                            wqd
+application/vnd.wrq-hp3000-labelled
+application/vnd.wt.stf                         stf
+application/vnd.wv.csp+wbxml
+application/vnd.wv.csp+xml
+application/vnd.wv.ssp+xml
+application/vnd.xara                           xar
+application/vnd.xfdl                           xfdl
+application/vnd.xmpie.cpkg
+application/vnd.xmpie.dpkg
+application/vnd.xmpie.plan
+application/vnd.xmpie.ppkg
+application/vnd.xmpie.xlim
+application/vnd.yamaha.hv-dic                  hvd
+application/vnd.yamaha.hv-script               hvs
+application/vnd.yamaha.hv-voice                        hvp
+application/vnd.yamaha.smaf-audio              saf
+application/vnd.yamaha.smaf-phrase             spf
+application/vnd.yellowriver-custom-menu                cmp
+application/vnd.zzazz.deck+xml                 zaz
+application/voicexml+xml                       vxml
+application/watcherinfo+xml
+application/whoispp-query
+application/whoispp-response
+application/winhlp                             hlp
+application/wita
+application/wordperfect5.1
+application/wsdl+xml                           wsdl
+application/wspolicy+xml                       wspolicy
+application/x-ace-compressed                   ace
+application/x-bcpio                            bcpio
+application/x-bittorrent                       torrent
+application/x-bzip                             bz
+application/x-bzip2                            bz2 boz
+application/x-cdlink                           vcd
+application/x-chat                             chat
+application/x-chess-pgn                                pgn
+application/x-compress
+application/x-cpio                             cpio
+application/x-csh                              csh
+application/x-director                         dcr dir dxr fgd
+application/x-dvi                              dvi
+application/x-futuresplash                     spl
+application/x-gtar                             gtar
+application/x-gzip
+application/x-hdf                              hdf
+application/x-java-jnlp-file   jnlp
+application/x-latex                            latex
+application/x-ms-wmd                           wmd
+application/x-ms-wmz                           wmz
+application/x-msaccess                         mdb
+application/x-msbinder                         obd
+application/x-mscardfile                       crd
+application/x-msclip                           clp
+application/x-msdownload                       exe dll com bat msi
+application/x-msmediaview                      mvb m13 m14
+application/x-msmetafile                       wmf
+application/x-msmoney                          mny
+application/x-mspublisher                      pub
+application/x-msschedule                       scd
+application/x-msterminal                       trm
+application/x-mswrite                          wri
+application/x-netcdf                           nc cdf
+application/x-pkcs12                           p12 pfx
+application/x-pkcs7-certificates               p7b spc
+application/x-pkcs7-certreqresp                        p7r
+application/x-rar-compressed                   rar
+application/x-sh                               sh
+application/x-shar                             shar
+application/x-shockwave-flash                  swf
+application/x-stuffit                          sit
+application/x-stuffitx                         sitx
+application/x-sv4cpio                          sv4cpio
+application/x-sv4crc                           sv4crc
+application/x-tar                              tar
+application/x-tcl                              tcl
+application/x-tex                              tex
+application/x-texinfo                          texinfo texi
+application/x-ustar                            ustar
+application/x-wais-source                      src
+application/x-x509-ca-cert                     der crt
+application/x400-bp
+application/xcap-att+xml
+application/xcap-caps+xml
+application/xcap-el+xml
+application/xcap-error+xml
+application/xcap-ns+xml
+application/xenc+xml                           xenc
+application/xhtml+xml                          xhtml xht
+application/xml                                        xml xsl
+application/xml-dtd                            dtd
+application/xml-external-parsed-entity
+application/xmpp+xml
+application/xop+xml                            xop
+application/xslt+xml                           xslt
+application/xspf+xml                           xspf
+application/xv+xml                             mxml xhvml xvml xvm
+application/zip                                        zip
+audio/32kadpcm
+audio/3gpp
+audio/3gpp2
+audio/ac3
+audio/amr
+audio/amr-wb
+audio/amr-wb+
+audio/asc
+audio/basic                                    au snd
+audio/bv16
+audio/bv32
+audio/clearmode
+audio/cn
+audio/dat12
+audio/dls
+audio/dsr-es201108
+audio/dsr-es202050
+audio/dsr-es202211
+audio/dsr-es202212
+audio/dvi4
+audio/eac3
+audio/evrc
+audio/evrc-qcp
+audio/evrc0
+audio/evrc1
+audio/evrcb
+audio/evrcb0
+audio/evrcb1
+audio/g722
+audio/g7221
+audio/g723
+audio/g726-16
+audio/g726-24
+audio/g726-32
+audio/g726-40
+audio/g728
+audio/g729
+audio/g7291
+audio/g729d
+audio/g729e
+audio/gsm
+audio/gsm-efr
+audio/ilbc
+audio/l16
+audio/l20
+audio/l24
+audio/l8
+audio/lpc
+audio/midi                                     mid midi kar rmi
+audio/mobile-xmf
+audio/mp4                                      mp4a
+audio/mp4a-latm                        m4a m4p
+audio/mpa
+audio/mpa-robust
+audio/mpeg                                     mpga mp2 mp2a mp3 m2a m3a
+audio/mpeg4-generic
+audio/parityfec
+audio/pcma
+audio/pcmu
+audio/prs.sid
+audio/qcelp
+audio/red
+audio/rtp-enc-aescm128
+audio/rtp-midi
+audio/rtx
+audio/smv
+audio/smv0
+audio/smv-qcp
+audio/sp-midi
+audio/t140c
+audio/t38
+audio/telephone-event
+audio/tone
+audio/vdvi
+audio/vmr-wb
+audio/vnd.3gpp.iufp
+audio/vnd.4sb
+audio/vnd.audiokoz
+audio/vnd.celp
+audio/vnd.cisco.nse
+audio/vnd.cmles.radio-events
+audio/vnd.cns.anp1
+audio/vnd.cns.inf1
+audio/vnd.digital-winds                                eol
+audio/vnd.dlna.adts
+audio/vnd.dolby.mlp
+audio/vnd.everad.plj
+audio/vnd.hns.audio
+audio/vnd.lucent.voice                         lvp
+audio/vnd.nokia.mobile-xmf
+audio/vnd.nortel.vbk
+audio/vnd.nuera.ecelp4800                      ecelp4800
+audio/vnd.nuera.ecelp7470                      ecelp7470
+audio/vnd.nuera.ecelp9600                      ecelp9600
+audio/vnd.octel.sbc
+audio/vnd.qcelp
+audio/vnd.rhetorex.32kadpcm
+audio/vnd.sealedmedia.softseal.mpeg
+audio/vnd.vmx.cvsd
+audio/wav                                      wav
+audio/x-aiff                                   aif aiff aifc
+audio/x-mpegurl                                        m3u
+audio/x-ms-wax                                 wax
+audio/x-ms-wma                                 wma
+audio/x-pn-realaudio                           ram ra
+audio/x-pn-realaudio-plugin                    rmp
+audio/x-wav                                    wav
+chemical/x-cdx                                 cdx
+chemical/x-cif                                 cif
+chemical/x-cmdf                                        cmdf
+chemical/x-cml                                 cml
+chemical/x-csml                                        csml
+chemical/x-pdb                                 pdb
+chemical/x-xyz                                 xyz
+image/bmp                                      bmp
+image/cgm                                      cgm
+image/fits
+image/g3fax                                    g3
+image/gif                                      gif
+image/ief                                      ief
+image/jp2                      jp2
+image/jpeg                                     jpeg jpg jpe
+image/jpm
+image/jpx
+image/naplps
+image/pict                     pict pic pct
+image/png                                      png
+image/prs.btif                                 btif
+image/prs.pti
+image/svg+xml                                  svg svgz
+image/t38
+image/tiff                                     tiff tif
+image/tiff-fx
+image/vnd.adobe.photoshop                      psd
+image/vnd.cns.inf2
+image/vnd.djvu                                 djvu djv
+image/vnd.dwg                                  dwg
+image/vnd.dxf                                  dxf
+image/vnd.fastbidsheet                         fbs
+image/vnd.fpx                                  fpx
+image/vnd.fst                                  fst
+image/vnd.fujixerox.edmics-mmr                 mmr
+image/vnd.fujixerox.edmics-rlc                 rlc
+image/vnd.globalgraphics.pgb
+image/vnd.microsoft.icon                       ico
+image/vnd.mix
+image/vnd.ms-modi                              mdi
+image/vnd.net-fpx                              npx
+image/vnd.sealed.png
+image/vnd.sealedmedia.softseal.gif
+image/vnd.sealedmedia.softseal.jpg
+image/vnd.svf
+image/vnd.wap.wbmp                             wbmp
+image/vnd.xiff                                 xif
+image/x-cmu-raster                             ras
+image/x-cmx                                    cmx
+image/x-icon
+image/x-macpaint               pntg pnt mac
+image/x-pcx                                    pcx
+image/x-pict                                   pic pct
+image/x-portable-anymap                                pnm
+image/x-portable-bitmap                                pbm
+image/x-portable-graymap                       pgm
+image/x-portable-pixmap                                ppm
+image/x-quicktime              qtif qti
+image/x-rgb                                    rgb
+image/x-xbitmap                                        xbm
+image/x-xpixmap                                        xpm
+image/x-xwindowdump                            xwd
+message/cpim
+message/delivery-status
+message/disposition-notification
+message/external-body
+message/http
+message/news
+message/partial
+message/rfc822                                 eml mime
+message/s-http
+message/sip
+message/sipfrag
+message/tracking-status
+model/iges                                     igs iges
+model/mesh                                     msh mesh silo
+model/vnd.dwf                                  dwf
+model/vnd.flatland.3dml
+model/vnd.gdl                                  gdl
+model/vnd.gs.gdl
+model/vnd.gtw                                  gtw
+model/vnd.moml+xml
+model/vnd.mts                                  mts
+model/vnd.parasolid.transmit.binary
+model/vnd.parasolid.transmit.text
+model/vnd.vtu                                  vtu
+model/vrml                                     wrl vrml
+multipart/alternative
+multipart/appledouble
+multipart/byteranges
+multipart/digest
+multipart/encrypted
+multipart/form-data
+multipart/header-set
+multipart/mixed
+multipart/parallel
+multipart/related
+multipart/report
+multipart/signed
+multipart/voice-message
+text/calendar                                  ics ifb
+text/css                                       css
+text/csv                                       csv
+text/directory
+text/dns
+text/enriched
+text/html                                      html htm
+text/parityfec
+text/plain                                     txt text conf def list log in
+text/prs.fallenstein.rst
+text/prs.lines.tag                             dsc
+text/red
+text/rfc822-headers
+text/richtext                                  rtx
+text/rtf
+text/rtp-enc-aescm128
+text/rtx
+text/sgml                                      sgml sgm
+text/t140
+text/tab-separated-values                      tsv
+text/troff                                     t tr roff man me ms
+text/uri-list                                  uri uris urls
+text/vnd.abc
+text/vnd.curl
+text/vnd.dmclientscript
+text/vnd.esmertec.theme-descriptor
+text/vnd.fly                                   fly
+text/vnd.fmi.flexstor                          flx
+text/vnd.in3d.3dml                             3dml
+text/vnd.in3d.spot                             spot
+text/vnd.iptc.newsml
+text/vnd.iptc.nitf
+text/vnd.latex-z
+text/vnd.motorola.reflex
+text/vnd.ms-mediapackage
+text/vnd.net2phone.commcenter.command
+text/vnd.sun.j2me.app-descriptor               jad
+text/vnd.trolltech.linguist
+text/vnd.wap.si
+text/vnd.wap.sl
+text/vnd.wap.wml                               wml
+text/vnd.wap.wmlscript                         wmls
+text/x-asm                                     s asm
+text/x-c                                       c cc cxx cpp h hh dic
+text/x-fortran                                 f for f77 f90
+text/x-pascal                                  p pas
+text/x-java-source                             java
+text/x-setext                                  etx
+text/x-uuencode                                        uu
+text/x-vcalendar                               vcs
+text/x-vcard                                   vcf
+text/xml
+text/xml-external-parsed-entity
+video/3gpp                                     3gp
+video/3gpp-tt
+video/3gpp2                                    3g2
+video/bmpeg
+video/bt656
+video/celb
+video/dv
+video/h261                                     h261
+video/h263                                     h263
+video/h263-1998
+video/h263-2000
+video/h264                                     h264
+video/jpeg                                     jpgv
+video/jpm                                      jpm jpgm
+video/mj2                                      mj2 mjp2
+video/mp1s
+video/mp2p
+video/mp2t
+video/mp4                                      mp4 mp4v mpg4 m4v
+video/mp4v-es
+video/mpeg                                     mpeg mpg mpe m1v m2v
+video/mpeg4-generic
+video/mpv
+video/nv
+video/parityfec
+video/pointer
+video/quicktime                                        qt mov
+video/raw
+video/rtp-enc-aescm128
+video/rtx
+video/smpte292m
+video/vc1
+video/vnd.dlna.mpeg-tts
+video/vnd.fvt                                  fvt
+video/vnd.hns.video
+video/vnd.motorola.video
+video/vnd.motorola.videop
+video/vnd.mpegurl                              mxu m4u
+video/vnd.nokia.interleaved-multimedia
+video/vnd.nokia.videovoip
+video/vnd.objectvideo
+video/vnd.sealed.mpeg1
+video/vnd.sealed.mpeg4
+video/vnd.sealed.swf
+video/vnd.sealedmedia.softseal.mov
+video/vnd.vivo                                 viv
+video/x-dv                     dv dif
+video/x-fli                                    fli
+video/x-ms-asf                                 asf asx
+video/x-ms-wm                                  wm
+video/x-ms-wmv                                 wmv
+video/x-ms-wmx                                 wmx
+video/x-ms-wvx                                 wvx
+video/x-msvideo                                        avi
+video/x-sgi-movie                              movie
+x-conference/x-cooltalk                                ice
diff --git a/basis/mime/types/types-docs.factor b/basis/mime/types/types-docs.factor
new file mode 100644 (file)
index 0000000..fc14227
--- /dev/null
@@ -0,0 +1,35 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs help.markup help.syntax io.streams.string sequences ;
+IN: mime.types
+
+HELP: mime-db
+{ $values
+    
+     { "seq" sequence } }
+{ $description "Outputs an array where the first element is a MIME type and the rest of the array is file extensions that have that MIME type." } ;
+
+HELP: mime-type
+{ $values
+    { "filename" "a filename" }
+    { "mime-type" "a MIME type string" } }
+{ $description "Outputs the MIME type associtated with a path by parsing the path's file extension and looking it up in the table returned by " { $link mime-types } "." } ;
+
+HELP: mime-types
+{ $values
+    
+     { "assoc" assoc } }
+{ $description "Outputs an " { $snippet "assoc" } " made from the data in the " { $link mime-db } " word where the keys are file extensions and the values are the corresponding MIME types." } ;
+
+HELP: nonstandard-mime-types
+{ $values
+    
+     { "assoc" assoc } }
+{ $description "A list of Factor-specific MIME types that are added to the MIME database loaded from disk." } ;
+
+ARTICLE: "mime.types" "MIME types"
+"The " { $vocab-link "mime.types" } " vocabulary loads a file of MIME types and provides a word to look up the MIME type based on a file extension." $nl
+"Looking up a MIME type:"
+{ $subsection mime-type } ;
+
+ABOUT: "mime.types"
diff --git a/basis/mime/types/types-tests.factor b/basis/mime/types/types-tests.factor
new file mode 100644 (file)
index 0000000..63535af
--- /dev/null
@@ -0,0 +1,6 @@
+IN: mime.types.tests
+USING: mime.types tools.test ;
+
+[ "application/postscript" ] [ "foo.ps" mime-type ] unit-test
+[ "application/octet-stream" ] [ "foo.ps.gz" mime-type ] unit-test
+[ "text/plain" ] [ "foo.factor" mime-type ] unit-test
diff --git a/basis/mime/types/types.factor b/basis/mime/types/types.factor
new file mode 100644 (file)
index 0000000..bb0d674
--- /dev/null
@@ -0,0 +1,25 @@
+! Copyright (C) 2004, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.files io.encodings.ascii assocs sequences splitting
+kernel namespaces fry memoize ;
+IN: mime.types
+
+MEMO: mime-db ( -- seq )
+    "resource:basis/mime/types/mime.types" ascii file-lines
+    [ "#" head? not ] filter [ " \t" split harvest ] map harvest ;
+
+: nonstandard-mime-types ( -- assoc )
+    H{
+        { "factor" "text/plain"                       }
+        { "cgi"    "application/x-cgi-script"         }
+        { "fhtml"  "application/x-factor-server-page" }
+    } ;
+
+MEMO: mime-types ( -- assoc )
+    [
+        mime-db [ unclip '[ [ _ ] dip set ] each ] each
+    ] H{ } make-assoc
+    nonstandard-mime-types assoc-union ;
+
+: mime-type ( filename -- mime-type )
+    file-extension mime-types at "application/octet-stream" or ;
index 284e42cd1b31399eba2c2bcf9af5fe52901e1298..8f14c60e14abf4bda8766efc662bd932d5d43654 100644 (file)
@@ -1,25 +1,13 @@
 ! Copyright (C) 2007, 2008, Slava Pestov, Elie CHAFTARI.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays kernel debugger sequences namespaces math
-math.order combinators init alien alien.c-types alien.strings libc
-continuations destructors debugger summary splitting assocs
-random math.parser locals unicode.case
-openssl.libcrypto openssl.libssl
-io.backend io.ports io.files io.encodings.8-bit io.sockets.secure
-io.timeouts ;
+USING: init kernel namespaces openssl.libcrypto openssl.libssl
+sequences ;
 IN: openssl
 
 ! This code is based on http://www.rtfm.com/openssl-examples/
 
 SINGLETON: openssl
 
-GENERIC: ssl-method ( symbol -- method )
-
-M: SSLv2  ssl-method drop SSLv2_client_method ;
-M: SSLv23 ssl-method drop SSLv23_method ;
-M: SSLv3  ssl-method drop SSLv3_method ;
-M: TLSv1  ssl-method drop TLSv1_method ;
-
 : (ssl-error-string) ( n -- string )
     ERR_clear_error f ERR_error_string ;
 
@@ -47,183 +35,3 @@ SYMBOL: ssl-initialized?
     ] unless ;
 
 [ f ssl-initialized? set-global ] "openssl" add-init-hook
-
-TUPLE: openssl-context < secure-context aliens sessions ;
-
-: set-session-cache ( ctx -- )
-    handle>>
-    [ SSL_SESS_CACHE_BOTH SSL_CTX_set_session_cache_mode ssl-error ]
-    [ 32 random-bits >hex dup length SSL_CTX_set_session_id_context ssl-error ]
-    bi ;
-
-: load-certificate-chain ( ctx -- )
-    dup config>> key-file>> [
-        [ handle>> ] [ config>> key-file>> (normalize-path) ] bi
-        SSL_CTX_use_certificate_chain_file
-        ssl-error
-    ] [ drop ] if ;
-
-: password-callback ( -- alien )
-    "int" { "void*" "int" "bool" "void*" } "cdecl"
-    [| buf size rwflag password! |
-        password [ B{ 0 } password! ] unless
-
-        [let | len [ password strlen ] |
-            buf password len 1+ size min memcpy
-            len
-        ]
-    ] alien-callback ;
-
-: default-pasword ( ctx -- alien )
-    [ config>> password>> latin1 malloc-string ] [ aliens>> ] bi
-    [ push ] [ drop ] 2bi ;
-
-: set-default-password ( ctx -- )
-    [ handle>> password-callback SSL_CTX_set_default_passwd_cb ]
-    [
-        [ handle>> ] [ default-pasword ] bi
-        SSL_CTX_set_default_passwd_cb_userdata
-    ] bi ;
-
-: use-private-key-file ( ctx -- )
-    dup config>> key-file>> [
-        [ handle>> ] [ config>> key-file>> (normalize-path) ] bi
-        SSL_FILETYPE_PEM SSL_CTX_use_PrivateKey_file
-        ssl-error
-    ] [ drop ] if ;
-
-: load-verify-locations ( ctx -- )
-    dup config>> [ ca-file>> ] [ ca-path>> ] bi or [
-        [ handle>> ]
-        [
-            config>>
-            [ ca-file>> dup [ (normalize-path) ] when ]
-            [ ca-path>> dup [ (normalize-path) ] when ] bi
-        ] bi
-        SSL_CTX_load_verify_locations
-    ] [ handle>> SSL_CTX_set_default_verify_paths ] if ssl-error ;
-
-: set-verify-depth ( ctx -- )
-    dup config>> verify-depth>> [
-        [ handle>> ] [ config>> verify-depth>> ] bi
-        SSL_CTX_set_verify_depth
-    ] [ drop ] if ;
-
-TUPLE: bio handle disposed ;
-
-: <bio> ( handle -- bio ) f bio boa ;
-
-M: bio dispose* handle>> BIO_free ssl-error ;
-
-: <file-bio> ( path -- bio )
-    normalize-path "r" BIO_new_file dup ssl-error <bio> ;
-
-: load-dh-params ( ctx -- )
-    dup config>> dh-file>> [
-        [ handle>> ] [ config>> dh-file>> ] bi <file-bio> &dispose
-        handle>> f f f PEM_read_bio_DHparams dup ssl-error
-        SSL_CTX_set_tmp_dh ssl-error
-    ] [ drop ] if ;
-
-TUPLE: rsa handle disposed ;
-
-: <rsa> ( handle -- rsa ) f rsa boa ;
-
-M: rsa dispose* handle>> RSA_free ;
-
-: generate-eph-rsa-key ( ctx -- )
-    [ handle>> ]
-    [
-        config>> ephemeral-key-bits>> RSA_F4 f f RSA_generate_key
-        dup ssl-error <rsa> &dispose handle>>
-    ] bi
-    SSL_CTX_set_tmp_rsa ssl-error ;
-
-: <openssl-context> ( config ctx -- context )
-    openssl-context new
-        swap >>handle
-        swap >>config
-        V{ } clone >>aliens
-        H{ } clone >>sessions ;
-
-M: openssl <secure-context> ( config -- context )
-    maybe-init-ssl
-    [
-        dup method>> ssl-method SSL_CTX_new
-        dup ssl-error <openssl-context> |dispose
-        {
-            [ set-session-cache ]
-            [ load-certificate-chain ]
-            [ set-default-password ]
-            [ use-private-key-file ]
-            [ load-verify-locations ]
-            [ set-verify-depth ]
-            [ load-dh-params ]
-            [ generate-eph-rsa-key ]
-            [ ]
-        } cleave
-    ] with-destructors ;
-
-M: openssl-context dispose*
-    [ aliens>> [ free ] each ]
-    [ sessions>> values [ SSL_SESSION_free ] each ]
-    [ handle>> SSL_CTX_free ]
-    tri ;
-
-TUPLE: ssl-handle file handle connected disposed ;
-
-SYMBOL: default-secure-context
-
-: context-expired? ( context -- ? )
-    dup [ handle>> expired? ] [ drop t ] if ;
-
-: current-secure-context ( -- ctx )
-    secure-context get [
-        default-secure-context get dup context-expired? [
-            drop
-            <secure-config> <secure-context> default-secure-context set-global
-            current-secure-context
-        ] when
-    ] unless* ;
-
-: <ssl-handle> ( fd -- ssl )
-    current-secure-context handle>> SSL_new dup ssl-error
-    f f ssl-handle boa ;
-
-M: ssl-handle dispose*
-    [ handle>> SSL_free ] [ file>> dispose ] bi ;
-
-: check-verify-result ( ssl-handle -- )
-    SSL_get_verify_result dup X509_V_OK =
-    [ drop ] [ verify-message certificate-verify-error ] if ;
-
-: common-name ( certificate -- host )
-    X509_get_subject_name
-    NID_commonName 256 <byte-array>
-    [ 256 X509_NAME_get_text_by_NID ] keep
-    swap -1 = [ drop f ] [ latin1 alien>string ] if ;
-
-: common-names-match? ( expected actual -- ? )
-    [ >lower ] bi@ "*." ?head [ tail? ] [ = ] if ;
-
-: check-common-name ( host ssl-handle -- )
-    SSL_get_peer_certificate common-name
-    2dup common-names-match?
-    [ 2drop ] [ common-name-verify-error ] if ;
-
-M: openssl check-certificate ( host ssl -- )
-    current-secure-context config>> verify>> [
-        handle>>
-        [ nip check-verify-result ]
-        [ check-common-name ]
-        2bi
-    ] [ 2drop ] if ;
-
-: get-session ( addrspec -- session/f )
-    current-secure-context sessions>> at
-    dup expired? [ drop f ] when ;
-
-: save-session ( session addrspec -- )
-    current-secure-context sessions>> set-at ;
-
-openssl secure-socket-backend set-global
index 5739482093550d321726f0a05386588b99db6360..af1b4aec047c6db6a2f7e28d48df9bc8d6f9dabd 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Chris Double, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences strings namespaces make math assocs
-shuffle vectors arrays math.parser accessors unicode.categories
+vectors arrays math.parser accessors unicode.categories
 sequences.deep peg peg.private peg.search math.ranges words ;
 IN: peg.parsers
 
index cc13d5d42510fbfa3fcb788dea3187e0f00cef31..2dabf1edf789221520b6fd53422384699ab6b6a0 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences strings fry namespaces make math assocs
-shuffle debugger io vectors arrays math.parser math.order
+debugger io vectors arrays math.parser math.order
 vectors combinators classes sets unicode.categories
 compiler.units parser words quotations effects memoize accessors
 locals effects splitting combinators.short-circuit
index 31b6ba3f2612de4c42224c190b4ce5c496c2522c..f1fd749666db5903e2b0e7f17dda1efc209d08ca 100644 (file)
@@ -216,17 +216,8 @@ M: object pprint* pprint-object ;
 M: vector pprint* pprint-object ;
 M: byte-vector pprint* pprint-object ;
 M: hashtable pprint* pprint-object ;
-
-M: curry pprint*
-    dup quot>> callable? [ pprint-object ] [
-        "( invalid curry )" swap present-text
-    ] if ;
-
-M: compose pprint*
-    dup [ first>> callable? ] [ second>> callable? ] bi and
-    [ pprint-object ] [
-        "( invalid compose )" swap present-text
-    ] if ;
+M: curry pprint* pprint-object ;
+M: compose pprint* pprint-object ;
 
 M: wrapper pprint*
     dup wrapped>> word? [
index 159421c18c94c6a6a033aa3e1ccced768a987c90..3c004e5b305c6837955f0025903d0ef1cb845e79 100644 (file)
@@ -17,7 +17,8 @@ ARTICLE: "prettyprint-stacks" "Prettyprinting stacks"
 "Prettyprinting any stack:"
 { $subsection stack. }
 "Prettyprinting any call stack:"
-{ $subsection callstack. } ;
+{ $subsection callstack. }
+"Note that calls to " { $link .s } " can also be included inside words as a debugging aid, however a more convenient way to achieve this is to use the annotation facility. See " { $link "tools.annotations" } "." ;
 
 ARTICLE: "prettyprint-variables" "Prettyprint control variables"
 "The following variables affect the " { $link . } " and " { $link pprint } " words if set in the current dynamic scope:"
index 8eaaab3c1db7f0bbe6b6babe17435aa897aa32a5..96698fc18f5778969912aa2d1ce7f307b307bd38 100644 (file)
@@ -323,10 +323,6 @@ M: class-see-layout class-see-layout ;
     [ 2 break 2 \ + (step-into-execute) . ] (remove-breakpoints)
 ] unit-test
 
-[ ] [ 1 \ + curry unparse drop ] unit-test
-
-[ ] [ 1 \ + compose unparse drop ] unit-test
-
 GENERIC: generic-see-test-with-f ( obj -- obj )
 
 M: f generic-see-test-with-f ;
index 3befdaff2bc012ec34ce96ffa7241627054532f5..6dd7175db8c220436893a72c27f613d0e5ea6088 100644 (file)
@@ -7,7 +7,7 @@ prettyprint.config sorting splitting grouping math.parser vocabs
 definitions effects classes.builtin classes.tuple io.files
 classes continuations hashtables classes.mixin classes.union
 classes.intersection classes.predicate classes.singleton
-combinators quotations sets accessors colors ;
+combinators quotations sets accessors colors parser ;
 IN: prettyprint
 
 : make-pprint ( obj quot -- block in use )
@@ -44,12 +44,28 @@ IN: prettyprint
         ] with-pprint nl
     ] unless-empty ;
 
-: vocabs. ( in use -- )
+: use/in. ( in use -- )
     dupd remove [ { "syntax" "scratchpad" } member? not ] filter
     use. in. ;
 
+: vocab-names ( words -- vocabs )
+    dictionary get
+    [ [ words>> eq? nip ] with assoc-find 2drop ] curry map sift ;
+
+: prelude. ( -- )
+    in get use get vocab-names use/in. ;
+
+[
+    nl
+    "Restarts were invoked adding vocabularies to the search path." print
+    "To avoid doing this in the future, add the following USING:" print
+    "and IN: forms at the top of the source file:" print nl
+    prelude.
+    nl
+] print-use-hook set-global
+
 : with-use ( obj quot -- )
-    make-pprint vocabs. do-pprint ; inline
+    make-pprint use/in. do-pprint ; inline
 
 : with-in ( obj quot -- )
     make-pprint drop [ write-in bl ] when* do-pprint ; inline
index d387ef4b0ecf8b7eb01b215fb6700ea73a52feea..25d04ed929efaf7d62c1606c89dadc4f1bd6729e 100644 (file)
@@ -17,15 +17,13 @@ IN: qualified
     #! Syntax: QUALIFIED-WITH: vocab prefix
     scan scan define-qualified ; parsing
 
-: expect=> ( -- ) scan "=>" assert= ;
-
 : partial-vocab ( words vocab -- assoc )
     '[ dup _ lookup [ no-word-error ] unless* ]
     { } map>assoc ;
 
 : FROM:
     #! Syntax: FROM: vocab => words... ;
-    scan dup load-vocab drop expect=>
+    scan dup load-vocab drop "=>" expect
     ";" parse-tokens swap partial-vocab use get push ; parsing
 
 : partial-vocab-excluding ( words vocab -- assoc )
@@ -33,13 +31,13 @@ IN: qualified
 
 : EXCLUDE:
     #! Syntax: EXCLUDE: vocab => words ... ;
-    scan expect=>
+    scan "=>" expect
     ";" parse-tokens swap partial-vocab-excluding use get push ; parsing
 
 : RENAME:
     #! Syntax: RENAME: word vocab => newname
     scan scan dup load-vocab drop
     dupd lookup [ ] [ no-word-error ] ?if
-    expect=>
+    "=>" expect
     scan associate use get push ; parsing
 
index 240b27a9ccd9da81298c7b55c0eba7f20f87b9ef..7b729b2e5088b3e9f01f32d0692a99f59c1dd947 100644 (file)
@@ -14,6 +14,9 @@ M: character-class-range class-member? ( obj class -- ? )
 
 M: any-char class-member? ( obj class -- ? )
     2drop t ;
+
+M: any-char-no-nl class-member? ( obj class -- ? )
+    drop CHAR: \n = not ;
     
 M: letter-class class-member? ( obj class -- ? )
     drop letter? ;
index b5022c602eeb039f3e7b2045c55729e24fd35b56..7f1d92a1ab91baace3f7dcb967c245d3898f544a 100644 (file)
@@ -43,6 +43,7 @@ INSTANCE: comment-group parentheses-group
 TUPLE: character-class-range from to ; INSTANCE: character-class-range node
 SINGLETON: epsilon INSTANCE: epsilon node
 SINGLETON: any-char INSTANCE: any-char node
+SINGLETON: any-char-no-nl INSTANCE: any-char-no-nl node
 SINGLETON: front-anchor INSTANCE: front-anchor node
 SINGLETON: back-anchor INSTANCE: back-anchor node
 
@@ -172,7 +173,7 @@ DEFER: (parse-regexp)
     [ drop1 (parse-special-group) ]
     [ capture-group f nested-parse-regexp ] if ;
 
-: handle-dot ( -- ) any-char push-stack ;
+: handle-dot ( -- ) get-dotall any-char any-char-no-nl ? push-stack ;
 : handle-pipe ( -- ) pipe push-stack ;
 : (handle-star) ( obj -- kleene-star )
     peek1 {
@@ -288,28 +289,9 @@ ERROR: bad-escaped-literals seq ;
         first|concatenation
     ] if-empty ;
 
-ERROR: unrecognized-escape char ;
-
 : parse-escaped ( -- obj )
     read1
     {
-        { CHAR: \ [ CHAR: \ <constant> ] }
-        { CHAR: / [ CHAR: / <constant> ] }
-        { CHAR: ^ [ CHAR: ^ <constant> ] }
-        { CHAR: $ [ CHAR: $ <constant> ] }
-        { CHAR: - [ CHAR: - <constant> ] }
-        { CHAR: { [ CHAR: { <constant> ] }
-        { CHAR: } [ CHAR: } <constant> ] }
-        { CHAR: [ [ CHAR: [ <constant> ] }
-        { CHAR: ] [ CHAR: ] <constant> ] }
-        { CHAR: ( [ CHAR: ( <constant> ] }
-        { CHAR: ) [ CHAR: ) <constant> ] }
-        { CHAR: @ [ CHAR: @ <constant> ] }
-        { CHAR: * [ CHAR: * <constant> ] }
-        { CHAR: + [ CHAR: + <constant> ] }
-        { CHAR: ? [ CHAR: ? <constant> ] }
-        { CHAR: . [ CHAR: . <constant> ] }
-        { CHAR: : [ CHAR: : <constant> ] }
         { CHAR: t [ CHAR: \t <constant> ] }
         { CHAR: n [ CHAR: \n <constant> ] }
         { CHAR: r [ CHAR: \r <constant> ] }
@@ -349,7 +331,7 @@ ERROR: unrecognized-escape char ;
         ! { CHAR: 9 [ CHAR: 9 <constant> ] }
 
         { CHAR: Q [ parse-escaped-literals ] }
-        [ unrecognized-escape ]
+        [ <constant> ]
     } case ;
 
 : handle-escape ( -- ) parse-escaped push-stack ;
index 4878b67d0f089100e0846149551fc8dcfaf89770..777d0985e4c34e50ae570d9dc7ea829e2717bf58 100644 (file)
@@ -1,5 +1,5 @@
 USING: regexp tools.test kernel sequences regexp.parser
-regexp.traversal eval ;
+regexp.traversal eval strings ;
 IN: regexp-tests
 
 \ <regexp> must-infer
@@ -40,7 +40,12 @@ IN: regexp-tests
 [ f ] [ "" "." <regexp> matches? ] unit-test
 [ t ] [ "a" "." <regexp> matches? ] unit-test
 [ t ] [ "." "." <regexp> matches? ] unit-test
-! [ f ] [ "\n" "." <regexp> matches? ] unit-test
+
+! Dotall mode -- when on, . matches newlines.
+! Off by default.
+[ f ] [ "\n" "." <regexp> matches? ] unit-test
+[ t ] [ "\n" "(?s)." <regexp> matches? ] unit-test
+[ f ] [ "\n\n" "(?s).(?-s)." <regexp> matches? ] unit-test
 
 [ f ] [ "" ".+" <regexp> matches? ] unit-test
 [ t ] [ "a" ".+" <regexp> matches? ] unit-test
@@ -170,7 +175,6 @@ IN: regexp-tests
 [ f ] [ "ABC" "\\p{Lower}{3}" <regexp> matches? ] unit-test
 [ t ] [ "ABC" "\\p{Upper}{3}" <regexp> matches? ] unit-test
 [ f ] [ "abc" "\\p{Upper}{3}" <regexp> matches? ] unit-test
-! 
 [ f ] [ "abc" "[\\p{Upper}]{3}" <regexp> matches? ] unit-test
 [ t ] [ "ABC" "[\\p{Upper}]{3}" <regexp> matches? ] unit-test
 
@@ -252,7 +256,40 @@ IN: regexp-tests
 ! Comment
 [ t ] [ "ac" "a(?#boo)c" <regexp> matches? ] unit-test
 
+[ ] [ "USING: regexp kernel ; R' -{3}[+]{1,6}(?:!!)?\\s' drop" eval ] unit-test
+
+[ ] [ "USING: regexp kernel ; R' (ftp|http|https)://(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?' drop" eval ] unit-test
+
+[ ] [ "USING: regexp kernel ; R' \\*[^\s*][^*]*\\*' drop" eval ] unit-test
+
+[ "ab" ] [ "ab" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
+[ "abc" ] [ "abc" "(a|ab)(bc)?" <regexp> first-match >string ] unit-test
+
+[ "ab" ] [ "ab" "(ab|a)(bc)?" <regexp> first-match >string ] unit-test
+[ "abc" ] [ "abc" "(ab|a)(bc)?" <regexp> first-match >string ] unit-test
+
+[ "b" ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" <regexp> first-match >string ] unit-test
+
+[ t ] [ "a:b" ".+:?" <regexp> matches? ] unit-test
+
+[ 1 ] [ "hello" ".+?" <regexp> match length ] unit-test
+
+[ { "1" "2" "3" "4" } ]
+[ "1ABC2DEF3GHI4" R/ [A-Z]+/ re-split [ >string ] map ] unit-test
+
+[ { "1" "2" "3" "4" } ]
+[ "1ABC2DEF3GHI4JK" R/ [A-Z]+/ re-split [ >string ] map ] unit-test
+
+[ { "ABC" "DEF" "GHI" } ]
+[ "1ABC2DEF3GHI4" R/ [A-Z]+/ all-matches [ >string ] map ] unit-test
 
+[ "1.2.3.4" ]
+[ "1ABC2DEF3GHI4JK" R/ [A-Z]+/ "." re-replace ] unit-test
+
+[ f ] [ "ab" "a(?!b)" <regexp> first-match ] unit-test
+[ "a" ] [ "ab" "a(?=b)(?=b)" <regexp> first-match >string ] unit-test
+[ "a" ] [ "ba" "a(?<=b)(?<=b)" <regexp> first-match >string ] unit-test
+[ "a" ] [ "cab" "a(?=b)(?<=c)" <regexp> first-match >string ] unit-test
 
 ! [ "{Lower}" <regexp> ] [ invalid-range? ] must-fail-with
 
@@ -286,21 +323,10 @@ IN: regexp-tests
 ! [ t ] [ "fooxbar" "foo\\Bxbar" <regexp> matches? ] unit-test
 ! [ f ] [ "foo" "foo\\Bbar" <regexp> matches? ] unit-test
 
-[ ] [ "USING: regexp kernel ; R' -{3}[+]{1,6}(?:!!)?\\s' drop" eval ] unit-test
-
-[ ] [ "USING: regexp kernel ; R' (ftp|http|https)://(\\w+:?\\w*@)?(\\S+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!\\-/]))?' drop" eval ] unit-test
-
-[ ] [ "USING: regexp kernel ; R' \\*[^\s*][^*]*\\*' drop" eval ] unit-test
 
 ! Bug in parsing word
 ! [ t ] [ "a" R' a' matches?  ] unit-test
 
-! ((A)(B(C)))
-! 1.  ((A)(B(C)))
-! 2. (A)
-! 3. (B(C))
-! 4. (C) 
-
 ! clear "a(?=b*)" <regexp> "ab" over match
 ! clear "a(?=b*c)" <regexp> "abbbbbc" over match
 ! clear "a(?=b*)" <regexp> "ab" over match
@@ -326,27 +352,11 @@ IN: regexp-tests
 ! "a(?#bcdefg)bcd" <regexp> "abcdefg" over first-match
 ! "a(?:bcdefg)" <regexp> "abcdefg" over first-match
 
-[ { 0 1 } ] [ "ac" "a(?!b)" <regexp> first-match ] unit-test
-[ f ] [ "ab" "a(?!b)" <regexp> first-match ] unit-test
+[ "a" ] [ "ac" "a(?!b)" <regexp> first-match >string ] unit-test
 
 ! "a(?<=b)" <regexp> "caba" over first-match
 
-[ { 0 1 } ] [ "ab" "a(?=b)(?=b)" <regexp> first-match ] unit-test
-[ { 1 2 } ] [ "ba" "a(?<=b)(?<=b)" <regexp> first-match ] unit-test
-[ { 1 2 } ] [ "cab" "a(?=b)(?<=c)" <regexp> first-match ] unit-test
 
 ! capture group 1: "aaaa"  2: ""
 ! "aaaa" "(a*)(a*)" <regexp> match*
 ! "aaaa" "(a*)(a+)" <regexp> match*
-
-[ { 0 2 } ] [ "ab" "(a|ab)(bc)?" <regexp> first-match ] unit-test
-[ { 0 3 } ] [ "abc" "(a|ab)(bc)?" <regexp> first-match ] unit-test
-
-[ { 0 2 } ] [ "ab" "(ab|a)(bc)?" <regexp> first-match ] unit-test
-[ { 0 3 } ] [ "abc" "(ab|a)(bc)?" <regexp> first-match ] unit-test
-
-[ { 23 24 } ] [ "aaaaaaaaaaaaaaaaaaaaaaab" "((a*)*b)*b" <regexp> first-match ] unit-test
-
-[ t ] [ "a:b" ".+:?" <regexp> matches? ] unit-test
-
-[ 1 ] [ "hello" ".+?" <regexp> match length ] unit-test
index c9a1d2f47d8e3a458cfcfe86b91cfe0a4bfe1a4e..66bc39415bc0a9ec4af8e820d087250283fe8168 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel math math.ranges sequences
+USING: accessors combinators kernel math sequences
 sets assocs prettyprint.backend make lexer namespaces parser
 arrays fry regexp.backend regexp.utils regexp.parser regexp.nfa
-regexp.dfa regexp.traversal regexp.transition-tables ;
+regexp.dfa regexp.traversal regexp.transition-tables splitting ;
 IN: regexp
 
 : default-regexp ( string -- regexp )
@@ -25,17 +25,20 @@ IN: regexp
         [ ]
     } cleave ;
 
-: match ( string regexp -- pair )
-    <dfa-traverser> do-match return-match ;
+: (match) ( string regexp -- dfa-traverser )
+    <dfa-traverser> do-match ; inline
 
-: match* ( string regexp -- pair captured-groups )
-    <dfa-traverser> do-match [ return-match ] [ captured-groups>> ] bi ;
+: match ( string regexp -- slice/f )
+    (match) return-match ;
+
+: match* ( string regexp -- slice/f captured-groups )
+    (match) [ return-match ] [ captured-groups>> ] bi ;
 
 : matches? ( string regexp -- ? )
     dupd match
-    [ [ length ] [ length>> 1- ] bi* = ] [ drop f ] if* ;
+    [ [ length ] bi@ = ] [ drop f ] if* ;
 
-: match-head ( string regexp -- end/f ) match [ length>> 1- ] [ f ] if* ;
+: match-head ( string regexp -- end/f ) match [ length ] [ f ] if* ;
 
 : match-at ( string m regexp -- n/f finished? )
     [
@@ -49,29 +52,25 @@ IN: regexp
         [ 3drop drop f f ] [ drop [ 1+ ] dip match-range ] if
     ] if ;
 
-: first-match ( string regexp -- pair/f )
-    0 swap match-range dup [ 2array ] [ 2drop f ] if ;
+: first-match ( string regexp -- slice/f )
+    dupd 0 swap match-range rot over [ <slice> ] [ 3drop f ] if ;
 
 : re-cut ( string regexp -- end/f start )
     dupd first-match
-    [ [ second tail-slice ] [ first head ] 2bi ]
-    [ "" like f swap ]
-    if* ;
+    [ split1-slice swap ] [ "" like f swap ] if* ;
 
 : re-split ( string regexp -- seq )
-    [ dup ] swap '[ _ re-cut ] [ ] produce nip ;
+    [ dup length 0 > ] swap '[ _ re-cut ] [ ] produce nip ;
 
 : re-replace ( string regexp replacement -- result )
     [ re-split ] dip join ;
 
 : next-match ( string regexp -- end/f match/f )
     dupd first-match dup
-    [ [ second tail-slice ] keep ]
-    [ 2drop f f ]
-    if ;
+    [ [ split1-slice nip ] keep ] [ 2drop f f ] if ;
 
 : all-matches ( string regexp -- seq )
-    [ dup ] swap '[ _ next-match ] [ ] produce nip ;
+    [ dup ] swap '[ _ next-match ] [ ] produce nip harvest ;
 
 : count-matches ( string regexp -- n )
     all-matches length 1- ;
index c9e8a5434886be8a8f6b0607ada0a400a26d85ff..86d315ee2fa5df58802d89ef2c1b850e0ab41696 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators kernel math math.ranges
+USING: accessors assocs combinators kernel math
 quotations sequences regexp.parser regexp.classes fry arrays
 combinators.short-circuit regexp.utils prettyprint regexp.nfa
 shuffle ;
@@ -144,7 +144,10 @@ M: capture-group-off flag-action ( dfa-traverser flag -- )
         [ increment-state do-match ] when*
     ] unless ;
 
-: return-match ( dfa-traverser -- interval/f )
+: return-match ( dfa-traverser -- slice/f )
     dup matches>>
     [ drop f ]
-    [ [ start-index>> ] [ peek ] bi* 1 <range> ] if-empty ;
+    [
+        [ [ text>> ] [ start-index>> ] bi ]
+        [ peek ] bi* rot <slice>
+    ] if-empty ;
index 63603ad131dc72ae4132351f38ce3bf52fa6a85f..9dc03dfac2a8ae7314a121a3612672f1e79873e8 100644 (file)
@@ -153,7 +153,7 @@ ERROR: invalid-header-string string ;
 
 : extract-email ( recepient -- email )
     ! This could be much smarter.
-    " " last-split1 swap or "<" ?head drop ">" ?tail drop ;
+    " " split1-last swap or "<" ?head drop ">" ?tail drop ;
 
 : email>headers ( email -- hashtable )
     [
index 7ee46cb440609c98a81149922c7d4ee0ede2cba7..986bbe4c7239981817141c31b6c988ab556f5fbc 100644 (file)
@@ -87,6 +87,15 @@ M: composed infer-call*
 M: object infer-call*
     \ literal-expected inference-warning ;
 
+: infer-slip ( -- )
+    1 infer->r pop-d infer-call 1 infer-r> ;
+
+: infer-2slip ( -- )
+    2 infer->r pop-d infer-call 2 infer-r> ;
+
+: infer-3slip ( -- )
+    3 infer->r pop-d infer-call 3 infer-r> ;
+
 : infer-curry ( -- )
     2 consume-d
     dup first2 <curried> make-known
@@ -150,6 +159,9 @@ M: object infer-call*
         { \ declare [ infer-declare ] }
         { \ call [ pop-d infer-call ] }
         { \ (call) [ pop-d infer-call ] }
+        { \ slip [ infer-slip ] }
+        { \ 2slip [ infer-2slip ] }
+        { \ 3slip [ infer-3slip ] }
         { \ curry [ infer-curry ] }
         { \ compose [ infer-compose ] }
         { \ execute [ infer-execute ] }
@@ -175,9 +187,10 @@ M: object infer-call*
     (( value -- )) apply-word/effect ;
 
 {
-    >r r> declare call (call) curry compose execute (execute) if
-dispatch <tuple-boa> (throw) load-locals get-local drop-locals
-do-primitive alien-invoke alien-indirect alien-callback
+    >r r> declare call (call) slip 2slip 3slip curry compose
+    execute (execute) if dispatch <tuple-boa> (throw)
+    load-locals get-local drop-locals do-primitive alien-invoke
+    alien-indirect alien-callback
 } [ t "special" set-word-prop ] each
 
 { call execute dispatch load-locals get-local drop-locals }
index e4f8c50eeb9d3ee9b04d11cee4f7b8ed49b3432c..6e11eb1189aeee0cd50bfb95874e17587e5b9c2d 100644 (file)
@@ -90,8 +90,12 @@ IN: stack-checker.transforms
 \ spread [ spread>quot ] 1 define-transform
 
 \ (call-next-method) [
-    [ [ inlined-dependency depends-on ] bi@ ] [ next-method-quot ] 2bi
-] 2 define-transform
+    [
+        [ "method-class" word-prop ]
+        [ "method-generic" word-prop ] bi
+        [ inlined-dependency depends-on ] bi@
+    ] [ next-method-quot ] bi
+] 1 define-transform
 
 ! Constructors
 \ boa [
index 4bb6d6142f7637c543b1756a2982b72af0f8f3ec..2306ff53a8cd51eb25d61ffc9e3792c54264d448 100644 (file)
@@ -72,7 +72,9 @@ IN: tools.completion
     ] if ;
 
 : string-completions ( short strs -- seq )
-    [ dup ] { } map>assoc completions ;
+    dup zip completions ;
 
 : limited-completions ( short candidates -- seq )
-    completions dup length 1000 > [ drop f ] when ;
+    [ completions ] [ drop ] 2bi
+    2dup [ length 50 > ] [ empty? ] bi* and
+    [ 2drop f ] [ drop 50 short head ] if ;
index 9431cb2c1982cae9d729369fce1d9e2d83ce58ed..18713c7b0c12c9a8ba685f57a8f73141fff91f2f 100644 (file)
@@ -55,6 +55,8 @@ DEFER: ?make-staging-image
 
 : staging-command-line ( profile -- flags )
     [
+        "-staging" ,
+
         dup empty? [
             "-i=" my-boot-image-name append ,
         ] [
index 226cf654b12d0ff3dbe22187d1548c865e2084ff..e0ac391fdfdfff862bd45e1bf5b6ed714e5c8951 100644 (file)
@@ -106,3 +106,8 @@ M: quit-responder call-responder*
     "tools.deploy.test.6" shake-and-bake\r
     run-temp-image\r
 ] unit-test\r
+\r
+[ ] [\r
+    "tools.deploy.test.7" shake-and-bake\r
+    run-temp-image\r
+] unit-test\r
diff --git a/basis/tools/deploy/shaker/next-methods.factor b/basis/tools/deploy/shaker/next-methods.factor
new file mode 100644 (file)
index 0000000..2bff407
--- /dev/null
@@ -0,0 +1,4 @@
+USING: words ;
+IN: generic
+
+: next-method-quot ( method -- quot ) "next-method-quot" word-prop ;
index f8f9680c16124536e82dce2d58f395776ac2eb0e..9cc5a66f7017fff29db7f51c0d7d4fb1b5de363c 100755 (executable)
@@ -5,7 +5,7 @@ namespaces make assocs kernel parser lexer strings.parser
 tools.deploy.config vocabs sequences words words.private memory
 kernel.private continuations io prettyprint vocabs.loader
 debugger system strings sets vectors quotations byte-arrays
-sorting compiler.units definitions ;
+sorting compiler.units definitions generic generic.standard ;
 QUALIFIED: bootstrap.stage2
 QUALIFIED: classes
 QUALIFIED: command-line
@@ -14,7 +14,6 @@ QUALIFIED: continuations
 QUALIFIED: definitions
 QUALIFIED: init
 QUALIFIED: layouts
-QUALIFIED: listener
 QUALIFIED: prettyprint.config
 QUALIFIED: source-files
 QUALIFIED: vocabs
@@ -95,20 +94,13 @@ IN: tools.deploy.shaker
 
 : stripped-word-props ( -- seq )
     [
-        strip-dictionary? deploy-compiler? get and [
-            {
-                "combination"
-                "members"
-                "methods"
-            } %
-        ] when
-
         strip-dictionary? [
             {
                 "alias"
                 "boa-check"
                 "cannot-infer"
                 "coercer"
+                "combination"
                 "compiled-effect"
                 "compiled-generic-uses"
                 "compiled-uses"
@@ -138,7 +130,9 @@ IN: tools.deploy.shaker
                 "local-writer?"
                 "local?"
                 "macro"
+                "members"
                 "memo-quot"
+                "methods"
                 "mixin"
                 "method-class"
                 "method-generic"
@@ -201,17 +195,13 @@ IN: tools.deploy.shaker
 
 : stripped-globals ( -- seq )
     [
-        "callbacks" "alien.compiler" lookup ,
-
         "inspector-hook" "inspector" lookup ,
 
         {
-            bootstrap.stage2:bootstrap-time
             continuations:error
             continuations:error-continuation
             continuations:error-thread
             continuations:restarts
-            listener:error-hook
             init:init-hooks
             source-files:source-files
             input-stream
@@ -234,6 +224,10 @@ IN: tools.deploy.shaker
             "tools"
             "io.launcher"
             "random"
+            "compiler"
+            "stack-checker"
+            "bootstrap"
+            "listener"
         } strip-vocab-globals %
 
         strip-dictionary? [
@@ -244,6 +238,7 @@ IN: tools.deploy.shaker
             {
                 gensym
                 name>char-hook
+                classes:next-method-quot-cache
                 classes:class-and-cache
                 classes:class-not-cache
                 classes:class-or-cache
@@ -266,7 +261,7 @@ IN: tools.deploy.shaker
                 layouts:tag-numbers
                 layouts:type-numbers
                 lexer-factory
-                listener:listener-hook
+                print-use-hook
                 root-cache
                 vocab-roots
                 vocabs:dictionary
@@ -304,10 +299,7 @@ IN: tools.deploy.shaker
             "ui-error-hook" "ui.gadgets.worlds" lookup ,
         ] when
 
-        "<value>" "stack-checker.state" lookup [ , ] when*
-
         "windows-messages" "windows.messages" lookup [ , ] when*
-
     ] { } make ;
 
 : strip-globals ( stripped-globals -- )
@@ -368,11 +360,21 @@ SYMBOL: deploy-vocab
     t "quiet" set-global
     f output-stream set-global ;
 
+: compute-next-methods ( -- )
+    [ standard-generic? ] instances [
+        "methods" word-prop [
+            nip
+            dup next-method-quot "next-method-quot" set-word-prop
+        ] assoc-each
+    ] each
+    "resource:basis/tools/deploy/shaker/next-methods.factor" run-file ;
+
 : strip ( -- )
     init-stripper
     strip-libc
     strip-cocoa
     strip-debugger
+    compute-next-methods
     strip-init-hooks
     strip-c-io
     f 5 setenv ! we can't use the Factor debugger or Factor I/O anymore
@@ -382,8 +384,7 @@ SYMBOL: deploy-vocab
     r> strip-words
     compress-byte-arrays
     compress-quotations
-    compress-strings
-    H{ } clone classes:next-method-quot-cache set-global ;
+    compress-strings ;
 
 : (deploy) ( final-image vocab config -- )
     #! Does the actual work of a deployment in the slave
index bdcc6c237eef7fe05114b9d66907172a58df6108..db7eb63bbfae62dfafd2542667f02e891aa6b345 100644 (file)
@@ -1,9 +1,13 @@
 USING: compiler.units words vocabs kernel threads.private ;
 IN: debugger
 
-: print-error ( error -- ) die drop ;
+: consume ( error -- )
+    #! We don't want DCE to drop the error before the die call!
+    drop ;
 
-: error. ( error -- ) die drop ;
+: print-error ( error -- ) die consume ;
+
+: error. ( error -- ) die consume ;
 
 "threads" vocab [
     [
diff --git a/basis/tools/deploy/test/7/7.factor b/basis/tools/deploy/test/7/7.factor
new file mode 100644 (file)
index 0000000..a16e3c8
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math namespaces ;
+IN: tools.deploy.test.7
+
+SYMBOL: my-var
+
+GENERIC: my-generic ( x -- b )
+
+M: integer my-generic sq ;
+
+M: fixnum my-generic call-next-method my-var get call ;
+
+: test-7 ( -- )
+    [ 1 + ] my-var set-global
+    12 my-generic 145 assert= ;
+
+MAIN: test-7
diff --git a/basis/tools/deploy/test/7/deploy.factor b/basis/tools/deploy/test/7/deploy.factor
new file mode 100644 (file)
index 0000000..bc374f1
--- /dev/null
@@ -0,0 +1,15 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-threads? t }
+    { deploy-word-props? f }
+    { deploy-ui? f }
+    { deploy-io 2 }
+    { deploy-math? t }
+    { "stop-after-last-window?" t }
+    { deploy-compiler? t }
+    { deploy-unicode? f }
+    { deploy-c-types? f }
+    { deploy-reflection 1 }
+    { deploy-word-defs? f }
+    { deploy-name "tools.deploy.test.7" }
+}
index 5c2bd8f4e322b77575e76c63428ba2abbd485e90..73b261bf13cb5de80c26dc7112ad4d2d2a53c752 100644 (file)
@@ -49,7 +49,7 @@ SYMBOL: this-test
     [ drop t ] must-fail-with ;
 
 : (run-test) ( vocab -- )
-    dup vocab-source-loaded? [
+    dup vocab source-loaded?>> [
         vocab-tests [ run-file ] each
     ] [ drop ] if ;
 
index 1901f27a24507e2512d93a1f956aaaa0d2f05714..e1907c6d91fb7d575f2cb507af988c2a5c7938f3 100755 (executable)
@@ -1 +1,2 @@
 Slava Pestov
+Eduardo Cavazos
index 3765efb863d3ead079da730ac790c64b5f52768b..6c5fb596e89ca0f38c06e8c26de015961deed4cb 100644 (file)
@@ -1,7 +1,13 @@
 USING: help.markup help.syntax io strings ;
 IN: tools.vocabs.browser
 
+ARTICLE: "vocab-tags" "Vocabulary tags"
+{ $all-tags } ;
+
+ARTICLE: "vocab-authors" "Vocabulary authors"
+{ $all-authors } ;
+
 ARTICLE: "vocab-index" "Vocabulary index"
-{ $tags }
-{ $authors }
+{ $subsection "vocab-tags" }
+{ $subsection "vocab-authors" }
 { $describe-vocab "" } ;
index c3296df280e4f7584d6336f2cd47508c3911cb0e..cfc541d9bc45912f1d9c0e0be13da3805d8a59bd 100644 (file)
@@ -1,9 +1,12 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel combinators vocabs vocabs.loader
-tools.vocabs io io.files io.styles help.markup help.stylesheet
-sequences assocs help.topics namespaces prettyprint words
-sorting definitions arrays summary sets generic ;
+USING: accessors arrays assocs classes classes.builtin
+classes.intersection classes.mixin classes.predicate
+classes.singleton classes.tuple classes.union combinators
+definitions effects fry generic help help.markup
+help.stylesheet help.topics io io.files io.styles kernel macros
+make namespaces prettyprint sequences sets sorting summary
+tools.vocabs vocabs vocabs.loader words ;
 IN: tools.vocabs.browser
 
 : vocab-status-string ( vocab -- string )
@@ -18,9 +21,9 @@ IN: tools.vocabs.browser
 
 : vocab. ( vocab -- )
     [
-        dup [ write-status ] with-cell
-        dup [ ($link) ] with-cell
-        [ vocab-summary write ] with-cell
+        [ [ write-status ] with-cell ]
+        [ [ ($link) ] with-cell ]
+        [ [ vocab-summary write ] with-cell ] tri
     ] with-row ;
 
 : vocab-headings. ( -- )
@@ -34,35 +37,25 @@ IN: tools.vocabs.browser
     [ "Children from " prepend ] [ "Children" ] if*
     $heading ;
 
-: vocabs. ( assoc -- )
+: $vocabs ( assoc -- )
     [
-        [
-            drop
-        ] [
-            swap root-heading.
-            standard-table-style [
-                vocab-headings. [ vocab. ] each
-            ] ($grid)
+        [ drop ] [
+            [ root-heading. ]
+            [
+                standard-table-style [
+                    vocab-headings. [ vocab. ] each
+                ] ($grid)
+            ] bi*
         ] if-empty
     ] assoc-each ;
 
-: describe-summary ( vocab -- )
-    vocab-summary [
-        "Summary" $heading print-element
-    ] when* ;
-
 TUPLE: vocab-tag name ;
 
 INSTANCE: vocab-tag topic
 
 C: <vocab-tag> vocab-tag
 
-: tags. ( seq -- ) [ <vocab-tag> ] map $links ;
-
-: describe-tags ( vocab -- )
-    vocab-tags f like [
-        "Tags" $heading tags.
-    ] when* ;
+: $tags ( seq -- ) [ <vocab-tag> ] map $links ;
 
 TUPLE: vocab-author name ;
 
@@ -70,20 +63,18 @@ INSTANCE: vocab-author topic
 
 C: <vocab-author> vocab-author
 
-: authors. ( seq -- ) [ <vocab-author> ] map $links ;
-
-: describe-authors ( vocab -- )
-    vocab-authors f like [
-        "Authors" $heading authors.
-    ] when* ;
+: $authors ( seq -- ) [ <vocab-author> ] map $links ;
 
 : describe-help ( vocab -- )
-    vocab-help [
-        "Documentation" $heading ($link)
-    ] when* ;
+    [
+        dup vocab-help
+        [ "Documentation" $heading ($link) ]
+        [ "Summary" $heading vocab-summary print-element ]
+        ?if
+    ] unless-empty ;
 
 : describe-children ( vocab -- )
-    vocab-name all-child-vocabs vocabs. ;
+    vocab-name all-child-vocabs $vocabs ;
 
 : describe-files ( vocab -- )
     vocab-files [ <pathname> ] map [
@@ -95,50 +86,167 @@ C: <vocab-author> vocab-author
                 ] with-nesting
             ] with-style
         ] ($block)
-    ] when* ;
+    ] unless-empty ;
 
-: describe-words ( vocab -- )
-    words [
-        "Words" $heading
-        natural-sort $links
+: describe-tuple-classes ( classes -- )
+    [
+        "Tuple classes" $subheading
+        [
+            [ <$link> ]
+            [ superclass <$link> ]
+            [ "slots" word-prop [ name>> ] map " " join \ $snippet swap 2array ]
+            tri 3array
+        ] map
+        { { $strong "Class" } { $strong "Superclass" } { $strong "Slots" } } prefix
+        $table
+    ] unless-empty ;
+
+: describe-predicate-classes ( classes -- )
+    [
+        "Predicate classes" $subheading
+        [
+            [ <$link> ]
+            [ superclass <$link> ]
+            bi 2array
+        ] map
+        { { $strong "Class" } { $strong "Superclass" } } prefix
+        $table
+    ] unless-empty ;
+
+: (describe-classes) ( classes heading -- )
+    '[
+        _ $subheading
+        [ <$link> 1array ] map $table
+    ] unless-empty ;
+
+: describe-builtin-classes ( classes -- )
+    "Builtin classes" (describe-classes) ;
+
+: describe-singleton-classes ( classes -- )
+    "Singleton classes" (describe-classes) ;
+
+: describe-mixin-classes ( classes -- )
+    "Mixin classes" (describe-classes) ;
+
+: describe-union-classes ( classes -- )
+    "Union classes" (describe-classes) ;
+
+: describe-intersection-classes ( classes -- )
+    "Intersection classes" (describe-classes) ;
+
+: describe-classes ( classes -- )
+    [ builtin-class? ] partition
+    [ tuple-class? ] partition
+    [ singleton-class? ] partition
+    [ predicate-class? ] partition
+    [ mixin-class? ] partition
+    [ union-class? ] partition
+    [ intersection-class? ] filter
+    {
+        [ describe-builtin-classes ]
+        [ describe-tuple-classes ]
+        [ describe-singleton-classes ]
+        [ describe-predicate-classes ]
+        [ describe-mixin-classes ]
+        [ describe-union-classes ]
+        [ describe-intersection-classes ]
+    } spread ;
+
+: word-syntax ( word -- string/f )
+    \ $syntax swap word-help elements dup length 1 =
+    [ first second ] [ drop f ] if ;
+
+: describe-parsing ( words -- )
+    [
+        "Parsing words" $subheading
+        [
+            [ <$link> ]
+            [ word-syntax dup [ \ $snippet swap 2array ] when ]
+            bi 2array
+        ] map
+        { { $strong "Word" } { $strong "Syntax" } } prefix
+        $table
     ] unless-empty ;
 
-: vocab-xref ( vocab quot -- vocabs )
-    >r dup vocab-name swap words [ generic? not ] filter r> map
-    [ [ word? ] filter [ vocabulary>> ] map ] gather natural-sort
-    remove sift ; inline
+: (describe-words) ( words heading -- )
+    '[
+        _ $subheading
+        [
+            [ <$link> ]
+            [ stack-effect dup [ effect>string \ $snippet swap 2array ] when ]
+            bi 2array
+        ] map
+        { { $strong "Word" } { $strong "Stack effect" } } prefix
+        $table
+    ] unless-empty ;
+
+: describe-generics ( words -- )
+    "Generic words" (describe-words) ;
+
+: describe-macros ( words -- )
+    "Macro words" (describe-words) ;
 
-: vocab-uses ( vocab -- vocabs ) [ uses ] vocab-xref ;
+: describe-primitives ( words -- )
+    "Primitives" (describe-words) ;
 
-: vocab-usage ( vocab -- vocabs ) [ usage ] vocab-xref ;
+: describe-compounds ( words -- )
+    "Ordinary words" (describe-words) ;
 
-: describe-uses ( vocab -- )
-    vocab-uses [
-        "Uses" $heading
-        $vocab-links
+: describe-predicates ( words -- )
+    "Class predicate words" (describe-words) ;
+
+: describe-symbols ( words -- )
+    [
+        "Symbol words" $subheading
+        [ <$link> 1array ] map $table
     ] unless-empty ;
 
-: describe-usage ( vocab -- )
-    vocab-usage [
-        "Used by" $heading
-        $vocab-links
+: describe-words ( vocab -- )
+    words [
+        "Words" $heading
+
+        natural-sort
+        [ [ class? ] filter describe-classes ]
+        [
+            [ [ class? ] [ symbol? ] bi and not ] filter
+            [ parsing-word? ] partition
+            [ generic? ] partition
+            [ macro? ] partition
+            [ symbol? ] partition
+            [ primitive? ] partition
+            [ predicate? ] partition swap
+            {
+                [ describe-parsing ]
+                [ describe-generics ]
+                [ describe-macros ]
+                [ describe-symbols ]
+                [ describe-primitives ]
+                [ describe-compounds ]
+                [ describe-predicates ]
+            } spread
+        ] bi
     ] unless-empty ;
 
+: words. ( vocab -- )
+    last-element off
+    vocab-name describe-words ;
+
+: describe-metadata ( vocab -- )
+    [
+        [ vocab-tags [ "Tags:" swap \ $tags prefix 2array , ] unless-empty ]
+        [ vocab-authors [ "Authors:" swap \ $authors prefix 2array , ] unless-empty ]
+        bi
+    ] { } make
+    [ "Meta-data" $heading $table ] unless-empty ;
+
 : $describe-vocab ( element -- )
-    first
-    dup describe-children
-    dup find-vocab-root [
-        dup describe-summary
-        dup describe-tags
-        dup describe-authors
-        dup describe-files
-    ] when
-    dup vocab [
-        dup describe-help
-        dup describe-words
-        dup describe-uses
-        dup describe-usage
-    ] when drop ;
+    first {
+        [ describe-help ]
+        [ describe-metadata ]
+        [ describe-words ]
+        [ describe-files ]
+        [ describe-children ]
+    } cleave ;
 
 : keyed-vocabs ( str quot -- seq )
     all-vocabs [
@@ -154,16 +262,16 @@ C: <vocab-author> vocab-author
     [ vocab-authors ] keyed-vocabs ;
 
 : $tagged-vocabs ( element -- )
-    first tagged vocabs. ;
+    first tagged $vocabs ;
 
 : $authored-vocabs ( element -- )
-    first authored vocabs. ;
+    first authored $vocabs ;
 
-: $tags ( element -- )
-    drop "Tags" $heading all-tags tags. ;
+: $all-tags ( element -- )
+    drop "Tags" $heading all-tags $tags ;
 
-: $authors ( element -- )
-    drop "Authors" $heading all-authors authors. ;
+: $all-authors ( element -- )
+    drop "Authors" $heading all-authors $authors ;
 
 INSTANCE: vocab topic
 
index b929c62e0452438de5f363abc9725bde0be1f8ae..d926b670786abc526be01ea0d427e0ec86b14a41 100644 (file)
@@ -4,9 +4,31 @@ USING: kernel io io.styles io.files io.encodings.utf8
 vocabs.loader vocabs sequences namespaces make math.parser\r
 arrays hashtables assocs memoize summary sorting splitting\r
 combinators source-files debugger continuations compiler.errors\r
-init checksums checksums.crc32 sets accessors ;\r
+init checksums checksums.crc32 sets accessors generic\r
+definitions words ;\r
 IN: tools.vocabs\r
 \r
+: vocab-xref ( vocab quot -- vocabs )\r
+    [ [ vocab-name ] [ words [ generic? not ] filter ] bi ] dip map\r
+    [\r
+        [ [ word? ] [ generic? not ] bi and ] filter [\r
+            dup method-body?\r
+            [ "method-generic" word-prop ] when\r
+            vocabulary>>\r
+        ] map\r
+    ] gather natural-sort remove sift ; inline\r
+\r
+: vocabs. ( seq -- )\r
+    [ dup >vocab-link write-object nl ] each ;\r
+\r
+: vocab-uses ( vocab -- vocabs ) [ uses ] vocab-xref ;\r
+\r
+: vocab-uses. ( vocab -- ) vocab-uses vocabs. ;\r
+\r
+: vocab-usage ( vocab -- vocabs ) [ usage ] vocab-xref ;\r
+\r
+: vocab-usage. ( vocab -- ) vocab-usage vocabs. ;\r
+\r
 : vocab-tests-file ( vocab -- path )\r
     dup "-tests.factor" vocab-dir+ vocab-append-path dup\r
     [ dup exists? [ drop f ] unless ] [ drop f ] if ;\r
@@ -112,12 +134,12 @@ SYMBOL: modified-docs
             [\r
                 [\r
                     [ modified-sources ]\r
-                    [ vocab-source-loaded? ]\r
+                    [ vocab source-loaded?>> ]\r
                     [ vocab-source-path ]\r
                     tri (to-refresh)\r
                 ] [\r
                     [ modified-docs ]\r
-                    [ vocab-docs-loaded? ]\r
+                    [ vocab docs-loaded?>> ]\r
                     [ vocab-docs-path ]\r
                     tri (to-refresh)\r
                 ] bi\r
@@ -132,8 +154,8 @@ SYMBOL: modified-docs
 : do-refresh ( modified-sources modified-docs unchanged -- )\r
     unchanged-vocabs\r
     [\r
-        [ [ f swap set-vocab-source-loaded? ] each ]\r
-        [ [ f swap set-vocab-docs-loaded? ] each ] bi*\r
+        [ [ vocab f >>source-loaded? drop ] each ]\r
+        [ [ vocab f >>docs-loaded? drop ] each ] bi*\r
     ]\r
     [\r
         append prune\r
index 9775bdff81a057b3ae8180dfb2e23e25af38b8d3..1d26567952e34a30e6a3cc660edeea52efc23094 100644 (file)
@@ -83,7 +83,7 @@ M: object add-breakpoint ;
 : (step-into-continuation) ( -- )
     continuation callstack >>call break ;
 
-: (step-into-call-next-method) ( class generic -- )
+: (step-into-call-next-method) ( method -- )
     next-method-quot (step-into-quot) ;
 
 ! Messages sent to walker thread
index 1a05d23aa0648ed7d40a826a5c5dff99c600bd83..9ff3a59f71bbd8c75847f65cfad4db67682b1eae 100644 (file)
@@ -15,9 +15,7 @@ C: <handle> handle
 SINGLETON: cocoa-ui-backend
 
 M: cocoa-ui-backend do-events ( -- )
-    [
-        [ NSApp [ do-event ] curry loop ui-wait ] ui-try
-    ] with-autorelease-pool ;
+    [ NSApp [ do-event ] curry loop ui-wait ] with-autorelease-pool ;
 
 TUPLE: pasteboard handle ;
 
index c6942a815836b282d727a202014bcb28552f6157..82a31ad0d9ec354231371ffb7bbfe94e3e389a34 100644 (file)
@@ -18,8 +18,8 @@ IN: ui.cocoa.views
     {
         { S+ HEX: 20000 }
         { C+ HEX: 40000 }
-        { A+ HEX: 80000 }
-        { M+ HEX: 100000 }
+        { A+ HEX: 100000 }
+        { M+ HEX: 80000 }
     } ;
 
 : key-codes
@@ -59,29 +59,26 @@ IN: ui.cocoa.views
 : key-event>gesture ( event -- modifiers keycode action? )
     dup event-modifiers swap key-code ;
 
-: send-key-event ( view event quot -- ? )
-    >r key-event>gesture r> call swap window-focus
-    send-gesture ; inline
-
-: send-user-input ( view string -- )
-    CF>string swap window-focus user-input ;
+: send-key-event ( view gesture -- )
+    swap window-focus propagate-gesture ;
 
 : interpret-key-event ( view event -- )
     NSArray swap -> arrayWithObject: -> interpretKeyEvents: ;
 
 : send-key-down-event ( view event -- )
-    2dup [ <key-down> ] send-key-event
-    [ interpret-key-event ] [ 2drop ] if ;
+    [ key-event>gesture <key-down> send-key-event ]
+    [ interpret-key-event ]
+    2bi ;
 
 : send-key-up-event ( view event -- )
-    [ <key-up> ] send-key-event drop ;
+    key-event>gesture <key-up> send-key-event ;
 
 : mouse-event>gesture ( event -- modifiers button )
     dup event-modifiers swap button ;
 
 : send-button-down$ ( view event -- )
-    [ mouse-event>gesture <button-down> ] 2keep
-    mouse-location rot window send-button-down ;
+    [ mouse-event>gesture <button-down> ]
+    [ mouse-location rot window send-button-down ] 2bi ;
 
 : send-button-up$ ( view event -- )
     [ mouse-event>gesture <button-up> ] 2keep
@@ -138,83 +135,83 @@ CLASS: {
 }
 
 { "mouseEntered:" "void" { "id" "SEL" "id" }
-    [ [ nip send-mouse-moved ] ui-try ]
+    [ nip send-mouse-moved ]
 }
 
 { "mouseExited:" "void" { "id" "SEL" "id" }
-    [ [ 3drop forget-rollover ] ui-try ]
+    [ 3drop forget-rollover ]
 }
 
 { "mouseMoved:" "void" { "id" "SEL" "id" }
-    [ [ nip send-mouse-moved ] ui-try ]
+    [ nip send-mouse-moved ]
 }
 
 { "mouseDragged:" "void" { "id" "SEL" "id" }
-    [ [ nip send-mouse-moved ] ui-try ]
+    [ nip send-mouse-moved ]
 }
 
 { "rightMouseDragged:" "void" { "id" "SEL" "id" }
-    [ [ nip send-mouse-moved ] ui-try ]
+    [ nip send-mouse-moved ]
 }
 
 { "otherMouseDragged:" "void" { "id" "SEL" "id" }
-    [ [ nip send-mouse-moved ] ui-try ]
+    [ nip send-mouse-moved ]
 }
 
 { "mouseDown:" "void" { "id" "SEL" "id" }
-    [ [ nip send-button-down$ ] ui-try ]
+    [ nip send-button-down$ ]
 }
 
 { "mouseUp:" "void" { "id" "SEL" "id" }
-    [ [ nip send-button-up$ ] ui-try ]
+    [ nip send-button-up$ ]
 }
 
 { "rightMouseDown:" "void" { "id" "SEL" "id" }
-    [ [ nip send-button-down$ ] ui-try ]
+    [ nip send-button-down$ ]
 }
 
 { "rightMouseUp:" "void" { "id" "SEL" "id" }
-    [ [ nip send-button-up$ ] ui-try ]
+    [ nip send-button-up$ ]
 }
 
 { "otherMouseDown:" "void" { "id" "SEL" "id" }
-    [ [ nip send-button-down$ ] ui-try ]
+    [ nip send-button-down$ ]
 }
 
 { "otherMouseUp:" "void" { "id" "SEL" "id" }
-    [ [ nip send-button-up$ ] ui-try ]
+    [ nip send-button-up$ ]
 }
 
 { "scrollWheel:" "void" { "id" "SEL" "id" }
-    [ [ nip send-wheel$ ] ui-try ]
+    [ nip send-wheel$ ]
 }
 
 { "keyDown:" "void" { "id" "SEL" "id" }
-    [ [ nip send-key-down-event ] ui-try ]
+    [ nip send-key-down-event ]
 }
 
 { "keyUp:" "void" { "id" "SEL" "id" }
-    [ [ nip send-key-up-event ] ui-try ]
+    [ nip send-key-up-event ]
 }
 
 { "cut:" "id" { "id" "SEL" "id" }
-    [ [ nip T{ cut-action } send-action$ ] ui-try ]
+    [ nip T{ cut-action } send-action$ ]
 }
 
 { "copy:" "id" { "id" "SEL" "id" }
-    [ [ nip T{ copy-action } send-action$ ] ui-try ]
+    [ nip T{ copy-action } send-action$ ]
 }
 
 { "paste:" "id" { "id" "SEL" "id" }
-    [ [ nip T{ paste-action } send-action$ ] ui-try ]
+    [ nip T{ paste-action } send-action$ ]
 }
 
 { "delete:" "id" { "id" "SEL" "id" }
-    [ [ nip T{ delete-action } send-action$ ] ui-try ]
+    [ nip T{ delete-action } send-action$ ]
 }
 
 { "selectAll:" "id" { "id" "SEL" "id" }
-    [ [ nip T{ select-all-action } send-action$ ] ui-try ]
+    [ nip T{ select-all-action } send-action$ ]
 }
 
 ! Multi-touch gestures: this is undocumented.
@@ -290,7 +287,7 @@ CLASS: {
 
 ! Text input
 { "insertText:" "void" { "id" "SEL" "id" }
-    [ [ nip send-user-input ] ui-try ]
+    [ nip CF>string swap window-focus user-input ]
 }
 
 { "hasMarkedText" "char" { "id" "SEL" }
@@ -335,11 +332,11 @@ CLASS: {
 
 ! Initialization
 { "updateFactorGadgetSize:" "void" { "id" "SEL" "id" }
-    [
-        [
-            2drop dup view-dim swap window (>>dim) yield
-        ] ui-try
-    ]
+    [ 2drop dup view-dim swap window (>>dim) yield ]
+}
+
+{ "doCommandBySelector:" "void" { "id" "SEL" "SEL" }
+    [ 3drop ]
 }
 
 { "initWithFrame:pixelFormat:" "id" { "id" "SEL" "NSRect" "id" }
index 5f1ff6dabd71dcce0e8d676d1cd657d97628671d..78b82a345c211ab150d32f4128e7977ff774a27b 100644 (file)
@@ -8,7 +8,7 @@ IN: ui.commands
         [ gesture>string , ]
         [
             [ command-name , ]
-            [ command-word \ $link swap 2array , ]
+            [ command-word <$link> , ]
             [ command-description , ]
             tri
         ] bi*
index d74284cbd6bb2c3eba523f6f3200d7e69c004e9a..88d957f8ccd688cfda00d69ba16c5e27158281e6 100644 (file)
@@ -2,10 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays kernel math models namespaces sequences
 strings quotations assocs combinators classes colors
-classes.tuple opengl opengl.gl math.vectors ui.commands ui.gadgets
-ui.gadgets.borders ui.gadgets.labels ui.gadgets.theme
-ui.gadgets.tracks ui.gadgets.packs ui.gadgets.worlds ui.gestures
-ui.render math.geometry.rect locals alien.c-types ;
+classes.tuple locals alien.c-types fry opengl opengl.gl
+math.vectors ui.commands ui.gadgets ui.gadgets.borders
+ui.gadgets.labels ui.gadgets.theme ui.gadgets.tracks
+ui.gadgets.packs ui.gadgets.worlds ui.gestures ui.render
+math.geometry.rect ;
 IN: ui.gadgets.buttons
 
 TUPLE: button < border pressed? selected? quot ;
@@ -27,7 +28,7 @@ TUPLE: button < border pressed? selected? quot ;
     relayout-1 ;
 
 : if-clicked ( button quot -- )
-    >r dup button-update dup button-rollover? r> [ drop ] if ;
+    [ dup button-update dup button-rollover? ] dip [ drop ] if ;
 
 : button-clicked ( button -- ) dup quot>> if-clicked ;
 
@@ -70,6 +71,7 @@ M: button-paint draw-boundary
 
 : roll-button-theme ( button -- button )
     f black <solid> dup f <button-paint> >>boundary
+    f f pressed-gradient f <button-paint> >>interior
     align-left ; inline
 
 : <roll-button> ( label quot -- button )
@@ -219,9 +221,8 @@ M: radio-control model-changed
     over value>> = >>selected?
     relayout-1 ;
 
-: <radio-controls> ( parent model assoc quot -- parent )
-    #! quot has stack effect ( value model label -- )
-    swapd [ swapd call add-gadget ] 2curry assoc-each ; inline
+: <radio-controls> ( assoc model parent quot: ( value model label -- ) -- parent )
+    '[ _ swap _ call add-gadget ] assoc-each ; inline
 
 : radio-button-theme ( gadget -- gadget )
     { 5 5 } >>gap
@@ -232,8 +233,7 @@ M: radio-control model-changed
 
 : <radio-buttons> ( model assoc -- gadget )
     <filled-pile>
-        -rot
-        [ <radio-button> ] <radio-controls>
+        spin [ <radio-button> ] <radio-controls>
         { 5 5 } >>gap ;
 
 : <toggle-button> ( value model label -- gadget )
@@ -241,20 +241,19 @@ M: radio-control model-changed
 
 : <toggle-buttons> ( model assoc -- gadget )
     <shelf>
-        -rot
-        [ <toggle-button> ] <radio-controls> ;
+        spin [ <toggle-button> ] <radio-controls> ;
 
 : command-button-quot ( target command -- quot )
-    [ invoke-command drop ] 2curry ;
+    '[ _ _ invoke-command drop ] ;
 
 : <command-button> ( target gesture command -- button )
-    [ command-string ] keep
-    swapd
-    command-button-quot
-    <bevel-button> ;
+    [ command-string swap ] keep command-button-quot <bevel-button> ;
 
 : <toolbar> ( target -- toolbar )
     <shelf>
         swap
         "toolbar" over class command-map commands>> swap
-        [ -rot <command-button> add-gadget ] curry assoc-each ;
+        '[ [ _ ] 2dip <command-button> add-gadget ] assoc-each ;
+
+: add-toolbar ( track -- track )
+    dup <toolbar> f track-add ;
index 2cf6d2415442bd31c4452d82aab80bcdf056cf8f..856795e4edbb36e93ea51af99a35579240075eb5 100644 (file)
@@ -2,17 +2,17 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays documents io kernel math models
 namespaces make opengl opengl.gl sequences strings io.styles
-math.vectors sorting colors combinators assocs math.order
-ui.clipboards ui.commands ui.gadgets ui.gadgets.borders
-ui.gadgets.buttons ui.gadgets.labels ui.gadgets.scrollers
-ui.gadgets.theme ui.gadgets.wrappers ui.render ui.gestures
-math.geometry.rect ;
+math.vectors sorting colors combinators assocs math.order fry
+calendar alarms ui.clipboards ui.commands ui.gadgets
+ui.gadgets.borders ui.gadgets.buttons ui.gadgets.labels
+ui.gadgets.scrollers ui.gadgets.theme ui.gadgets.wrappers
+ui.render ui.gestures math.geometry.rect ;
 IN: ui.gadgets.editors
 
 TUPLE: editor < gadget
 font color caret-color selection-color
 caret mark
-focused? ;
+focused? blink blink-alarm ;
 
 : <loc> ( -- loc ) { 0 0 } <model> ;
 
@@ -45,6 +45,28 @@ focused? ;
     dup deactivate-model
     swap model>> remove-loc ;
 
+: blink-caret ( editor -- )
+    [ not ] change-blink relayout-1 ;
+
+SYMBOL: blink-interval
+
+750 milliseconds blink-interval set-global
+
+: start-blinking ( editor -- )
+    t >>blink
+    dup '[ _ blink-caret ] blink-interval get every >>blink-alarm drop ;
+
+: stop-blinking ( editor -- )
+    [ [ cancel-alarm ] when* f ] change-blink-alarm drop ;
+
+: restart-blinking ( editor -- )
+    dup focused?>> [
+        [ stop-blinking ]
+        [ start-blinking ]
+        [ relayout-1 ]
+        tri
+    ] [ drop ] if ;
+
 M: editor graft*
     dup
     dup caret>> activate-editor-model
@@ -52,6 +74,7 @@ M: editor graft*
 
 M: editor ungraft*
     dup
+    dup stop-blinking
     dup caret>> deactivate-editor-model
     dup mark>> deactivate-editor-model ;
 
@@ -64,14 +87,14 @@ M: editor ungraft*
     caret>> set-model ;
 
 : change-caret ( editor quot -- )
-    over >r >r dup editor-caret* swap model>> r> call r>
+    [ [ [ editor-caret* ] [ model>> ] bi ] dip call ] [ drop ] 2bi
     set-caret ; inline
 
 : mark>caret ( editor -- )
-    dup editor-caret* swap mark>> set-model ;
+    [ editor-caret* ] [ mark>> ] bi set-model ;
 
 : change-caret&mark ( editor quot -- )
-    over >r change-caret r> mark>caret ; inline
+    [ change-caret ] [ drop mark>caret ] 2bi ; inline
 
 : editor-line ( n editor -- str ) control-value nth ;
 
@@ -85,8 +108,8 @@ M: editor ungraft*
 
 : point>loc ( point editor -- loc )
     [
-        >r first2 r> tuck y>line dup ,
-        >r dup editor-font* r>
+        [ first2 ] dip tuck y>line dup ,
+        [ dup editor-font* ] dip
         rot editor-line x>offset ,
     ] { } make ;
 
@@ -94,11 +117,17 @@ M: editor ungraft*
     [ hand-rel ] keep point>loc ;
 
 : click-loc ( editor model -- )
-    >r clicked-loc r> set-model ;
+    [ clicked-loc ] dip set-model ;
 
-: focus-editor ( editor -- ) t >>focused? relayout-1 ;
+: focus-editor ( editor -- )
+    dup start-blinking
+    t >>focused?
+    relayout-1 ;
 
-: unfocus-editor ( editor -- ) f >>focused? relayout-1 ;
+: unfocus-editor ( editor -- )
+    dup stop-blinking
+    f >>focused?
+    relayout-1 ;
 
 : (offset>x) ( font col# str -- x )
     swap head-slice string-width ;
@@ -106,7 +135,7 @@ M: editor ungraft*
 : offset>x ( col# line# editor -- x )
     [ editor-line ] keep editor-font* -rot (offset>x) ;
 
-: loc>x ( loc editor -- x ) >r first2 swap r> offset>x ;
+: loc>x ( loc editor -- x ) [ first2 swap ] dip offset>x ;
 
 : line>y ( lines# editor -- y )
     line-height * ;
@@ -120,12 +149,13 @@ M: editor ungraft*
 
 : scroll>caret ( editor -- )
     dup graft-state>> second [
-        dup caret-loc over caret-dim <rect>
-        over scroll>rect
-    ] when drop ;
+        [
+            [ caret-loc ] [ caret-dim { 1 0 } v+ ] bi <rect>
+        ] keep scroll>rect
+    ] [ drop ] if ;
 
 : draw-caret ( -- )
-    editor get focused?>> [
+    editor get [ focused?>> ] [ blink>> ] bi and [
         editor get
         [ caret-color>> gl-color ]
         [
@@ -142,7 +172,7 @@ M: editor ungraft*
     line-translation gl-translate ;
 
 : draw-line ( editor str -- )
-    >r font>> r> { 0 0 } draw-string ;
+    [ font>> ] dip { 0 0 } draw-string ;
 
 : first-visible-line ( editor -- n )
     clip get rect-loc second origin get second -
@@ -168,7 +198,7 @@ M: editor ungraft*
     rot control-value <slice> ;
 
 : with-editor-translation ( n quot -- )
-    >r line-translation origin get v+ r> with-translation ;
+    [ line-translation origin get v+ ] dip with-translation ;
     inline
 
 : draw-lines ( -- )
@@ -198,7 +228,7 @@ M: editor ungraft*
     editor get selection-start/end
     over first [
         2dup [
-            >r 2dup r> draw-selected-line
+            [ 2dup ] dip draw-selected-line
             1 translate-lines
         ] each-line 2drop
     ] with-editor-translation ;
@@ -216,7 +246,7 @@ M: editor pref-dim*
     drop relayout ;
 
 : caret/mark-changed ( model editor -- )
-    nip [ relayout-1 ] [ scroll>caret ] bi ;
+    nip [ restart-blinking ] [ scroll>caret ] bi ;
 
 M: editor model-changed
     {
@@ -246,7 +276,9 @@ M: editor user-input*
 M: editor gadget-text* editor-string % ;
 
 : extend-selection ( editor -- )
-    dup request-focus dup caret>> click-loc ;
+    dup request-focus
+    dup restart-blinking
+    dup caret>> click-loc ;
 
 : mouse-elt ( -- element )
     hand-click# get {
@@ -258,14 +290,15 @@ M: editor gadget-text* editor-string % ;
     editor-mark* before? ;
 
 : drag-selection-caret ( loc editor element -- loc )
-    >r [ drag-direction? ] 2keep
-    model>>
-    r> prev/next-elt ? ;
+    [
+        [ drag-direction? ] 2keep model>>
+    ] dip prev/next-elt ? ;
 
 : drag-selection-mark ( loc editor element -- loc )
-    >r [ drag-direction? not ] 2keep
-    nip dup editor-mark* swap model>>
-    r> prev/next-elt ? ;
+    [
+        [ drag-direction? not ] keep
+        [ editor-mark* ] [ model>> ] bi
+    ] dip prev/next-elt ? ;
 
 : drag-caret&mark ( editor -- caret mark )
     dup clicked-loc swap mouse-elt
@@ -284,15 +317,16 @@ M: editor gadget-text* editor-string % ;
     over gadget-selection? [
         drop nip remove-selection
     ] [
-        over >r >r dup editor-caret* swap model>>
-        r> call r> model>> remove-doc-range
+        [ [ [ editor-caret* ] [ model>> ] bi ] dip call ]
+        [ drop model>> ]
+        2bi remove-doc-range
     ] if ; inline
 
 : editor-delete ( editor elt -- )
-    swap [ over >r rot next-elt r> swap ] delete/backspace ;
+    swap [ over [ rot next-elt ] dip swap ] delete/backspace ;
 
 : editor-backspace ( editor elt -- )
-    swap [ over >r rot prev-elt r> ] delete/backspace ;
+    swap [ over [ rot prev-elt ] dip ] delete/backspace ;
 
 : editor-select-prev ( editor elt -- )
     swap [ rot prev-elt ] change-caret ;
@@ -310,9 +344,8 @@ M: editor gadget-text* editor-string % ;
     tuck caret>> set-model mark>> set-model ;
 
 : select-elt ( editor elt -- )
-    over >r
-    >r dup editor-caret* swap model>> r> prev/next-elt
-    r> editor-select ;
+    [ [ [ editor-caret* ] [ model>> ] bi ] dip prev/next-elt ] [ drop ] 2bi
+    editor-select ;
 
 : start-of-document ( editor -- ) T{ doc-elt } editor-prev ;
 
@@ -323,7 +356,7 @@ M: editor gadget-text* editor-string % ;
     [ drop dup extend-selection dup mark>> click-loc ]
     [ select-elt ] if ;
 
-: insert-newline ( editor -- ) "\n" swap user-input ;
+: insert-newline ( editor -- ) "\n" swap user-input* drop ;
 
 : delete-next-character ( editor -- ) 
     T{ char-elt } editor-delete ;
@@ -452,7 +485,7 @@ editor "caret-motion" f {
     T{ doc-elt } editor-select-next ;
 
 editor "selection" f {
-    { T{ button-down f { S+ } } extend-selection }
+    { T{ button-down f { S+ } } extend-selection }
     { T{ drag } drag-selection }
     { T{ gain-focus } focus-editor }
     { T{ lose-focus } unfocus-editor }
index c210d1b7e2c40e7976f9c646ae6df9d904c78704..b5c373689623436c7ac6e28cae770d156ae35f4f 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2005, 2007 Slava Pestov.
+! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic kernel math namespaces sequences words
 splitting grouping math.vectors ui.gadgets.grids ui.gadgets
@@ -11,16 +11,16 @@ TUPLE: frame < grid ;
 
 : <frame-grid> ( -- grid ) 9 [ <gadget> ] replicate 3 group ;
 
-: @center 1 1 ;
-: @left 0 1 ;
-: @right 2 1 ;
-: @top 1 0 ;
-: @bottom 1 2 ;
+: @center 1 1 ; inline
+: @left 0 1 ; inline
+: @right 2 1 ; inline
+: @top 1 0 ; inline
+: @bottom 1 2 ; inline
 
-: @top-left 0 0 ;
-: @top-right 2 0 ;
-: @bottom-left 0 2 ;
-: @bottom-right 2 2 ;
+: @top-left 0 0 ; inline
+: @top-right 2 0 ; inline
+: @bottom-left 0 2 ; inline
+: @bottom-right 2 2 ; inline
 
 : new-frame ( class -- frame )
     <frame-grid> swap new-grid ; inline
@@ -28,13 +28,12 @@ TUPLE: frame < grid ;
 : <frame> ( -- frame )
     frame new-frame ;
 
-: (fill-center) ( vec n -- )
-    over first pick third v+ [v-] 1 rot set-nth ;
+: (fill-center) ( n vec -- )
+    [ [ first ] [ third ] bi v+ [v-] ] keep set-second ;
 
-: fill-center ( horiz vert dim -- )
-    tuck (fill-center) (fill-center) ;
+: fill-center ( dim horiz vert -- )
+    [ over ] dip [ (fill-center) ] 2bi@ ;
 
 M: frame layout*
     dup compute-grid
-    [ rot rect-dim fill-center ] 3keep
-    grid-layout ;
+    [ [ rect-dim ] 2dip fill-center ] [ grid-layout ] 3bi ;
index a18571d472e8eb9152618ca4143b352de4f93e54..7d33ec21fdadd8e5da4b74fd009d7a7ac880cf08 100644 (file)
@@ -10,11 +10,9 @@ SYMBOL: ui-notify-flag
 
 : notify-ui-thread ( -- ) ui-notify-flag get-global raise-flag ;
 
-TUPLE: gadget < rect
-       pref-dim parent children orientation focus
-       visible? root? clipped? layout-state graft-state graft-node
-       interior boundary
-       model ;
+TUPLE: gadget < rect pref-dim parent children orientation focus
+visible? root? clipped? layout-state graft-state graft-node
+interior boundary model ;
 
 M: gadget equal? 2drop f ;
 
diff --git a/basis/ui/gadgets/labels/labels-tests.factor b/basis/ui/gadgets/labels/labels-tests.factor
new file mode 100644 (file)
index 0000000..a9b5074
--- /dev/null
@@ -0,0 +1,9 @@
+USING: accessors tools.test ui.gadgets ui.gadgets.labels ;
+IN: ui.gadgets.labels.tests
+
+[ { 119 14 } ] [
+    <gadget> { 100 14 } >>dim
+    <gadget> { 14 14 } >>dim
+    label-on-right { 5 5 } >>gap
+    pref-dim
+] unit-test
index 109c0a14618123391300f436f7a8d3d550ec0778..8627f7fbfe2b72f0b560f0507f7b0095c8d700ce 100644 (file)
@@ -40,7 +40,7 @@ IN: ui.gadgets.panes.tests
 [ t ] [ [ [ 1 2 3 ] pprint ] test-gadget-text ] unit-test
 [ t ] [ [ \ + describe ] test-gadget-text ] unit-test
 [ t ] [ [ \ = see ] test-gadget-text ] unit-test
-[ t ] [ [ \ = help ] test-gadget-text ] unit-test
+[ t ] [ [ \ = print-topic ] test-gadget-text ] unit-test
 
 [ t ] [
     [
@@ -84,16 +84,16 @@ ARTICLE: "test-article-1" "This is a test article"
 
 [ t ] [ [ "test-article-1" $title ] test-gadget-text ] unit-test
 
-[ t ] [ [ "test-article-1" help ] test-gadget-text ] unit-test
+[ t ] [ [ "test-article-1" print-topic ] test-gadget-text ] unit-test
 
 ARTICLE: "test-article-2" "This is a test article"
 "Hello world, how are you today."
 { $table { "a" "b" } { "c" "d" } } ;
 
-[ t ] [ [ "test-article-2" help ] test-gadget-text ] unit-test
+[ t ] [ [ "test-article-2" print-topic ] test-gadget-text ] unit-test
 
 <pane> [ \ = see ] with-pane
-<pane> [ \ = help ] with-pane
+<pane> [ \ = print-topic ] with-pane
 
 [ ] [
     \ = <model> [ see ] <pane-control> [ ] with-grafted-gadget
index ef5745809e06ea94eddf47ce6a0b1733ea0881a7..c612cbef0ad815f40d5697c0d83c1613af1abcc9 100644 (file)
@@ -10,7 +10,6 @@ io.streams.nested assocs ui.gadgets.presentations
 ui.gadgets.slots ui.gadgets.grids ui.gadgets.grid-lines
 classes.tuple models continuations destructors accessors
 math.geometry.rect ;
-
 IN: ui.gadgets.panes
 
 TUPLE: pane < pack
@@ -363,7 +362,11 @@ M: f sloppy-pick-up*
     dup hand-rel over sloppy-pick-up >>caret
     dup relayout-1 ;
 
-: begin-selection ( pane -- ) move-caret f >>mark drop ;
+: begin-selection ( pane -- )
+    f >>selecting?
+    move-caret
+    f >>mark
+    drop ;
 
 : extend-selection ( pane -- )
     hand-moved? [
@@ -389,6 +392,7 @@ M: f sloppy-pick-up*
     ] if ;
 
 : select-to-caret ( pane -- )
+    t >>selecting?
     dup mark>> [ caret>mark ] unless
     move-caret
     dup request-focus
@@ -397,7 +401,7 @@ M: f sloppy-pick-up*
 pane H{
     { T{ button-down } [ begin-selection ] }
     { T{ button-down f { S+ } 1 } [ select-to-caret ] }
-    { T{ button-up f { S+ } 1 } [ drop ] }
+    { T{ button-up f { S+ } 1 } [ end-selection ] }
     { T{ button-up } [ end-selection ] }
     { T{ drag } [ extend-selection ] }
     { T{ copy-action } [ com-copy ] }
index 625bfd7880a8a65b25b1f74502483e28b5330a33..d6792abd49993f631da1f376d6445a8972c8cfdd 100644 (file)
@@ -2,7 +2,8 @@ USING: ui.gadgets ui.gadgets.scrollers namespaces tools.test
 kernel models models.compose models.range ui.gadgets.viewports
 ui.gadgets.labels ui.gadgets.grids ui.gadgets.frames
 ui.gadgets.sliders math math.vectors arrays sequences
-tools.test.ui math.geometry.rect accessors ;
+tools.test.ui math.geometry.rect accessors ui.gadgets.buttons
+ui.gadgets.packs ;
 IN: ui.gadgets.scrollers.tests
 
 [ ] [
@@ -74,7 +75,7 @@ dup layout
         "g2" get scroll>gadget
         "s" get layout
         "s" get scroller-value
-    ] map [ { 3 0 } = ] all?
+    ] map [ { 2 0 } = ] all?
 ] unit-test
 
 [ ] [ "Hi" <label> dup "l" set <scroller> "s" set ] unit-test
@@ -86,4 +87,22 @@ dup layout
 [ t ] [ "s" get @right grid-child slider? ] unit-test
 [ f ] [ "s" get @right grid-child find-scroller* ] unit-test
 
+[ ] [
+    "Click Me" [ [ scroll>gadget ] [ unparent ] bi ] <bevel-button>
+    [ <pile> swap add-gadget <scroller> ] keep
+    dup quot>> call
+    layout
+] unit-test
+
+[ t ] [
+    <gadget> { 200 200 } >>dim
+    [ [ scroll>gadget ] [ unparent ] bi ] <bevel-button>
+    dup
+    <pile> swap add-gadget <scroller> { 100 100 } >>dim dup layout
+    swap dup quot>> call
+    dup layout
+    model>> dependencies>> [ range-max value>> ] map
+    viewport-gap 2 v*n =
+] unit-test
+
 \ <scroller> must-infer
index d1429c40065a13d7ddf0df5fd6f11dfd3cdbd704..37f6e83e0cc2ff3378b5fcf154bb47abb098d6ec 100644 (file)
@@ -3,9 +3,8 @@
 USING: accessors arrays ui.gadgets ui.gadgets.viewports
 ui.gadgets.frames ui.gadgets.grids ui.gadgets.theme
 ui.gadgets.sliders ui.gestures kernel math namespaces sequences
-models models.range models.compose
-combinators math.vectors classes.tuple math.geometry.rect
-combinators.short-circuit ;
+models models.range models.compose combinators math.vectors
+classes.tuple math.geometry.rect combinators.short-circuit ;
 IN: ui.gadgets.scrollers
 
 TUPLE: scroller < frame viewport x y follows ;
@@ -22,9 +21,10 @@ TUPLE: scroller < frame viewport x y follows ;
 : scroll-down-line ( scroller -- ) y>> 1 swap slide-by-line ;
 
 : do-mouse-scroll ( scroller -- )
-    scroll-direction get-global first2
-    pick y>> slide-by-line
-    swap x>> slide-by-line ;
+    scroll-direction get-global
+    [ first swap x>> slide-by-line ]
+    [ second swap y>> slide-by-line ]
+    2bi ;
 
 scroller H{
     { T{ mouse-scroll } [ do-mouse-scroll ] }
@@ -43,30 +43,29 @@ scroller H{
         dup model>> dependencies>> second <y-slider> >>y dup y>> @right  grid-add
 
         tuck model>> <viewport> >>viewport
-        dup viewport>> @center grid-add ;
+        dup viewport>> @center grid-add ; inline
 
 : <scroller> ( gadget -- scroller ) scroller new-scroller ;
 
 : scroll ( value scroller -- )
     [
-        dup viewport>> rect-dim { 0 0 }
-        rot viewport>> viewport-dim 4array flip
+        viewport>> [ rect-dim { 0 0 } ] [ viewport-dim ] bi
+        4array flip
     ] keep
     2dup control-value = [ 2drop ] [ set-control-value ] if ;
 
-: rect-min ( rect1 rect2 -- rect )
-    >r [ rect-loc ] keep r> [ rect-dim ] bi@ vmin <rect> ;
+: rect-min ( rect dim -- rect' )
+    [ [ loc>> ] [ dim>> ] bi ] dip vmin <rect> ;
 
 : (scroll>rect) ( rect scroller -- )
-    [
-        scroller-value vneg offset-rect
-        viewport-gap offset-rect
-    ] keep
-    [ viewport>> rect-min ] keep
-    [
-        viewport>> 2rect-extent
-        >r >r v- { 0 0 } vmin r> r> v- { 0 0 } vmax v+
-    ] keep dup scroller-value rot v+ swap scroll ;
+    [ [ loc>> { 1 1 } v- ] [ dim>> { 1 1 } v+ ] bi <rect> ] dip
+    {
+        [ scroller-value vneg offset-rect viewport-gap offset-rect ]
+        [ viewport>> dim>> rect-min ]
+        [ viewport>> 2rect-extent [ v- { 0 0 } vmin ] [ v- { 0 0 } vmax ] 2bi* v+ ]
+        [ scroller-value v+ ]
+        [ scroll ]
+    } cleave ;
 
 : relative-scroll-rect ( rect gadget scroller -- newrect )
     viewport>> gadget-child relative-loc offset-rect ;
@@ -81,14 +80,17 @@ scroller H{
         [ relative-scroll-rect ] keep
         swap >>follows
         relayout
-    ] [
-        3drop
-    ] if ;
+    ] [ 3drop ] if ;
+
+: (update-scroller) ( scroller -- )
+    [ scroller-value ] keep scroll ;
 
 : (scroll>gadget) ( gadget scroller -- )
-    >r { 0 0 } over pref-dim <rect> swap r>
-    [ relative-scroll-rect ] keep
-    (scroll>rect) ;
+    2dup swap child? [
+        [ [ pref-dim { 0 0 } swap <rect> ] keep ] dip
+        [ relative-scroll-rect ] keep
+        (scroll>rect)
+    ] [ f >>follows (update-scroller) drop ] if ;
 
 : scroll>gadget ( gadget -- )
     dup find-scroller* dup [
@@ -99,7 +101,7 @@ scroller H{
     ] if ;
 
 : (scroll>bottom) ( scroller -- )
-    dup viewport>> viewport-dim { 0 1 } v* swap scroll ;
+    [ viewport>> viewport-dim { 0 1 } v* ] keep scroll ;
 
 : scroll>bottom ( gadget -- )
     find-scroller [ t >>follows relayout-1 ] when* ;
@@ -115,24 +117,26 @@ M: gadget update-scroller swap (scroll>gadget) ;
 
 M: rect update-scroller swap (scroll>rect) ;
 
-M: f update-scroller drop dup scroller-value swap scroll ;
+M: f update-scroller drop (update-scroller) ;
 
 M: scroller layout*
-    dup call-next-method
-    dup follows>>
-    2dup update-scroller
-    >>follows drop ;
+    [ call-next-method ] [
+        dup follows>>
+        [ update-scroller ] [ >>follows drop ] 2bi
+    ] bi ; 
 
 M: scroller focusable-child*
     viewport>> ;
 
 M: scroller model-changed
-    nip f >>follows drop ;
+    f >>follows 2drop ;
 
-TUPLE: limited-scroller < scroller fixed-dim ;
+TUPLE: limited-scroller < scroller
+{ min-dim initial: { 0 0 } }
+{ max-dim initial: { 1/0. 1/0. } } ;
 
-: <limited-scroller> ( gadget dim -- scroller )
-    >r limited-scroller new-scroller r> >>fixed-dim ;
+: <limited-scroller> ( gadget -- scroller )
+    limited-scroller new-scroller ;
 
 M: limited-scroller pref-dim*
-    fixed-dim>> ;
+    [ call-next-method ] [ min-dim>> vmax ] [ max-dim>> vmin ] tri ;
index 1cf23e2d061bcb93a5e111b1f84ad14a6f5ca155..e04b288a5d747feb9eaae7c0f6a8173c94a0ccfc 100644 (file)
@@ -26,10 +26,10 @@ TUPLE: slot-editor < track ref text ;
 GENERIC: finish-editing ( slot-editor ref -- )
 
 M: key-ref finish-editing
-    drop T{ update-object } swap send-gesture drop ;
+    drop T{ update-object } swap propagate-gesture ;
 
 M: value-ref finish-editing
-    drop T{ update-slot } swap send-gesture drop ;
+    drop T{ update-slot } swap propagate-gesture ;
 
 : slot-editor-value ( slot-editor -- object )
     text>> control-value parse-fresh ;
@@ -55,14 +55,14 @@ M: value-ref finish-editing
 
 : delete ( slot-editor -- )
     dup ref>> delete-ref
-    T{ update-object } swap send-gesture drop ;
+    T{ update-object } swap propagate-gesture ;
 
 \ delete H{
     { +description+ "Delete the slot and close the slot editor." }
 } define-command
 
 : close ( slot-editor -- )
-    T{ update-slot } swap send-gesture drop ;
+    T{ update-slot } swap propagate-gesture ;
 
 \ close H{
     { +description+ "Close the slot editor without saving changes." }
@@ -71,7 +71,7 @@ M: value-ref finish-editing
 : <slot-editor> ( ref -- gadget )
     { 0 1 } slot-editor new-track
         swap >>ref
-        dup <toolbar> f track-add
+        add-toolbar
         <source-editor> >>text
         dup text>> <scroller> 1 track-add
         dup revert ;
@@ -92,7 +92,7 @@ TUPLE: editable-slot < track printer ref ;
 
 : <edit-button> ( -- gadget )
     "..."
-    [ T{ edit-slot } swap send-gesture drop ]
+    [ T{ edit-slot } swap propagate-gesture ]
     <roll-button> ;
 
 : display-slot ( gadget editable-slot -- )
index 93f2d145282fe25f7bd651cccaf3a093702badb0..5381eebb015c518be4d87f8445ed3a8d35e10a40 100644 (file)
@@ -14,3 +14,10 @@ IN: ui.gadgets.tracks.tests
         <gadget> { 100 100 } >>dim 1 track-add
     pref-dim
 ] unit-test
+
+[ { 10 10 } ] [
+    { 0 1 } <track>
+        <gadget> { 10 10 } >>dim 1 track-add
+        <gadget> { 10 10 } >>dim 0 track-add
+    pref-dim
+] unit-test
index 5a9683ceff80f83ccd399cf021fa08961e6f1e63..ddc7cf18fd21b122f02f00d39b10196177e6f4d5 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors io kernel math namespaces
-       sequences words math.vectors ui.gadgets ui.gadgets.packs
-       math.geometry.rect fry ;
+USING: accessors io kernel namespaces fry
+math math.vectors math.geometry.rect math.order
+sequences words ui.gadgets ui.gadgets.packs ;
 
 IN: ui.gadgets.tracks
 
@@ -35,13 +35,17 @@ TUPLE: track < pack sizes ;
 
 M: track layout* ( track -- ) dup track-layout pack-layout ;
 
-: track-pref-dims-1 ( track -- dim ) children>> pref-dims max-dim ;
+: track-pref-dims-1 ( track -- dim )
+    children>> pref-dims max-dim ;
 
 : track-pref-dims-2 ( track -- dim )
-    [ children>> pref-dims ] [ normalized-sizes ] bi
-    [ [ v/n ] when* ] 2map
-    max-dim
-    [ >fixnum ] map ;
+    [
+        [ children>> pref-dims ] [ normalized-sizes ] bi
+        [ dup { 0 f } memq? [ drop ] [ v/n ] if ] 2map
+        max-dim [ >fixnum ] map
+    ]
+    [ [ gap>> ] [ children>> length 1 [-] ] bi v*n ] bi
+    v+ ;
 
 M: track pref-dim* ( gadget -- dim )
     [ track-pref-dims-1 ]
index 5f714a526b222845c7715532a4c830f4d231fece..f01ef3bf426cfef5d8d9de15dacd03938f49ae2e 100644 (file)
@@ -21,9 +21,11 @@ TUPLE: viewport < gadget ;
         swap add-gadget ;
 
 M: viewport layout*
-    dup rect-dim viewport-gap 2 v*n v-
-    over gadget-child pref-dim vmax
-    swap gadget-child (>>dim) ;
+    [
+        [ rect-dim viewport-gap 2 v*n v- ]
+        [ gadget-child pref-dim ]
+        bi vmax
+    ] [ gadget-child ] bi (>>dim) ;
 
 M: viewport focusable-child*
     gadget-child ;
index 6f901c37ee4f787cbe0e754299ce456784c72279..904a2a5bac29f259b687b735a25f80e4f4fc17d1 100644 (file)
@@ -30,7 +30,7 @@ ERROR: no-world-found ;
 
 : (request-focus) ( child world ? -- )
     pick parent>> pick eq? [
-        >r >r dup parent>> dup r> r>
+        [ dup parent>> dup ] 2dip
         [ (request-focus) ] keep
     ] unless focus-child ;
 
@@ -80,7 +80,7 @@ SYMBOL: ui-error-hook
 : ui-error ( error -- )
     ui-error-hook get [ call ] [ print-error ] if* ;
 
-[ rethrow ] ui-error-hook set-global
+ui-error-hook global [ [ rethrow ] or ] change-at
 
 : draw-world ( world -- )
     dup draw-world? [
@@ -103,10 +103,29 @@ world H{
     { T{ key-down f { C+ } "a" } [ T{ select-all-action } send-action ] }
     { T{ button-down f { C+ } 1 } [ drop T{ button-down f f 3 } button-gesture ] }
     { T{ button-down f { A+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
+    { T{ button-down f { M+ } 1 } [ drop T{ button-down f f 2 } button-gesture ] }
     { T{ button-up f { C+ } 1 } [ drop T{ button-up f f 3 } button-gesture ] }
     { T{ button-up f { A+ } 1 } [ drop T{ button-up f f 2 } button-gesture ] }
+    { T{ button-up f { M+ } 1 } [ drop T{ button-up f f 2 } button-gesture ] }
 } set-gestures
 
+PREDICATE: specific-button-up < button-up #>> ;
+PREDICATE: specific-button-down < button-down #>> ;
+PREDICATE: specific-drag < drag #>> ;
+
+: generalize-gesture ( gesture -- )
+    clone f >># button-gesture ;
+
+M: world handle-gesture ( gesture gadget -- ? )
+    2dup call-next-method [
+        {
+            { [ over specific-button-up? ] [ drop generalize-gesture f ] }
+            { [ over specific-button-down? ] [ drop generalize-gesture f ] }
+            { [ over specific-drag? ] [ drop generalize-gesture f ] }
+            [ 2drop t ]
+        } cond
+    ] [ 2drop f ] if ;
+
 : close-global ( world global -- )
     dup get-global find-world rot eq?
     [ f swap set-global ] [ drop ] if ;
index 1db0d04f43baed15e01a9046279dd2dc216bb2aa..1e472e921f0591ca9d8d8ada303af57a7f52f318 100644 (file)
@@ -15,14 +15,14 @@ $nl
 "The default implementation looks at the " { $snippet "\"gestures\"" } " word property of each superclass of the gadget's class." }
 { $notes "Methods should be defined on this word if you desire to handle an arbitrary set of gestures. To define handlers for a fixed set, it is easier to use " { $link set-gestures } "." } ;
 
-{ send-gesture handle-gesture set-gestures } related-words
+{ propagate-gesture handle-gesture set-gestures } related-words
 
-HELP: send-gesture
-{ $values { "gesture" "a gesture" } { "gadget" gadget } { "?" "a boolean" } }
-{ $description "Calls " { $link send-gesture } " on every parent of " { $snippet "gadget" } ". Outputs " { $link f } " if some parent handled the gesture, else outputs " { $link t } "." } ;
+HELP: propagate-gesture
+{ $values { "gesture" "a gesture" } { "gadget" gadget } }
+{ $description "Calls " { $link handle-gesture } " on every parent of " { $snippet "gadget" } "." } ;
 
 HELP: user-input
-{ $values { "str" string } { "gadget" gadget } }
+{ $values { "string" string } { "gadget" gadget } }
 { $description "Calls " { $link user-input* } " on every parent of the gadget." } ;
 
 HELP: motion
@@ -90,10 +90,6 @@ HELP: select-all-action
 { $class-description "Gesture sent when the " { $emphasis "select all" } " standard window system action is invoked." }
 { $examples { $code "T{ select-all-action }" } } ;
 
-HELP: generalize-gesture
-{ $values { "gesture" "a gesture" } { "newgesture" "a new gesture" } }
-{ $description "Turns a " { $link button-down } ", " { $link button-up } " or " { $link drag } " action naming a specific mouse button into one which can apply regardless of which mouse button was pressed." } ;
-
 HELP: C+
 { $description "Control key modifier." } ;
 
index e37bea538f6a232969c1ff1c2cc8efde3003af6f..e4a600f252372dff9c4291d41a75de88b0c35ec8 100644 (file)
@@ -2,12 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs kernel math models namespaces
 make sequences words strings system hashtables math.parser
-math.vectors classes.tuple classes ui.gadgets boxes calendar
-alarms symbols combinators sets columns ;
+math.vectors classes.tuple classes  boxes calendar
+alarms symbols combinators sets columns fry deques ui.gadgets ;
 IN: ui.gestures
 
-: set-gestures ( class hash -- ) "gestures" set-word-prop ;
-
 GENERIC: handle-gesture ( gesture gadget -- ? )
 
 M: object handle-gesture
@@ -15,13 +13,42 @@ M: object handle-gesture
     [ "gestures" word-prop ] map
     assoc-stack dup [ call f ] [ 2drop t ] if ;
 
-: send-gesture ( gesture gadget -- ? )
-    [ dupd handle-gesture ] each-parent nip ;
+: set-gestures ( class hash -- ) "gestures" set-word-prop ;
+
+: gesture-queue ( -- deque ) \ gesture-queue get ;
+
+GENERIC: send-queued-gesture ( request -- )
+
+TUPLE: send-gesture gesture gadget ;
+
+M: send-gesture send-queued-gesture
+    [ gesture>> ] [ gadget>> ] bi handle-gesture drop ;
+
+: queue-gesture ( ... class -- )
+    boa gesture-queue push-front notify-ui-thread ; inline
+
+: send-gesture ( gesture gadget -- )
+    \ send-gesture queue-gesture ;
+
+: each-gesture ( gesture seq -- ) [ send-gesture ] with each ;
 
-: user-input ( str gadget -- )
-    over empty?
-    [ [ dupd user-input* ] each-parent ] unless
-    2drop ;
+TUPLE: propagate-gesture gesture gadget ;
+
+M: propagate-gesture send-queued-gesture
+    [ gesture>> ] [ gadget>> ] bi
+    [ handle-gesture ] with each-parent drop ;
+
+: propagate-gesture ( gesture gadget -- )
+    \ propagate-gesture queue-gesture ;
+
+TUPLE: user-input string gadget ;
+
+M: user-input send-queued-gesture
+    [ string>> ] [ gadget>> ] bi
+    [ user-input* ] with each-parent drop ;
+
+: user-input ( string gadget -- )
+    '[ _ \ user-input queue-gesture ] unless-empty ;
 
 ! Gesture objects
 TUPLE: motion ;             C: <motion> motion
@@ -46,11 +73,8 @@ TUPLE: right-action ;       C: <right-action> right-action
 TUPLE: up-action ;          C: <up-action> up-action
 TUPLE: down-action ;        C: <down-action> down-action
 
-TUPLE: zoom-in-action ;  C: <zoom-in-action> zoom-in-action
-TUPLE: zoom-out-action ; C: <zoom-out-action> zoom-out-action
-
-: generalize-gesture ( gesture -- newgesture )
-    clone f >># ;
+TUPLE: zoom-in-action ;     C: <zoom-in-action> zoom-in-action
+TUPLE: zoom-out-action ;    C: <zoom-out-action> zoom-out-action
 
 ! Modifiers
 SYMBOLS: C+ A+ M+ S+ ;
@@ -58,7 +82,7 @@ SYMBOLS: C+ A+ M+ S+ ;
 TUPLE: key-down mods sym ;
 
 : <key-gesture> ( mods sym action? class -- mods' sym' )
-    >r [ S+ rot remove swap ] unless r> boa ; inline
+    [ [ [ S+ swap remove f like ] dip ] unless ] dip boa ; inline
 
 : <key-down> ( mods sym action? -- key-down )
     key-down <key-gesture> ;
@@ -100,11 +124,7 @@ SYMBOL: double-click-timeout
     hand-loc get hand-click-loc get = not ;
 
 : button-gesture ( gesture -- )
-    hand-clicked get-global 2dup send-gesture [
-        >r generalize-gesture r> send-gesture drop
-    ] [
-        2drop
-    ] if ;
+    hand-clicked get-global propagate-gesture ;
 
 : drag-gesture ( -- )
     hand-buttons get-global
@@ -130,14 +150,11 @@ SYMBOL: drag-timer
 
 : fire-motion ( -- )
     hand-buttons get-global empty? [
-        T{ motion } hand-gadget get-global send-gesture drop
+        T{ motion } hand-gadget get-global propagate-gesture
     ] [
         drag-gesture
     ] if ;
 
-: each-gesture ( gesture seq -- )
-    [ handle-gesture drop ] with each ;
-
 : hand-gestures ( new old -- )
     drop-prefix <reversed>
     T{ mouse-leave } swap each-gesture
@@ -145,15 +162,15 @@ SYMBOL: drag-timer
 
 : forget-rollover ( -- )
     f hand-world set-global
-    hand-gadget get-global >r
-    f hand-gadget set-global
-    f r> parents hand-gestures ;
+    hand-gadget get-global
+    [ f hand-gadget set-global f ] dip
+    parents hand-gestures ;
 
 : send-lose-focus ( gadget -- )
-    T{ lose-focus } swap handle-gesture drop ;
+    T{ lose-focus } swap send-gesture ;
 
 : send-gain-focus ( gadget -- )
-    T{ gain-focus } swap handle-gesture drop ;
+    T{ gain-focus } swap send-gesture ;
 
 : focus-child ( child gadget ? -- )
     [
@@ -219,9 +236,11 @@ SYMBOL: drag-timer
 
 : move-hand ( loc world -- )
     dup hand-world set-global
-    under-hand >r over hand-loc set-global
-    pick-up hand-gadget set-global
-    under-hand r> hand-gestures ;
+    under-hand [
+        over hand-loc set-global
+        pick-up hand-gadget set-global
+        under-hand
+    ] dip hand-gestures ;
 
 : send-button-down ( gesture loc world -- )
     move-hand
@@ -240,14 +259,13 @@ SYMBOL: drag-timer
 : send-wheel ( direction loc world -- )
     move-hand
     scroll-direction set-global
-    T{ mouse-scroll } hand-gadget get-global send-gesture
-    drop ;
+    T{ mouse-scroll } hand-gadget get-global propagate-gesture ;
 
 : world-focus ( world -- gadget )
     dup focus>> [ world-focus ] [ ] ?if ;
 
 : send-action ( world gesture -- )
-    swap world-focus send-gesture drop ;
+    swap world-focus propagate-gesture ;
 
 GENERIC: gesture>string ( gesture -- string/f )
 
index 83a3b7ff68a4f9a393348a2ebf52623c9d2a2365..becb401fa618e234a01f11548d4e956e8b126538 100644 (file)
@@ -4,17 +4,17 @@ USING: debugger ui.tools.workspace help help.topics kernel
 models models.history ui.commands ui.gadgets ui.gadgets.panes
 ui.gadgets.scrollers ui.gadgets.tracks ui.gestures
 ui.gadgets.buttons compiler.units assocs words vocabs
-accessors ;
+accessors fry combinators.short-circuit ;
 IN: ui.tools.browser
 
 TUPLE: browser-gadget < track pane history ;
 
 : show-help ( link help -- )
-    dup history>> add-history
-    >r >link r> history>> set-model ;
+    history>> dup add-history
+    [ >link ] dip set-model ;
 
 : <help-pane> ( browser-gadget -- gadget )
-    history>> [ [ help ] curry try ] <pane-control> ;
+    history>> [ '[ _ print-topic ] try ] <pane-control> ;
 
 : init-history ( browser-gadget -- )
     "handbook" >link <history> >>history drop ;
@@ -22,7 +22,7 @@ TUPLE: browser-gadget < track pane history ;
 : <browser-gadget> ( -- gadget )
     { 0 1 } browser-gadget new-track
         dup init-history
-        dup <toolbar> f track-add
+        add-toolbar
         dup <help-pane> >>pane
         dup pane>> <scroller> 1 track-add ;
 
@@ -38,10 +38,11 @@ M: browser-gadget ungraft*
     [ call-next-method ] [ remove-definition-observer ] bi ;
 
 : showing-definition? ( defspec assoc -- ? )
-    [ key? ] 2keep
-    [ >r dup word-link? [ name>> ] when r> key? ] 2keep
-    >r dup vocab-link? [ vocab ] when r> key?
-    or or ;
+    {
+        [ key? ]
+        [ [ dup word-link? [ name>> ] when ] dip key? ]
+        [ [ dup vocab-link? [ vocab ] when ] dip key? ]
+    } 2|| ;
 
 M: browser-gadget definitions-changed ( assoc browser -- )
     history>>
@@ -66,10 +67,10 @@ M: browser-gadget definitions-changed ( assoc browser -- )
 \ browser-help H{ { +nullary+ t } } define-command
 
 browser-gadget "toolbar" f {
-    { T{ key-down f { A+ } "b" } com-back }
-    { T{ key-down f { A+ } "f" } com-forward }
-    { T{ key-down f { A+ } "h" } com-documentation }
-    { T{ key-down f { A+ } "v" } com-vocabularies }
+    { T{ key-down f { A+ } "LEFT" } com-back }
+    { T{ key-down f { A+ } "RIGHT" } com-forward }
+    { f com-documentation }
+    { f com-vocabularies }
     { T{ key-down f f "F1" } browser-help }
 } define-command-map
 
index 12a2e0d806177817904674a1b7b28e9e1080ab8c..94c118953de612c4c8f1e57884f40802fc05c09c 100644 (file)
@@ -8,7 +8,7 @@ HELP: <debugger>
     "Creates a gadget displaying a description of the error, along with buttons to print the contents of the stacks in the listener, and a list of restarts."
 } ;
 
-{ <debugger> debugger-window ui-try } related-words
+{ <debugger> debugger-window } related-words
 
 HELP: debugger-window
 { $values { "error" "an error" } }
index 4ba4374bb8e5c10ac3ed347623d52f6531df575e..641763c0b13babcd404d0c474f4b6a2c8362e12d 100644 (file)
@@ -25,7 +25,7 @@ TUPLE: debugger < track restarts ;
 
 : <debugger> ( error restarts restart-hook -- gadget )
     { 0 1 } debugger new-track
-        dup <toolbar> f track-add
+        add-toolbar
         -rot <restart-list> >>restarts
         dup restarts>> rot <debugger-display> <scroller> 1 track-add ;
 
@@ -35,7 +35,15 @@ M: debugger focusable-child* restarts>> ;
     #! No restarts for the debugger window
     f [ drop ] <debugger> "Error" open-window ;
 
-[ debugger-window ] ui-error-hook set-global
+GENERIC: error-in-debugger? ( error -- ? )
+
+M: world-error error-in-debugger? world>> gadget-child debugger? ;
+
+M: object error-in-debugger? drop f ;
+
+[
+    dup error-in-debugger? [ rethrow ] [ debugger-window ] if 
+] ui-error-hook set-global
 
 M: world-error error.
     "An error occurred while drawing the world " write
index 0ac89e122f6d23d1355860f54c347506fe5259ae..f310f727808432a937ad14c7ac1d5aaeb253c995 100644 (file)
@@ -96,9 +96,12 @@ TUPLE: deploy-gadget < pack vocab settings ;
 : com-close ( gadget -- )
     close-window ;
 
+deploy-gadget "misc" "Miscellaneous commands" {
+    { T{ key-down f f "ESC" } com-close }
+} define-command-map
+
 deploy-gadget "toolbar" f {
-    { f com-close }
-    { f com-help }
+    { T{ key-down f f "F1" } com-help }
     { f com-revert }
     { f com-save }
     { T{ key-down f f "RET" } com-deploy }
index dcb3a3f8adc361e73c828d3ebee4f9af34e46cc2..579210325b26d96fc4931a1c067e580daecfea50 100644 (file)
@@ -17,7 +17,7 @@ TUPLE: inspector-gadget < track object pane ;
 
 : <inspector-gadget> ( -- gadget )
     { 0 1 } inspector-gadget new-track
-        dup <toolbar> f track-add
+        add-toolbar
         <pane> >>pane
         dup pane>> <scroller> 1 track-add ;
 
index a36610a7f532cafa85a3ebd5f09f3bed5cdd6773..5739a469ea7b7554ad734f9ca59965f803449b20 100644 (file)
@@ -164,7 +164,7 @@ M: interactor dispose drop ;
 : handle-interactive ( lines interactor -- quot/f ? )
     tuck try-parse {
         { [ dup quotation? ] [ nip t ] }
-        { [ dup not ] [ drop "\n" swap user-input f f ] }
+        { [ dup not ] [ drop "\n" swap user-input* drop f f ] }
         [ handle-parse-error f f ]
     } cond ;
 
@@ -178,10 +178,6 @@ M: interactor stream-read-quot
         ]
     } cond ;
 
-M: interactor pref-dim*
-    [ line-height 4 * 0 swap 2array ] [ call-next-method ] bi
-    vmax ;
-
 interactor "interactor" f {
     { T{ key-down f f "RET" } evaluate-input }
     { T{ key-down f { C+ } "k" } clear-input }
index d842bf8a68f673f6675faf8078d4c3f9d8d313a5..1fe2d8eb24b574bf2bd991e86934acb2f13a8f2b 100644 (file)
@@ -1,20 +1,17 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: inspector ui.tools.interactor ui.tools.inspector
-ui.tools.workspace help.markup io io.styles
-kernel models namespaces parser quotations sequences ui.commands
-ui.gadgets ui.gadgets.editors ui.gadgets.labelled
-ui.gadgets.panes ui.gadgets.buttons ui.gadgets.scrollers
-ui.gadgets.tracks ui.gestures ui.operations vocabs words
-prettyprint listener debugger threads boxes concurrency.flags
-math arrays generic accessors combinators assocs ;
+USING: inspector help help.markup io io.styles kernel models
+namespaces parser quotations sequences vocabs words prettyprint
+listener debugger threads boxes concurrency.flags math arrays
+generic accessors combinators assocs fry ui.commands ui.gadgets
+ui.gadgets.editors ui.gadgets.labelled ui.gadgets.panes
+ui.gadgets.buttons ui.gadgets.scrollers ui.gadgets.packs
+ui.gadgets.tracks ui.gadgets.borders ui.gestures ui.operations
+ui.tools.browser ui.tools.interactor ui.tools.inspector
+ui.tools.workspace ;
 IN: ui.tools.listener
 
-TUPLE: listener-gadget < track input output stack ;
-
-: listener-output, ( listener -- listener )
-    <scrolling-pane> >>output
-    dup output>> <scroller> "Output" <labelled-gadget> 1 track-add ;
+TUPLE: listener-gadget < track input output ;
 
 : listener-streams ( listener -- input output )
     [ input>> ] [ output>> <pane-stream> ] bi ;
@@ -22,16 +19,10 @@ TUPLE: listener-gadget < track input output stack ;
 : <listener-input> ( listener -- gadget )
     output>> <pane-stream> <interactor> ;
 
-: listener-input, ( listener -- listener )
-    dup <listener-input> >>input
-    dup input>>
-        { 0 100 } <limited-scroller>
-        "Input" <labelled-gadget>
-    f track-add ;
-
 : welcome. ( -- )
     "If this is your first time with Factor, please read the " print
-    "handbook" ($link) "." print nl ;
+    "handbook" ($link) ". To see a list of keyboard shortcuts," print
+    "press F1." print nl ;
 
 M: listener-gadget focusable-child*
     input>> ;
@@ -58,7 +49,7 @@ M: listener-gadget tool-scroller
 
 : call-listener ( quot -- )
     [ workspace-busy? not ] get-workspace* listener>>
-    [ dup wait-for-listener (call-listener) ] 2curry
+    '[ _ _ dup wait-for-listener (call-listener) ]
     "Listener call" spawn drop ;
 
 M: listener-command invoke-command ( target command -- )
@@ -74,7 +65,7 @@ M: listener-operation invoke-command ( target command -- )
 
 : listener-run-files ( seq -- )
     [
-        [ [ run-file ] each ] curry call-listener
+        '[ _ [ run-file ] each ] call-listener
     ] unless-empty ;
 
 : com-end ( listener -- )
@@ -110,7 +101,7 @@ M: engine-word word-completion-string
 
 : insert-word ( word -- )
     get-workspace listener>> input>>
-    [ >r word-completion-string r> user-input ]
+    [ >r word-completion-string r> user-input* drop ]
     [ interactor-use use-if-necessary ]
     2bi ;
 
@@ -120,20 +111,8 @@ M: engine-word word-completion-string
     [ select-all ]
     2bi ;
 
-TUPLE: stack-display < track ;
-
-: <stack-display> ( workspace -- gadget )
-    listener>>
-    { 0 1 } stack-display new-track
-    over <toolbar> f track-add
-    swap stack>> [ [ stack. ] curry try ] t "Data stack" <labelled-pane>
-    1 track-add ;
-
-M: stack-display tool-scroller
-    find-workspace listener>> tool-scroller ;
-
-: ui-listener-hook ( listener -- )
-    >r datastack r> stack>> set-model ;
+: ui-help-hook ( topic -- )
+    browser-gadget call-tool ;
 
 : ui-error-hook ( error listener -- )
     find-workspace debugger-popup ;
@@ -144,17 +123,20 @@ M: stack-display tool-scroller
 
 : listener-thread ( listener -- )
     dup listener-streams [
-        [ [ ui-listener-hook ] curry listener-hook set ]
-        [ [ ui-error-hook ] curry error-hook set ]
-        [ [ ui-inspector-hook ] curry inspector-hook set ] tri
+        [ ui-help-hook ] help-hook set
+        [ '[ _ ui-error-hook ] error-hook set ]
+        [ '[ _ ui-inspector-hook ] inspector-hook set ] bi
         welcome.
         listener
     ] with-streams* ;
 
 : start-listener-thread ( listener -- )
-    [
-        [ input>> register-self ] [ listener-thread ] bi
-    ] curry "Listener" spawn drop ;
+    '[
+        _
+        [ input>> register-self ]
+        [ listener-thread ]
+        bi
+    ] "Listener" spawn drop ;
 
 : restart-listener ( listener -- )
     #! Returns when listener is ready to receive input.
@@ -166,25 +148,41 @@ M: stack-display tool-scroller
         [ wait-for-listener ]
     } cleave ;
 
-: init-listener ( listener -- )
-    f <model> >>stack drop ;
+: init-listener ( listener -- listener )
+    <scrolling-pane> >>output
+    dup <listener-input> >>input ;
+
+: <listener-scroller> ( listener -- scroller )
+    <filled-pile>
+        over output>> add-gadget
+        swap input>> add-gadget
+    <scroller> ;
 
 : <listener-gadget> ( -- gadget )
     { 0 1 } listener-gadget new-track
-        dup init-listener
-        listener-output,
-        listener-input, ;
+        add-toolbar
+        init-listener
+        dup <listener-scroller> 1 track-add ;
 
 : listener-help ( -- ) "ui-listener" help-window ;
 
 \ listener-help H{ { +nullary+ t } } define-command
 
+: com-auto-use ( -- )
+    auto-use? [ not ] change ;
+
+\ com-auto-use H{ { +nullary+ t } { +listener+ t } } define-command
+
+listener-gadget "misc" "Miscellaneous commands" {
+    { T{ key-down f f "F1" } listener-help }
+} define-command-map
+
 listener-gadget "toolbar" f {
     { f restart-listener }
-    {  T{ key-down f { A+ } "c" } clear-output }
-    {  T{ key-down f { A+ } "C" } clear-stack }
+    { T{ key-down f { A+ } "u" } com-auto-use }
+    { T{ key-down f { A+ } "k" } clear-output }
+    { T{ key-down f { A+ } "K" } clear-stack }
     { T{ key-down f { C+ } "d" } com-end }
-    { T{ key-down f f "F1" } listener-help }
 } define-command-map
 
 M: listener-gadget handle-gesture ( gesture gadget -- ? )
index c60d0dac0981e825e502e09bba5e316e83b3fbbd..05d1ccdb82a97435e367cea00d8b75d0f12bb337 100644 (file)
@@ -9,7 +9,7 @@ TUPLE: profiler-gadget < track pane ;
 
 : <profiler-gadget> ( -- gadget )
     { 0 1 } profiler-gadget new-track
-        dup <toolbar> f track-add
+        add-toolbar
         <pane> >>pane
         dup pane>> <scroller> 1 track-add ;
 
index b88fe8454e8115343799ee7868475a65f068e035..cf980cfc234a57ba58fecb334d9d24ed96b808bc 100644 (file)
@@ -1,14 +1,14 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs ui.tools.interactor ui.tools.listener
-ui.tools.workspace help help.topics io.files io.styles kernel
-models models.delay models.filter namespaces prettyprint
+USING: accessors assocs help help.topics io.files io.styles
+kernel models models.delay models.filter namespaces prettyprint
 quotations sequences sorting source-files definitions strings
-tools.completion tools.crossref classes.tuple ui.commands
-ui.gadgets ui.gadgets.editors ui.gadgets.lists
-ui.gadgets.scrollers ui.gadgets.tracks ui.gestures ui.operations
-vocabs words vocabs.loader tools.vocabs unicode.case calendar ui
-;
+tools.completion tools.crossref classes.tuple vocabs words
+vocabs.loader tools.vocabs unicode.case calendar locals
+ui.tools.interactor ui.tools.listener ui.tools.workspace
+ui.commands ui.gadgets ui.gadgets.editors ui.gadgets.lists
+ui.gadgets.scrollers ui.gadgets.tracks ui.gadgets.borders
+ui.gestures ui.operations ui ;
 IN: ui.tools.search
 
 TUPLE: live-search < track field list ;
@@ -23,7 +23,7 @@ TUPLE: live-search < track field list ;
 M: live-search handle-gesture ( gesture live-search -- ? )
     tuck search-gesture dup [
         over find-workspace hide-popup
-        >r search-value r> invoke-command f
+        [ search-value ] dip invoke-command f
     ] [
         2drop t
     ] if ;
@@ -47,27 +47,29 @@ search-field H{
     { T{ key-down f f "RET" } [ find-search-list invoke-value-action ] }
 } set-gestures
 
-: <search-model> ( live-search producer -- live-search filter )
-    >r dup field>> model>>                   ! live-search model :: producer
-    ui-running? [ 1/5 seconds <delay> ] when
-    [ "\n" join ] r> append <filter> ;
+: <search-model> ( live-search producer -- filter )
+    [
+        field>> model>>
+        ui-running? [ 1/5 seconds <delay> ] when
+    ] dip [ "\n" join ] prepend <filter> ;
 
-: <search-list> ( live-search seq limited? presenter -- live-search list )
-    >r
-    [ limited-completions ] [ completions ] ? curry
-    <search-model>
-    >r [ find-workspace hide-popup ] r> r>
-    swap <list> ;
+: init-search-model ( live-search seq limited? -- live-search )
+    [ 2drop ]
+    [ [ limited-completions ] [ completions ] ? curry <search-model> ] 3bi
+    >>model ; inline
 
-: <live-search> ( string seq limited? presenter -- gadget )
+: <search-list> ( presenter live-search -- list )
+    [ [ find-workspace hide-popup ] ] [ ] [ model>> ] tri* <list> ;
+
+:: <live-search> ( string seq limited? presenter -- gadget )
     { 0 1 } live-search new-track
         <search-field> >>field
-        dup field>> f track-add
-        -roll <search-list> >>list
+        seq limited? init-search-model
+        presenter over <search-list> >>list
+        dup field>> 1 <border> { 1 1 } >>fill f track-add
         dup list>> <scroller> 1 track-add
-    swap                         
-        over field>> set-editor-string
-    dup field>> end-of-document ;
+        string over field>> set-editor-string
+        dup field>> end-of-document ;
 
 M: live-search focusable-child* field>> ;
 
@@ -80,26 +82,27 @@ M: live-search pref-dim* drop { 400 200 } ;
     [ dup synopsis >lower ] { } map>assoc sort-values ;
 
 : <definition-search> ( string words limited? -- gadget )
-    >r definition-candidates r> [ synopsis ] <live-search> ;
+    [ definition-candidates ] dip [ synopsis ] <live-search> ;
 
 : word-candidates ( words -- candidates )
     [ dup name>> >lower ] { } map>assoc ;
 
 : <word-search> ( string words limited? -- gadget )
-    >r word-candidates r> [ synopsis ] <live-search> ;
+    [ word-candidates ] dip [ synopsis ] <live-search> ;
 
 : com-words ( workspace -- )
     dup current-word all-words t <word-search>
     "Word search" show-titled-popup ;
 
 : show-vocab-words ( workspace vocab -- )
-    "" over words natural-sort f <word-search>
-    "Words in " rot vocab-name append show-titled-popup ;
+    [ "" swap words natural-sort f <word-search> ]
+    [ "Words in " swap vocab-name append ]
+    bi show-titled-popup ;
 
 : show-word-usage ( workspace word -- )
-    "" over smart-usage f <definition-search>
-    "Words and methods using " rot name>> append
-    show-titled-popup ;
+    [ "" swap smart-usage f <definition-search> ]
+    [ "Words and methods using " swap name>> append ]
+    bi show-titled-popup ;
 
 : help-candidates ( seq -- candidates )
     [ dup >link swap article-title >lower ] { } map>assoc
@@ -127,8 +130,9 @@ M: live-search pref-dim* drop { 400 200 } ;
     "Source file search" show-titled-popup ;
 
 : show-vocab-files ( workspace vocab -- )
-    "" over vocab-files <source-file-search>
-    "Source files in " rot vocab-name append show-titled-popup ;
+    [ "" swap vocab-files <source-file-search> ]
+    [ "Source files in " swap vocab-name append ]
+    bi show-titled-popup ;
 
 : vocab-candidates ( -- candidates )
     all-vocabs-seq [ dup vocab-name >lower ] { } map>assoc ;
index f54e1e40417b81b8a08a1464934f6badb61ceb3f..6368737460a9c1056c5a8ca25bb595811e715754 100644 (file)
@@ -32,7 +32,7 @@ ARTICLE: "ui-listener" "UI listener"
 { $heading "Editing commands" }
 "The text editing commands are standard; see " { $link "gadgets-editors" } "."
 { $heading "Implementation" }
-"Listeners are instances of " { $link listener-gadget } ". The listener consists of an output area (instance of " { $link pane } "), and an input area (instance of " { $link interactor } "), and a stack display kept up to date using a " { $link listener-hook } "." ;
+"Listeners are instances of " { $link listener-gadget } ". The listener consists of an output area (instance of " { $link pane } ") and an input area (instance of " { $link interactor } ")." ;
 
 ARTICLE: "ui-inspector" "UI inspector"
 "The graphical inspector builds on the terminal inspector (see " { $link "inspector" } ") and provides in-place editing of slot values."
index aed4b9d675f60da03db92f57aa7fd15d918ff205..3310a3e0a56a9c919d4e9f3058e88636de825326 100644 (file)
@@ -19,8 +19,7 @@ IN: ui.tools
     <toggle-buttons> ;
 
 : <workspace-book> ( workspace -- gadget )
-    dup
-        <stack-display>
+        <gadget>
         <browser-gadget>
         <inspector-gadget>
         <profiler-gadget>
@@ -34,14 +33,14 @@ IN: ui.tools
         dup <workspace-book> >>book
 
         dup <workspace-tabs> f track-add
-        dup book>> 1/5 track-add
-        dup listener>> 4/5 track-add
-        dup <toolbar> f track-add ;
+        dup book>> 0 track-add
+        dup listener>> 1 track-add
+        add-toolbar ;
 
 : resize-workspace ( workspace -- )
-    dup sizes>> over control-value zero? [
-        1/5 over set-second
-        4/5 swap set-third
+    dup sizes>> over control-value 0 = [
+        0 over set-second
+        1 swap set-third
     ] [
         2/3 over set-second
         1/3 swap set-third
@@ -55,13 +54,15 @@ M: workspace model-changed
 
 [ workspace-window ] ui-hook set-global
 
-: com-listener ( workspace -- ) stack-display select-tool ;
+: select-tool ( workspace n -- ) swap book>> model>> set-model ;
 
-: com-browser ( workspace -- ) browser-gadget select-tool ;
+: com-listener ( workspace -- ) 0 select-tool ;
 
-: com-inspector ( workspace -- ) inspector-gadget select-tool ;
+: com-browser ( workspace -- ) 1 select-tool ;
 
-: com-profiler ( workspace -- ) profiler-gadget select-tool ;
+: com-inspector ( workspace -- ) 2 select-tool ;
+
+: com-profiler ( workspace -- ) 3 select-tool ;
 
 workspace "tool-switching" f {
     { T{ key-down f { A+ } "1" } com-listener }
index 6cb79916e08299698769acb02de5939d1db3c799..45f15b1ffc9f80b6423c4af355a8f101ff2d54ef 100644 (file)
@@ -36,14 +36,17 @@ M: traceback-gadget pref-dim* drop { 550 600 } ;
 
     dup model>> <callstack-display> 2/3 track-add
 
-    dup <toolbar> f track-add ;
+    add-toolbar ;
 
 : <namestack-display> ( model -- gadget )
     [ [ name>> namestack. ] when* ]
     <pane-control> ;
 
 : <variables-gadget> ( model -- gadget )
-    <namestack-display> { 400 400 } <limited-scroller> ;
+    <namestack-display>
+    <limited-scroller>
+        { 400 400 } >>min-dim
+        { 400 400 } >>max-dim ;
 
 : variables ( traceback -- )
     model>> <variables-gadget>
index 7bc42ea6761f89b6b7472eae839fe98f5a7aa1c9..9c825d49202a9ddef1c0fe7e70aa0f7ccf7d700c 100644 (file)
@@ -62,9 +62,9 @@ M: walker-gadget focusable-child*
         swap >>status
         dup continuation>> <traceback-gadget> >>traceback
 
-        dup <toolbar>                     f track-add
+        add-toolbar
         dup status>> self <thread-status> f track-add
-        dup traceback>>                   1 track-add ;
+        dup traceback>> 1 track-add ;
     
 : walker-help ( -- ) "ui-walker" help-window ;
 
index bbe4b127128379e5d0fabb10299d1cf648fe17cf..6536cb8c7d9ff874b9ae6d672e11e5fc6de1d0b3 100644 (file)
@@ -1,12 +1,12 @@
-! Copyright (C) 2006, 2007 Slava Pestov.
+! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: classes continuations help help.topics kernel models
-       sequences ui ui.backend ui.tools.debugger ui.gadgets
-       ui.gadgets.books ui.gadgets.buttons ui.gadgets.labelled
-       ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks
-       ui.gadgets.worlds ui.gadgets.presentations ui.gadgets.status-bar
-       ui.commands ui.gestures assocs arrays namespaces accessors ;
-
+sequences assocs arrays namespaces accessors math.vectors ui
+ui.backend ui.tools.debugger ui.gadgets ui.gadgets.books
+ui.gadgets.buttons ui.gadgets.labelled ui.gadgets.panes
+ui.gadgets.scrollers ui.gadgets.tracks ui.gadgets.worlds
+ui.gadgets.presentations ui.gadgets.status-bar ui.commands
+ui.gestures ;
 IN: ui.tools.workspace
 
 TUPLE: workspace < track book listener popup ;
@@ -32,8 +32,6 @@ M: gadget tool-scroller drop f ;
     [ find-tool swap ] keep book>> model>>
     set-model ;
 
-: select-tool ( workspace class -- ) swap show-tool drop ;
-
 : get-workspace* ( quot -- workspace )
     [ >r dup workspace? r> [ drop f ] if ] curry find-window
     [ dup raise-window gadget-child ]
@@ -47,12 +45,15 @@ M: gadget tool-scroller drop f ;
 : get-tool ( class -- gadget )
     get-workspace find-tool nip ;
 
+: <help-pane> ( topic -- pane )
+    <pane> [ [ help ] with-pane ] keep ;
+
 : help-window ( topic -- )
     [
-        <pane> [ [ help ] with-pane ] keep
-        { 550 700 } <limited-scroller>
-    ] keep
-    article-title open-window ;
+        <help-pane> <limited-scroller>
+            { 550 700 } >>max-dim
+    ] [ article-title ] bi
+    open-window ;
 
 : hide-popup ( workspace -- )
     dup popup>> track-remove
@@ -78,7 +79,7 @@ SYMBOL: workspace-dim
 
 { 600 700 } workspace-dim set-global
 
-M: workspace pref-dim* drop workspace-dim get ;
+M: workspace pref-dim* call-next-method workspace-dim get vmax ;
 
 M: workspace focusable-child*
     dup popup>> [ ] [ listener>> ] ?if ;
index 58509fc2df78c8fc13f3a49f677ed9feac4a877b..978bd2405527487efa4d4e93b8fb28c7acc8c3c2 100644 (file)
@@ -47,11 +47,6 @@ HELP: (open-window)
 { $description "Opens a native window containing the given world. This grafts the world by calling " { $link graft } ". Each world can only be displayed in one top-level window at a time." }
 { $notes "This word should not be called directly by user code. Instead, use " { $link open-window } "." } ;
 
-HELP: ui-try
-{ $values { "quot" quotation } }
-{ $description "Calls the quotation. If it throws an error, opens a window with the error and restores the data stack." }
-{ $notes "This is essentially a graphical variant of " { $link try } "." } ;
-
 ARTICLE: "ui-glossary" "UI glossary"
 { $table
     { "color specifier"
@@ -105,24 +100,7 @@ ARTICLE: "gadgets" "Pre-made UI gadgets"
 
 ARTICLE: "ui-geometry" "Gadget geometry"
 "The " { $link gadget } " class inherits from the " { $link rect } " class, and thus all gadgets have a bounding box:"
-{ $subsection rect }
-"Rectangles can be taken apart:"
-{ $subsection rect-loc }
-{ $subsection rect-dim }
-{ $subsection rect-bounds }
-{ $subsection rect-extent }
-"New rectangles can be created:"
-{ $subsection <zero-rect> }
-{ $subsection <rect> }
-{ $subsection <extent-rect> }
-"More utility words for working with rectangles:"
-{ $subsection offset-rect }
-{ $subsection rect-intersect }
-{ $subsection intersects? }
-
-! "A gadget's bounding box is always relative to its parent. "
-! { $subsection gadget-parent }
-
+{ $subsection "math.geometry.rect" }
 "Word for converting from a child gadget's co-ordinate system to a parent's:"
 { $subsection relative-loc }
 { $subsection screen-loc }
diff --git a/basis/ui/ui-tests.factor b/basis/ui/ui-tests.factor
new file mode 100644 (file)
index 0000000..2920b58
--- /dev/null
@@ -0,0 +1,5 @@
+IN: ui.tests
+USING: ui tools.test ;
+
+\ event-loop must-infer
+\ open-window must-infer
index dc868154bb3958b0048a01bc46586e724bb04db7..de2eb713072989a25b8af0c592c0415df46ba51d 100644 (file)
@@ -87,6 +87,7 @@ SYMBOL: ui-hook
 : init-ui ( -- )
     <dlist> \ graft-queue set-global
     <dlist> \ layout-queue set-global
+    <dlist> \ gesture-queue set-global
     V{ } clone windows set-global ;
 
 : restore-gadget-later ( gadget -- )
@@ -129,8 +130,8 @@ SYMBOL: ui-hook
 
 : notify ( gadget -- )
     dup graft-state>>
-    dup first { f f } { t t } ?
-    pick (>>graft-state) {
+    [ first { f f } { t t } ? >>graft-state ] keep
+    {
         { { f t } [ dup activate-control graft* ] }
         { { t f } [ dup deactivate-control ungraft* ] }
     } case ;
@@ -138,14 +139,22 @@ SYMBOL: ui-hook
 : notify-queued ( -- )
     graft-queue [ notify ] slurp-deque ;
 
+: send-queued-gestures ( -- )
+    gesture-queue [ send-queued-gesture ] slurp-deque ;
+
 : update-ui ( -- )
-    [ notify-queued layout-queued redraw-worlds ] assert-depth ;
+    [
+        [
+            notify-queued
+            layout-queued
+            redraw-worlds
+            send-queued-gestures
+        ] assert-depth
+    ] [ ui-error ] recover ;
 
 : ui-wait ( -- )
     10 milliseconds sleep ;
 
-: ui-try ( quot -- ) [ ui-error ] recover ;
-
 SYMBOL: ui-thread
 
 : ui-running ( quot -- )
@@ -156,11 +165,9 @@ SYMBOL: ui-thread
     \ ui-running get-global ;
 
 : update-ui-loop ( -- )
-    ui-running? ui-thread get-global self eq? and [
-        ui-notify-flag get lower-flag
-        [ update-ui ] ui-try
-        update-ui-loop
-    ] when ;
+    [ ui-running? ui-thread get-global self eq? and ]
+    [ ui-notify-flag get lower-flag update-ui ]
+    [ ] while ;
 
 : start-ui-thread ( -- )
     [ self ui-thread set-global update-ui-loop ]
old mode 100644 (file)
new mode 100755 (executable)
index 3e600d2..512930d
@@ -6,9 +6,10 @@ ui.gadgets ui.backend ui.clipboards ui.gadgets.worlds
 ui.gestures io kernel math math.vectors namespaces make
 sequences strings vectors words windows.kernel32 windows.gdi32
 windows.user32 windows.opengl32 windows.messages windows.types
-windows.nt windows threads libc combinators continuations
-command-line shuffle opengl ui.render unicode.case ascii
-math.bitwise locals symbols accessors math.geometry.rect ;
+windows.nt windows threads libc combinators
+combinators.short-circuit continuations command-line shuffle
+opengl ui.render ascii math.bitwise locals symbols accessors
+math.geometry.rect math.order ascii ;
 IN: ui.windows
 
 SINGLETON: windows-ui-backend
@@ -144,11 +145,6 @@ SYMBOLS: msg-obj class-name-ptr mouse-captured ;
 : alt? ( -- ? ) left-alt? right-alt? or ;
 : caps-lock? ( -- ? ) VK_CAPITAL GetKeyState zero? not ;
 
-: switch-case ( seq -- seq )
-    dup first CHAR: a >= [ >upper ] [ >lower ] if ;
-
-: switch-case? ( -- ? ) shift? caps-lock? xor not ;
-
 : key-modifiers ( -- seq )
     [
         shift? [ S+ , ] when
@@ -179,33 +175,53 @@ SYMBOLS: msg-obj class-name-ptr mouse-captured ;
 : exclude-key-wm-char? ( n -- bool )
     exclude-keys-wm-char key? ;
 
-: keystroke>gesture ( n -- mods sym ? )
-    dup wm-keydown-codes at* [
-        nip >r key-modifiers r> t
-    ] [
-        drop 1string >r key-modifiers r>
-        C+ pick member? >r A+ pick member? r> or [
-            shift? [ >lower ] unless f
-        ] [
-            switch-case? [ switch-case ] when t
-        ] if
-    ] if ;
+: keystroke>gesture ( n -- mods sym )
+    wm-keydown-codes at* [ key-modifiers swap ] [ drop f f ] if ;
+
+: send-key-gesture ( sym action? quot hWnd -- )
+    [ [ key-modifiers ] 3dip call ] dip
+    window-focus propagate-gesture ; inline
+
+: send-key-down ( sym action? hWnd -- )
+    [ [ <key-down> ] ] dip send-key-gesture ;
+
+: send-key-up ( sym action? hWnd -- )
+    [ [ <key-up> ] ] dip send-key-gesture ;
+
+: key-sym ( wParam -- string/f action? )
+    {
+        {
+            [ dup LETTER? ]
+            [ shift? caps-lock? xor [ CHAR: a + CHAR: A - ] unless 1string f ]
+        }
+        { [ dup digit? ] [ 1string f ] }
+        [ wm-keydown-codes at t ]
+    } cond ;
 
 :: handle-wm-keydown ( hWnd uMsg wParam lParam -- )
     wParam exclude-key-wm-keydown? [
-        wParam keystroke>gesture <key-down>
-        hWnd window-focus send-gesture drop
+        wParam key-sym over [
+            dup ctrl? alt? xor or [
+                hWnd send-key-down
+            ] [ 2drop ] if
+        ] [ 2drop ] if
     ] unless ;
 
 :: handle-wm-char ( hWnd uMsg wParam lParam -- )
-    wParam exclude-key-wm-char? ctrl? alt? xor or [
-        wParam 1string
-        hWnd window-focus user-input
+    wParam exclude-key-wm-char? [
+        ctrl? alt? xor [
+            wParam 1string
+            [ f hWnd send-key-down ]
+            [ hWnd window-focus user-input ] bi
+        ] unless
     ] unless ;
 
 :: handle-wm-keyup ( hWnd uMsg wParam lParam -- )
-    wParam keystroke>gesture <key-up>
-    hWnd window-focus send-gesture drop ;
+    wParam exclude-key-wm-keydown? [
+        wParam key-sym over [
+            hWnd send-key-up
+        ] [ 2drop ] if
+    ] unless ;
 
 :: set-window-active ( hwnd uMsg wParam lParam ? -- n )
     ? hwnd window (>>active?)
@@ -241,20 +257,20 @@ M: windows-ui-backend (close-window)
 
 : message>button ( uMsg -- button down? )
     {
-        { [ dup WM_LBUTTONDOWN   = ] [ drop 1 t ] }
-        { [ dup WM_LBUTTONUP     = ] [ drop 1 f ] }
-        { [ dup WM_MBUTTONDOWN   = ] [ drop 2 t ] }
-        { [ dup WM_MBUTTONUP     = ] [ drop 2 f ] }
-        { [ dup WM_RBUTTONDOWN   = ] [ drop 3 t ] }
-        { [ dup WM_RBUTTONUP     = ] [ drop 3 f ] }
-
-        { [ dup WM_NCLBUTTONDOWN = ] [ drop 1 t ] }
-        { [ dup WM_NCLBUTTONUP   = ] [ drop 1 f ] }
-        { [ dup WM_NCMBUTTONDOWN = ] [ drop 2 t ] }
-        { [ dup WM_NCMBUTTONUP   = ] [ drop 2 f ] }
-        { [ dup WM_NCRBUTTONDOWN = ] [ drop 3 t ] }
-        { [ dup WM_NCRBUTTONUP   = ] [ drop 3 f ] }
-    } cond ;
+        { WM_LBUTTONDOWN   [ 1 t ] }
+        { WM_LBUTTONUP     [ 1 f ] }
+        { WM_MBUTTONDOWN   [ 2 t ] }
+        { WM_MBUTTONUP     [ 2 f ] }
+        { WM_RBUTTONDOWN   [ 3 t ] }
+        { WM_RBUTTONUP     [ 3 f ] }
+
+        { WM_NCLBUTTONDOWN [ 1 t ] }
+        { WM_NCLBUTTONUP   [ 1 f ] }
+        { WM_NCMBUTTONDOWN [ 2 t ] }
+        { WM_NCMBUTTONUP   [ 2 f ] }
+        { WM_NCRBUTTONDOWN [ 3 t ] }
+        { WM_NCRBUTTONUP   [ 3 f ] }
+    } case ;
 
 ! If the user clicks in the window border ("non-client area")
 ! Windows sends us an NC[LMR]BUTTONDOWN message; but if the
@@ -381,11 +397,9 @@ SYMBOL: trace-messages?
 ! return 0 if you handle the message, else just let DefWindowProc return its val
 : ui-wndproc ( -- object )
     "uint" { "void*" "uint" "long" "long" } "stdcall" [
-        [
-            pick
-            trace-messages? get-global [ dup windows-message-name name>> print flush ] when
-            wm-handlers get-global at* [ call ] [ drop DefWindowProc ] if
-        ] ui-try
+        pick
+        trace-messages? get-global [ dup windows-message-name name>> print flush ] when
+        wm-handlers get-global at* [ call ] [ drop DefWindowProc ] if
      ] alien-callback ;
 
 : peek-message? ( msg -- ? ) f 0 0 PM_REMOVE PeekMessage zero? ;
index e3c8421080d139110bd9d0bb33020c4203033d55..de57c2dc7295355a871ff1995c09e2dda320baa0 100644 (file)
@@ -7,7 +7,7 @@ x11.events x11.xim x11.glx x11.clipboard x11.constants
 x11.windows io.encodings.string io.encodings.ascii
 io.encodings.utf8 combinators debugger command-line qualified
 math.vectors classes.tuple opengl.gl threads math.geometry.rect
-environment ;
+environment ascii ;
 IN: ui.x11
 
 SINGLETON: x11-ui-backend
@@ -67,20 +67,32 @@ M: world configure-event
 : event-modifiers ( event -- seq )
     XKeyEvent-state modifiers modifier ;
 
+: valid-input? ( string gesture -- ? )
+    over empty? [ 2drop f ] [
+        mods>> { f { S+ } } member? [
+            [ [ 127 = not ] [ CHAR: \s >= ] bi and ] all?
+        ] [
+            [ [ 127 = not ] [ CHAR: \s >= ] [ alpha? not ] tri and and ] all?
+        ] if
+    ] if ;
+
 : key-down-event>gesture ( event world -- string gesture )
     dupd
     handle>> xic>> lookup-string
     >r swap event-modifiers r> key-code <key-down> ;
 
 M: world key-down-event
-    [ key-down-event>gesture ] keep world-focus
-    [ send-gesture ] keep swap [ user-input ] [ 2drop ] if ;
+    [ key-down-event>gesture ] keep
+    world-focus
+    [ propagate-gesture drop ]
+    [ 2over valid-input? [ nip user-input ] [ 3drop ] if ]
+    3bi ;
 
 : key-up-event>gesture ( event -- gesture )
     dup event-modifiers swap 0 XLookupKeysym key-code <key-up> ;
 
 M: world key-up-event
-    >r key-up-event>gesture r> world-focus send-gesture drop ;
+    >r key-up-event>gesture r> world-focus propagate-gesture ;
 
 : mouse-event>gesture ( event -- modifiers button loc )
     dup event-modifiers over XButtonEvent-button
@@ -185,7 +197,7 @@ M: world client-event
 
 M: x11-ui-backend do-events
     wait-event dup XAnyEvent-window window dup
-    [ [ 2dup handle-event ] assert-depth ] when 2drop ;
+    [ handle-event ] [ 2drop ] if ;
 
 : x-clipboard@ ( gadget clipboard -- prop win )
     atom>> swap
index bd66c5253e69515f040d46f3c25dbbd79ab512b9..bf426ad8672cce3ffea90f9d6d0e3a365ea15b95 100644 (file)
@@ -83,16 +83,6 @@ C-STRUCT: passwd
 : SEEK_CUR 1 ; inline
 : SEEK_END 2 ; inline
 
-: DT_UNKNOWN   0 ; inline
-: DT_FIFO      1 ; inline
-: DT_CHR       2 ; inline
-: DT_DIR       4 ; inline
-: DT_BLK       6 ; inline
-: DT_REG       8 ; inline
-: DT_LNK      10 ; inline
-: DT_SOCK     12 ; inline
-: DT_WHT      14 ; inline
-
 os {
     { macosx  [ "unix.bsd.macosx"  require ] }
     { freebsd [ "unix.bsd.freebsd" require ] }
index 17d6604fc00d0e386dfff7cd8358c0db0e248d00..a3b0ed11b7f6caf984af2605939c88b3f99edb60 100644 (file)
@@ -13,6 +13,7 @@ IN: unix.stat
 : S_IFIFO  OCT: 010000 ; inline   ! FIFO.
 : S_IFLNK  OCT: 120000 ; inline   ! Symbolic link.
 : S_IFSOCK OCT: 140000 ; inline   ! Socket.
+: S_IFWHT  OCT: 160000 ; inline   ! Whiteout.
 
 FUNCTION: int chmod ( char* path, mode_t mode ) ;
 FUNCTION: int fchmod ( int fd, mode_t mode ) ;
index 4950daef2ce4a4b1a9be6c0db8694f11016e2859..ca8a7a2e60fb9a7a125e7d8035c6e2db8c5f6106 100644 (file)
@@ -4,7 +4,7 @@ USING: alien alien.c-types alien.syntax kernel libc
 sequences continuations byte-arrays strings math namespaces
 system combinators vocabs.loader qualified accessors
 stack-checker macros locals generalizations unix.types
-debugger io prettyprint ;
+debugger io prettyprint io.files ;
 IN: unix
 
 : PROT_NONE   0 ; inline
@@ -20,6 +20,29 @@ IN: unix
 
 : NGROUPS_MAX 16 ; inline
 
+: DT_UNKNOWN   0 ; inline
+: DT_FIFO      1 ; inline
+: DT_CHR       2 ; inline
+: DT_DIR       4 ; inline
+: DT_BLK       6 ; inline
+: DT_REG       8 ; inline
+: DT_LNK      10 ; inline
+: DT_SOCK     12 ; inline
+: DT_WHT      14 ; inline
+
+: dirent-type>file-type ( ch -- type )
+    {
+        { DT_BLK  [ +block-device+ ] }
+        { DT_CHR  [ +character-device+ ] }
+        { DT_DIR  [ +directory+ ] }
+        { DT_LNK  [ +symbolic-link+ ] }
+        { DT_SOCK [ +socket+ ] }
+        { DT_FIFO [ +fifo+ ] }
+        { DT_REG  [ +regular-file+ ] }
+        { DT_WHT  [ +whiteout+ ] }
+        [ drop +unknown+ ]
+    } case ;
+
 C-STRUCT: group
     { "char*" "gr_name" }
     { "char*" "gr_passwd" }
index 597cdfdb7fdcaa773b459b55a2568c629bd42f3b..c0fb1695c3358603e6abbd3fa1bcdb5a32358a81 100644 (file)
@@ -132,7 +132,7 @@ M: url present
         { [ dup empty? ] [ drop ] }
         { [ over "/" tail? ] [ append ] }
         { [ "/" pick start not ] [ nip ] }
-        [ [ "/" last-split1 drop "/" ] dip 3append ]
+        [ [ "/" split1-last drop "/" ] dip 3append ]
     } cond ;
 
 PRIVATE>
index 69e2801110c81deb5fd3d2601b20f6f6f37919aa..866af469e94357c84f46e2190df3e2fef30a1a98 100644 (file)
@@ -2,7 +2,7 @@ USING: help.markup help.syntax ;
 IN: values\r
 \r
 ARTICLE: "values" "Global values"\r
-"Usually, dynamically scoped variables are sufficient for holding data which is not literal. But occasionally, for global information that's calculated just once, it's useful to use the word mechanism instead, and set the word to the appropriate value just once. Values abstract over this concept. To create a new word as a value, use the following syntax:"\r
+"Usually, dynamically scoped variables are sufficient for holding data which is not literal. But occasionally, for global information that's calculated just once, it's useful to use the word mechanism instead, and set the word to the appropriate value just once. The " { $vocab-link "values" } " vocabulary implements " { $emphasis "values" } ", which abstract over this concept. To create a new word as a value, use the following syntax:"\r
 { $subsection POSTPONE: VALUE: }\r
 "To get the value, just call the word. The following words manipulate values:"\r
 { $subsection get-value }\r
@@ -10,6 +10,8 @@ ARTICLE: "values" "Global values"
 { $subsection POSTPONE: to: }\r
 { $subsection change-value } ;\r
 \r
+ABOUT: "values"\r
+\r
 HELP: VALUE:\r
 { $syntax "VALUE: word" }\r
 { $values { "word" "a word to be created" } }\r
index 8d75b8cff29a8f746916c2183e0c4c2ccb9b3f08..b2b6ad1ff94bea6f3ba3055a2fbb62173056623f 100755 (executable)
@@ -131,10 +131,10 @@ check_library_exists() {
         $ECHO "***Factor will compile NO_UI=1"
         NO_UI=1
     fi
-    rm -f $GCC_TEST
-    check_ret rm
-    rm -f $GCC_OUT
-    check_ret rm
+    $DELETE -f $GCC_TEST
+    check_ret $DELETE
+    $DELETE -f $GCC_OUT
+    check_ret $DELETE
     $ECHO "found."
 }
 
@@ -209,7 +209,7 @@ c_find_word_size() {
     gcc -o $C_WORD $C_WORD.c
     WORD=$(./$C_WORD)
     check_ret $C_WORD
-    rm -f $C_WORD*
+    $DELETE -f $C_WORD*
 }
 
 intel_macosx_word_size() {
@@ -236,17 +236,30 @@ find_word_size() {
 
 set_factor_binary() {
     case $OS in
-        # winnt) FACTOR_BINARY=factor-nt;;
-        # macosx) FACTOR_BINARY=./Factor.app/Contents/MacOS/factor;;
+        winnt) FACTOR_BINARY=factor.exe;;
         *) FACTOR_BINARY=factor;;
     esac
 }
 
+set_factor_library() {
+    case $OS in
+        winnt) FACTOR_LIBRARY=factor.dll;;
+        macosx) FACTOR_LIBRARY=libfactor.dylib;;
+        *) FACTOR_LIBRARY=libfactor.a;;
+    esac
+}
+
+set_factor_image() {
+    FACTOR_IMAGE=factor.image
+}
+
 echo_build_info() {
     $ECHO OS=$OS
     $ECHO ARCH=$ARCH
     $ECHO WORD=$WORD
     $ECHO FACTOR_BINARY=$FACTOR_BINARY
+    $ECHO FACTOR_LIBRARY=$FACTOR_LIBRARY
+    $ECHO FACTOR_IMAGE=$FACTOR_IMAGE
     $ECHO MAKE_TARGET=$MAKE_TARGET
     $ECHO BOOT_IMAGE=$BOOT_IMAGE
     $ECHO MAKE_IMAGE_TARGET=$MAKE_IMAGE_TARGET
@@ -255,6 +268,8 @@ echo_build_info() {
     $ECHO DOWNLOADER=$DOWNLOADER
     $ECHO CC=$CC
     $ECHO MAKE=$MAKE
+    $ECHO COPY=$COPY
+    $ECHO DELETE=$DELETE
 }
 
 check_os_arch_word() {
@@ -312,6 +327,8 @@ find_build_info() {
     find_architecture
     find_word_size
     set_factor_binary
+    set_factor_library
+    set_factor_image
     set_build_info
     set_downloader
     set_gcc
@@ -339,6 +356,29 @@ cd_factor() {
     check_ret cd
 }
 
+set_copy() {
+    case $OS in
+        winnt) COPY=cp;;
+        *) COPY=cp;;
+    esac
+}
+
+set_delete() {
+    case $OS in
+        winnt) DELETE=rm;;
+        *) DELETE=rm;;
+    esac
+}
+
+backup_factor() {
+    $ECHO "Backing up factor..."
+    $COPY $FACTOR_BINARY $FACTOR_BINARY.bak
+    $COPY $FACTOR_LIBRARY $FACTOR_LIBRARY.bak
+    $COPY $BOOT_IMAGE $BOOT_IMAGE.bak
+    $COPY $FACTOR_IMAGE $FACTOR_IMAGE.bak
+    $ECHO "Done with backup."
+}
+
 check_makefile_exists() {
     if [[ ! -e "Makefile" ]] ; then
         echo ""
@@ -366,9 +406,10 @@ make_factor() {
 
 update_boot_images() {
     echo "Deleting old images..."
-    rm checksums.txt* > /dev/null 2>&1
-    rm $BOOT_IMAGE.* > /dev/null 2>&1
-    rm temp/staging.*.image > /dev/null 2>&1
+    $DELETE checksums.txt* > /dev/null 2>&1
+       # delete boot images with one or two characters after the dot
+    $DELETE $BOOT_IMAGE.{?,??} > /dev/null 2>&1
+    $DELETE temp/staging.*.image > /dev/null 2>&1
     if [[ -f $BOOT_IMAGE ]] ; then
         get_url http://factorcode.org/images/latest/checksums.txt
         factorcode_md5=`cat checksums.txt|grep $BOOT_IMAGE|cut -f2 -d' '`;
@@ -382,7 +423,7 @@ update_boot_images() {
         if [[ "$factorcode_md5" == "$disk_md5" ]] ; then
             echo "Your disk boot image matches the one on factorcode.org."
         else
-            rm $BOOT_IMAGE > /dev/null 2>&1
+            $DELETE $BOOT_IMAGE > /dev/null 2>&1
             get_boot_image;
         fi
     else
@@ -459,6 +500,7 @@ install() {
 update() {
     get_config_info
     git_pull_factorcode
+    backup_factor
     make_clean
     make_factor
 }
@@ -469,12 +511,12 @@ update_bootstrap() {
 }
 
 refresh_image() {
-    ./$FACTOR_BINARY -script -e="USE: vocabs.loader refresh-all USE: memory save 0 USE: system exit"
+    ./$FACTOR_BINARY -script -e="USE: vocabs.loader USE: system refresh-all USE: memory save 0 exit"
     check_ret factor
 }
 
 make_boot_image() {
-    ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: bootstrap.image make-image save 0 USE: system exit"
+    ./$FACTOR_BINARY -script -e="\"$MAKE_IMAGE_TARGET\" USE: system USE: bootstrap.image make-image save 0 exit"
     check_ret factor
 
 }
@@ -513,6 +555,9 @@ if [[ -n "$2" ]] ; then
     parse_build_info $2
 fi
 
+set_copy
+set_delete
+
 case "$1" in
     install) install ;;
     install-x11) install_build_system_apt; install ;;
index b023398762af1c75bec09b8013c32e4cd2142692..74bc57e9db80c80940e44df38831ffffdfac3e8a 100644 (file)
@@ -6,8 +6,8 @@ IN: arrays
 
 M: array clone (clone) ;
 M: array length length>> ;
-M: array nth-unsafe >r >fixnum r> array-nth ;
-M: array set-nth-unsafe >r >fixnum r> set-array-nth ;
+M: array nth-unsafe [ >fixnum ] dip array-nth ;
+M: array set-nth-unsafe [ >fixnum ] dip set-array-nth ;
 M: array resize resize-array ;
 
 : >array ( seq -- array ) { } clone-like ;
index 9b8065e6c471f161b92539c29bd615bd80d25197..953cc38c5632283fabc023c07dca72513fed58e9 100644 (file)
@@ -21,7 +21,7 @@ GENERIC: assoc-clone-like ( assoc exemplar -- newassoc )
 GENERIC: >alist ( assoc -- newassoc )
 
 : (assoc-each) ( assoc quot -- seq quot' )
-    >r >alist r> [ first2 ] prepose ; inline
+    [ >alist ] dip [ first2 ] prepose ; inline
 
 : assoc-find ( assoc quot -- key value ? )
     (assoc-each) find swap [ first2 t ] [ drop f f f ] if ; inline
@@ -32,23 +32,26 @@ GENERIC: >alist ( assoc -- newassoc )
     (assoc-each) each ; inline
 
 : assoc>map ( assoc quot exemplar -- seq )
-    >r accumulator >r assoc-each r> r> like ; inline
+    [ accumulator [ assoc-each ] dip ] dip like ; inline
 
 : assoc-map-as ( assoc quot exemplar -- newassoc )
-    >r [ 2array ] compose V{ } assoc>map r> assoc-like ; inline
+    [ [ 2array ] compose V{ } assoc>map ] dip assoc-like ; inline
 
 : assoc-map ( assoc quot -- newassoc )
     over assoc-map-as ; inline
 
 : assoc-push-if ( key value quot accum -- )
-    >r 2keep r> roll
-    [ >r 2array r> push ] [ 3drop ] if ; inline
+    [ 2keep rot ] dip swap
+    [ [ 2array ] dip push ] [ 3drop ] if ; inline
 
 : assoc-pusher ( quot -- quot' accum )
     V{ } clone [ [ assoc-push-if ] 2curry ] keep ; inline
 
+: assoc-filter-as ( assoc quot exemplar -- subassoc )
+    [ assoc-pusher [ assoc-each ] dip ] dip assoc-like ; inline
+
 : assoc-filter ( assoc quot -- subassoc )
-    over >r assoc-pusher >r assoc-each r> r> assoc-like ; inline
+    over assoc-filter-as ; inline
 
 : assoc-contains? ( assoc quot -- ? )
     assoc-find 2nip ; inline
@@ -83,7 +86,7 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
         3drop f
     ] [
         3dup nth-unsafe at*
-        [ >r 3drop r> ] [ drop >r 1- r> (assoc-stack) ] if
+        [ [ 3drop ] dip ] [ drop [ 1- ] dip (assoc-stack) ] if
     ] if ; inline recursive
 
 : assoc-stack ( key seq -- value )
@@ -97,7 +100,7 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
 
 : assoc-hashcode ( n assoc -- code )
     [
-        >r over r> hashcode* 2/ >r dupd hashcode* r> bitxor
+        [ over ] dip hashcode* 2/ [ dupd hashcode* ] dip bitxor
     ] { } assoc>map hashcode* ;
 
 : assoc-intersect ( assoc1 assoc2 -- intersection )
@@ -130,19 +133,19 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
 
 : cache ( key assoc quot -- value )
     2over at* [
-        >r 3drop r>
+        [ 3drop ] dip
     ] [
-        drop pick rot >r >r call dup r> r> set-at
+        drop pick rot [ call dup ] 2dip set-at
     ] if ; inline
 
 : change-at ( key assoc quot -- )
-    [ >r at r> call ] 3keep drop set-at ; inline
+    [ [ at ] dip call ] 3keep drop set-at ; inline
 
 : at+ ( n key assoc -- )
     [ 0 or + ] change-at ;
 
 : map>assoc ( seq quot exemplar -- assoc )
-    >r [ 2array ] compose { } map-as r> assoc-like ; inline
+    [ [ 2array ] compose { } map-as ] dip assoc-like ; inline
 
 : extract-keys ( seq assoc -- subassoc )
     [ [ dupd at ] curry ] keep map>assoc ;
@@ -173,7 +176,7 @@ M: sequence at*
 M: sequence set-at
     2dup search-alist
     [ 2nip set-second ]
-    [ drop >r swap 2array r> push ] if ;
+    [ drop [ swap 2array ] dip push ] if ;
 
 M: sequence new-assoc drop <vector> ;
 
@@ -186,10 +189,10 @@ M: sequence delete-at
 M: sequence assoc-size length ;
 
 M: sequence assoc-clone-like
-    >r >alist r> clone-like ;
+    [ >alist ] dip clone-like ;
 
 M: sequence assoc-like
-    >r >alist r> like ;
+    [ >alist ] dip like ;
 
 M: sequence >alist ;
 
index f0aefa53cb7ee760d59382c6af8eb77a3c7758f1..8f280cb53a37ecc5c648aee0a3ecc2d0e37efab1 100644 (file)
@@ -129,8 +129,7 @@ bootstrapping? on
     [ "slots" set-word-prop ] [ define-accessors ] 2bi ;
 
 : define-builtin ( symbol slotspec -- )
-    >r [ define-builtin-predicate ] keep
-    r> define-builtin-slots ;
+    [ [ define-builtin-predicate ] keep ] dip define-builtin-slots ;
 
 "fixnum" "math" create register-builtin
 "bignum" "math" create register-builtin
@@ -303,7 +302,13 @@ tuple
     [ f "inline" set-word-prop ]
     [ make-flushable ]
     [ ]
-    [ tuple-layout [ <tuple-boa> ] curry ]
+    [
+        [
+            callable instance-check-quot %
+            tuple-layout ,
+            \ <tuple-boa> ,
+        ] [ ] make
+    ]
 } cleave
 (( obj quot -- curry )) define-declared
 
@@ -319,7 +324,14 @@ tuple
     [ f "inline" set-word-prop ]
     [ make-flushable ]
     [ ]
-    [ tuple-layout [ <tuple-boa> ] curry ]
+    [
+        [
+            callable instance-check-quot [ dip ] curry %
+            callable instance-check-quot %
+            tuple-layout ,
+            \ <tuple-boa> ,
+        ] [ ] make
+    ]
 } cleave
 (( quot1 quot2 -- compose )) define-declared
 
@@ -341,6 +353,8 @@ tuple
     { "fixnum-bitnot" "math.private" }
     { "fixnum-mod" "math.private" }
     { "fixnum-shift-fast" "math.private" }
+    { "fixnum/i-fast" "math.private" }
+    { "fixnum/mod-fast" "math.private" }
     { "fixnum<" "math.private" }
     { "fixnum<=" "math.private" }
     { "fixnum>" "math.private" }
@@ -372,7 +386,7 @@ tuple
 
 ! Primitive words
 : make-primitive ( word vocab n -- )
-    >r create dup reset-word r>
+    [ create dup reset-word ] dip
     [ do-primitive ] curry [ ] like define ;
 
 {
@@ -516,7 +530,7 @@ tuple
     { "unimplemented" "kernel.private" }
     { "gc-reset" "memory" }
 }
-[ >r first2 r> make-primitive ] each-index
+[ [ first2 ] dip make-primitive ] each-index
 
 ! Bump build number
 "build" "kernel" create build 1+ 1quotation define
index 08a13297d11be2b74ed0d392343668933e5144ce..4b0d9e5072658b35e4f976801a4e313b866bb6da 100644 (file)
@@ -12,14 +12,17 @@ GENERIC: checksum-stream ( stream checksum -- value )
 
 GENERIC: checksum-lines ( lines checksum -- value )
 
-M: checksum checksum-bytes >r binary <byte-reader> r> checksum-stream ;
+M: checksum checksum-bytes
+    [ binary <byte-reader> ] dip checksum-stream ;
 
-M: checksum checksum-stream >r contents r> checksum-bytes ;
+M: checksum checksum-stream
+    [ contents ] dip checksum-bytes ;
 
-M: checksum checksum-lines >r B{ CHAR: \n } join r> checksum-bytes ;
+M: checksum checksum-lines
+    [ B{ CHAR: \n } join ] dip checksum-bytes ;
 
 : checksum-file ( path checksum -- value )
-    >r binary <file-reader> r> checksum-stream ;
+    [ binary <file-reader> ] dip checksum-stream ;
 
 : hex-string ( seq -- str )
     [ >hex 2 CHAR: 0 pad-left ] { } map-as concat ;
index e1f0b9417bf3c958c66a730f032b582ce4f57344..7cff22de19bedd11402b1d1f6de7d504cce40b33 100644 (file)
@@ -11,7 +11,7 @@ IN: checksums.crc32
 
 256 [
     8 [
-        dup even? >r 2/ r> [ crc32-polynomial bitxor ] unless
+        [ 2/ ] [ even? ] bi [ crc32-polynomial bitxor ] unless
     ] times >bignum
 ] map 0 crc32-table copy
 
@@ -24,7 +24,7 @@ SINGLETON: crc32
 
 INSTANCE: crc32 checksum
 
-: init-crc32 drop >r HEX: ffffffff dup r> ; inline
+: init-crc32 drop [ HEX: ffffffff dup ] dip ; inline
 
 : finish-crc32 bitxor 4 >be ; inline
 
index 4558ce4737a71d34dfeaa58b0cd80fde0267c439..a3610ff7c56d2e31c628fde3de2bc3d05ece2492 100644 (file)
@@ -13,9 +13,9 @@ IN: classes.algebra.tests
 \ flatten-class must-infer\r
 \ flatten-builtin-class must-infer\r
 \r
-: class-and* ( cls1 cls2 cls3 -- ? ) >r class-and r> class= ;\r
+: class-and* ( cls1 cls2 cls3 -- ? ) [ class-and ] dip class= ;\r
 \r
-: class-or* ( cls1 cls2 cls3 -- ? ) >r class-or r> class= ;\r
+: class-or* ( cls1 cls2 cls3 -- ? ) [ class-or ] dip class= ;\r
 \r
 [ t ] [ object  object  object class-and* ] unit-test\r
 [ t ] [ fixnum  object  fixnum class-and* ] unit-test\r
@@ -240,9 +240,9 @@ UNION: z1 b1 c1 ;
         20 [ random-boolean-op ] [ ] replicate-as dup .\r
         [ infer in>> [ random-boolean ] replicate dup . ] keep\r
         \r
-        [ >r [ ] each r> call ] 2keep\r
+        [ [ [ ] each ] dip call ] 2keep\r
         \r
-        >r [ boolean>class ] each r> [ boolean-op>class-op ] map call object class=\r
+        [ [ boolean>class ] each ] dip [ boolean-op>class-op ] map call object class=\r
         \r
         =\r
     ] unit-test\r
index b7e6800950cd10d27ace132138efb410b9c4af3e..1b86ce0b0a939e44afd21b709222af71ade524a6 100644 (file)
@@ -18,7 +18,7 @@ TUPLE: anonymous-complement class ;
 C: <anonymous-complement> anonymous-complement\r
 \r
 : 2cache ( key1 key2 assoc quot -- value )\r
-    >r >r 2array r> [ first2 ] r> compose cache ; inline\r
+    [ 2array ] 2dip [ first2 ] prepose cache ; inline\r
 \r
 GENERIC: valid-class? ( obj -- ? )\r
 \r
@@ -66,13 +66,13 @@ DEFER: (class-or)
     swap superclass dup [ swap class<= ] [ 2drop f ] if ;\r
 \r
 : left-anonymous-union<= ( first second -- ? )\r
-    >r members>> r> [ class<= ] curry all? ;\r
+    [ members>> ] dip [ class<= ] curry all? ;\r
 \r
 : right-anonymous-union<= ( first second -- ? )\r
     members>> [ class<= ] with contains? ;\r
 \r
 : left-anonymous-intersection<= ( first second -- ? )\r
-    >r participants>> r> [ class<= ] curry contains? ;\r
+    [ participants>> ] dip [ class<= ] curry contains? ;\r
 \r
 : right-anonymous-intersection<= ( first second -- ? )\r
     participants>> [ class<= ] with all? ;\r
@@ -95,7 +95,7 @@ DEFER: (class-or)
     } cond ;\r
 \r
 : left-anonymous-complement<= ( first second -- ? )\r
-    >r normalize-complement r> class<= ;\r
+    [ normalize-complement ] dip class<= ;\r
 \r
 PREDICATE: nontrivial-anonymous-complement < anonymous-complement\r
     class>> {\r
@@ -212,7 +212,7 @@ M: anonymous-complement (classes-intersect?)
 : sort-classes ( seq -- newseq )\r
     [ [ name>> ] compare ] sort >vector\r
     [ dup empty? not ]\r
-    [ dup largest-class >r over delete-nth r> ]\r
+    [ dup largest-class [ over delete-nth ] dip ]\r
     [ ] produce nip ;\r
 \r
 : min-class ( class seq -- class/f )\r
index 8261e713a55228e3f091d150397cc67fd3a4ebfb..8d2610ccd7ffce1d9cbe2a74872f5008e8a268e0 100644 (file)
@@ -485,7 +485,7 @@ must-fail-with
 [ t ] [ "forget-accessors-test" "classes.tuple.tests" lookup class? ] unit-test
 
 : accessor-exists? ( class name -- ? )
-    >r "forget-accessors-test" "classes.tuple.tests" lookup r>
+    [ "forget-accessors-test" "classes.tuple.tests" lookup ] dip
     ">>" append "accessors" lookup method >boolean ;
 
 [ t ] [ "x" accessor-exists? ] unit-test
index a56a4df0292257ebeda118082537a5f80a56521f..b6b277a32f41b6d3897711209be03ce58aa7dbe8 100644 (file)
@@ -58,7 +58,7 @@ PRIVATE>
 
 : tuple>array ( tuple -- array )
     prepare-tuple>array
-    >r copy-tuple-slots r>
+    [ copy-tuple-slots ] dip
     first prefix ;
 
 : tuple-slots ( tuple -- seq )
@@ -121,7 +121,7 @@ ERROR: bad-superclass class ;
     [
         \ dup ,
         [ "predicate" word-prop % ]
-        [ [ bad-slot-value ] curry , ] bi
+        [ [ literalize , \ bad-slot-value , ] [ ] make , ] bi
         \ unless ,
     ] [ ] make ;
 
@@ -178,9 +178,9 @@ ERROR: bad-superclass class ;
 
 : update-slot ( old-values n class initial -- value )
     pick [
-        >r >r swap nth dup r> instance? r> swap
+        [ [ swap nth dup ] dip instance? ] dip swap
         [ drop ] [ nip ] if
-    ] [ >r 3drop r> ] if ;
+    ] [ [ 3drop ] dip ] if ;
 
 : apply-slot-permutation ( old-values triples -- new-values )
     [ first3 update-slot ] with map ;
@@ -233,7 +233,7 @@ M: tuple-class update-class
     class-usages [ tuple-class? ] filter ;
 
 : each-subclass ( class quot -- )
-    >r subclasses r> each ; inline
+    [ subclasses ] dip each ; inline
 
 : redefine-tuple-class ( class superclass slots -- )
     [
@@ -320,7 +320,7 @@ M: tuple equal? over tuple? [ tuple= ] [ 2drop f ] if ;
 M: tuple hashcode*
     [
         [ class hashcode ] [ tuple-size ] [ ] tri
-        >r rot r> [
+        [ rot ] dip [
             swapd array-nth hashcode* sequence-hashcode-step
         ] 2curry each
     ] recursive-hashcode ;
index 0caabf2fad7104a487db3c5fb3fadcb29a26662e..3afc0a3c3d1ce853714e12a00a540c3be8a8143e 100644 (file)
@@ -74,7 +74,7 @@ HELP: spread
     { $code
         "! Equivalent"
         "{ [ p ] [ q ] [ r ] [ s ] } spread"
-        ">r >r >r p r> q r> r r> s"
+        "[ [ [ p ] dip q ] dip r ] dip s"
     }
 } ;
 
index 8cfa671a8b2ef4b2a8dcd106dc48bce09863a9af..893078fb39d3c71903d6de0328e5dda49da799af 100644 (file)
@@ -28,10 +28,7 @@ IN: combinators
 
 ! spread
 : spread>quot ( seq -- quot )
-    [ ] [
-        [ dup empty? [ [ >r ] swap [ r> ] 3append ] unless ] dip
-        append
-    ] reduce ;
+    [ ] [ [ dup empty? [ [ dip ] curry ] unless ] dip append ] reduce ;
 
 : spread ( objs... seq -- )
     spread>quot call ;
@@ -83,7 +80,7 @@ ERROR: no-case ;
         drop [ swap adjoin ] curry each
     ] [
         [
-            >r 2dup r> hashcode pick length rem rot nth adjoin
+            [ 2dup ] dip hashcode pick length rem rot nth adjoin
         ] each 2drop
     ] if ;
 
@@ -91,13 +88,13 @@ ERROR: no-case ;
     next-power-of-2 swap [ nip clone ] curry map ;
 
 : distribute-buckets ( alist initial quot -- buckets )
-    swapd [ >r dup first r> call 2array ] curry map
+    swapd [ [ dup first ] dip call 2array ] curry map
     [ length <buckets> dup ] keep
     [ first2 (distribute-buckets) ] with each ; inline
 
 : hash-case-table ( default assoc -- array )
     V{ } [ 1array ] distribute-buckets
-    [ [ >r literalize r> ] assoc-map linear-case-quot ] with map ;
+    [ [ [ literalize ] dip ] assoc-map linear-case-quot ] with map ;
 
 : hash-dispatch-quot ( table -- quot )
     [ length 1- [ fixnum-bitand ] curry ] keep
@@ -133,20 +130,20 @@ ERROR: no-case ;
         { [ dup [ length 4 <= ] [ [ word? ] contains? ] bi or ] [ drop linear-case-quot ] }
         { [ dup contiguous-range? ] [ drop dispatch-case-quot ] }
         { [ dup [ wrapper? ] contains? not ] [ drop hash-case-quot ] }
-        { [ dup [ wrapper? ] all? ] [ drop [ >r wrapped>> r> ] assoc-map hash-case-quot ] }
+        { [ dup [ wrapper? ] all? ] [ drop [ [ wrapped>> ] dip ] assoc-map hash-case-quot ] }
         [ drop linear-case-quot ]
     } cond ;
 
 ! assert-depth
 : trim-datastacks ( seq1 seq2 -- seq1' seq2' )
-    2dup [ length ] bi@ min tuck tail >r tail r> ;
+    2dup [ length ] bi@ min tuck [ tail ] 2bi@ ;
 
 ERROR: relative-underflow stack ;
 
 ERROR: relative-overflow stack ;
 
 : assert-depth ( quot -- )
-    >r datastack r> dip >r datastack r>
+    [ datastack ] dip dip [ datastack ] dip
     2dup [ length ] compare {
         { +lt+ [ trim-datastacks nip relative-underflow ] }
         { +eq+ [ 2drop ] }
index c2452f719da75038f39175adc1d7f93ea0a66720..1ea497c3fc5cbeab65f5e8b63329c4dac23b7a7d 100644 (file)
@@ -20,7 +20,7 @@ SYMBOL: with-compiler-errors?
 
 : errors-of-type ( type -- assoc )
     compiler-errors get-global
-    swap [ >r nip compiler-error-type r> eq? ] curry
+    swap [ [ nip compiler-error-type ] dip eq? ] curry
     assoc-filter ;
 
 : compiler-errors. ( type -- )
index 6dde851963442774f3b24cfaf305a43f60ddfb39..af8cda37c69cfb655e98d59b732ec29f63eb1ff7 100644 (file)
@@ -65,7 +65,7 @@ C: <continuation> continuation
     #! ( value f r:capture r:restore )
     #! Execution begins right after the call to 'continuation'.
     #! The 'restore' branch is taken.
-    >r >r dummy-1 continuation r> r> [ dummy-2 ] prepose ?if ; inline
+    [ dummy-1 continuation ] 2dip [ dummy-2 ] prepose ?if ; inline
 
 : callcc0 ( quot -- ) [ drop ] ifcc ; inline
 
@@ -78,7 +78,7 @@ C: <continuation> continuation
     set-catchstack
     set-namestack
     set-retainstack
-    >r set-datastack r>
+    [ set-datastack ] dip
     set-callstack ;
 
 : (continue-with) ( obj continuation -- )
@@ -87,7 +87,7 @@ C: <continuation> continuation
     set-catchstack
     set-namestack
     set-retainstack
-    >r set-datastack drop 4 getenv f 4 setenv f r>
+    [ set-datastack drop 4 getenv f 4 setenv f ] dip
     set-callstack ;
 
 PRIVATE>
@@ -135,14 +135,13 @@ SYMBOL: thread-error-hook
     c> continue-with ;
 
 : recover ( try recovery -- )
-    >r [ swap >c call c> drop ] curry r> ifcc ; inline
+    [ [ swap >c call c> drop ] curry ] dip ifcc ; inline
 
 : ignore-errors ( quot -- )
     [ drop ] recover ; inline
 
 : cleanup ( try cleanup-always cleanup-error -- )
-    over >r compose [ dip rethrow ] curry
-    recover r> call ; inline
+    [ compose [ dip rethrow ] curry recover ] [ drop ] 2bi call ; inline
 
 ERROR: attempt-all-error ;
 
index b5f22ec1207a81e7d6a3dcf81ff54dab4d3689bf..35029a3fb0976e34dba5bba8424da45bb61135e7 100644 (file)
@@ -162,6 +162,6 @@ HELP: forget-methods
 { sort-classes order } related-words
 
 HELP: (call-next-method)
-{ $values { "class" class } { "generic" generic } }
+{ $values { "method" method-body } }
 { $description "Low-level word implementing " { $link POSTPONE: call-next-method } "." }
 { $notes "In most cases, " { $link POSTPONE: call-next-method } " should be used instead." } ;
index e2818a51b21958db220c5230e9c94a9106f774d1..8d7ed4cb600cf1df616227d441c42281be29b356 100644 (file)
@@ -49,12 +49,16 @@ GENERIC: effective-method ( generic -- method )
 
 GENERIC: next-method-quot* ( class generic combination -- quot )
 
-: next-method-quot ( class generic -- quot )
+: next-method-quot ( method -- quot )
     next-method-quot-cache get [
-        dup "combination" word-prop next-method-quot*
-    ] 2cache ;
+        [ "method-class" word-prop ]
+        [
+            "method-generic" word-prop
+            dup "combination" word-prop
+        ] bi next-method-quot*
+    ] cache ;
 
-: (call-next-method) ( class generic -- )
+: (call-next-method) ( method -- )
     next-method-quot call ;
 
 TUPLE: check-method class generic ;
index ebe1c08cb3d1e426018736f739c0ffd3fb953c63..0c7bb2d8e8dbeb122aef81db283adda6fd717245 100644 (file)
@@ -36,9 +36,10 @@ PREDICATE: math-class < class
 
 : math-upgrade ( class1 class2 -- quot )
     [ math-class-max ] 2keep
-    >r over r> (math-upgrade) >r (math-upgrade)
-    dup empty? [ [ dip ] curry [ ] like ] unless
-    r> append ;
+    [ over ] dip (math-upgrade) [
+        (math-upgrade)
+        dup empty? [ [ dip ] curry [ ] like ] unless
+    ] dip append ;
 
 ERROR: no-math-method left right generic ;
 
@@ -55,9 +56,9 @@ ERROR: no-math-method left right generic ;
 
 : math-method ( word class1 class2 -- quot )
     2dup and [
-        2dup math-upgrade >r
-        math-class-max over order min-class applicable-method
-        r> prepend
+        2dup math-upgrade
+        [ math-class-max over order min-class applicable-method ] dip
+        prepend
     ] [
         2drop object-method
     ] if ;
@@ -85,7 +86,7 @@ M: math-combination perform-combination
     dup
     \ over [
         dup math-class? [
-            \ dup [ >r 2dup r> math-method ] math-vtable
+            \ dup [ [ 2dup ] dip math-method ] math-vtable
         ] [
             over object-method
         ] if nip
index 7380399b5c10b8b5af0f555f5ef93bdc9efbf36e..c6420164d2bc83d084ce354c3d3c729cbd0ec8c3 100644 (file)
@@ -13,17 +13,10 @@ ERROR: not-in-a-method-error ;
 : CREATE-METHOD ( -- method )
     scan-word bootstrap-word scan-word create-method-in ;
 
-SYMBOL: current-class
-SYMBOL: current-generic
-
-: with-method-definition ( quot -- parsed )
-    [
-        [
-            [ "method-class" word-prop current-class set ]
-            [ "method-generic" word-prop current-generic set ]
-            [ ] tri
-        ] dip call
-    ] with-scope ; inline
+SYMBOL: current-method
+
+: with-method-definition ( method quot -- )
+    [ dup current-method ] dip with-variable ; inline
 
 : (M:) ( method def -- )
     CREATE-METHOD [ parse-definition ] with-method-definition ;
index 6a5e8d1bb0310fc09c09c89ef6e9d9f218d482e3..b6cb9fc9f7aeab1aff28903ad42a67958f041808 100644 (file)
@@ -18,7 +18,7 @@ GENERIC: engine>quot ( engine -- quot )
     [ over assumed [ engine>quot ] with-variable ] assoc-map ;
 
 : if-small? ( assoc true false -- )
-    >r >r dup assoc-size 4 <= r> r> if ; inline
+    [ dup assoc-size 4 <= ] 2dip if ; inline
 
 : linear-dispatch-quot ( alist -- quot )
     default get [ drop ] prepend swap
@@ -45,7 +45,7 @@ GENERIC: engine>quot ( engine -- quot )
         { 0 [ [ dup ] ] }
         { 1 [ [ over ] ] }
         { 2 [ [ pick ] ] }
-        [ 1- (picker) [ >r ] swap [ r> swap ] 3append ]
+        [ 1- (picker) [ dip swap ] curry ]
     } case ;
 
 : picker ( -- quot ) \ (dispatch#) get (picker) ;
index 8846c9eee776072afa6ca39202fb7b738cb798b2..152b112c2a73114a4be6e97487e61763f223909a 100644 (file)
@@ -10,7 +10,7 @@ TUPLE: predicate-dispatch-engine methods ;
 C: <predicate-dispatch-engine> predicate-dispatch-engine
 
 : class-predicates ( assoc -- assoc )
-    [ >r "predicate" word-prop picker prepend r> ] assoc-map ;
+    [ [ "predicate" word-prop picker prepend ] dip ] assoc-map ;
 
 : keep-going? ( assoc -- ? )
     assumed get swap second first class<= ;
index d1bc6d7417d883e8518f21225d884f7e407f2b72..dbdc6e0742b94fe76c4d3bacfa92bcf48de45162 100644 (file)
@@ -26,7 +26,7 @@ C: <lo-tag-dispatch-engine> lo-tag-dispatch-engine
 
 M: lo-tag-dispatch-engine engine>quot
     methods>> engines>quots*
-    [ >r lo-tag-number r> ] assoc-map
+    [ [ lo-tag-number ] dip ] assoc-map
     [
         picker % [ tag ] % [
             sort-tags linear-dispatch-quot
@@ -53,13 +53,13 @@ C: <hi-tag-dispatch-engine> hi-tag-dispatch-engine
 
 M: hi-tag-dispatch-engine engine>quot
     methods>> engines>quots*
-    [ >r hi-tag-number r> ] assoc-map
+    [ [ hi-tag-number ] dip ] assoc-map
     [
         picker % hi-tag-quot % [
             sort-tags linear-dispatch-quot
         ] [
             num-tags get , \ fixnum-fast ,
-            [ >r num-tags get - r> ] assoc-map
+            [ [ num-tags get - ] dip ] assoc-map
             num-hi-tags direct-dispatch-quot
         ] if-small? %
     ] [ ] make ;
index 284a58836f3ee68715a60168909ce86581e0f7ef..4f26c40e7807f3518c6796c062b055b6eed73929 100644 (file)
@@ -33,8 +33,8 @@ ERROR: no-method object generic ;
     ] change-at ;
 
 : flatten-method ( class method assoc -- )
-    >r >r dup flatten-class keys swap r> r> [
-        >r spin r> push-method
+    [ dup flatten-class keys swap ] 2dip [
+        [ spin ] dip push-method
     ] 3curry each ;
 
 : flatten-methods ( assoc -- assoc' )
@@ -113,7 +113,7 @@ PREDICATE: simple-generic < standard-generic
     T{ standard-combination f 0 } define-generic ;
 
 : with-standard ( combination quot -- quot' )
-    >r #>> (dispatch#) r> with-variable ; inline
+    [ #>> (dispatch#) ] dip with-variable ; inline
 
 M: standard-generic extra-values drop 0 ;
 
index 336f1da91a5d55f164710d57d2a921e8d1e3bedb..3c487af0a54245e5e82631f282af97d4bb3b5497 100644 (file)
@@ -43,10 +43,10 @@ M: growable set-length ( n seq -- )
     growable-check
     2dup length >= [
         2dup capacity >= [ over new-size over expand ] when
-        >r >fixnum r>
+        [ >fixnum ] dip
         over 1 fixnum+fast over (>>length)
     ] [
-        >r >fixnum r>
+        [ >fixnum ] dip
     ] if ; inline
 
 M: growable set-nth ensure set-nth-unsafe ;
index a59c6495983b9bdde080ea63452af2e1070d5bba..0e6deb77465488387704519adfb632a08bd4e48d 100644 (file)
@@ -134,7 +134,7 @@ H{ } "x" set
 
 [ H{ { -1 4 } { -3 16 } { -5 36 } } ] [
     H{ { 1 2 } { 3 4 } { 5 6 } }
-    [ >r neg r> sq ] assoc-map
+    [ [ neg ] dip sq ] assoc-map
 ] unit-test
 
 ! Bug discovered by littledan
index 0fde459a25b129dadba2b9c97d9b55165882cac1..474cf4c9d60b40b65ed3733ae53e487077a71987 100644 (file)
@@ -15,7 +15,7 @@ TUPLE: hashtable
     length>> 1 fixnum-fast fixnum-bitand ; inline
 
 : hash@ ( key array -- i )
-    >r hashcode >fixnum dup fixnum+fast r> wrap ; inline
+    [ hashcode >fixnum dup fixnum+fast ] dip wrap ; inline
 
 : probe ( array i -- array i )
     2 fixnum+fast over wrap ; inline
@@ -105,7 +105,7 @@ M: hashtable clear-assoc ( hash -- )
 
 M: hashtable delete-at ( key hash -- )
     tuck key@ [
-        >r >r ((tombstone)) dup r> r> set-nth-pair
+        [ ((tombstone)) dup ] 2dip set-nth-pair
         hash-deleted+
     ] [
         3drop
@@ -115,9 +115,9 @@ M: hashtable assoc-size ( hash -- n )
     [ count>> ] [ deleted>> ] bi - ;
 
 : rehash ( hash -- )
-    dup >alist >r
+    dup >alist [
     dup clear-assoc
-    r> (rehash) ;
+    ] dip (rehash) ;
 
 M: hashtable set-at ( value key hash -- )
     dup ?grow-hash
@@ -133,7 +133,7 @@ M: hashtable set-at ( value key hash -- )
 : push-unsafe ( elt seq -- )
     [ length ] keep
     [ underlying>> set-array-nth ]
-    [ >r 1+ r> (>>length) ]
+    [ [ 1+ ] dip (>>length) ]
     2bi ; inline
 
 PRIVATE>
@@ -141,9 +141,10 @@ PRIVATE>
 M: hashtable >alist
     [ array>> [ length 2/ ] keep ] [ assoc-size <vector> ] bi [
         [
-            >r
-            >r 1 fixnum-shift-fast r>
-            [ array-nth ] [ >r 1 fixnum+fast r> array-nth ] 2bi r>
+            [
+                [ 1 fixnum-shift-fast ] dip
+                [ array-nth ] [ [ 1 fixnum+fast ] dip array-nth ] 2bi
+            ] dip
             pick tombstone? [ 3drop ] [ [ 2array ] dip push-unsafe ] if
         ] 2curry each
     ] keep { } like ;
index 48a428d36e6c480a7b789bee4b2e4395e662b603..d165ad3138cc7c5e939b25bcc53c7acac2915f8e 100644 (file)
@@ -95,7 +95,7 @@ M: decoder stream-read-partial stream-read ;
 
 : ((read-until)) ( buf quot: ( -- char stop? ) -- string/f sep/f )
     dup call
-    [ >r drop "" like r> ]
+    [ [ drop "" like ] dip ]
     [ pick push ((read-until)) ] if ; inline recursive
 
 : (read-until) ( quot -- string/f sep/f )
index ca8125d9362ca475e6c78245ace99981476de2a3..7c7a2ece313cecfcac346e0bbbfa54a6839fc5bb 100644 (file)
@@ -26,13 +26,13 @@ HOOK: (file-appender) io-backend ( path -- stream )
     <file-reader> lines ;
 
 : with-file-reader ( path encoding quot -- )
-    >r <file-reader> r> with-input-stream ; inline
+    [ <file-reader> ] dip with-input-stream ; inline
 
 : file-contents ( path encoding -- str )
     <file-reader> contents ;
 
 : with-file-writer ( path encoding quot -- )
-    >r <file-writer> r> with-output-stream ; inline
+    [ <file-writer> ] dip with-output-stream ; inline
 
 : set-file-lines ( seq path encoding -- )
     [ [ print ] each ] with-file-writer ;
@@ -41,7 +41,7 @@ HOOK: (file-appender) io-backend ( path -- stream )
     [ write ] with-file-writer ;
 
 : with-file-appender ( path encoding quot -- )
-    >r <file-appender> r> with-output-stream ; inline
+    [ <file-appender> ] dip with-output-stream ; inline
 
 ! Pathnames
 : path-separator? ( ch -- ? ) os windows? "/\\" "/" ? member? ;
@@ -127,13 +127,13 @@ PRIVATE>
         { [ dup head.? ] [ rest trim-left-separators append-path ] }
         { [ dup head..? ] [
             2 tail trim-left-separators
-            >r parent-directory r> append-path
+            [ parent-directory ] dip append-path
         ] }
         { [ over absolute-path? over first path-separator? and ] [
-            >r 2 head r> append
+            [ 2 head ] dip append
         ] }
         [
-            >r trim-right-separators "/" r>
+            [ trim-right-separators "/" ] dip
             trim-left-separators 3append
         ]
     } cond ;
@@ -150,7 +150,7 @@ PRIVATE>
     ] unless ;
 
 : file-extension ( filename -- extension )
-    "." last-split1 nip ;
+    "." split1-last nip ;
 
 ! File info
 TUPLE: file-info type size permissions created modified
@@ -166,7 +166,7 @@ HOOK: make-link io-backend ( target symlink -- )
 HOOK: read-link io-backend ( symlink -- path )
 
 : copy-link ( target symlink -- )
-    >r read-link r> make-link ;
+    [ read-link ] dip make-link ;
 
 SYMBOL: +regular-file+
 SYMBOL: +directory+
@@ -175,6 +175,7 @@ SYMBOL: +character-device+
 SYMBOL: +block-device+
 SYMBOL: +fifo+
 SYMBOL: +socket+
+SYMBOL: +whiteout+
 SYMBOL: +unknown+
 
 ! File metadata
@@ -227,7 +228,7 @@ M: object normalize-path ( path -- path' )
     (normalize-path) current-directory set ;
 
 : with-directory ( path quot -- )
-    >r (normalize-path) current-directory r> with-variable ; inline
+    [ (normalize-path) current-directory ] dip with-variable ; inline
 
 ! Creating directories
 HOOK: make-directory io-backend ( path -- )
index c50fc6f46c6004c959a5799660412c05175fc7bd..d7d4edf49ff1656c56457069e989dd510155f2eb 100644 (file)
@@ -69,7 +69,7 @@ SYMBOL: error-stream
     [ ] cleanup ; inline
 
 : tabular-output ( style quot -- )
-    swap >r { } make r> output-stream get stream-write-table ; inline
+    swap [ { } make ] dip output-stream get stream-write-table ; inline
 
 : with-row ( quot -- )
     { } make , ; inline
@@ -89,8 +89,8 @@ SYMBOL: error-stream
     ] if ; inline
 
 : with-nesting ( style quot -- )
-    >r output-stream get make-block-stream
-    r> with-output-stream ; inline
+    [ output-stream get make-block-stream ] dip
+    with-output-stream ; inline
 
 : print ( string -- ) output-stream get stream-print ;
 
index 28d789d66f1ee514e070746c74d422c9307e412c..9d89c3d814d8e6e3ba43c17f279da60fffad3f76 100644 (file)
@@ -6,11 +6,11 @@ IN: io.streams.byte-array
     512 <byte-vector> swap <encoder> ;
 
 : with-byte-writer ( encoding quot -- byte-array )
-    >r <byte-writer> r> [ output-stream get ] compose with-output-stream*
+    [ <byte-writer> ] dip [ output-stream get ] compose with-output-stream*
     dup encoder? [ stream>> ] when >byte-array ; inline
 
 : <byte-reader> ( byte-array encoding -- stream )
-    >r >byte-vector dup reverse-here r> <decoder> ;
+    [ >byte-vector dup reverse-here ] dip <decoder> ;
 
 : with-byte-reader ( byte-array encoding quot -- )
-    >r <byte-reader> r> with-input-stream* ; inline
+    [ <byte-reader> ] dip with-input-stream* ; inline
old mode 100644 (file)
new mode 100755 (executable)
index 287ee3a..47e19d2
@@ -83,6 +83,6 @@ M: c-io-backend (file-appender)
     #! print stuff from contexts where the I/O system would
     #! otherwise not work (tools.deploy.shaker, the I/O
     #! multiplexer thread).
-    "\r\n" append >byte-array
+    "\n" append >byte-array
     stdout-handle fwrite
     stdout-handle fflush ;
index bb6a7a9111ac0258a2e5d2843f68917a4f2ff389..a155f842afade620893237502d3b146ea661e931 100644 (file)
@@ -56,7 +56,7 @@ M: style-stream stream-write
     [ style>> ] [ stream>> ] bi stream-format ;
 
 M: style-stream stream-write1
-    >r 1string r> stream-write ;
+    [ 1string ] dip stream-write ;
 
 M: style-stream make-span-stream
     do-nested-style make-span-stream ;
index 10d8f7d9476fa11b117058790a4a2aaaf19b25e1..57c0cb37e8a25780fa3c6b951ad90ed6ff47fe8b 100644 (file)
@@ -24,7 +24,7 @@ M: null-encoding decode-char drop stream-read1 ;
     ] unless ;
 
 : map-last ( seq quot -- seq )
-    >r dup length <reversed> [ zero? ] r> compose 2map ; inline
+    [ dup length <reversed> ] dip [ 0 = ] prepose 2map ; inline
 
 PRIVATE>
 
@@ -75,7 +75,7 @@ M: growable stream-read-partial
     >sbuf dup reverse-here null-encoding <decoder> ;
 
 : with-string-reader ( str quot -- )
-    >r <string-reader> r> with-input-stream ; inline
+    [ <string-reader> ] dip with-input-stream ; inline
 
 INSTANCE: growable plain-writer
 
index 40094d5589e2c7f9285044c35c9ad24f6ba47a33..31798c92957908b965d323325616a3a1e7dfd931 100644 (file)
@@ -29,12 +29,6 @@ HELP: spin                           $shuffle ;
 HELP: roll                           $shuffle ;
 HELP: -roll                          $shuffle ;
 
-HELP: >r ( x -- )
-{ $values { "x" object } } { $description "Moves the top of the data stack to the retain stack." } ;
-
-HELP: r> ( -- x )
-{ $values { "x" object } } { $description "Moves the top of the retain stack to the data stack." } ;
-
 HELP: datastack ( -- ds )
 { $values { "ds" array } }
 { $description "Outputs an array containing a copy of the data stack contents right before the call to this word, with the top of the stack at the end of the array." } ;
@@ -212,7 +206,10 @@ HELP: 3slip
 
 HELP: keep
 { $values { "quot" { $quotation "( x -- )" } } { "x" object } }
-{ $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." } ;
+{ $description "Call a quotation with a value on the stack, restoring the value when the quotation returns." }
+{ $examples
+    { $example "USING: arrays kernel prettyprint ;" "2 \"greetings\" [ <array> ] keep 2array ." "{ { \"greetings\" \"greetings\" } \"greetings\" }" }
+} ;
 
 HELP: 2keep
 { $values { "quot" { $quotation "( x y -- )" } } { "x" object } { "y" object } }
@@ -347,7 +344,7 @@ HELP: bi*
     "The following two lines are equivalent:"
     { $code
         "[ p ] [ q ] bi*"
-        ">r p r> q"
+        "[ p ] dip q"
     }
 } ;
 
@@ -358,7 +355,7 @@ HELP: 2bi*
     "The following two lines are equivalent:"
     { $code
         "[ p ] [ q ] 2bi*"
-        ">r >r p r> r> q"
+        "[ p ] 2dip q"
     }
 } ;
 
@@ -369,7 +366,7 @@ HELP: tri*
     "The following two lines are equivalent:"
     { $code
         "[ p ] [ q ] [ r ] tri*"
-        ">r >r p r> q r> r"
+        "[ [ p ] dip q ] dip r"
     }
 } ;
 
@@ -380,7 +377,7 @@ HELP: bi@
     "The following two lines are equivalent:"
     { $code
         "[ p ] bi@"
-        ">r p r> p"
+        "[ p ] dip p"
     }
     "The following two lines are also equivalent:"
     { $code
@@ -396,7 +393,7 @@ HELP: 2bi@
     "The following two lines are equivalent:"
     { $code
         "[ p ] 2bi@"
-        ">r >r p r> r> p"
+        "[ p ] 2dip p"
     }
     "The following two lines are also equivalent:"
     { $code
@@ -412,7 +409,7 @@ HELP: tri@
     "The following two lines are equivalent:"
     { $code
         "[ p ] tri@"
-        ">r >r p r> p r> p"
+        "[ [ p ] dip p ] dip p"
     }
     "The following two lines are also equivalent:"
     { $code
@@ -565,11 +562,7 @@ HELP: compose
 { $values { "quot1" callable } { "quot2" callable } { "compose" compose } }
 { $description "Quotation composition. Outputs a " { $link callable } " which calls " { $snippet "quot1" } " followed by " { $snippet "quot2" } "." }
 { $notes
-    "The two quotations must leave the retain stack in the same state on exit as it was on entry, so the following code is not allowed:"
-    { $code
-        "[ 3 >r ] [ r> . ] compose"
-    }
-    "Except for this restriction, the following two lines are equivalent:"
+    "The following two lines are equivalent:"
     { $code
         "compose call"
         "append call"
@@ -589,15 +582,7 @@ HELP: 3compose
 { $values { "quot1" callable } { "quot2" callable } { "quot3" callable } { "compose" compose } }
 { $description "Quotation composition. Outputs a " { $link callable } " which calls " { $snippet "quot1" } ", " { $snippet "quot2" } " and then " { $snippet "quot3" } "." }
 { $notes
-    "The three quotations must leave the retain stack in the same state on exit as it was on entry, so for example, the following code is not allowed:"
-    { $code
-        "[ >r ] swap [ r> ] 3compose"
-    }
-    "The correct way to achieve the effect of the above is the following:"
-    { $code
-        "[ dip ] curry"
-    }
-    "Excepting the retain stack restriction, the following two lines are equivalent:"
+    "The following two lines are equivalent:"
     { $code
         "3compose call"
         "3append call"
@@ -608,16 +593,15 @@ HELP: 3compose
 HELP: dip
 { $values { "x" object } { "quot" quotation } }
 { $description "Calls " { $snippet "quot" } " with " { $snippet "obj" } " hidden on the retain stack." }
-{ $notes "The following are equivalent:"
-    { $code ">r foo bar r>" }
-    { $code "[ foo bar ] dip" }
+{ $examples
+    { $example "USING: arrays kernel math prettyprint ;" "10 20 30 [ / ] dip 2array ." "{ 1/2 30 }" }
 } ;
 
 HELP: 2dip
 { $values { "x" object } { "y" object } { "quot" quotation } }
 { $description "Calls " { $snippet "quot" } " with " { $snippet "obj1" } " and " { $snippet "obj2" } " hidden on the retain stack." }
 { $notes "The following are equivalent:"
-    { $code ">r >r foo bar r> r>" }
+    { $code "[ [ foo bar ] dip ] dip" }
     { $code "[ foo bar ] 2dip" }
 } ;
 
@@ -625,7 +609,7 @@ HELP: 3dip
 { $values { "x" object } { "y" object } { "z" object } { "quot" quotation } }
 { $description "Calls " { $snippet "quot" } " with " { $snippet "obj1" } ", " { $snippet "obj2" } " and " { $snippet "obj3" } " hidden on the retain stack." }
 { $notes "The following are equivalent:"
-    { $code ">r >r >r foo bar r> r> r>" }
+    { $code "[ [ [ foo bar ] dip ] dip ] dip" }
     { $code "[ foo bar ] 3dip" }
 } ;
 
@@ -692,15 +676,7 @@ $nl
 { $subsection -rot }
 { $subsection spin }
 { $subsection roll }
-{ $subsection -roll }
-"Sometimes an additional storage area is needed to hold objects. The " { $emphasis "retain stack" } " is an auxilliary stack for this purpose. Objects can be moved between the data and retain stacks using the following two words:"
-{ $subsection >r }
-{ $subsection r> }
-"The top of the data stack is ``hidden'' between " { $link >r } " and " { $link r> } ":"
-{ $example "1 2 3 >r .s r>" "1\n2" }
-"Usages of " { $link >r } " and " { $link r> } " must be balanced within a single quotation; quotations are not permitted to pop retain stack elements they did not push, or leave elements on the retain stack after returning."
-$nl
-"The " { $link "inference" } " tool checks retain stack usage. The " { $link "slip-keep-combinators" } " combinators abstract out common retain stack usage patterns." ;
+{ $subsection -roll } ;
 
 ARTICLE: "cleave-shuffle-equivalence" "Expressing shuffle words with cleave combinators"
 "Cleave combinators are defined in terms of shuffle words, and mappings from certain shuffle idioms to cleave combinators are discussed in the documentation for " { $link bi } ", " { $link 2bi } ", " { $link 3bi } ", " { $link tri } ", " { $link 2tri } " and " { $link 3tri } "."
@@ -793,14 +769,10 @@ $nl
 { $subsection tri* }
 "Technically, the spread combinators are redundant because they can be simulated using shuffle words and other combinators, and in addition, they do not reduce token counts by much, if at all. However, they can make code more readable by expressing intention and exploiting any inherent symmetry. For example, a piece of code which performs three operations on three related values can be written in one of two ways:"
 { $code
-    "! First alternative; uses retain stack explicitly"
-    ">r >r 1 +"
-    "r> 1 -"
-    "r> 2 *"
+    "! First alternative; uses dip"
+    "[ [ 1 + ] dip 1 - dip ] 2 *"
     "! Second alternative: uses tri*"
-    "[ 1 + ]"
-    "[ 1 - ]"
-    "[ 2 * ] tri*"
+    "[ 1 + ] [ 1 - ] [ 2 * ] tri*"
 }
 
 $nl
@@ -819,7 +791,9 @@ $nl
 { $subsection both? }
 { $subsection either? } ;
 
-ARTICLE: "slip-keep-combinators" "The dip, slip and keep combinators"
+ARTICLE: "slip-keep-combinators" "Retain stack combinators"
+"Sometimes an additional storage area is needed to hold objects. The " { $emphasis "retain stack" } " is an auxilliary stack for this purpose. Objects can be moved between the data and retain stacks using a set of combinators."
+$nl
 "The dip combinators invoke the quotation at the top of the stack, hiding the values underneath:"
 { $subsection dip }
 { $subsection 2dip }
@@ -851,7 +825,7 @@ ARTICLE: "implementing-combinators" "Implementing combinators"
 "These words are used to implement combinators. Note that combinator definitions must be followed by the " { $link POSTPONE: inline } " declaration in order to compile in the optimizing compiler; for example:"
 { $code
     ": keep ( x quot -- x )"
-    "    over >r call r> ; inline"
+    "    over [ call ] dip ; inline"
 }
 "Word inlining is documented in " { $link "declarations" } "." ;
 
@@ -935,10 +909,10 @@ ARTICLE: "dataflow" "Data and control flow"
 { $subsection "booleans" }
 { $subsection "shuffle-words" }
 "A central concept in Factor is that of a " { $emphasis "combinator" } ", which is a word taking code as input."
+{ $subsection "slip-keep-combinators" }
 { $subsection "cleave-combinators" }
 { $subsection "spread-combinators" }
 { $subsection "apply-combinators" }
-{ $subsection "slip-keep-combinators" }
 { $subsection "conditionals" }
 { $subsection "compositional-combinators" }
 { $subsection "combinators" }
index 8a51d45447a2e88307b4140e08a9a331670f4d0b..6619d331f17ab8ea1e65ff1e48431b8236e703f3 100644 (file)
@@ -106,11 +106,11 @@ IN: kernel.tests
 
 ! Regression
 : (loop) ( a b c d -- )
-    >r pick r> swap >r pick r> swap
-    < [ >r >r >r 1+ r> r> r> (loop) ] [ 2drop 2drop ] if ; inline
+    [ pick ] dip swap [ pick ] dip swap
+    < [ [ 1+ ] 3dip (loop) ] [ 2drop 2drop ] if ; inline
 
 : loop ( obj obj -- )
-    H{ } values swap >r dup length swap r> 0 -roll (loop) ;
+    H{ } values swap [ dup length swap ] dip 0 -roll (loop) ;
 
 [ loop ] must-fail
 
index 18bead109dac4a9027cea2b04abd930476043af8..1677a2faaac1e1d9cdc84320dd9cc30c209f5a03 100644 (file)
@@ -3,12 +3,16 @@
 USING: kernel.private slots.private classes.tuple.private ;
 IN: kernel
 
+DEFER: dip
+DEFER: 2dip
+DEFER: 3dip
+
 ! Stack stuff
 : spin ( x y z -- z y x ) swap rot ; inline
 
-: roll ( x y z t -- y z t x ) >r rot r> swap ; inline
+: roll ( x y z t -- y z t x ) [ rot ] dip swap ; inline
 
-: -roll ( x y z t -- t x y z ) swap >r -rot r> ; inline
+: -roll ( x y z t -- t x y z ) swap [ -rot ] dip ; inline
 
 : 2over ( x y z -- x y z x y ) pick pick ; inline
 
@@ -49,56 +53,68 @@ DEFER: if
     pick [ roll 2drop call ] [ 2nip call ] if ; inline
 
 ! Slippers
-: slip ( quot x -- x ) >r call r> ; inline
-
-: 2slip ( quot x y -- x y ) >r >r call r> r> ; inline
-
-: 3slip ( quot x y z -- x y z ) >r >r >r call r> r> r> ; inline
+: slip ( quot x -- x )
+    #! 'slip' and 'dip' can be defined in terms of each other
+    #! because the JIT special-cases a 'dip' preceeded by
+    #! a literal quotation.
+    [ call ] dip ;
+
+: 2slip ( quot x y -- x y )
+    #! '2slip' and '2dip' can be defined in terms of each other
+    #! because the JIT special-cases a '2dip' preceeded by
+    #! a literal quotation.
+    [ call ] 2dip ;
+
+: 3slip ( quot x y z -- x y z )
+    #! '3slip' and '3dip' can be defined in terms of each other
+    #! because the JIT special-cases a '3dip' preceeded by
+    #! a literal quotation.
+    [ call ] 3dip ;
 
 : dip ( x quot -- x ) swap slip ; inline
 
-: 2dip ( x y quot -- x y ) swap >r dip r> ; inline
+: 2dip ( x y quot -- x y ) -rot 2slip ; inline
 
-: 3dip ( x y z quot -- x y z ) swap >r 2dip r> ; inline
+: 3dip ( x y z quot -- x y z ) -roll 3slip ; inline
 
 ! Keepers
-: keep ( x quot -- x ) dupd dip ; inline
+: keep ( x quot -- x ) over slip ; inline
 
-: 2keep ( x y quot -- x y ) >r 2dup r> 2dip ; inline
+: 2keep ( x y quot -- x y ) [ 2dup ] dip 2dip ; inline
 
-: 3keep ( x y z quot -- x y z ) >r 3dup r> 3dip ; inline
+: 3keep ( x y z quot -- x y z ) [ 3dup ] dip 3dip ; inline
 
 ! Cleavers
 : bi ( x p q -- )
-    >r keep r> call ; inline
+    [ keep ] dip call ; inline
 
 : tri ( x p q r -- )
-    >r >r keep r> keep r> call ; inline
+    [ [ keep ] dip keep ] dip call ; inline
 
 ! Double cleavers
 : 2bi ( x y p q -- )
-    >r 2keep r> call ; inline
+    [ 2keep ] dip call ; inline
 
 : 2tri ( x y p q r -- )
-    >r >r 2keep r> 2keep r> call ; inline
+    [ [ 2keep ] dip 2keep ] dip call ; inline
 
 ! Triple cleavers
 : 3bi ( x y z p q -- )
-    >r 3keep r> call ; inline
+    [ 3keep ] dip call ; inline
 
 : 3tri ( x y z p q r -- )
-    >r >r 3keep r> 3keep r> call ; inline
+    [ [ 3keep ] dip 3keep ] dip call ; inline
 
 ! Spreaders
 : bi* ( x y p q -- )
-    >r dip r> call ; inline
+    [ dip ] dip call ; inline
 
 : tri* ( x y z p q r -- )
-    >r >r 2dip r> dip r> call ; inline
+    [ [ 2dip ] dip dip ] dip call ; inline
 
 ! Double spreaders
 : 2bi* ( w x y z p q -- )
-    >r 2dip r> call ; inline
+    [ 2dip ] dip call ; inline
 
 ! Appliers
 : bi@ ( x y quot -- )
@@ -115,8 +131,8 @@ DEFER: if
     dup slip swap [ loop ] [ drop ] if ; inline recursive
 
 : while ( pred: ( -- ? ) body: ( -- ) tail: ( -- ) -- )
-    >r >r dup slip r> r> roll
-    [ >r tuck 2slip r> while ]
+    [ dup slip ] 2dip roll
+    [ [ tuck 2slip ] dip while ]
     [ 2nip call ] if ; inline recursive
 
 ! Object protocol
@@ -182,7 +198,7 @@ GENERIC: boa ( ... class -- tuple )
 : either? ( x y quot -- ? ) bi@ or ; inline
 
 : most ( x y quot -- z )
-    >r 2dup r> call [ drop ] [ nip ] if ; inline
+    [ 2dup ] dip call [ drop ] [ nip ] if ; inline
 
 ! Error handling -- defined early so that other files can
 ! throw errors before continuations are loaded
index d284be00c9776008a10628178024e75ce90a9099..c36e6da19056d11ab1de53bc8821d8f690878532 100644 (file)
@@ -23,7 +23,7 @@ TUPLE: lexer text line line-text line-length column ;
     lexer new-lexer ;
 
 : skip ( i seq ? -- n )
-    >r tuck r>
+    [ tuck ] dip
     [ swap CHAR: \s eq? xor ] curry find-from drop
     [ ] [ length ] ?if ;
 
@@ -74,6 +74,12 @@ PREDICATE: unexpected-eof < unexpected
 
 : unexpected-eof ( word -- * ) f unexpected ;
 
+: expect ( token -- )
+    scan
+    [ 2dup = [ 2drop ] [ unexpected ] if ]
+    [ unexpected-eof ]
+    if* ;
+
 : (parse-tokens) ( accum end -- accum )
     scan 2dup = [
         2drop
index 74a93d39bd306e50b70f6087f95716fa64ea1c90..fcb1b65d80c466bd4dc57fd1b1dd83dba39c81e7 100644 (file)
@@ -25,7 +25,7 @@ M: fixnum + fixnum+ ;
 M: fixnum - fixnum- ;
 M: fixnum * fixnum* ;
 M: fixnum /i fixnum/i ;
-M: fixnum /f >r >float r> >float float/f ;
+M: fixnum /f [ >float ] dip >float float/f ;
 
 M: fixnum mod fixnum-mod ;
 
@@ -41,7 +41,7 @@ M: fixnum bitnot fixnum-bitnot ;
 M: fixnum bit? neg shift 1 bitand 0 > ;
 
 : (fixnum-log2) ( accum n -- accum )
-    dup 1 number= [ drop ] [ >r 1+ r> 2/ (fixnum-log2) ] if ;
+    dup 1 number= [ drop ] [ [ 1+ ] [ 2/ ] bi* (fixnum-log2) ] if ;
     inline recursive
 
 M: fixnum (log2) 0 swap (fixnum-log2) ;
@@ -94,7 +94,7 @@ M: bignum (log2) bignum-log2 ;
 
 : pre-scale ( num den -- scale shifted-num scaled-den )
     2dup [ log2 ] bi@ -
-    tuck [ neg 54 + shift ] [ >r scale-denonimator r> + ] 2bi*
+    tuck [ neg 54 + shift ] [ [ scale-denonimator ] dip + ] 2bi*
     -rot ; inline
 
 ! Second step: loop
@@ -103,7 +103,7 @@ M: bignum (log2) bignum-log2 ;
 
 : /f-loop ( scale mantissa den -- scale' fraction-and-guard rem )
     [ 2dup /i log2 53 > ]
-    [ >r shift-mantissa r> ]
+    [ [ shift-mantissa ] dip ]
     [ ] while /mod ; inline
 
 ! Third step: post-scaling
@@ -111,7 +111,7 @@ M: bignum (log2) bignum-log2 ;
     52 2^ 1- bitand 1022 52 shift bitor bits>double ; inline
 
 : scale-float ( scale mantissa -- float' )
-    >r dup 0 < [ neg 2^ recip ] [ 2^ ] if r> * ; inline
+    [ dup 0 < [ neg 2^ recip ] [ 2^ ] if ] dip * ; inline
 
 : post-scale ( scale mantissa -- n )
     2/ dup log2 52 > [ shift-mantissa ] when
index 20b4e0bbbebe73a335f199e276ff6cff7be42913..aca43add5c4e163013f6313050d9d20262434d6b 100644 (file)
@@ -348,6 +348,7 @@ ARTICLE: "bitwise-arithmetic" "Bitwise arithmetic"
 { $subsection 2/ }
 { $subsection 2^ }
 { $subsection bit? }
+"The " { $vocab-link "math.bitwise" } " vocabulary implements additional bitwise integer operations."
 { $see-also "conditionals" } ;
 
 ARTICLE: "arithmetic" "Arithmetic"
index 6efdd53825d884474d3b8b706f06007b35820a10..5c53d99cff566a31f604fd4ae81bedd58b899e30 100644 (file)
@@ -107,7 +107,7 @@ M: float fp-infinity? ( float -- ? )
     2dup >= [
         drop
     ] [
-        >r 1 shift r> (next-power-of-2)
+        [ 1 shift ] dip (next-power-of-2)
     ] if ;
 
 : next-power-of-2 ( m -- n ) 2 swap (next-power-of-2) ; foldable
@@ -122,13 +122,13 @@ M: float fp-infinity? ( float -- ? )
 
 : iterate-prep 0 -rot ; inline
 
-: if-iterate? >r >r 2over < r> r> if ; inline
+: if-iterate? [ 2over < ] 2dip if ; inline
 
 : iterate-step ( i n quot -- i n quot )
     #! Apply quot to i, keep i and quot, hide n.
-    swap >r 2dup 2slip r> swap ; inline
+    swap [ 2dup 2slip ] dip swap ; inline
 
-: iterate-next >r >r 1+ r> r> ; inline
+: iterate-next [ 1+ ] 2dip ; inline
 
 PRIVATE>
 
@@ -167,6 +167,6 @@ PRIVATE>
         2dup 2slip rot [
             drop
         ] [
-            >r 1- r> find-last-integer
+            [ 1- ] dip find-last-integer
         ] if
     ] if ; inline recursive
index 0134693761969ab845b793380d8dc524658fe4bc..8fc6e6dd9e488a3cc4407dd72a822d206996082d 100644 (file)
@@ -51,12 +51,12 @@ SYMBOL: negative?
 : (base>) ( str -- n ) radix get base> ;
 
 : whole-part ( str -- m n )
-    sign split1 >r (base>) r>
+    sign split1 [ (base>) ] dip
     dup [ (base>) ] [ drop 0 swap ] if ;
 
 : string>ratio ( str -- a/b )
     "-" ?head dup negative? set swap
-    "/" split1 (base>) >r whole-part r>
+    "/" split1 (base>) [ whole-part ] dip
     3dup and and [ / + swap [ neg ] when ] [ 2drop 2drop f ] if ;
 
 : valid-digits? ( seq -- ? )
@@ -137,7 +137,7 @@ M: ratio >base
     {
         {
             [ CHAR: e over member? ]
-            [ "e" split1 >r fix-float "e" r> 3append ]
+            [ "e" split1 [ fix-float "e" ] dip 3append ]
         } {
             [ CHAR: . over member? ]
             [ ]
index 20400f4e54d11848677f99b0d54b71a919f2bf19..427c294759bb570d2836f3a3b20672232dd61ec3 100644 (file)
@@ -23,7 +23,7 @@ PRIVATE>
 : off ( variable -- ) f swap set ; inline
 : get-global ( variable -- value ) global at ;
 : set-global ( value variable -- ) global set-at ;
-: change ( variable quot -- ) >r dup get r> rot slip set ; inline
+: change ( variable quot -- ) [ [ get ] keep ] dip dip set ; inline
 : +@ ( n variable -- ) [ 0 or + ] change ;
 : inc ( variable -- ) 1 swap +@ ; inline
 : dec ( variable -- ) -1 swap +@ ; inline
@@ -37,4 +37,4 @@ PRIVATE>
     H{ } clone >n call ndrop ; inline
 
 : with-variable ( value key quot -- )
-    >r associate >n r> call ndrop ; inline
+    [ associate >n ] dip call ndrop ; inline
index d3c2cff19d1a4db200e399b76d0ec32c2a5ebf34..92e5922802bbab824b4691a228d27f1792282303 100644 (file)
@@ -41,13 +41,15 @@ $nl
 }
 "The " { $vocab-link "qualified" } " vocabulary contains some tools for helping with shadowing." ;
 
-ARTICLE: "vocabulary-search-errors" "Word lookup errors"
-"If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies. Then, one of three things happen:"
-{ $list
-    { "If there are no words having this name at all, an error is thrown and parsing stops." }
-    { "If there are vocabularies which contain words with this name, a restartable error is thrown, with a restart for each vocabulary in question. The restarts add the vocabulary to the search path and continue parsing." }
-}
-"When writing a new vocabulary, one approach is to ignore " { $link POSTPONE: USING: } " declarations altogether, then to load the vocabulary and observe any parser notes and restarts and use this information to write the correct " { $link POSTPONE: USING: } " declaration." ;
+ARTICLE: "vocabulary-search-errors"  "Word lookup errors"
+"If the parser cannot not find a word in the current vocabulary search path, it attempts to look for the word in all loaded vocabularies."
+$nl
+"If " { $link auto-use? } " mode is off, a restartable error is thrown with a restart for each vocabulary in question, together with a restart which defers the word in the current vocabulary, as if " { $link POSTPONE: DEFER: } " was used."
+$nl
+"If " { $link auto-use? } " mode is on and only one vocabulary has a word with this name, the vocabulary is added to the search path and parsing continues."
+$nl
+"If any restarts were invoked, or if " { $link auto-use? } " is on, the parser will print the correct " { $link POSTPONE: USING: } " after parsing completes. This form can be copy and pasted back into the source file."
+{ $subsection auto-use? } ;
 
 ARTICLE: "vocabulary-search" "Vocabulary search path"
 "When the parser reads a token, it attempts to look up a word named by that token. The lookup is performed by searching each vocabulary in the search path, in order."
@@ -353,3 +355,7 @@ HELP: staging-violation
 { $description "Throws a " { $link staging-violation } " error." }
 { $error-description "Thrown by the parser if a parsing word is used in the same compilation unit as where it was defined; see " { $link "compilation-units" } "." }
 { $notes "One possible workaround is to use the " { $link POSTPONE: << } " word to execute code at parse time. However, executing words defined in the same source file at parse time is still prohibited." } ;
+
+HELP: auto-use?
+{ $var-description "If set to a true value, the behavior of the parser when encountering an unknown word name is changed. If only one loaded vocabulary has a word with this name, instead of throwing an error, the parser adds the vocabulary to the search path and prints a parse note. Off by default." }
+{ $notes "This feature is intended to help during development. To generate a " { $link POSTPONE: USING: } " form automatically, enable " { $link auto-use? } ", load the source file, and copy and paste the " { $link POSTPONE: USING: } " form printed by the parser back into the file, then disable " { $link auto-use? } ". See " { $link "vocabulary-search-errors" } "." } ;
index c4fa0890f9a403e3bbe155c8b02fa2eb24f74ec3..1e93a762f2cc8dd3e7cc7ec9db9d4a10eeae4637 100644 (file)
@@ -2,7 +2,7 @@ USING: arrays math parser tools.test kernel generic words
 io.streams.string namespaces classes effects source-files
 assocs sequences strings io.files definitions continuations
 sorting classes.tuple compiler.units debugger vocabs
-vocabs.loader accessors eval combinators ;
+vocabs.loader accessors eval combinators lexer ;
 IN: parser.tests
 
 [
@@ -428,7 +428,7 @@ must-fail-with
     "USE: this-better-not-exist" eval
 ] must-fail
 
-[ ": foo ;" eval ] [ error>> no-current-vocab? ] must-fail-with
+[ ": foo ;" eval ] [ error>> error>> no-current-vocab? ] must-fail-with
 
 [ 92 ] [ "CHAR: \\" eval ] unit-test
 [ 92 ] [ "CHAR: \\\\" eval ] unit-test
@@ -483,7 +483,7 @@ must-fail-with
 
 [ t ] [ "staging-problem-test-2" "parser.tests" lookup >boolean ] unit-test
 
-[ "DEFER: blah" eval ] [ error>> no-current-vocab? ] must-fail-with
+[ "DEFER: blah" eval ] [ error>> error>> no-current-vocab? ] must-fail-with
 
 [
     "IN: parser.tests : blah ; parsing FORGET: blah" eval
@@ -496,3 +496,7 @@ DEFER: blah
 
 [ "IN: parser.tests USE: kernel TUPLE: blah < tuple ; : blah ; TUPLE: blah < tuple ; : blah ;" eval ]
 [ error>> error>> def>> \ blah eq? ] must-fail-with
+
+[ ] [ f lexer set f file set "Hello world" note. ] unit-test
+
+[ "CHAR: \\u9999999999999" eval ] must-fail
index ed8fc4510b5d2897ad9bb85da0197ca25d707bbc..42e4e7705540c1b9596bfe7c68ccc1c88072e630 100644 (file)
@@ -10,7 +10,7 @@ IN: parser
 
 : location ( -- loc )
     file get lexer get line>> 2dup and
-    [ >r path>> r> 2array ] [ 2drop f ] if ;
+    [ [ path>> ] dip 2array ] [ 2drop f ] if ;
 
 : save-location ( definition -- )
     location remember-definition ;
@@ -25,7 +25,7 @@ t parser-notes set-global
 : note. ( str -- )
     parser-notes? [
         file get [ path>> write ":" write ] when* 
-        lexer get line>> number>string write ": " write
+        lexer get [ line>> number>string write ": " write ] when*
         "Note: " write dup print
     ] when drop ;
 
@@ -52,7 +52,12 @@ SYMBOL: in
 
 M: parsing-word stack-effect drop (( parsed -- parsed )) ;
 
-ERROR: no-current-vocab ;
+TUPLE: no-current-vocab ;
+
+: no-current-vocab ( -- vocab )
+    \ no-current-vocab boa
+    { { "Define words in scratchpad vocabulary" "scratchpad" } }
+    throw-restarts dup set-in ;
 
 : current-vocab ( -- str )
     in get [ no-current-vocab ] unless* ;
@@ -64,20 +69,36 @@ ERROR: no-current-vocab ;
 
 : CREATE-WORD ( -- word ) CREATE dup reset-generic ;
 
-: word-restarts ( possibilities -- restarts )
-    natural-sort [
-        [
-            "Use the " swap vocabulary>> " vocabulary" 3append
-        ] keep
-    ] { } map>assoc ;
+: word-restarts ( name possibilities -- restarts )
+    natural-sort
+    [ [ "Use the " swap vocabulary>> " vocabulary" 3append ] keep ] { } map>assoc
+    swap "Defer word in current vocabulary" swap 2array
+    suffix ;
 
 ERROR: no-word-error name ;
 
+: <no-word-error> ( name possibilities -- error restarts )
+    [ drop \ no-word-error boa ] [ word-restarts ] 2bi ;
+
+SYMBOL: amended-use?
+
+SYMBOL: auto-use?
+
+: no-word-restarted ( restart-value -- word )
+    dup word? [
+        amended-use? on
+        dup vocabulary>>
+        [ (use+) ] [
+            "Added ``" swap "'' vocabulary to search path" 3append note.
+        ] bi
+    ] [ create-in ] if ;
+
 : no-word ( name -- newword )
-    dup \ no-word-error boa
-    swap words-named [ forward-reference? not ] filter
-    word-restarts throw-restarts
-    dup vocabulary>> (use+) ;
+    dup words-named [ forward-reference? not ] filter
+    dup length 1 = auto-use? get and
+    [ nip first no-word-restarted ]
+    [ <no-word-error> throw-restarts no-word-restarted ]
+    if ;
 
 : check-forward ( str word -- word/f )
     dup forward-reference? [
@@ -119,7 +140,7 @@ ERROR: staging-violation word ;
     } cond ;
 
 : (parse-until) ( accum end -- accum )
-    dup >r parse-step [ r> (parse-until) ] [ r> drop ] if ;
+    [ parse-step ] keep swap [ (parse-until) ] [ drop ] if ;
 
 : parse-until ( end -- vec )
     100 <vector> swap (parse-until) ;
@@ -127,13 +148,15 @@ ERROR: staging-violation word ;
 : parsed ( accum obj -- accum ) over push ;
 
 : (parse-lines) ( lexer -- quot )
-    [ f parse-until >quotation ] with-lexer ;
+    [
+        f parse-until >quotation
+    ] with-lexer ;
 
 : parse-lines ( lines -- quot )
     lexer-factory get call (parse-lines) ;
 
 : parse-literal ( accum end quot -- accum )
-    >r parse-until r> call parsed ; inline
+    [ parse-until ] dip call parsed ; inline
 
 : parse-definition ( -- quot )
     \ ; parse-until >quotation ;
@@ -206,8 +229,18 @@ SYMBOL: interactive-vocabs
         call
     ] with-scope ; inline
 
+SYMBOL: print-use-hook
+
+print-use-hook global [ [ ] or ] change-at
+
 : parse-fresh ( lines -- quot )
-    [ parse-lines ] with-file-vocabs ;
+    [
+        amended-use? off
+        parse-lines
+        amended-use? get [
+            print-use-hook get call
+        ] when
+    ] with-file-vocabs ;
 
 : parsing-file ( file -- )
     "quiet" get [
index d311dfad718e266a211e1c132ab1ee479fab54f8..29e13043345887646d52e72d0f4ddbf5fb4e2edc 100644 (file)
@@ -15,4 +15,4 @@ IN: quotations.tests
 
 [ [ "hi" ] ] [ "hi" 1quotation ] unit-test
 
-[ 1 \ + curry ] must-fail
+[ 1 \ + curry ] must-fail
index 31e5e4753d2b86613b663316bda4cfd0855e7226..2df11d485874958d20f3acbd412844110f307abc 100644 (file)
@@ -49,7 +49,10 @@ M: wrapper literalize <wrapper> ;
 M: curry length quot>> length 1+ ;
 
 M: curry nth
-    over zero? [ nip obj>> literalize ] [ >r 1- r> quot>> nth ] if ;
+    over 0 =
+    [ nip obj>> literalize ]
+    [ [ 1- ] dip quot>> nth ]
+    if ;
 
 INSTANCE: curry immutable-sequence
 
index 0fe47f00999955b03caea55534211115367b9c60..832de612dd1276a323cbba53f3eeb379f5df9d8a 100644 (file)
@@ -16,7 +16,7 @@ GENERIC: like ( seq exemplar -- newseq ) flushable
 GENERIC: clone-like ( seq exemplar -- newseq ) flushable
 
 : new-like ( len exemplar quot -- seq )
-    over >r >r new-sequence r> call r> like ; inline
+    over [ [ new-sequence ] dip call ] dip like ; inline
 
 M: sequence like drop ;
 
@@ -111,14 +111,14 @@ INSTANCE: integer immutable-sequence
     [ first3-unsafe 3 ] [ nth-unsafe ] bi ; inline
 
 : exchange-unsafe ( m n seq -- )
-    [ tuck nth-unsafe >r nth-unsafe r> ] 3keep tuck
-    >r >r set-nth-unsafe r> r> set-nth-unsafe ; inline
+    [ tuck [ nth-unsafe ] 2bi@ ]
+    [ tuck [ set-nth-unsafe ] 2bi@ ] 3bi ; inline
 
 : (head) ( seq n -- from to seq ) 0 spin ; inline
 
 : (tail) ( seq n -- from to seq ) over length rot ; inline
 
-: from-end >r dup length r> - ; inline
+: from-end [ dup length ] dip - ; inline
 
 : (2sequence)
     tuck 1 swap set-nth-unsafe
@@ -188,9 +188,9 @@ TUPLE: slice
 { seq read-only } ;
 
 : collapse-slice ( m n slice -- m' n' seq )
-    [ from>> ] [ seq>> ] bi >r tuck + >r + r> r> ; inline
+    [ from>> ] [ seq>> ] bi [ tuck [ + ] 2bi@ ] dip ; inline
 
-ERROR: slice-error reason ;
+ERROR: slice-error from to seq reason ;
 
 : check-slice ( from to seq -- from to seq )
     pick 0 < [ "start < 0" slice-error ] when
@@ -253,12 +253,12 @@ INSTANCE: repetition immutable-sequence
 
 : prepare-subseq ( from to seq -- dst i src j n )
     #! The check-length call forces partial dispatch
-    [ >r swap - r> new-sequence dup 0 ] 3keep
+    [ [ swap - ] dip new-sequence dup 0 ] 3keep
     -rot drop roll length check-length ; inline
 
 : check-copy ( src n dst -- )
     over 0 < [ bounds-error ] when
-    >r swap length + r> lengthen ; inline
+    [ swap length + ] dip lengthen ; inline
 
 PRIVATE>
 
@@ -279,11 +279,11 @@ PRIVATE>
 
 : copy ( src i dst -- )
     #! The check-length call forces partial dispatch
-    pick length check-length >r 3dup check-copy spin 0 r>
+    pick length check-length [ 3dup check-copy spin 0 ] dip
     (copy) drop ; inline
 
 M: sequence clone-like
-    >r dup length r> new-sequence [ 0 swap copy ] keep ;
+    [ dup length ] dip new-sequence [ 0 swap copy ] keep ;
 
 M: immutable-sequence clone-like like ;
 
@@ -291,31 +291,31 @@ M: immutable-sequence clone-like like ;
 
 <PRIVATE
 
-: ((append)) ( seq1 seq2 accum -- accum )
-    [ >r over length r> copy ]
-    [ 0 swap copy ] 
+: (append) ( seq1 seq2 accum -- accum )
+    [ [ over length ] dip copy ]
+    [ 0 swap copy ]
     [ ] tri ; inline
 
-: (append) ( seq1 seq2 exemplar -- newseq )
-    >r over length over length + r>
-    [ ((append)) ] new-like ; inline
+PRIVATE>
 
-: (3append) ( seq1 seq2 seq3 exemplar -- newseq )
-    >r pick length pick length pick length + + r> [
-        [ >r pick length pick length + r> copy ]
-        [ ((append)) ] bi
-    ] new-like ; inline
+: append-as ( seq1 seq2 exemplar -- newseq )
+    [ over length over length + ] dip
+    [ (append) ] new-like ; inline
 
-PRIVATE>
+: 3append-as ( seq1 seq2 seq3 exemplar -- newseq )
+    [ pick length pick length pick length + + ] dip [
+        [ [ pick length pick length + ] dip copy ]
+        [ (append) ] bi
+    ] new-like ; inline
 
-: append ( seq1 seq2 -- newseq ) over (append) ;
+: append ( seq1 seq2 -- newseq ) over append-as ;
 
 : prepend ( seq1 seq2 -- newseq ) swap append ; inline
 
-: 3append ( seq1 seq2 seq3 -- newseq ) pick (3append) ;
+: 3append ( seq1 seq2 seq3 -- newseq ) pick 3append-as ;
 
 : change-nth ( i seq quot -- )
-    [ >r nth r> call ] 3keep drop set-nth ; inline
+    [ [ nth ] dip call ] 3keep drop set-nth ; inline
 
 : min-length ( seq1 seq2 -- n ) [ length ] bi@ min ; inline
 
@@ -324,32 +324,32 @@ PRIVATE>
 <PRIVATE
 
 : (each) ( seq quot -- n quot' )
-    >r dup length swap [ nth-unsafe ] curry r> compose ; inline
+    [ dup length swap [ nth-unsafe ] curry ] dip compose ; inline
 
 : (collect) ( quot into -- quot' )
-    [ >r keep r> set-nth-unsafe ] 2curry ; inline
+    [ [ keep ] dip set-nth-unsafe ] 2curry ; inline
 
 : collect ( n quot into -- )
     (collect) each-integer ; inline
 
 : map-into ( seq quot into -- )
-    >r (each) r> collect ; inline
+    [ (each) ] dip collect ; inline
 
 : 2nth-unsafe ( n seq1 seq2 -- elt1 elt2 )
-    >r over r> nth-unsafe >r nth-unsafe r> ; inline
+    [ over ] dip nth-unsafe [ nth-unsafe ] dip ; inline
 
 : (2each) ( seq1 seq2 quot -- n quot' )
-    >r [ min-length ] 2keep r>
-    [ >r 2nth-unsafe r> call ] 3curry ; inline
+    [ [ min-length ] 2keep ] dip
+    [ [ 2nth-unsafe ] dip call ] 3curry ; inline
 
 : 2map-into ( seq1 seq2 quot into -- newseq )
-    >r (2each) r> collect ; inline
+    [ (2each) ] dip collect ; inline
 
 : finish-find ( i seq -- i elt )
     over [ dupd nth-unsafe ] [ drop f ] if ; inline
 
 : (find) ( seq quot quot' -- i elt )
-    pick >r >r (each) r> call r> finish-find ; inline
+    pick [ [ (each) ] dip call ] dip finish-find ; inline
 
 : (find-from) ( n seq quot quot' -- i elt )
     [ 2dup bounds-check? ] 2dip
@@ -373,7 +373,7 @@ PRIVATE>
     swapd each ; inline
 
 : map-as ( seq quot exemplar -- newseq )
-    >r over length r> [ [ map-into ] keep ] new-like ; inline
+    [ over length ] dip [ [ map-into ] keep ] new-like ; inline
 
 : map ( seq quot -- newseq )
     over map-as ; inline
@@ -382,7 +382,7 @@ PRIVATE>
     [ drop ] prepose map ; inline
 
 : replicate-as ( seq quot exemplar -- newseq )
-    >r [ drop ] prepose r> map-as ; inline
+    [ [ drop ] prepose ] dip map-as ; inline
 
 : change-each ( seq quot -- )
     over map-into ; inline
@@ -394,13 +394,13 @@ PRIVATE>
     (2each) each-integer ; inline
 
 : 2reverse-each ( seq1 seq2 quot -- )
-    >r [ <reversed> ] bi@ r> 2each ; inline
+    [ [ <reversed> ] bi@ ] dip 2each ; inline
 
 : 2reduce ( seq1 seq2 identity quot -- result )
-    >r -rot r> 2each ; inline
+    [ -rot ] dip 2each ; inline
 
 : 2map-as ( seq1 seq2 quot exemplar -- newseq )
-    >r 2over min-length r>
+    [ 2over min-length ] dip
     [ [ 2map-into ] keep ] new-like ; inline
 
 : 2map ( seq1 seq2 quot -- newseq )
@@ -422,49 +422,49 @@ PRIVATE>
     [ nip find-last-integer ] (find-from) ; inline
 
 : find-last ( seq quot -- i elt )
-    [ >r 1- r> find-last-integer ] (find) ; inline
+    [ [ 1- ] dip find-last-integer ] (find) ; inline
 
 : all? ( seq quot -- ? )
     (each) all-integers? ; inline
 
 : push-if ( elt quot accum -- )
-    >r keep r> rot [ push ] [ 2drop ] if  ; inline
+    [ keep ] dip rot [ push ] [ 2drop ] if ; inline
 
 : pusher ( quot -- quot accum )
     V{ } clone [ [ push-if ] 2curry ] keep ; inline
 
 : filter ( seq quot -- subseq )
-    over >r pusher >r each r> r> like ; inline
+    over [ pusher [ each ] dip ] dip like ; inline
 
 : push-either ( elt quot accum1 accum2 -- )
-    >r >r keep swap r> r> ? push ; inline
+    [ keep swap ] 2dip ? push ; inline
 
 : 2pusher ( quot -- quot accum1 accum2 )
     V{ } clone V{ } clone [ [ push-either ] 3curry ] 2keep ; inline
 
 : partition ( seq quot -- trueseq falseseq )
-    over >r 2pusher >r >r each r> r> r> tuck [ like ] 2bi@ ; inline
+    over [ 2pusher [ each ] 2dip ] dip tuck [ like ] 2bi@ ; inline
 
 : monotonic? ( seq quot -- ? )
-    >r dup length 1- swap r> (monotonic) all? ; inline
+    [ dup length 1- swap ] dip (monotonic) all? ; inline
 
 : interleave ( seq between quot -- )
-    [ (interleave) ] 2curry >r dup length swap r> 2each ; inline
+    [ (interleave) ] 2curry [ dup length swap ] dip 2each ; inline
 
 : accumulator ( quot -- quot' vec )
     V{ } clone [ [ push ] curry compose ] keep ; inline
 
 : produce-as ( pred quot tail exemplar -- seq )
-    >r swap accumulator >r swap while r> r> like ; inline
+    [ swap accumulator [ swap while ] dip ] dip like ; inline
 
 : produce ( pred quot tail -- seq )
     { } produce-as ; inline
 
 : follow ( obj quot -- seq )
-    >r [ dup ] r> [ keep ] curry [ ] produce nip ; inline
+    [ dup ] swap [ keep ] curry [ ] produce nip ; inline
 
 : prepare-index ( seq quot -- seq n quot )
-    >r dup length r> ; inline
+    [ dup length ] dip ; inline
 
 : each-index ( seq quot -- )
     prepare-index 2each ; inline
@@ -518,9 +518,9 @@ PRIVATE>
 
 : cache-nth ( i seq quot -- elt )
     2over ?nth dup [
-        >r 3drop r>
+        [ 3drop ] dip
     ] [
-        drop swap >r over >r call dup r> r> set-nth
+        drop swap [ over [ call dup ] dip ] dip set-nth
     ] if ; inline
 
 : mismatch ( seq1 seq2 -- i )
@@ -575,14 +575,14 @@ PRIVATE>
     [ eq? not ] with filter-here ;
 
 : prefix ( seq elt -- newseq )
-    over >r over length 1+ r> [
+    over [ over length 1+ ] dip [
         [ 0 swap set-nth-unsafe ] keep
         [ 1 swap copy ] keep
     ] new-like ;
 
 : suffix ( seq elt -- newseq )
-    over >r over length 1+ r> [
-        [ >r over length r> set-nth-unsafe ] keep
+    over [ over length 1+ ] dip [
+        [ [ over length ] dip set-nth-unsafe ] keep
         [ 0 swap copy ] keep
     ] new-like ;
 
@@ -596,7 +596,7 @@ PRIVATE>
     2over = [
         2drop 2drop
     ] [
-        [ >r 2over + pick r> move >r 1+ r> ] keep
+        [ [ 2over + pick ] dip move [ 1+ ] dip ] keep
         move-backward
     ] if ;
 
@@ -604,15 +604,15 @@ PRIVATE>
     2over = [
         2drop 2drop
     ] [
-        [ >r pick >r dup dup r> + swap r> move 1- ] keep
+        [ [ pick [ dup dup ] dip + swap ] dip move 1- ] keep
         move-forward
     ] if ;
 
 : (open-slice) ( shift from to seq ? -- )
     [
-        >r [ 1- ] bi@ r> move-forward
+        [ [ 1- ] bi@ ] dip move-forward
     ] [
-        >r >r over - r> r> move-backward
+        [ over - ] 2dip move-backward
     ] if ;
 
 PRIVATE>
@@ -621,19 +621,19 @@ PRIVATE>
     pick 0 = [
         3drop
     ] [
-        pick over length + over >r >r
-        pick 0 > >r [ length ] keep r> (open-slice)
-        r> r> set-length
+        pick over length + over
+        [ pick 0 > [ [ length ] keep ] dip (open-slice) ] 2dip
+        set-length
     ] if ;
 
 : delete-slice ( from to seq -- )
-    check-slice >r over >r - r> r> open-slice ;
+    check-slice [ over [ - ] dip ] dip open-slice ;
 
 : delete-nth ( n seq -- )
-    >r dup 1+ r> delete-slice ;
+    [ dup 1+ ] dip delete-slice ;
 
 : replace-slice ( new from to seq -- )
-    [ >r >r dup pick length + r> - over r> open-slice ] keep
+    [ [ [ dup pick length + ] dip - over ] dip open-slice ] keep
     copy ;
 
 : remove-nth ( n seq -- seq' )
@@ -652,7 +652,7 @@ PRIVATE>
 
 : reverse-here ( seq -- )
     dup length dup 2/ [
-        >r 2dup r>
+        [ 2dup ] dip
         tuck - 1- rot exchange-unsafe
     ] each 2drop ;
 
@@ -679,7 +679,7 @@ PRIVATE>
 <PRIVATE
 
 : joined-length ( seq glue -- n )
-    >r dup sum-lengths swap length 1 [-] r> length * + ;
+    [ dup sum-lengths swap length 1 [-] ] dip length * + ;
 
 PRIVATE>
 
@@ -696,7 +696,7 @@ PRIVATE>
     ] dip compose if ; inline
 
 : pad-left ( seq n elt -- padded )
-    [ swap dup (append) ] padding ;
+    [ swap dup append-as ] padding ;
 
 : pad-right ( seq n elt -- padded )
     [ append ] padding ;
@@ -735,12 +735,12 @@ PRIVATE>
         >fixnum {
             [ drop nip ]
             [ 2drop first ]
-            [ >r drop first2 r> call ]
-            [ >r drop first3 r> bi@ ]
+            [ [ drop first2 ] dip call ]
+            [ [ drop first3 ] dip bi@ ]
         } dispatch
     ] [
         drop
-        >r >r halves r> r>
+        [ halves ] 2dip
         [ [ binary-reduce ] 2curry bi@ ] keep
         call
     ] if ; inline recursive
@@ -755,7 +755,7 @@ PRIVATE>
 
 : (start) ( subseq seq n -- subseq seq ? )
     pick length [
-        >r 3dup r> [ + swap nth-unsafe ] keep rot nth-unsafe =
+        [ 3dup ] dip [ + swap nth-unsafe ] keep rot nth-unsafe =
     ] all? nip ; inline
 
 PRIVATE>
@@ -763,7 +763,7 @@ PRIVATE>
 : start* ( subseq seq n -- i )
     pick length pick length swap - 1+
     [ (start) ] find-from
-    swap >r 3drop r> ;
+    swap [ 3drop ] dip ;
 
 : start ( subseq seq -- i ) 0 start* ; inline
 
@@ -771,7 +771,7 @@ PRIVATE>
 
 : drop-prefix ( seq1 seq2 -- slice1 slice2 )
     2dup mismatch [ 2dup min-length ] unless*
-    tuck tail-slice >r tail-slice r> ;
+    tuck [ tail-slice ] 2bi@ ;
 
 : unclip ( seq -- rest first )
     [ rest ] [ first ] bi ;
@@ -801,14 +801,14 @@ PRIVATE>
     inline
 
 : trim-left-slice ( seq quot -- slice )
-    over >r [ not ] compose find drop r> swap
+    over [ [ not ] compose find drop ] dip swap
     [ tail-slice ] [ dup length tail-slice ] if* ; inline
     
 : trim-left ( seq quot -- newseq )
     over [ trim-left-slice ] dip like ; inline
 
 : trim-right-slice ( seq quot -- slice )
-    over >r [ not ] compose find-last drop r> swap
+    over [ [ not ] compose find-last drop ] dip swap
     [ 1+ head-slice ] [ 0 head-slice ] if* ; inline
 
 : trim-right ( seq quot -- newseq )
index 72c79928cb34bb50888f859c5193b23da11045d9..35aa49d0534c6ede10b45bba61a6395d87b469d6 100644 (file)
@@ -3,7 +3,7 @@
 USING: arrays byte-arrays kernel kernel.private math namespaces
 make sequences strings words effects generic generic.standard
 classes classes.algebra slots.private combinators accessors
-words sequences.private assocs alien ;
+words sequences.private assocs alien quotations ;
 IN: slots
 
 TUPLE: slot-spec name offset class initial read-only ;
@@ -23,7 +23,7 @@ PREDICATE: writer < word "writer" word-prop ;
     3bi ;
 
 : create-accessor ( name effect -- word )
-    >r "accessors" create dup r>
+    [ "accessors" create dup ] dip
     "declared-effect" set-word-prop ;
 
 : reader-quot ( slot-spec -- quot )
@@ -59,7 +59,7 @@ ERROR: bad-slot-value value class ;
     offset>> , \ set-slot , ;
 
 : writer-quot/coerce ( slot-spec -- )
-    [ \ >r , class>> "coercer" word-prop % \ r> , ]
+    [ class>> "coercer" word-prop [ dip ] curry % ]
     [ offset>> , \ set-slot , ]
     bi ;
 
@@ -75,7 +75,7 @@ ERROR: bad-slot-value value class ;
     bi ;
 
 : writer-quot/fixnum ( slot-spec -- )
-    [ >r >fixnum r> ] % writer-quot/check ;
+    [ [ >fixnum ] dip ] % writer-quot/check ;
 
 : writer-quot ( slot-spec -- quot )
     [
@@ -108,9 +108,9 @@ ERROR: bad-slot-value value class ;
 : define-changer ( name -- )
     dup changer-word dup deferred? [
         [
-            [ over >r >r ] %
-            over reader-word ,
-            [ r> call r> swap ] %
+            \ over ,
+            over reader-word 1quotation
+            [ dip call ] curry [ dip swap ] curry %
             swap setter-word ,
         ] [ ] make define-inline
     ] [ 2drop ] if ;
index b57e6616247a2708854a07825a9c8900509d4f33..47399b61767940882bfa83bc17878c441811e669 100644 (file)
@@ -25,20 +25,20 @@ TUPLE: merge
 
 : dump ( from to seq accum -- )
     #! Optimize common case where to - from = 1, 2, or 3.
-    >r >r 2dup swap - r> r> pick 1 = 
-    [ >r >r 2drop r> nth-unsafe r> push ] [
+    [ 2dup swap - ] 2dip pick 1 = 
+    [ [ [ 2drop ] dip nth-unsafe ] dip push ] [
         pick 2 = [
-            >r >r 2drop dup 1+
-            r> [ nth-unsafe ] curry bi@
-            r> [ push ] curry bi@
+            [
+                [ 2drop dup 1+ ] dip
+                [ nth-unsafe ] curry bi@
+            ] dip [ push ] curry bi@
         ] [
             pick 3 = [
-                >r >r 2drop dup 1+ dup 1+
-                r> [ nth-unsafe ] curry tri@
-                r> [ push ] curry tri@
-            ] [
-                >r nip subseq r> push-all
-            ] if
+                [
+                    [ 2drop dup 1+ dup 1+ ] dip
+                    [ nth-unsafe ] curry tri@
+                ] dip [ push ] curry tri@
+            ] [ [ nip subseq ] dip push-all ] if
         ] if
     ] if ; inline
 
index 472b303059ef50380e37f954b30ac362ec9b35e0..354df832cab99bd2d1c3bb722c22a88c21c14c04 100644 (file)
@@ -8,6 +8,9 @@ ARTICLE: "sequences-split" "Splitting sequences"
 { $subsection ?tail }
 { $subsection ?tail-slice }
 { $subsection split1 }
+{ $subsection split1-slice }
+{ $subsection split1-last }
+{ $subsection split1-last-slice }
 { $subsection split }
 "Splitting a string into lines:"
 { $subsection string-lines } ;
@@ -18,11 +21,19 @@ HELP: split1
 { $values { "seq" "a sequence" } { "subseq" "a sequence" } { "before" "a new sequence" } { "after" "a new sequence" } }
 { $description "Splits " { $snippet "seq" } " at the first occurrence of " { $snippet "subseq" } ", and outputs the pieces before and after the split. If " { $snippet "subseq" } " does not occur in " { $snippet "seq" } ", then " { $snippet "before" } " is just " { $snippet "seq" } " and " { $snippet "after" } " is " { $link f } "." } ;
 
-HELP: last-split1
+HELP: split1-slice
+{ $values { "seq" "a sequence" } { "subseq" "a sequence" } { "before-slice" slice } { "after-slice" slice } }
+{ $description "Splits " { $snippet "seq" } " at the first occurrence of " { $snippet "subseq" } ", and outputs the pieces before and after the split as slices. If " { $snippet "subseq" } " does not occur in " { $snippet "seq" } ", then " { $snippet "before" } " is just " { $snippet "seq" } " and " { $snippet "after" } " is " { $link f } "." } ;
+
+HELP: split1-last
 { $values { "seq" "a sequence" } { "subseq" "a sequence" } { "before" "a new sequence" } { "after" "a new sequence" } }
 { $description "Splits " { $snippet "seq" } " at the last occurrence of " { $snippet "subseq" } ", and outputs the pieces before and after the split. If " { $snippet "subseq" } " does not occur in " { $snippet "seq" } ", then " { $snippet "before" } " is just " { $snippet "seq" } " and " { $snippet "after" } " is " { $link f } "." } ;
 
-{ split1 last-split1 } related-words
+HELP: split1-last-slice
+{ $values { "seq" "a sequence" } { "subseq" "a sequence" } { "before-slice" slice } { "after-slice" slice } }
+{ $description "Splits " { $snippet "seq" } " at the last occurrence of " { $snippet "subseq" } ", and outputs the pieces before and after the split as slices. If " { $snippet "subseq" } " does not occur in " { $snippet "seq" } ", then " { $snippet "before" } " is just " { $snippet "seq" } " and " { $snippet "after" } " is " { $link f } "." } ;
+
+{ split1 split1-slice split1-last split1-last-slice } related-words
 
 HELP: split
 { $values { "seq" "a sequence" } { "separators" "a sequence" } { "pieces" "a new array" } }
index 0f3dbdea1b0189e0bb48f4e60e811f4e15eccdb7..ed68038fa6ddc5579c48fc0c93cda31cec0772ac 100644 (file)
@@ -1,4 +1,4 @@
-USING: splitting tools.test kernel sequences arrays ;
+USING: splitting tools.test kernel sequences arrays strings ;
 IN: splitting.tests
 
 [ "hello" "world ." ] [ "hello world ." " " split1 ] unit-test
@@ -6,10 +6,15 @@ IN: splitting.tests
 [ "goodbye" f ] [ "goodbye" " " split1 ] unit-test
 [ "" "" ] [ "great" "great" split1 ] unit-test
 
-[ "hello world" "." ] [ "hello world ." " " last-split1 ] unit-test
-[ "hello-+world" "." ] [ "hello-+world-+." "-+" last-split1 ] unit-test
-[ "goodbye" f ] [ "goodbye" " " last-split1 ] unit-test
-[ "" "" ] [ "great" "great" last-split1 ] unit-test
+[ "hello world" "." ] [ "hello world ." " " split1-last ] unit-test
+[ "hello-+world" "." ] [ "hello-+world-+." "-+" split1-last ] unit-test
+[ "goodbye" f ] [ "goodbye" " " split1-last ] unit-test
+[ "" "" ] [ "great" "great" split1-last ] unit-test
+
+[ "hello world" "." ] [ "hello world ." " " split1-last-slice [ >string ] bi@ ] unit-test
+[ "hello-+world" "." ] [ "hello-+world-+." "-+" split1-last-slice [ >string ] bi@ ] unit-test
+[ "goodbye" f ] [ "goodbye" " " split1-last-slice [ >string ] dip ] unit-test
+[ "" f ] [ "great" "great" split1-last-slice [ >string ] dip ] unit-test
 
 [ "and end" t ] [ "Beginning and end" "Beginning " ?head ] unit-test
 [ "Beginning and end" f ] [ "Beginning and end" "Beginning x" ?head ] unit-test
index aac32784a1f8c49465c72f61b460b7fe31ea66cb..29fee2e5c3c063d0b3cb2d65ae9760fabd2244ef 100644 (file)
@@ -18,15 +18,26 @@ IN: splitting
 
 : split1 ( seq subseq -- before after )
     dup pick start dup [
-        [ >r over r> head -rot length ] keep + tail
+        [ [ over ] dip head -rot length ] keep + tail
     ] [
         2drop f
     ] if ;
 
-: last-split1 ( seq subseq -- before after )
+: split1-slice ( seq subseq -- before-slice after-slice )
+    dup pick start dup [
+        [ [ over ] dip head-slice -rot length ] keep + tail-slice
+    ] [
+        2drop f
+    ] if ;
+
+: split1-last ( seq subseq -- before after )
     [ <reversed> ] bi@ split1 [ reverse ] bi@
     dup [ swap ] when ;
 
+: split1-last-slice ( seq subseq -- before-slice after-slice )
+    [ <reversed> ] bi@ split1-slice [ <reversed> ] bi@
+    [ f ] [ swap ] if-empty ;
+
 : (split) ( separators n seq -- )
     3dup rot [ member? ] curry find-from drop
     [ [ swap subseq , ] 2keep 1+ swap (split) ]
index 2695860a59b53c7c5cbba4c6350df41667297dfc..cfe5d1a90ac9acf822c3fca4fc8ab3bfa3805915 100644 (file)
@@ -29,10 +29,10 @@ name>char-hook global [
 : unicode-escape ( str -- ch str' )
     "{" ?head-slice [
         CHAR: } over index cut-slice
-        >r >string name>char-hook get call r>
+        [ >string name>char-hook get call ] dip
         rest-slice
     ] [
-        6 cut-slice >r hex> r>
+        6 cut-slice [ hex> ] dip
     ] if ;
 
 : next-escape ( str -- ch str' )
@@ -44,11 +44,11 @@ name>char-hook global [
 
 : (parse-string) ( str -- m )
     dup [ "\"\\" member? ] find dup [
-        >r cut-slice >r % r> rest-slice r>
+        [ cut-slice [ % ] dip rest-slice ] dip
         dup CHAR: " = [
             drop from>>
         ] [
-            drop next-escape >r , r> (parse-string)
+            drop next-escape [ , ] dip (parse-string)
         ] if
     ] [
         "Unterminated string" throw
index 944286cce567d72bbd5f01b30c015e76a22cc297..39628ede98cdfd64edb60f02d3447ac6523e908c 100644 (file)
@@ -34,11 +34,11 @@ M: string length
     length>> ;
 
 M: string nth-unsafe
-    >r >fixnum r> string-nth ;
+    [ >fixnum ] dip string-nth ;
 
 M: string set-nth-unsafe
     dup reset-string-hashcode
-    >r >fixnum >r >fixnum r> r> set-string-nth ;
+    [ [ >fixnum ] dip >fixnum ] dip set-string-nth ;
 
 M: string clone
     (clone) [ clone ] change-aux ;
index 105bdc325f123a6673f849956acafc418eef2d78..7d3553faeed48cb26849676d76f80e1b3eb890fa 100644 (file)
@@ -23,7 +23,7 @@ IN: bootstrap.syntax
     "syntax" lookup t "delimiter" set-word-prop ;
 
 : define-syntax ( name quot -- )
-    >r "syntax" lookup dup r> define t "parsing" set-word-prop ;
+    [ "syntax" lookup dup ] dip define t "parsing" set-word-prop ;
 
 [
     { "]" "}" ";" ">>" } [ define-delimiter ] each
@@ -62,7 +62,7 @@ IN: bootstrap.syntax
     "CHAR:" [
         scan {
             { [ dup length 1 = ] [ first ] }
-            { [ "\\" ?head ] [ next-escape drop ] }
+            { [ "\\" ?head ] [ next-escape >string "" assert= ] }
             [ name>char-hook get call ]
         } cond parsed
     ] define-syntax
@@ -145,9 +145,10 @@ IN: bootstrap.syntax
     ] define-syntax
 
     "INSTANCE:" [
-        location >r
-        scan-word scan-word 2dup add-mixin-instance
-        <mixin-instance> r> remember-definition
+        location [
+            scan-word scan-word 2dup add-mixin-instance
+            <mixin-instance>
+        ] dip remember-definition
     ] define-syntax
 
     "PREDICATE:" [
@@ -202,13 +203,12 @@ IN: bootstrap.syntax
     ] define-syntax
 
     "call-next-method" [
-        current-class get current-generic get
-        2dup [ word? ] both? [
-            [ literalize parsed ] bi@
+        current-method get [
+            literalize parsed
             \ (call-next-method) parsed
         ] [
             not-in-a-method-error
-        ] if
+        ] if*
     ] define-syntax
     
     "initial:" "syntax" lookup define-symbol
index 4f9bba348320409eacafa36cb228aae3a9cecf74..f2e29d79e84de3c3ddc3c27a8de5fe937ab59cb2 100644 (file)
@@ -71,7 +71,7 @@ IN: vectors.tests
 
 [ t ] [
     V{ 1 2 3 4 } dup underlying>> length
-    >r clone underlying>> length r>
+    [ clone underlying>> length ] dip
     =
 ] unit-test
 
@@ -91,7 +91,7 @@ IN: vectors.tests
 [ 4 ] [ 5 V{ 1 2 3 4 5 } index ] unit-test
 
 [ t ] [
-    100 >array dup >vector <reversed> >array >r reverse r> =
+    100 >array dup >vector <reversed> >array [ reverse ] dip =
 ] unit-test
 
 [ fixnum ] [ 1 >bignum V{ } new-sequence length class ] unit-test
index 1325110122d31fb4fb0837bc2e4ca6d84558ba00..89b8a0728de60454a6977ca58f3be345db700186 100644 (file)
@@ -1,4 +1,5 @@
-USING: vocabs help.markup help.syntax words strings io ;
+USING: vocabs vocabs.loader.private help.markup help.syntax
+words strings io ;
 IN: vocabs.loader
 
 ARTICLE: "vocabs.roots" "Vocabulary roots"
index 3f06b9735ce020f5e18bd0b8aa4511fe3ffa6282..7b53e98df18526b8ff56dcbfb12f1e5b54f52766 100644 (file)
@@ -51,7 +51,7 @@ IN: vocabs.loader.tests
 2 [
     [ "vocabs.loader.test.a" require ] must-fail
     
-    [ f ] [ "vocabs.loader.test.a" vocab-source-loaded? ] unit-test
+    [ f ] [ "vocabs.loader.test.a" vocab source-loaded?>> ] unit-test
     
     [ t ] [
         "resource:core/vocabs/loader/test/a/a.factor"
@@ -129,9 +129,9 @@ IN: vocabs.loader.tests
     ] with-compilation-unit
 ] unit-test
 
-[ t ] [
+[ +done+ ] [
     [ "vocabs.loader.test.d" require ] [ :1 ] recover
-    "vocabs.loader.test.d" vocab-source-loaded?
+    "vocabs.loader.test.d" vocab source-loaded?>>
 ] unit-test
 
 : forget-junk
@@ -156,3 +156,21 @@ forget-junk
 
 [ "vocabs.loader.test.e" require ]
 [ relative-overflow? ] must-fail-with
+
+0 "vocabs.loader.test.g" set-global
+
+[
+    "vocabs.loader.test.f" forget-vocab
+    "vocabs.loader.test.g" forget-vocab
+] with-compilation-unit
+
+[ ] [ "vocabs.loader.test.g" require ] unit-test
+
+[ 1 ] [ "vocabs.loader.test.g" get-global ] unit-test
+
+[
+    "vocabs.loader.test.h" forget-vocab
+    "vocabs.loader.test.i" forget-vocab
+] with-compilation-unit
+
+[ ] [ "vocabs.loader.test.h" require ] unit-test
index 690b8b0d920a7c5ed0f48fed8a2bfa440e70a57f..49fad2626fb6f212b540fbbf55412ccff33a22b4 100644 (file)
@@ -19,24 +19,27 @@ V{
     vocab-name { { CHAR: . CHAR: / } } substitute ;
 
 : vocab-dir+ ( vocab str/f -- path )
-    >r vocab-name "." split r>
-    [ >r dup peek r> append suffix ] when*
+    [ vocab-name "." split ] dip
+    [ [ dup peek ] dip append suffix ] when*
     "/" join ;
 
 : vocab-dir? ( root name -- ? )
-    over [
-        ".factor" vocab-dir+ append-path exists?
-    ] [
-        2drop f
-    ] if ;
+    over
+    [ ".factor" vocab-dir+ append-path exists? ]
+    [ 2drop f ]
+    if ;
 
 SYMBOL: root-cache
 
 H{ } clone root-cache set-global
 
+<PRIVATE
+
 : (find-vocab-root) ( name -- path/f )
     vocab-roots get swap [ vocab-dir? ] curry find nip ;
 
+PRIVATE>
+
 : find-vocab-root ( vocab -- path/f )
     vocab-name dup root-cache get at [ ] [ (find-vocab-root) ] ?if ;
 
@@ -51,26 +54,37 @@ H{ } clone root-cache set-global
 
 SYMBOL: load-help?
 
-: load-source ( vocab -- vocab )
-    f over set-vocab-source-loaded?
-    [ vocab-source-path [ parse-file ] [ [ ] ] if* ] keep
-    t swap set-vocab-source-loaded?
-    [ % ] [ assert-depth ] if-bootstrapping ;
+ERROR: circular-dependency name ;
 
-: load-docs ( vocab -- vocab )
-    load-help? get [
-        f over set-vocab-docs-loaded?
-        [ vocab-docs-path [ ?run-file ] when* ] keep
-        t swap set-vocab-docs-loaded?
-    ] [ drop ] if ;
+<PRIVATE
 
-: reload ( name -- )
+: load-source ( vocab -- )
     [
-        dup vocab [ [ load-source ] [ load-docs ] bi ] [ no-vocab ] ?if
-    ] with-compiler-errors ;
+        +parsing+ >>source-loaded?
+        dup vocab-source-path [ parse-file ] [ [ ] ] if*
+        [ % ] [ assert-depth ] if-bootstrapping
+        +done+ >>source-loaded? drop
+    ] [ ] [ f >>source-loaded? ] cleanup ;
+
+: load-docs ( vocab -- )
+    load-help? get [
+        [
+            +parsing+ >>docs-loaded?
+            [ vocab-docs-path [ ?run-file ] when* ] keep
+            +done+ >>docs-loaded?
+        ] [ ] [ f >>docs-loaded? ] cleanup
+    ] when drop ;
+
+PRIVATE>
 
 : require ( vocab -- )
-    load-vocab drop ;
+    [ load-vocab drop ] with-compiler-errors ;
+
+: reload ( name -- )
+    dup vocab
+    [ [ [ load-source ] [ load-docs ] bi ] with-compiler-errors ]
+    [ require ]
+    ?if ;
 
 : run ( vocab -- )
     dup load-vocab vocab-main [
@@ -83,6 +97,8 @@ SYMBOL: load-help?
 
 SYMBOL: blacklist
 
+<PRIVATE
+
 : add-to-blacklist ( error vocab -- )
     vocab-name blacklist get dup [ set-at ] [ 3drop ] if ;
 
@@ -90,9 +106,10 @@ GENERIC: (load-vocab) ( name -- )
 
 M: vocab (load-vocab)
     [
-        dup vocab-source-loaded? [ dup load-source ] unless
-        dup vocab-docs-loaded? [ dup load-docs ] unless
-        drop
+        dup source-loaded?>> +parsing+ eq? [
+            dup source-loaded?>> [ dup load-source ] unless
+            dup docs-loaded?>> [ dup load-docs ] unless
+        ] unless drop
     ] [ [ swap add-to-blacklist ] keep rethrow ] recover ;
 
 M: vocab-link (load-vocab)
@@ -103,19 +120,17 @@ M: string (load-vocab)
 
 [
     [
-        dup vocab-name blacklist get at* [
-            rethrow
-        ] [
-            drop
-            dup find-vocab-root [
-                [ (load-vocab) ] with-compiler-errors
-            ] [
-                dup vocab [ drop ] [ no-vocab ] if
-            ] if
+        dup vocab-name blacklist get at* [ rethrow ] [
+            drop dup find-vocab-root
+            [ [ (load-vocab) ] with-compiler-errors ]
+            [ dup vocab [ drop ] [ no-vocab ] if ]
+            if
         ] if
     ] with-compiler-errors
 ] load-vocab-hook set-global
 
+PRIVATE>
+
 : vocab-where ( vocab -- loc )
     vocab-source-path dup [ 1 2array ] when ;
 
diff --git a/core/vocabs/loader/test/f/f.factor b/core/vocabs/loader/test/f/f.factor
new file mode 100644 (file)
index 0000000..39d4534
--- /dev/null
@@ -0,0 +1,4 @@
+IN: vocabs.laoder.test.f
+USE: vocabs.loader
+
+"vocabs.loader.test.g" require
diff --git a/core/vocabs/loader/test/f/tags.txt b/core/vocabs/loader/test/f/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/core/vocabs/loader/test/g/g.factor b/core/vocabs/loader/test/g/g.factor
new file mode 100644 (file)
index 0000000..8f124b1
--- /dev/null
@@ -0,0 +1,4 @@
+IN: vocabs.loader.test.g
+USING: vocabs.loader.test.f namespaces ;
+
+global [ "vocabs.loader.test.g" inc ] bind
diff --git a/core/vocabs/loader/test/g/tags.txt b/core/vocabs/loader/test/g/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/core/vocabs/loader/test/h/h.factor b/core/vocabs/loader/test/h/h.factor
new file mode 100644 (file)
index 0000000..5100621
--- /dev/null
@@ -0,0 +1 @@
+USE: vocabs.loader.test.i
diff --git a/core/vocabs/loader/test/h/tags.txt b/core/vocabs/loader/test/h/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/core/vocabs/loader/test/i/i.factor b/core/vocabs/loader/test/i/i.factor
new file mode 100644 (file)
index 0000000..932288d
--- /dev/null
@@ -0,0 +1,2 @@
+IN: vocabs.loader.test.i
+USE: vocabs.loader.test.h
diff --git a/core/vocabs/loader/test/i/tags.txt b/core/vocabs/loader/test/i/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
index 64a5a589dc6b0f23bb33086e85293cb5842cd782..2929b5008180fd1d1f1386b7394eea41911566b9 100644 (file)
@@ -53,14 +53,6 @@ HELP: vocab-words
 { $values { "vocab-spec" "a vocabulary specifier" } { "words" "an assoc mapping strings to words" } }
 { $description "Outputs the words defined in a vocabulary." } ;
 
-HELP: vocab-source-loaded?
-{ $values { "vocab-spec" "a vocabulary specifier" } { "?" "a boolean" } }
-{ $description "Outputs if the source for this vocubulary has been loaded." } ;
-
-HELP: vocab-docs-loaded?
-{ $values { "vocab-spec" "a vocabulary specifier" } { "?" "a boolean" } }
-{ $description "Outputs if the documentation for this vocubulary has been loaded." } ;
-
 HELP: words
 { $values { "vocab" string } { "seq" "a sequence of words" } }
 { $description "Outputs a sequence of words defined in the vocabulary, or " { $link f } " if no vocabulary with this name exists." } ;
index 1bdbe3ce1401b63dca1d61c2fa865942291c3ea4..13f79b04ecccbb5dac560b7b29a8a8057e58d146 100644 (file)
@@ -11,6 +11,11 @@ name words
 main help
 source-loaded? docs-loaded? ;
 
+! sources-loaded? slot is one of these two
+SYMBOL: +parsing+
+SYMBOL: +running+
+SYMBOL: +done+
+
 : <vocab> ( name -- vocab )
     \ vocab new
         swap >>name
@@ -52,42 +57,6 @@ M: object vocab-main vocab vocab-main ;
 
 M: f vocab-main ;
 
-GENERIC: vocab-source-loaded? ( vocab-spec -- ? )
-
-M: vocab vocab-source-loaded? source-loaded?>> ;
-
-M: object vocab-source-loaded?
-    vocab vocab-source-loaded? ;
-
-M: f vocab-source-loaded? ;
-
-GENERIC: set-vocab-source-loaded? ( ? vocab-spec -- )
-
-M: vocab set-vocab-source-loaded? (>>source-loaded?) ;
-
-M: object set-vocab-source-loaded?
-    vocab set-vocab-source-loaded? ;
-
-M: f set-vocab-source-loaded? 2drop ;
-
-GENERIC: vocab-docs-loaded? ( vocab-spec -- ? )
-
-M: vocab vocab-docs-loaded? docs-loaded?>> ;
-
-M: object vocab-docs-loaded?
-    vocab vocab-docs-loaded? ;
-
-M: f vocab-docs-loaded? ;
-
-GENERIC: set-vocab-docs-loaded? ( ? vocab-spec -- )
-
-M: vocab set-vocab-docs-loaded? (>>docs-loaded?) ;
-
-M: object set-vocab-docs-loaded?
-    vocab set-vocab-docs-loaded? ;
-
-M: f set-vocab-docs-loaded? 2drop ;
-
 : create-vocab ( name -- vocab )
     dictionary get [ <vocab> ] cache ;
 
index 66c60dc06e5c322b1a94820e428903749f7817f3..929161c5d6e87f4fdd7d1d357fe0248ea421af58 100644 (file)
@@ -87,11 +87,11 @@ M: word (quot-uses) over crossref? [ conjoin ] [ 2drop ] if ;
 
 M: array (quot-uses) seq-uses ;
 
-M: hashtable (quot-uses) >r >alist r> seq-uses ;
+M: hashtable (quot-uses) [ >alist ] dip seq-uses ;
 
 M: callable (quot-uses) seq-uses ;
 
-M: wrapper (quot-uses) >r wrapped>> r> (quot-uses) ;
+M: wrapper (quot-uses) [ wrapped>> ] dip (quot-uses) ;
 
 : quot-uses ( quot -- assoc )
     global [ H{ } clone [ (quot-uses) ] keep ] bind ;
@@ -113,7 +113,7 @@ compiled-generic-crossref global [ H{ } assoc-like ] change-at
     bi* 2bi ;
 
 : compiled-xref ( word dependencies generic-dependencies -- )
-    [ [ drop crossref? ] assoc-filter ] bi@
+    [ [ drop crossref? ] { } assoc-filter-as f like ] bi@
     [ over ] dip
     [ "compiled-uses" compiled-crossref (compiled-xref) ]
     [ "compiled-generic-uses" compiled-generic-crossref (compiled-xref) ]
@@ -121,7 +121,7 @@ compiled-generic-crossref global [ H{ } assoc-like ] change-at
 
 : (compiled-unxref) ( word word-prop variable -- )
     [ [ [ dupd word-prop ] dip get remove-vertex* ] 2curry ]
-    [ drop [ f swap set-word-prop ] curry ]
+    [ drop [ remove-word-prop ] curry ]
     2bi bi ;
 
 : compiled-unxref ( word -- )
@@ -239,7 +239,7 @@ ERROR: bad-create name vocab ;
     dup [ 2nip ] [ drop <word> dup reveal ] if ;
 
 : constructor-word ( name vocab -- word )
-    >r "<" swap ">" 3append r> create ;
+    [ "<" swap ">" 3append ] dip create ;
 
 PREDICATE: parsing-word < word "parsing" word-prop ;
 
index b9f9882e88d935b4cd00480c0b64a3777b6cc06c..d82500edba98454d804886c1f83873ab4015faa7 100644 (file)
@@ -44,7 +44,7 @@ DEFER: shallow-fry
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 : deep-fry ( quot -- quot )
-  { _ } last-split1 dup
+  { _ } split1-last dup
     [
       shallow-fry [ >r ] rot
       deep-fry    [ [ dip ] curry r> compose ] 4array concat
@@ -77,4 +77,4 @@ DEFER: shallow-fry
 
 MACRO: fry ( seq -- quot ) [fry] ;
 
-: '[ \ ] [ >quotation ] parse-literal \ fry parsed ; parsing
\ No newline at end of file
+: '[ \ ] [ >quotation ] parse-literal \ fry parsed ; parsing
index 594b451876e1968c592f0fb788d7f6a4cae04643..64d1b6c53333c889a86feb285ee7df122d617ab8 100755 (executable)
@@ -9,6 +9,6 @@ USING: math kernel alien ;
     ] alien-callback\r
     "int" { "int" } "cdecl" alien-indirect ;\r
 \r
-: fib-main ( -- ) 25 fib drop ;\r
+: fib-main ( -- ) 34 fib drop ;\r
 \r
 MAIN: fib-main\r
index 9f64d438c7b4f7375e3944f58e742609b06c4763..cdd83cb9afe8574624384b2cff0baaa95402b409 100644 (file)
@@ -4,7 +4,7 @@ IN: benchmark.regex-dna.tests
 
 [ t ] [
     "resource:extra/benchmark/regex-dna/regex-dna-test-in.txt"
-    [ regex-dna ] with-string-writer <string-reader> lines
+    [ regex-dna ] with-string-writer
     "resource:extra/benchmark/regex-dna/regex-dna-test-out.txt"
-    ascii file-lines =
+    ascii file-contents =
 ] unit-test
index 3d4cd392caaecbd9d98a8485b23f5c3d55517b09..eeebe1c12de9184d3bbe20224ffe4fc415632cbc 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: combinators.short-circuit kernel namespaces
+USING: kernel namespaces
        math
        math.constants
        math.functions
@@ -10,6 +10,7 @@ USING: combinators.short-circuit kernel namespaces
        math.physics.vel
        combinators arrays sequences random vars
        combinators.lib
+       combinators.short-circuit
        accessors ;
 
 IN: boids
@@ -156,7 +157,7 @@ VAR: separation-radius
   2&& ;
 
 : alignment-neighborhood ( self -- boids )
-boids> [ within-alignment-neighborhood? ] with filter ;
+  boids> [ within-alignment-neighborhood? ] with filter ;
 
 : alignment-force ( self -- force )
   alignment-neighborhood
index d160740c4448aa0e4e89708d937a7e9eff466a29..8ed7a3c31b70c9278c443b92f8cf037a202551c5 100644 (file)
@@ -1,58 +1,34 @@
 ! Copyright (C) 2008 Matthew Willis.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences math opengl.gadgets kernel
-byte-arrays cairo.ffi cairo io.backend
-ui.gadgets accessors opengl.gl
-arrays fry classes ;
+USING: sequences math kernel byte-arrays cairo.ffi cairo
+io.backend ui.gadgets accessors opengl.gl arrays fry
+classes ui.render namespaces ;
 
 IN: cairo.gadgets
 
 : width>stride ( width -- stride ) 4 * ;
     
-: copy-cairo ( dim quot -- byte-array )
-    >r first2 over width>stride
-    [ * nip <byte-array> dup CAIRO_FORMAT_ARGB32 ]
+GENERIC: render-cairo* ( gadget -- )
+
+: render-cairo ( gadget -- byte-array )
+    dup dim>> first2 over width>stride
+    [ * nip <byte-array> dup CAIRO_FORMAT_ARGB32 ] 
     [ cairo_image_surface_create_for_data ] 3bi
-    r> with-cairo-from-surface ; inline
+    rot '[ _ render-cairo* ] with-cairo-from-surface ; inline
 
-TUPLE: cairo-gadget < texture-gadget ;
+TUPLE: cairo-gadget < gadget ;
 
 : <cairo-gadget> ( dim -- gadget )
     cairo-gadget new-gadget
         swap >>dim ;
 
-M: cairo-gadget cache-key* [ dim>> ] [ class ] bi 2array ;
-
-: render-cairo ( dim quot -- bytes format )
-    >r 2^-bounds r> copy-cairo GL_BGRA ; inline
-
-GENERIC: render-cairo* ( gadget -- )
-
-M: cairo-gadget render*
-    [ dim>> dup ] [ '[ _ render-cairo* ] ] bi
-    render-cairo render-bytes* ;
-
-! maybe also texture>png
-! : cairo>png ( gadget path -- )
-!    >r [ cairo>bytes CAIRO_FORMAT_ARGB32 ] [ width>> ]
-!    [ height>> ] tri over width>stride
-!    cairo_image_surface_create_for_data
-!    r> [ cairo_surface_write_to_png check-cairo ] curry with-surface ;
+M: cairo-gadget draw-gadget*
+    [ dim>> ] [ render-cairo ] bi
+    origin get first2 glRasterPos2i
+    1.0 -1.0 glPixelZoom
+    >r first2 GL_BGRA GL_UNSIGNED_BYTE r>
+    glDrawPixels ;
 
 : copy-surface ( surface -- )
     cr swap 0 0 cairo_set_source_surface
     cr cairo_paint ;
-
-TUPLE: png-gadget < texture-gadget path ;
-: <png> ( path -- gadget )
-    png-gadget new-gadget
-        swap >>path ;
-
-M: png-gadget render*
-    path>> normalize-path cairo_image_surface_create_from_png
-    [ cairo_image_surface_get_width ]
-    [ cairo_image_surface_get_height 2array dup 2^-bounds ]
-    [ [ copy-surface ] curry copy-cairo ] tri
-    GL_BGRA render-bytes* ;
-
-M: png-gadget cache-key* path>> ;
index 102de8fd22edc6caad73780ffd882f249130c918..3278cc6ec1f04a9ca5f995abba938b52facf6336 100644 (file)
@@ -224,13 +224,13 @@ SYMBOL: dlist
 
 : delete-dlist ( -- ) dlist get [ dlist get 1 glDeleteLists dlist off ] when ;
 
-: cfdg-window* ( -- )
+: cfdg-window* ( -- slate )
   C[ display ] <slate>
     { 500 500 }       >>pdim
     C[ delete-dlist ] >>ungraft
   dup "CFDG" open-window ;
 
-: cfdg-window ( -- ) [ cfdg-window* ] with-ui ;
+: cfdg-window ( -- slate ) [ cfdg-window* ] with-ui ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
diff --git a/extra/display-stack/display-stack.factor b/extra/display-stack/display-stack.factor
deleted file mode 100644 (file)
index 98af43f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-
-USING: kernel namespaces sequences math
-       listener io prettyprint sequences.lib bake bake.fry ;
-
-IN: display-stack
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SYMBOL: watched-variables
-
-: watch-var ( sym -- ) watched-variables get push ;
-
-: watch-vars ( seq -- ) watched-variables get [ push ] curry each ;
-
-: unwatch-var ( sym -- ) watched-variables get delete ;
-
-: unwatch-vars ( seq -- ) watched-variables get [ delete ] curry each ;
-
-: print-watched-variables ( -- )
-  watched-variables get length 0 >
-    [
-      "----------" print
-      watched-variables get
-        watched-variables get [ unparse ] map longest length 2 +
-        '[ [ unparse ": " append , 32 pad-right write ] [ get . ] bi ]
-      each
-
-    ]
-  when ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: display-stack ( -- )
-  V{ } clone watched-variables set
-    [
-      print-watched-variables
-      "----------" print
-      datastack [ . ] each
-      "----------" print
-      retainstack reverse [ . ] each
-    ]
-  listener-hook set ;
-
index 758bfe280e2d02338ca741b8e359ddd9450e2fa4..d028ea958cfd40fb90081611e58a82c6b97808a0 100644 (file)
@@ -47,6 +47,11 @@ C: <entry> cache-entry
     cache-key* textures get delete-at*
     [ tex>> delete-texture ] [ drop ] if ;
 
+: clear-textures ( -- )
+    textures get values [ tex>> delete-texture ] each
+    H{ } clone textures set-global
+    H{ } clone refcounts set-global ;
+
 M: texture-gadget graft* ( gadget -- ) [ 1+ ] refcount-change ;
 
 M: texture-gadget ungraft* ( gadget -- )
index 06468b875189a0f730db102621830f5893df15da..826c66851e048974c8b82aee0cdedb10ccf436d7 100755 (executable)
@@ -15,16 +15,26 @@ main()
 ;
 
 STRING: plane-fragment-shader
+uniform float checker_size_inv;
+uniform vec4 checker_color_1, checker_color_2;
 varying vec3 object_position;
+
+bool
+checker_color(vec3 p)
+{
+    vec3 pprime = checker_size_inv * object_position;
+    return fract((floor(pprime.x) + floor(pprime.z)) * 0.5) == 0.0;
+}
+
 void
 main()
 {
     float distance_factor = (gl_FragCoord.z * 0.5 + 0.5);
     distance_factor = pow(distance_factor, 500.0)*0.5;
     
-    gl_FragColor = fract((floor(0.125*object_position.x)+floor(0.125*object_position.z)) * 0.5) == 0.0
-        ? vec4(1.0, 1.0 - distance_factor, 1.0 - distance_factor, 1.0)
-        : vec4(1.0, distance_factor, distance_factor, 1.0);
+    gl_FragColor = checker_color(object_position)
+        ? mix(checker_color_1, checker_color_2, distance_factor)
+        : mix(checker_color_2, checker_color_1, distance_factor);
 }
 ;
 
@@ -213,7 +223,11 @@ M: spheres-gadget pref-dim* ( gadget -- dim )
         ] with-gl-program
     ] [
         plane-program>> [
-            drop
+            {
+                [ "checker_size_inv" glGetUniformLocation 0.125 glUniform1f ]
+                [ "checker_color_1"  glGetUniformLocation 1.0 0.5 0.0 1.0 glUniform4f ]
+                [ "checker_color_2"  glGetUniformLocation 0.0 0.0 0.0 1.0 glUniform4f ]
+            } cleave
             GL_QUADS [
                 -1000.0 -30.0  1000.0 glVertex3f
                 -1000.0 -30.0 -1000.0 glVertex3f
diff --git a/extra/ui/gadgets/broken/broken.factor b/extra/ui/gadgets/broken/broken.factor
new file mode 100644 (file)
index 0000000..d282e41
--- /dev/null
@@ -0,0 +1,26 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors ui ui.gadgets ui.gadgets.buttons ui.render ;
+IN: ui.gadgets.broken
+
+! An intentionally broken gadget -- used to test UI error handling,
+! make sure that one bad gadget doesn't bring the whole system down
+
+: <bad-button> ( -- button )
+    "Click me if you dare"
+    [ "Haha" throw ]
+    <bevel-button> ;
+
+TUPLE: bad-gadget < gadget ;
+
+M: bad-gadget draw-gadget* "Lulz" throw ;
+
+M: bad-gadget pref-dim* drop { 100 100 } ;
+
+: <bad-gadget> ( -- gadget ) bad-gadget new-gadget ;
+
+: bad-gadget-test ( -- )
+    <bad-button> "Test 1" open-window
+    <bad-gadget> "Test 2" open-window ;
+
+MAIN: bad-gadget-test
index f75cb7f359092c175d643fea1c86f852e9997e95..351b0e97d1d16c8ea42e3192d5f537bd83147ad7 100644 (file)
@@ -35,6 +35,7 @@
 
 (require 'font-lock)
 (require 'comint)
+(require 'view)
 
 ;;; Customization:
 
@@ -64,6 +65,30 @@ value from the existing code in the buffer."
   :type '(file :must-match t)
   :group 'factor)
 
+(defcustom factor-use-doc-window t
+  "When on, use a separate window to display help information.
+Disable to see that information in the factor-listener comint
+window."
+  :type 'boolean
+  :group 'factor)
+
+(defcustom factor-listener-use-other-window t
+  "Use a window other than the current buffer's when switching to
+the factor-listener buffer."
+  :type 'boolean
+  :group 'factor)
+
+(defcustom factor-listener-window-allow-split t
+  "Allow window splitting when switching to the factor-listener
+buffer."
+  :type 'boolean
+  :group 'factor)
+
+(defcustom factor-help-always-ask t
+  "When enabled, always ask for confirmation in help prompts."
+  :type 'boolean
+  :group 'factor)
+
 (defcustom factor-display-compilation-output t
   "Display the REPL buffer before compiling files."
   :type 'boolean
@@ -74,6 +99,11 @@ value from the existing code in the buffer."
   :type 'hook
   :group 'factor)
 
+(defcustom factor-help-mode-hook nil
+  "Hook run by `factor-help-mode'."
+  :type 'hook
+  :group 'factor)
+
 (defgroup factor-faces nil
   "Faces used in Factor mode"
   :group 'factor
@@ -125,6 +155,10 @@ value from the existing code in the buffer."
   "Face for parsing words."
   :group 'factor-faces)
 
+(defface factor-font-lock-help-mode-headlines '((t (:bold t :weight bold)))
+  "Face for headlines in help buffers."
+  :group 'factor-faces)
+
 \f
 ;;; Factor mode font lock:
 
@@ -265,7 +299,7 @@ value from the existing code in the buffer."
 (defsubst factor--ppss-brackets-start ()
   (nth 1 (syntax-ppss)))
 
-(defsubst factor--line-indent (pos)
+(defsubst factor--indentation-at (pos)
   (save-excursion (goto-char pos) (current-indentation)))
 
 (defconst factor--regex-closing-paren "[])}]")
@@ -276,7 +310,8 @@ value from the existing code in the buffer."
   (= (- (point) (line-beginning-position)) (current-indentation)))
 
 (defconst factor--regex-single-liner
-  (format "^%s" (regexp-opt '("DEFER:" "GENERIC:" "IN:" "PRIVATE>" "<PRIVATE" "USE:"))))
+  (format "^%s" (regexp-opt '("DEFER:" "GENERIC:" "IN:"
+                              "PRIVATE>" "<PRIVATE" "SYMBOL:" "USE:"))))
 
 (defsubst factor--at-begin-of-def ()
   (looking-at "\\([^ ]\\|^\\)+:"))
@@ -302,6 +337,11 @@ value from the existing code in the buffer."
     (beginning-of-line)
     (re-search-forward factor--regex-constructor (line-end-position) t)))
 
+(defsubst factor--increased-indentation (&optional i)
+  (+ (or i (current-indentation)) factor-indent-width))
+(defsubst factor--decreased-indentation (&optional i)
+  (- (or i (current-indentation)) factor-indent-width))
+
 (defun factor--indent-in-brackets ()
   (save-excursion
     (beginning-of-line)
@@ -312,8 +352,8 @@ value from the existing code in the buffer."
       (let ((op (factor--ppss-brackets-start)))
         (when (> (line-number-at-pos) (line-number-at-pos op))
           (if (factor--at-closing-paren-p)
-              (factor--line-indent op)
-            (+ (factor--line-indent op) factor-indent-width)))))))
+              (factor--indentation-at op)
+            (factor--increased-indentation (factor--indentation-at op))))))))
 
 (defun factor--indent-definition ()
   (save-excursion
@@ -323,29 +363,26 @@ value from the existing code in the buffer."
 (defun factor--indent-setter-line ()
   (when (factor--at-setter-line)
     (save-excursion
-      (beginning-of-line)
-      (let ((indent (when (factor--at-constructor-line) (current-indentation))))
+      (let ((indent (and (factor--at-constructor-line) (current-indentation))))
         (while (not (or indent
                         (bobp)
                         (factor--at-begin-of-def)
                         (factor--at-end-of-def)))
           (if (factor--at-constructor-line)
-              (setq indent (+ (current-indentation) factor-indent-width))
+              (setq indent (factor--increased-indentation))
             (forward-line -1)))
         indent))))
 
 (defun factor--indent-continuation ()
   (save-excursion
     (forward-line -1)
-    (beginning-of-line)
-    (if (bobp) 0
-      (if (factor--looking-at-emptiness)
-          (factor--indent-continuation)
-        (if (or (factor--at-end-of-def) (factor--at-setter-line))
-            (- (current-indentation) factor-indent-width)
-          (if (factor--at-begin-of-def)
-              (+ (current-indentation) factor-indent-width)
-            (current-indentation)))))))
+    (while (and (not (bobp)) (factor--looking-at-emptiness))
+      (forward-line -1))
+    (if (or (factor--at-end-of-def) (factor--at-setter-line))
+        (factor--decreased-indentation)
+      (if (factor--at-begin-of-def)
+          (factor--increased-indentation)
+        (current-indentation)))))
 
 (defun factor--calculate-indentation ()
   "Calculate Factor indentation for line at point."
@@ -426,18 +463,6 @@ value from the existing code in the buffer."
   (factor-send-region (search-backward ":")
                       (search-forward  ";")))
 
-(defun factor-see ()
-  (interactive)
-  (comint-send-string "*factor*" "\\ ")
-  (comint-send-string "*factor*" (thing-at-point 'sexp))
-  (comint-send-string "*factor*" " see\n"))
-
-(defun factor-help ()
-  (interactive)
-  (comint-send-string "*factor*" "\\ ")
-  (comint-send-string "*factor*" (thing-at-point 'sexp))
-  (comint-send-string "*factor*" " help\n"))
-
 (defun factor-edit ()
   (interactive)
   (comint-send-string "*factor*" "\\ ")
@@ -456,17 +481,6 @@ value from the existing code in the buffer."
 (defvar factor-mode-map (make-sparse-keymap)
   "Key map used by Factor mode.")
 
-(define-key factor-mode-map "\C-c\C-f" 'factor-run-file)
-(define-key factor-mode-map "\C-c\C-r" 'factor-send-region)
-(define-key factor-mode-map "\C-c\C-d" 'factor-send-definition)
-(define-key factor-mode-map "\C-c\C-s" 'factor-see)
-(define-key factor-mode-map "\C-ce"    'factor-edit)
-(define-key factor-mode-map "\C-c\C-h" 'factor-help)
-(define-key factor-mode-map "\C-cc"    'comment-region)
-(define-key factor-mode-map [return]   'newline-and-indent)
-(define-key factor-mode-map [tab]      'indent-for-tab-command)
-
-
 \f
 ;; Factor mode:
 
@@ -491,23 +505,118 @@ value from the existing code in the buffer."
 (add-to-list 'auto-mode-alist '("\\.factor\\'" . factor-mode))
 
 \f
-;;; Factor listener mode
+;;; Factor listener mode:
 
 ;;;###autoload
-(define-derived-mode factor-listener-mode comint-mode "Factor Listener")
-
-(define-key factor-listener-mode-map [f8] 'factor-refresh-all)
+(define-derived-mode factor-listener-mode comint-mode "Factor Listener"
+  "Major mode for interacting with an inferior Factor listener process.
+\\{factor-listener-mode-map}"
+  (set (make-local-variable 'comint-prompt-regexp) "^( [^)]+ ) "))
+
+(defvar factor--listener-buffer nil
+  "The buffer in which the Factor listener is running.")
+
+(defun factor--listener-start-process ()
+  "Start an inferior Factor listener process, using
+`factor-binary' and `factor-image'."
+  (setq factor--listener-buffer
+        (apply 'make-comint "factor" (expand-file-name factor-binary) nil
+               `("-run=listener" ,(format "-i=%s" (expand-file-name factor-image)))))
+  (with-current-buffer factor--listener-buffer
+    (factor-listener-mode)))
+
+(defun factor--listener-process ()
+  (or (and (buffer-live-p factor--listener-buffer)
+           (get-buffer-process factor--listener-buffer))
+      (progn (factor--listener-start-process)
+             (factor--listener-process))))
 
 ;;;###autoload
-(defun run-factor ()
-  "Start a factor listener inside emacs, or switch to it if it
-already exists."
+(defalias 'switch-to-factor 'run-factor)
+;;;###autoload
+(defun run-factor (&optional arg)
+  "Show the factor-listener buffer, starting the process if needed."
   (interactive)
-  (switch-to-buffer
-   (make-comint-in-buffer "factor" nil (expand-file-name factor-binary) nil
-                         (concat "-i=" (expand-file-name factor-image))
-                         "-run=listener"))
-  (factor-listener-mode))
+  (let ((buf (process-buffer (factor--listener-process)))
+        (pop-up-windows factor-listener-window-allow-split))
+    (if factor-listener-use-other-window
+        (pop-to-buffer buf)
+      (switch-to-buffer buf))))
+
+\f
+;;;; Factor help mode:
+
+(defvar factor-help-mode-map (make-sparse-keymap)
+  "Keymap for Factor help mode.")
+
+(defconst factor--help-headlines
+  (regexp-opt '("Parent topics:"
+                "Inputs and outputs"
+                "Word description"
+                "Generic word contract"
+                "Vocabulary"
+                "Definition")
+              t))
+
+(defconst factor--help-headlines-regexp (format "^%s" factor--help-headlines))
+
+(defconst factor--help-font-lock-keywords
+  `((,factor--help-headlines-regexp . 'factor-font-lock-help-mode-headlines)
+    ,@factor-font-lock-keywords))
+
+(defun factor-help-mode ()
+  "Major mode for displaying Factor help messages.
+\\{factor-help-mode-map}"
+  (interactive)
+  (kill-all-local-variables)
+  (use-local-map factor-help-mode-map)
+  (setq mode-name "Factor Help")
+  (setq major-mode 'factor-help-mode)
+  (set (make-local-variable 'font-lock-defaults)
+       '(factor--help-font-lock-keywords t nil nil nil))
+  (set (make-local-variable 'comint-redirect-subvert-readonly) t)
+  (set (make-local-variable 'view-no-disable-on-exit) t)
+  (view-mode)
+  (setq view-exit-action
+        (lambda (buffer)
+          ;; Use `with-current-buffer' to make sure that `bury-buffer'
+          ;; also removes BUFFER from the selected window.
+          (with-current-buffer buffer
+            (bury-buffer))))
+  (run-mode-hooks 'factor-help-mode-hook))
+
+(defun factor--listener-help-buffer ()
+  (set-buffer (get-buffer-create "*factor-help*"))
+  (let ((inhibit-read-only t))
+    (delete-region (point-min) (point-max)))
+  (factor-help-mode)
+  (current-buffer))
+
+(defvar factor--help-history nil)
+
+(defun factor--listener-show-help (&optional see)
+  (let* ((def (thing-at-point 'sexp))
+         (prompt (format "%s (%s): " (if see "See" "Help") def))
+         (ask (or (not (eq major-mode 'factor-mode))
+                  (not def)
+                  factor-help-always-ask))
+         (cmd (format "\\ %s %s"
+                      (if ask (read-string prompt nil 'factor--help-history def) def)
+                      (if see "see" "help")))
+         (hb (factor--listener-help-buffer))
+         (proc (factor--listener-process)))
+    (comint-redirect-send-command-to-process cmd hb proc nil)
+    (pop-to-buffer hb)))
+
+(defun factor-see ()
+  (interactive)
+  (factor--listener-show-help t))
+
+(defun factor-help ()
+  (interactive)
+  (factor--listener-show-help))
+
+\f
 
 (defun factor-refresh-all ()
   "Reload source files and documentation for all loaded
@@ -516,6 +625,28 @@ vocabularies which have been modified on disk."
   (comint-send-string "*factor*" "refresh-all\n"))
 
 \f
+;;; Key bindings:
 
+(defmacro factor--define-key (key cmd)
+  `(progn
+     (define-key factor-mode-map [(control ?c) ,key] ,cmd)
+     (define-key factor-mode-map [(control ?c) (control ,key)] ,cmd)))
+
+(factor--define-key ?f 'factor-run-file)
+(factor--define-key ?r 'factor-send-region)
+(factor--define-key ?d 'factor-send-definition)
+(factor--define-key ?s 'factor-see)
+(factor--define-key ?e 'factor-edit)
+(factor--define-key ?z 'switch-to-factor)
+(factor--define-key ?c 'comment-region)
+
+(define-key factor-mode-map "\C-ch" 'factor-help)
+(define-key factor-mode-map "\C-m" 'newline-and-indent)
+(define-key factor-mode-map [tab] 'indent-for-tab-command)
+
+(define-key factor-listener-mode-map [f8] 'factor-refresh-all)
+
+
+\f
 (provide 'factor)
 ;;; factor.el ends here
diff --git a/unfinished/vocab-browser/vocab-browser.factor b/unfinished/vocab-browser/vocab-browser.factor
deleted file mode 100644 (file)
index cec2dd2..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-
-USING: kernel words accessors
-       classes
-       classes.builtin
-       classes.tuple
-       classes.predicate
-       vocabs
-       arrays
-       sequences sorting
-       io help.markup
-       effects
-       generic
-       prettyprint
-       prettyprint.sections
-       prettyprint.backend
-       combinators.cleave
-       obj.print ;
-
-IN: vocab-browser
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: word-effect-as-string ( word -- string )
-  stack-effect dup
-    [ effect>string ]
-    [ drop "" ]
-  if ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: print-vocabulary-summary ( vocabulary -- )
-
-  dup vocab words [ builtin-class? ] filter natural-sort
-  dup empty?
-    [ drop ]
-    [
-      "Builtin Classes" $heading nl
-      print-seq
-    ]
-  if
-
-  dup vocab words [ tuple-class? ] filter natural-sort
-  dup empty?
-    [ drop ]
-    [
-      "Tuple Classes" $heading nl
-      [
-        { [ ] [ superclass ] [ "slots" word-prop [ name>> ] map " " join ] }
-        1arr
-      ]
-      map
-      { "CLASS" "PARENT" "SLOTS" } prefix
-      print-table
-    ]
-  if
-
-  dup vocab words [ predicate-class? ] filter natural-sort
-  dup empty?
-    [ drop ]
-    [
-      "Predicate Classes" $heading nl
-      ! [ pprint-class ] each
-      [ { [ ] [ superclass ] } 1arr ] map
-      { "CLASS" "SUPERCLASS" } prefix
-      print-table
-    ]
-  if
-
-  dup vocab words [ class? not ] filter [ symbol? ] filter natural-sort
-  dup empty?
-    [ drop ]
-    [
-      "Symbols" $heading nl
-      print-seq
-    ]
-  if
-
-  dup vocab words [ generic? ] filter natural-sort
-  dup empty?
-    [ drop ]
-    [
-      "Generic words" $heading nl
-      [ [ ] [ stack-effect effect>string ] bi 2array ] map
-      print-table
-    ]
-  if
-
-  "Words" $heading nl
-  dup vocab words
-    [ predicate-class? not ] filter
-    [ builtin-class?   not ] filter
-    [ tuple-class?     not ] filter
-    [ generic?         not ] filter
-    [ symbol?          not ] filter
-    [ word?                ] filter
-    natural-sort
-    [ [ ] [ word-effect-as-string ] bi 2array ] map
-  print-table
-
-  drop ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-USING: vocabs.loader tools.vocabs.browser ;
-
-: $vocab-summary ( seq -- )
-  first
-  dup vocab
-    [
-      dup print-vocabulary-summary
-      dup describe-help
-      ! dup describe-uses
-      ! dup describe-usage
-    ]
-  when
-  dup find-vocab-root
-    [
-      dup describe-summary
-      dup describe-tags
-      dup describe-authors
-      ! dup describe-files
-    ]
-  when
-  ! dup describe-children
-  drop ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-USING: assocs ui.tools.browser ui.operations io.styles ;
-
-! IN: tools.vocabs.browser
-
-! : $describe-vocab ( element -- ) $vocab-summary ;
-
-USING: tools.vocabs ;
-
-: print-vocabs ( -- )
-  vocabs
-    [ { [ vocab ] [ vocab-summary ] } 1arr ]
-  map
-  print-table ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! : $all-vocabs ( seq -- ) drop print-vocabs ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-USING: help.syntax help.topics ;
-
-! ARTICLE: "vocab-index" "Vocabulary Index" { $all-vocabs } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-M: vocab-spec article-content ( vocab-spec -- content )
-   { $vocab-summary } swap name>> suffix ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: loaded-and-unloaded-vocabs ( -- seq )
-  "" all-child-vocabs values concat [ name>> ] map ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! ARTICLE: "loaded-vocabs-index" "Loaded Vocabularies" { $loaded-vocabs } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-USING: debugger ;
-
-TUPLE: load-this-vocab name ;
-
-! : do-load-vocab ( ltv -- )
-!   dup name>> require
-!   name>> vocab com-follow ;
-
-: do-load-vocab ( ltv -- )
-  [
-    dup name>> require
-    name>> vocab com-follow
-  ]
-  curry
-  try ;
-
-[ load-this-vocab? ] \ do-load-vocab { { +primary+ t } } define-operation
-
-M: load-this-vocab pprint* ( obj -- )
-   [ name>> "*" append ] [ ] bi write-object ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: vocab-or-loader ( name -- obj )
-  dup vocab
-    [ vocab ]
-    [ load-this-vocab boa ]
-  if ;
-
-: vocab-summary-text ( vocab-name -- text )
-  dup vocab-summary-path vocab-file-contents
-  dup empty?
-    [ drop "" ]
-    [ first   ]
-  if ;
-
-! : vocab-table-entry ( vocab-name -- seq )
-!   { [ vocab-or-loader ] [ vocab-summary ] } 1arr ;
-
-: vocab-table-entry ( vocab-name -- seq )
-  { [ vocab-or-loader ] [ vocab-summary-text ] } 1arr ;
-
-: print-these-vocabs ( seq -- ) [ vocab-table-entry ] map print-table ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! : vocab-list ( -- seq ) "" all-child-vocabs values concat [ name>> ] map ;
-
-: all-vocab-names ( -- seq )
-  all-vocabs values concat [ name>> ] map natural-sort ;
-
-: loaded-vocab-names ( -- seq ) all-vocab-names [ vocab ] filter ;
-
-: unloaded-vocab-names ( -- seq ) all-vocab-names [ vocab not ] filter ;
-
-: root->names ( root -- seq ) all-vocabs at [ name>> ] map natural-sort ;
-
-: vocab-names-core  ( -- seq ) "resource:core"  root->names ;
-: vocab-names-basis ( -- seq ) "resource:basis" root->names ;
-: vocab-names-extra ( -- seq ) "resource:extra" root->names ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: $all-vocabs      ( seq -- ) drop all-vocab-names      print-these-vocabs ;
-: $loaded-vocabs   ( seq -- ) drop loaded-vocab-names   print-these-vocabs ;
-: $unloaded-vocabs ( seq -- ) drop unloaded-vocab-names print-these-vocabs ;
-
-: $vocabs-core     ( seq -- ) drop vocab-names-core     print-these-vocabs ;
-: $vocabs-basis    ( seq -- ) drop vocab-names-basis    print-these-vocabs ;
-: $vocabs-extra    ( seq -- ) drop vocab-names-extra    print-these-vocabs ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-! { "" }
-
-! all-child-vocabs values concat [ name>> ] map
-
-! : vocab-tree ( vocab -- seq )
-!   dup
-!   all-child-vocabs values concat [ name>> ] map prune
-!   [ vocab-tree ]
-!   map
-!   concat
-!   swap prefix
-!   [ vocab-source-path ] filter ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-M: vocab-author pprint* ( vocab-author -- ) [ name>> ] [ ] bi write-object ;
-
-: $vocab-authors ( seq -- )
-  drop all-authors [ vocab-author boa ] map print-seq ;
-
-ARTICLE: "vocab-authors" "Vocabulary Authors" { $vocab-authors } ;
-
-: vocabs-by-author ( author -- vocab-names )
-  authored values concat [ name>> ] map ;
-
-: $vocabs-by-author ( seq -- )
-  first name>> vocabs-by-author print-these-vocabs ;
-
-M: vocab-author article-content ( vocab-author -- content )
-   { $vocabs-by-author } swap suffix ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-M: vocab-tag pprint* ( vocab-tag -- ) [ name>> ] [ ] bi write-object ;
-
-: print-vocab-tags ( -- ) all-tags [ vocab-tag boa ] map print-seq ;
-
-: $vocab-tags ( seq -- ) drop print-vocab-tags ;
-
-ARTICLE: "vocab-tags" "Vocabulary Tags" { $vocab-tags } ;
-
-: $vocabs-with-tag ( seq -- )
-  first tagged values concat [ name>> ] map print-these-vocabs ;
-
-M: vocab-tag article-content ( vocab-tag -- content )
-   name>> { $vocabs-with-tag } swap suffix ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-ARTICLE: "vocab-index-all"      "All Vocabularies"      { $all-vocabs    } ;
-ARTICLE: "vocab-index-loaded"   "Loaded Vocabularies"   { $loaded-vocabs } ;
-ARTICLE: "vocab-index-unloaded" "Unloaded Vocabularies" { $loaded-vocabs } ;
-
-ARTICLE: "vocab-index-core"      "Core Vocabularies"    { $vocabs-core   } ;
-ARTICLE: "vocab-index-basis"     "Basis Vocabularies"   { $vocabs-basis  } ;
-ARTICLE: "vocab-index-extra"     "Extra Vocabularies"   { $vocabs-extra  } ;
-
-ARTICLE: "vocab-indices" "Vocabulary Indices"
-  { $subsection "vocab-index-core"     }
-  { $subsection "vocab-index-basis"    }
-  { $subsection "vocab-index-extra"    }
-  { $subsection "vocab-index-all"      }
-  { $subsection "vocab-index-loaded"   }
-  { $subsection "vocab-index-unloaded" }
-  { $subsection "vocab-authors"        }
-  { $subsection "vocab-tags"           } ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
diff --git a/unmaintained/io/load.factor b/unmaintained/io/load.factor
deleted file mode 100644 (file)
index ac9b954..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-USING: kernel ;
-
-REQUIRES: libs/calendar libs/shuffle ;
-
-PROVIDE: libs/io
-{ +files+ {
-    "io.factor"
-    "mmap.factor"
-    "shell.factor"
-    { "os-unix.factor" [ unix? ] }
-    { "os-unix-shell.factor" [ unix? ] }
-    { "mmap-os-unix.factor" [ unix? ] }
-
-    { "os-winnt.factor" [ winnt? ] }
-    { "os-winnt-shell.factor" [ winnt? ] }
-    { "mmap-os-winnt.factor" [ winnt? ] }
-
-    { "os-wince.factor" [ wince? ] }
-} }
-{ +tests+ {
-    "test/io.factor"
-    "test/mmap.factor"
-} } ;
-
diff --git a/unmaintained/io/os-unix-shell.factor b/unmaintained/io/os-unix-shell.factor
deleted file mode 100644 (file)
index 6c3919d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-USING: arrays kernel libs-io sequences prettyprint unix-internals
-calendar namespaces math ;
-USE: io
-IN: shell
-
-TUPLE: unix-shell ;
-
-T{ unix-shell } \ shell set-global
-
-TUPLE: file name mode nlink uid gid size mtime symbol ;
-
-M: unix-shell directory* ( path -- seq )
-    dup (directory) [ tuck >r "/" r> 3append stat* 2array ] map-with ;
-
-M: unix-shell make-file ( path -- file )
-    first2
-    [ stat-mode ] keep
-    [ stat-nlink ] keep
-    [ stat-uid ] keep
-    [ stat-gid ] keep
-    [ stat-size ] keep
-    [ stat-mtime timespec>timestamp >local-time ] keep
-    stat-mode mode>symbol <file> ;
-
-M: unix-shell file. ( file -- )
-    [ [ file-mode >oct write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-nlink unparse write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-uid unparse write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-gid unparse write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-size unparse write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-mtime file-time-string write ] keep ] with-cell
-    [ bl ] with-cell
-    [ file-name write ] with-cell ;
-
-USE: unix-internals
-M: unix-shell touch-file ( path -- )
-    dup open-append dup -1 = [
-        drop now dup set-file-times
-    ] [
-        nip [ now dup set-file-times* ] keep close
-    ] if ;
diff --git a/unmaintained/io/os-unix.factor b/unmaintained/io/os-unix.factor
deleted file mode 100644 (file)
index 280908b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-! Copyright (C) 2007 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays calendar errors io io-internals kernel
-math nonblocking-io sequences unix-internals unix-io ;
-IN: libs-io
-
-: O_APPEND  HEX: 100 ; inline
-: O_EXCL    HEX: 800 ; inline
-: SEEK_SET 0 ; inline
-: SEEK_CUR 1 ; inline
-: SEEK_END 2 ; inline
-: EEXIST 17 ; inline
-
-: mode>symbol ( mode -- ch )
-    S_IFMT bitand
-    {
-        { [ dup S_IFDIR = ] [ drop "/" ] }
-        { [ dup S_IFIFO = ] [ drop "|" ] }
-        { [ dup S_IXUSR = ] [ drop "*" ] }
-        { [ dup S_IFLNK = ] [ drop "@" ] }
-        { [ dup S_IFWHT = ] [ drop "%" ] }
-        { [ dup S_IFSOCK = ] [ drop "=" ] }
-        { [ t ] [ drop "" ] }
-    } cond ;
diff --git a/unmaintained/io/os-winnt-shell.factor b/unmaintained/io/os-winnt-shell.factor
deleted file mode 100644 (file)
index a2be22d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-USING: alien calendar io io-internals kernel libs-io math
-namespaces prettyprint sequences windows-api ;
-IN: shell
-
-TUPLE: winnt-shell ;
-
-T{ winnt-shell } \ shell set-global
-
-TUPLE: file name size mtime attributes ;
-
-: ((directory*)) ( handle -- )
-    "WIN32_FIND_DATA" <c-object> [ FindNextFile ] 2keep
-    rot zero? [ 2drop ] [ , ((directory*)) ] if ;
-
-: (directory*) ( path -- )
-    "WIN32_FIND_DATA" <c-object> [
-        FindFirstFile dup INVALID_HANDLE_VALUE = [
-            win32-error
-        ] when
-    ] keep ,
-    [ ((directory*)) ] keep FindClose win32-error=0/f ;
-
-: append-star ( path -- path )
-    dup peek CHAR: \\ = "*" "\\*" ? append ;
-
-M: winnt-shell directory* ( path -- seq )
-    normalize-pathname append-star [ (directory*) ] { } make ;
-
-: WIN32_FIND_DATA>file-size ( WIN32_FILE_ATTRIBUTE_DATA -- n )
-    [ WIN32_FIND_DATA-nFileSizeLow ] keep
-    WIN32_FIND_DATA-nFileSizeHigh 32 shift + ; 
-
-M: winnt-shell make-file ( WIN32_FIND_DATA -- file )
-    [ WIN32_FIND_DATA-cFileName alien>u16-string ] keep
-    [ WIN32_FIND_DATA>file-size ] keep
-    [
-        WIN32_FIND_DATA-ftCreationTime
-        FILETIME>timestamp >local-time
-    ] keep
-    WIN32_FIND_DATA-dwFileAttributes <file> ;
-
-M: winnt-shell file. ( file -- )
-    [ [ file-attributes >oct write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-size unparse write ] keep ] with-cell
-    [ bl ] with-cell
-    [ [ file-mtime file-time-string write ] keep ] with-cell
-    [ bl ] with-cell
-    [ file-name write ] with-cell ;
-
-M: winnt-shell touch-file ( path -- )
-    #! Set the file write time to 'now'
-    normalize-pathname
-    dup maybe-create-file [ drop ] [ now set-file-write-time ] if ;
-
diff --git a/unmaintained/io/os-winnt.factor b/unmaintained/io/os-winnt.factor
deleted file mode 100644 (file)
index 971ae79..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-USING: alien calendar errors generic io io-internals kernel
-math namespaces nonblocking-io parser quotations sequences
-shuffle windows-api words ;
-IN: libs-io
-
-: stat* ( path -- WIN32_FIND_DATA )
-    "WIN32_FIND_DATA" <c-object>
-    [
-        FindFirstFile
-        [ INVALID_HANDLE_VALUE = [ win32-error ] when ] keep
-        FindClose win32-error=0/f
-    ] keep ;
-
-: set-file-time ( path timestamp/f timestamp/f timestamp/f -- )
-    #! timestamp order: creation access write
-    >r >r >r open-existing dup r> r> r>
-    [ timestamp>FILETIME ] 3 napply
-    SetFileTime win32-error=0/f
-    close-handle ;
-
-: set-file-times ( path timestamp/f timestamp/f -- )
-    f -rot set-file-time ;
-
-: set-file-create-time ( path timestamp -- )
-    f f set-file-time ;
-
-: set-file-access-time ( path timestamp -- )
-    >r f r> f set-file-time ;
-
-: set-file-write-time ( path timestamp -- )
-    >r f f r> set-file-time ;
-
-: maybe-make-filetime ( ? -- FILETIME/f )
-    [ "FILETIME" <c-object> ] [ f ] if ;
-
-: file-time ( path ? ? ? -- FILETIME/f FILETIME/f FILETIME/f )
-    >r >r >r open-existing dup r> r> r>
-    [ maybe-make-filetime ] 3 napply
-    [ GetFileTime win32-error=0/f close-handle ] 3keep ;
-
-: file-times ( path -- FILETIME FILETIME FILETIME )
-    t t t file-time [ FILETIME>timestamp ] 3 napply ;
-
-: file-create-time ( path -- FILETIME )
-    t f f file-time 2drop FILETIME>timestamp ;
-
-: file-access-time ( path -- FILETIME )
-    f t f file-time drop nip FILETIME>timestamp ;
-
-: file-write-time ( path -- FILETIME )
-    f f t file-time 2nip FILETIME>timestamp ;
-
-: attrib ( path -- n )
-    [ stat* WIN32_FIND_DATA-dwFileAttributes ] catch
-    [ drop 0 ] when ;
-
-: (read-only?) ( mode -- ? )
-    FILE_ATTRIBUTE_READONLY bit-set? ;
-
-: read-only? ( path -- ? )
-    attrib (read-only?) ;
-
-: (hidden?) ( mode -- ? )
-    FILE_ATTRIBUTE_HIDDEN bit-set? ;
-
-: hidden? ( path -- ? )
-    attrib (hidden?) ;
-
-: (system?) ( mode -- ? )
-    FILE_ATTRIBUTE_SYSTEM bit-set? ;
-
-: system? ( path -- ? )
-    attrib (system?) ;
-
-: (directory?) ( mode -- ? )
-    FILE_ATTRIBUTE_DIRECTORY bit-set? ;
-
-: directory? ( path -- ? )
-    attrib (directory?) ;
-
-: (archive?) ( mode -- ? )
-    FILE_ATTRIBUTE_ARCHIVE bit-set? ;
-    
-: archive? ( path -- ? )
-    attrib (archive?) ;
-
-! FILE_ATTRIBUTE_DEVICE
-! FILE_ATTRIBUTE_NORMAL
-! FILE_ATTRIBUTE_TEMPORARY
-! FILE_ATTRIBUTE_SPARSE_FILE
-! FILE_ATTRIBUTE_REPARSE_POINT
-! FILE_ATTRIBUTE_COMPRESSED
-! FILE_ATTRIBUTE_OFFLINE
-! FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
-! FILE_ATTRIBUTE_ENCRYPTED
-
diff --git a/unmaintained/io/shell.factor b/unmaintained/io/shell.factor
deleted file mode 100644 (file)
index 5213eb2..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-USING: calendar io io-internals kernel math namespaces
-nonblocking-io prettyprint quotations sequences ;
-IN: shell
-
-SYMBOL: shell
-HOOK: directory* shell ( path -- seq )
-HOOK: make-file shell ( bytes -- file )
-HOOK: file. shell ( file -- )
-HOOK: touch-file shell ( path -- )
-
-: (ls) ( path -- )
-    >r H{ } r> directory*
-    [
-        [ [ make-file file. ] with-row ] each
-    ] curry tabular-output ;
-
-: ls ( -- )
-    cwd (ls) ;
-
-: pwd ( -- )
-    cwd pprint nl ;
-
-: (slurp) ( quot -- )
-    >r default-buffer-size read r> over [
-        dup slip (slurp)
-    ] [
-        2drop
-    ] if ;
-
-: slurp ( stream quot -- )
-    [ (slurp) ] curry with-stream ;
-
-: cat ( path -- )
-     <file-reader> stdio get
-     duplex-stream-out <duplex-stream>
-     [ write ] slurp ;
-
-: copy-file ( path path -- )
-    >r <file-reader> r>
-    <file-writer> <duplex-stream> [ write ] slurp ;
diff --git a/unmaintained/io/test/io.factor b/unmaintained/io/test/io.factor
deleted file mode 100644 (file)
index 379e123..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-USING: calendar errors io kernel libs-io math namespaces sequences\r
-shell test ;\r
-IN: temporary\r
-\r
-SYMBOL: file "file-appender-test.txt" \ file set\r
-[ \ file get delete-file ] catch drop\r
-[ f ] [ \ file get exists? ] unit-test\r
-\ file get <file-appender> [ "asdf" write ] with-stream\r
-[ t ] [ \ file get exists? ] unit-test\r
-[ 4 ] [ \ file get file-length ] unit-test\r
-\ file get <file-appender> [ "jkl;" write ] with-stream\r
-[ t ] [ \ file get exists? ] unit-test\r
-[ 8 ] [ \ file get file-length ] unit-test\r
-[ "asdfjkl;" ] [ \ file get <file-reader> contents ] unit-test\r
-\ file get delete-file\r
-[ f ] [ \ file get exists? ] unit-test\r
-\r
-SYMBOL: directory "test-directory" \ directory set\r
-\ directory get create-directory\r
-[ t ] [ \ directory get directory? ] unit-test\r
-\ directory get delete-directory\r
-[ f ] [ \ directory get directory? ] unit-test\r
-\r
-SYMBOL: time "time-test.txt" \ time set\r
-[ \ time get delete-file ] catch drop\r
-\ time get touch-file\r
-[ 0 ] [ \ time get file-length ] unit-test\r
-[ t ] [ \ time get exists? ] unit-test\r
-\ time get 0 unix-time>timestamp dup set-file-times\r
-[ t ] [ \ time get file-write-time 0 unix-time>timestamp = ] unit-test\r
-[ t ] [ \ time get file-access-time 0 unix-time>timestamp = ] unit-test\r
-\ time get touch-file\r
-[ t ] [ now \ time get file-write-time timestamp- 10 < ] unit-test\r
-\ time get delete-file\r
-\r
-SYMBOL: longname "" 255 CHAR: a pad-left \ longname set\r
-\ longname get touch-file\r
-[ t ] [ \ longname get exists? ] unit-test\r
-[ 0 ] [ \ longname get file-length ] unit-test\r
-\ longname get delete-file\r
-[ f ] [ \ longname get exists? ] unit-test\r
-\r
diff --git a/unmaintained/io/test/mmap.factor b/unmaintained/io/test/mmap.factor
deleted file mode 100644 (file)
index faeca55..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-USING: alien errors io kernel libs-io mmap namespaces test ;\r
-\r
-IN: temporary\r
-SYMBOL: mmap "mmap-test.txt" \ mmap set\r
-\r
-[ \ mmap get delete-file ] catch drop\r
-\ mmap get [\r
-    "Four" write\r
-] with-file-writer\r
-\r
-\ mmap get [\r
-    >r CHAR: R r> mmap-address 3 set-alien-unsigned-1\r
-] with-mmap\r
-\r
-\ mmap get [\r
-    mmap-address 3 alien-unsigned-1 CHAR: R = [\r
-        "mmap test failed" throw\r
-    ] unless\r
-] with-mmap\r
-\r
-[ \ mmap get delete-file ] catch drop\r
index 8c6ec203adaed612e6a5654539d297547ba5d004..db8e60c781232a67f4d36b39973089c5e758b205 100755 (executable)
@@ -167,7 +167,9 @@ void print_stack_frame(F_STACK_FRAME *frame)
        print_obj(frame_scan(frame));
        print_string("\n");
        print_cell_hex((CELL)frame_executing(frame));
+       print_string(" ");
        print_cell_hex((CELL)frame->xt);
+       print_string("\n");
 }
 
 void print_callstack(void)
index c6b91bc8f7dedb23a161c297a9415fae5c624bf2..07493a947fa7955dc2d59887387bc4a272eb4668 100644 (file)
--- a/vm/math.c
+++ b/vm/math.c
@@ -33,18 +33,18 @@ void primitive_float_to_fixnum(void)
 
 #define POP_FIXNUMS(x,y) \
        F_FIXNUM y = untag_fixnum_fast(dpop()); \
-       F_FIXNUM x = untag_fixnum_fast(dpop());
+       F_FIXNUM x = untag_fixnum_fast(dpeek());
 
 void primitive_fixnum_add(void)
 {
        POP_FIXNUMS(x,y)
-       box_signed_cell(x + y);
+       drepl(allot_integer(x + y));
 }
 
 void primitive_fixnum_subtract(void)
 {
        POP_FIXNUMS(x,y)
-       box_signed_cell(x - y);
+       drepl(allot_integer(x - y));
 }
 
 /* Multiply two integers, and trap overflow.
@@ -54,20 +54,20 @@ void primitive_fixnum_multiply(void)
        POP_FIXNUMS(x,y)
 
        if(x == 0 || y == 0)
-               dpush(tag_fixnum(0));
+               drepl(tag_fixnum(0));
        else
        {
                F_FIXNUM prod = x * y;
                /* if this is not equal, we have overflow */
                if(prod / x == y)
-                       box_signed_cell(prod);
+                       drepl(allot_integer(prod));
                else
                {
                        F_ARRAY *bx = fixnum_to_bignum(x);
                        REGISTER_BIGNUM(bx);
                        F_ARRAY *by = fixnum_to_bignum(y);
                        UNREGISTER_BIGNUM(bx);
-                       dpush(tag_bignum(bignum_multiply(bx,by)));
+                       drepl(tag_bignum(bignum_multiply(bx,by)));
                }
        }
 }
@@ -75,14 +75,27 @@ void primitive_fixnum_multiply(void)
 void primitive_fixnum_divint(void)
 {
        POP_FIXNUMS(x,y)
-       box_signed_cell(x / y);
+       F_FIXNUM result = x / y;
+       if(result == -FIXNUM_MIN)
+               drepl(allot_integer(-FIXNUM_MIN));
+       else
+               drepl(tag_fixnum(result));
 }
 
 void primitive_fixnum_divmod(void)
 {
-       POP_FIXNUMS(x,y)
-       box_signed_cell(x / y);
-       dpush(tag_fixnum(x % y));
+       F_FIXNUM y = get(ds);
+       F_FIXNUM x = get(ds - CELLS);
+       if(y == tag_fixnum(-1) && x == tag_fixnum(FIXNUM_MIN))
+       {
+               put(ds - CELLS,allot_integer(-FIXNUM_MIN));
+               put(ds,tag_fixnum(0));
+       }
+       else
+       {
+               put(ds - CELLS,tag_fixnum(x / y));
+               put(ds,x % y);
+       }
 }
 
 /*
@@ -96,15 +109,15 @@ void primitive_fixnum_shift(void)
 
        if(x == 0 || y == 0)
        {
-               dpush(tag_fixnum(x));
+               drepl(tag_fixnum(x));
                return;
        }
        else if(y < 0)
        {
                if(y <= -WORD_SIZE)
-                       dpush(x < 0 ? tag_fixnum(-1) : tag_fixnum(0));
+                       drepl(x < 0 ? tag_fixnum(-1) : tag_fixnum(0));
                else
-                       dpush(tag_fixnum(x >> -y));
+                       drepl(tag_fixnum(x >> -y));
                return;
        }
        else if(y < WORD_SIZE - TAG_BITS)
@@ -112,12 +125,12 @@ void primitive_fixnum_shift(void)
                F_FIXNUM mask = -((F_FIXNUM)1 << (WORD_SIZE - 1 - TAG_BITS - y));
                if((x > 0 && (x & mask) == 0) || (x & mask) == mask)
                {
-                       dpush(tag_fixnum(x << y));
+                       drepl(tag_fixnum(x << y));
                        return;
                }
        }
 
-       dpush(tag_bignum(bignum_arithmetic_shift(
+       drepl(tag_bignum(bignum_arithmetic_shift(
                fixnum_to_bignum(x),y)));
 }
 
index 54b5d0bcff190bc899d852164d5fc31a261b9ac3..6486acda4abc7fb570748ce367e16cde8165c189 100644 (file)
@@ -2,5 +2,4 @@
 
 #define UAP_PROGRAM_COUNTER(uap)    _UC_MACHINE_PC((ucontext_t *)uap)
 
-#define UNKNOWN_TYPE_P(file) ((file)->d_type == DT_UNKNOWN)
 #define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
index bf917aeec06a7c40155870ee2c42d3dc6e7306dd..179224f7987d0acaa6047d98302b5c520dc81b36 100755 (executable)
@@ -54,6 +54,27 @@ bool jit_fast_dispatch_p(F_ARRAY *array, CELL i)
                && array_nth(array,i + 1) == userenv[JIT_DISPATCH_WORD];
 }
 
+bool jit_fast_dip_p(F_ARRAY *array, CELL i)
+{
+       return (i + 2) <= array_capacity(array)
+               && type_of(array_nth(array,i)) == QUOTATION_TYPE
+               && array_nth(array,i + 1) == userenv[JIT_DIP_WORD];
+}
+
+bool jit_fast_2dip_p(F_ARRAY *array, CELL i)
+{
+       return (i + 2) <= array_capacity(array)
+               && type_of(array_nth(array,i)) == QUOTATION_TYPE
+               && array_nth(array,i + 1) == userenv[JIT_2DIP_WORD];
+}
+
+bool jit_fast_3dip_p(F_ARRAY *array, CELL i)
+{
+       return (i + 2) <= array_capacity(array)
+               && type_of(array_nth(array,i)) == QUOTATION_TYPE
+               && array_nth(array,i + 1) == userenv[JIT_3DIP_WORD];
+}
+
 bool jit_ignore_declare_p(F_ARRAY *array, CELL i)
 {
        return (i + 1) < array_capacity(array)
@@ -115,6 +136,13 @@ bool jit_stack_frame_p(F_ARRAY *array)
                        if(word->subprimitive == F && obj != userenv[JIT_DECLARE_WORD])
                                return true;
                }
+               else if(type_of(obj) == QUOTATION_TYPE)
+               {
+                       if(jit_fast_dip_p(array,i)
+                               || jit_fast_2dip_p(array,i)
+                               || jit_fast_3dip_p(array,i))
+                               return true;
+               }
        }
 
        return false;
@@ -232,6 +260,30 @@ void jit_compile(CELL quot, bool relocate)
                                tail_call = true;
                                break;
                        }
+                       else if(jit_fast_dip_p(untag_object(array),i))
+                       {
+                               GROWABLE_ARRAY_ADD(literals,array_nth(untag_object(array),i));
+                               EMIT(userenv[JIT_DIP],literals_count - 1);
+
+                               i++;
+                               break;
+                       }
+                       else if(jit_fast_2dip_p(untag_object(array),i))
+                       {
+                               GROWABLE_ARRAY_ADD(literals,array_nth(untag_object(array),i));
+                               EMIT(userenv[JIT_2DIP],literals_count - 1);
+
+                               i++;
+                               break;
+                       }
+                       else if(jit_fast_3dip_p(untag_object(array),i))
+                       {
+                               GROWABLE_ARRAY_ADD(literals,array_nth(untag_object(array),i));
+                               EMIT(userenv[JIT_3DIP],literals_count - 1);
+
+                               i++;
+                               break;
+                       }
                case ARRAY_TYPE:
                        if(jit_fast_dispatch_p(untag_object(array),i))
                        {
@@ -366,6 +418,24 @@ F_FIXNUM quot_code_offset_to_scan(CELL quot, F_FIXNUM offset)
                                tail_call = true;
                                break;
                        }
+                       else if(jit_fast_dip_p(untag_object(array),i))
+                       {
+                               i++;
+                               COUNT(userenv[JIT_DIP],i)
+                               break;
+                       }
+                       else if(jit_fast_2dip_p(untag_object(array),i))
+                       {
+                               i++;
+                               COUNT(userenv[JIT_2DIP],i)
+                               break;
+                       }
+                       else if(jit_fast_3dip_p(untag_object(array),i))
+                       {
+                               i++;
+                               COUNT(userenv[JIT_3DIP],i)
+                               break;
+                       }
                case ARRAY_TYPE:
                        if(jit_fast_dispatch_p(untag_object(array),i))
                        {
index b8c8d78ba1f94d08f56fde12bf60e32965f63289..a28a956f2974257e6a25099037103a4b88e72499 100755 (executable)
--- a/vm/run.c
+++ b/vm/run.c
@@ -29,10 +29,35 @@ void save_stacks(void)
        }
 }
 
+F_CONTEXT *alloc_context(void)
+{
+       F_CONTEXT *context;
+
+       if(unused_contexts)
+       {
+               context = unused_contexts;
+               unused_contexts = unused_contexts->next;
+       }
+       else
+       {
+               context = safe_malloc(sizeof(F_CONTEXT));
+               context->datastack_region = alloc_segment(ds_size);
+               context->retainstack_region = alloc_segment(rs_size);
+       }
+
+       return context;
+}
+
+void dealloc_context(F_CONTEXT *context)
+{
+       context->next = unused_contexts;
+       unused_contexts = context;
+}
+
 /* called on entry into a compiled callback */
 void nest_stacks(void)
 {
-       F_CONTEXT *new_stacks = safe_malloc(sizeof(F_CONTEXT));
+       F_CONTEXT *new_stacks = alloc_context();
 
        new_stacks->callstack_bottom = (F_STACK_FRAME *)-1;
        new_stacks->callstack_top = (F_STACK_FRAME *)-1;
@@ -54,9 +79,6 @@ void nest_stacks(void)
        new_stacks->current_callback_save = userenv[CURRENT_CALLBACK_ENV];
        new_stacks->catchstack_save = userenv[CATCHSTACK_ENV];
 
-       new_stacks->datastack_region = alloc_segment(ds_size);
-       new_stacks->retainstack_region = alloc_segment(rs_size);
-
        new_stacks->next = stack_chain;
        stack_chain = new_stacks;
 
@@ -67,9 +89,6 @@ void nest_stacks(void)
 /* called when leaving a compiled callback */
 void unnest_stacks(void)
 {
-       dealloc_segment(stack_chain->datastack_region);
-       dealloc_segment(stack_chain->retainstack_region);
-
        ds = stack_chain->datastack_save;
        rs = stack_chain->retainstack_save;
 
@@ -79,7 +98,7 @@ void unnest_stacks(void)
 
        F_CONTEXT *old_stacks = stack_chain;
        stack_chain = old_stacks->next;
-       free(old_stacks);
+       dealloc_context(old_stacks);
 }
 
 /* called on startup */
@@ -88,6 +107,7 @@ void init_stacks(CELL ds_size_, CELL rs_size_)
        ds_size = ds_size_;
        rs_size = rs_size_;
        stack_chain = NULL;
+       unused_contexts = NULL;
 }
 
 bool stack_to_array(CELL bottom, CELL top)
index 378b93e8bd1d1b85680c86721f73f9af91228d77..eae0146298835c70a74129fbd6b1cd4be78168c0 100755 (executable)
--- a/vm/run.h
+++ b/vm/run.h
@@ -50,6 +50,12 @@ typedef enum {
        JIT_PUSH_IMMEDIATE,
        JIT_DECLARE_WORD    = 42,
        JIT_SAVE_STACK,
+       JIT_DIP_WORD,
+       JIT_DIP,
+       JIT_2DIP_WORD,
+       JIT_2DIP,
+       JIT_3DIP_WORD,
+       JIT_3DIP,
 
        STACK_TRACES_ENV    = 59,
 
@@ -211,6 +217,8 @@ typedef struct _F_CONTEXT {
 
 DLLEXPORT F_CONTEXT *stack_chain;
 
+F_CONTEXT *unused_contexts;
+
 CELL ds_size, rs_size;
 
 #define ds_bot (stack_chain->datastack_region->start)