]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix locals conflict
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 8 Dec 2008 21:28:27 +0000 (15:28 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 8 Dec 2008 21:28:27 +0000 (15:28 -0600)
240 files changed:
basis/alien/prettyprint/prettyprint.factor [new file with mode: 0644]
basis/alien/syntax/syntax.factor
basis/bit-arrays/bit-arrays.factor
basis/bit-vectors/bit-vectors.factor
basis/bootstrap/bootstrap-error.factor [new file with mode: 0644]
basis/bootstrap/compiler/compiler.factor
basis/bootstrap/finish-bootstrap.factor [new file with mode: 0644]
basis/bootstrap/finish-staging.factor [new file with mode: 0644]
basis/bootstrap/image/image.factor
basis/bootstrap/math/math.factor
basis/bootstrap/stage2.factor
basis/byte-vectors/byte-vectors-docs.factor [new file with mode: 0644]
basis/byte-vectors/byte-vectors-tests.factor [new file with mode: 0644]
basis/byte-vectors/byte-vectors.factor [new file with mode: 0644]
basis/byte-vectors/summary.txt [new file with mode: 0644]
basis/byte-vectors/tags.txt [new file with mode: 0644]
basis/calendar/calendar-docs.factor
basis/calendar/calendar-tests.factor
basis/calendar/calendar.factor
basis/checksums/md5/md5.factor
basis/checksums/openssl/openssl.factor
basis/checksums/sha1/sha1.factor
basis/checksums/stream/stream.factor [new file with mode: 0644]
basis/command-line/command-line.factor
basis/compiler/cfg/alias-analysis/alias-analysis-tests.factor
basis/compiler/cfg/alias-analysis/alias-analysis.factor
basis/compiler/cfg/dead-code/dead-code-tests.factor
basis/compiler/cfg/debugger/debugger.factor
basis/compiler/cfg/hats/hats.factor
basis/compiler/cfg/instructions/instructions.factor
basis/compiler/cfg/intrinsics/fixnum/fixnum.factor
basis/compiler/cfg/intrinsics/intrinsics.factor
basis/compiler/cfg/intrinsics/misc/misc.factor [new file with mode: 0644]
basis/compiler/cfg/intrinsics/slots/slots.factor
basis/compiler/cfg/registers/registers.factor
basis/compiler/cfg/two-operand/two-operand.factor
basis/compiler/cfg/value-numbering/value-numbering-tests.factor
basis/compiler/cfg/write-barrier/write-barrier-tests.factor
basis/compiler/codegen/codegen.factor
basis/compiler/codegen/fixup/fixup.factor
basis/compiler/compiler.factor
basis/compiler/tests/optimizer.factor
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/combinators/combinators.factor
basis/compiler/tree/dead-code/liveness/liveness.factor
basis/compiler/tree/debugger/debugger.factor
basis/compiler/tree/def-use/simplified/simplified.factor
basis/compiler/tree/escape-analysis/branches/branches.factor
basis/compiler/tree/escape-analysis/check/check.factor [new file with mode: 0644]
basis/compiler/tree/finalization/finalization.factor
basis/compiler/tree/normalization/normalization.factor
basis/compiler/tree/optimizer/optimizer.factor
basis/compiler/tree/propagation/branches/branches.factor
basis/compiler/tree/propagation/copy/copy.factor
basis/compiler/tree/propagation/inlining/inlining.factor
basis/compiler/tree/propagation/known-words/known-words.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/compiler/tree/tuple-unboxing/tuple-unboxing.factor
basis/compiler/utilities/utilities.factor [new file with mode: 0644]
basis/concurrency/messaging/messaging-docs.factor
basis/core-foundation/core-foundation.factor
basis/core-foundation/run-loop/run-loop.factor
basis/cpu/architecture/architecture.factor
basis/cpu/ppc/bootstrap.factor
basis/cpu/ppc/ppc.factor
basis/cpu/x86/32/32.factor
basis/cpu/x86/64/64.factor
basis/cpu/x86/assembler/assembler.factor
basis/cpu/x86/bootstrap.factor
basis/cpu/x86/x86.factor
basis/db/sqlite/sqlite.factor
basis/debugger/debugger.factor
basis/grouping/grouping-tests.factor
basis/help/definitions/definitions.factor
basis/help/lint/lint.factor
basis/html/elements/elements.factor
basis/io/streams/byte-array/byte-array-docs.factor [new file with mode: 0644]
basis/io/streams/byte-array/byte-array-tests.factor [new file with mode: 0644]
basis/io/streams/byte-array/byte-array.factor [new file with mode: 0644]
basis/io/styles/styles.factor
basis/io/unix/files/macosx/macosx.factor
basis/io/unix/kqueue/kqueue.factor
basis/io/windows/launcher/launcher.factor
basis/locals/locals.factor
basis/locals/prettyprint/prettyprint.factor
basis/math/complex/complex.factor
basis/math/complex/prettyprint/prettyprint.factor [new file with mode: 0644]
basis/math/intervals/intervals-docs.factor
basis/math/intervals/intervals.factor
basis/math/partial-dispatch/partial-dispatch.factor
basis/nibble-arrays/nibble-arrays.factor
basis/persistent/hashtables/hashtables.factor
basis/persistent/vectors/vectors.factor
basis/prettyprint/backend/backend-docs.factor
basis/prettyprint/backend/backend.factor
basis/prettyprint/custom/custom-docs.factor [new file with mode: 0644]
basis/prettyprint/custom/custom.factor [new file with mode: 0644]
basis/prettyprint/prettyprint-docs.factor
basis/prettyprint/prettyprint.factor
basis/qualified/qualified.factor
basis/regexp/regexp.factor
basis/smtp/smtp.factor
basis/specialized-arrays/functor/functor.factor
basis/specialized-vectors/functor/functor.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/errors/errors.factor
basis/stack-checker/errors/prettyprint/prettyprint.factor [new file with mode: 0644]
basis/stack-checker/known-words/known-words.factor
basis/summary/summary.factor
basis/tools/deploy/backend/backend.factor
basis/tools/deploy/config/config-docs.factor
basis/tools/deploy/config/config.factor
basis/tools/deploy/config/editor/editor-docs.factor [new file with mode: 0644]
basis/tools/deploy/config/editor/editor.factor [new file with mode: 0644]
basis/tools/deploy/deploy-docs.factor
basis/tools/deploy/deploy-tests.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/test/8/8.factor [new file with mode: 0644]
basis/tools/deploy/test/8/deploy.factor [new file with mode: 0644]
basis/tools/disassembler/disassembler-tests.factor
basis/tools/vocabs/browser/browser.factor
basis/ui/freetype/freetype.factor
basis/ui/gadgets/labelled/labelled.factor
basis/ui/gadgets/presentations/presentations.factor
basis/ui/gadgets/sliders/sliders.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/tools/deploy/deploy.factor
basis/ui/ui.factor
basis/ui/x11/x11.factor
basis/unicode/case/case-tests.factor
basis/unicode/case/case.factor
basis/urls/urls.factor
basis/vlists/vlists.factor
core/arrays/arrays.factor
core/assocs/assocs.factor
core/bootstrap/primitives.factor
core/bootstrap/stage1.factor
core/bootstrap/syntax.factor
core/byte-vectors/byte-vectors-docs.factor [deleted file]
core/byte-vectors/byte-vectors-tests.factor [deleted file]
core/byte-vectors/byte-vectors.factor [deleted file]
core/byte-vectors/summary.txt [deleted file]
core/byte-vectors/tags.txt [deleted file]
core/checksums/checksums.factor
core/classes/algebra/algebra-docs.factor
core/classes/builtin/builtin.factor
core/classes/intersection/intersection.factor
core/classes/tuple/tuple.factor
core/generic/math/math.factor
core/generic/standard/engines/tag/tag.factor
core/growable/growable-docs.factor
core/hashtables/hashtables.factor
core/io/streams/byte-array/byte-array-docs.factor [deleted file]
core/io/streams/byte-array/byte-array-tests.factor [deleted file]
core/io/streams/byte-array/byte-array.factor [deleted file]
core/kernel/kernel.factor
core/math/integers/integers.factor
core/math/math.factor
core/namespaces/namespaces.factor
core/parser/parser.factor
core/sequences/sequences-docs.factor
core/sequences/sequences-tests.factor
core/sequences/sequences.factor
core/slots/slots.factor
core/syntax/syntax.factor
core/vectors/vectors.factor
core/words/words.factor
extra/combinators/lib/lib-tests.factor
extra/crypto/barrett/barrett.factor
extra/crypto/hmac/hmac.factor
extra/crypto/timing/timing.factor
extra/crypto/xor/xor.factor
extra/hardware-info/authors.txt [deleted file]
extra/hardware-info/backend/authors.txt [deleted file]
extra/hardware-info/backend/backend.factor [deleted file]
extra/hardware-info/hardware-info.factor [deleted file]
extra/hardware-info/linux/authors.txt [deleted file]
extra/hardware-info/linux/linux.factor [deleted file]
extra/hardware-info/linux/tags.txt [deleted file]
extra/hardware-info/macosx/authors.txt [deleted file]
extra/hardware-info/macosx/macosx.factor [deleted file]
extra/hardware-info/macosx/tags.txt [deleted file]
extra/hardware-info/summary.txt [deleted file]
extra/hardware-info/windows/authors.txt [deleted file]
extra/hardware-info/windows/ce/authors.txt [deleted file]
extra/hardware-info/windows/ce/ce.factor [deleted file]
extra/hardware-info/windows/ce/tags.txt [deleted file]
extra/hardware-info/windows/nt/authors.txt [deleted file]
extra/hardware-info/windows/nt/nt.factor [deleted file]
extra/hardware-info/windows/nt/tags.txt [deleted file]
extra/hardware-info/windows/tags.txt [deleted file]
extra/hardware-info/windows/windows.factor [deleted file]
extra/html/parser/utils/utils.factor
extra/inverse/inverse.factor
extra/irc/messages/messages.factor
extra/irc/ui/ui.factor
extra/lint/authors.txt [new file with mode: 0644]
extra/lint/lint-tests.factor [new file with mode: 0644]
extra/lint/lint.factor [new file with mode: 0644]
extra/lint/summary.txt [new file with mode: 0755]
extra/math/finance/finance-docs.factor
extra/math/finance/finance-tests.factor
extra/math/finance/finance.factor
extra/math/numerical-integration/numerical-integration.factor
extra/multi-methods/multi-methods.factor
extra/parser-combinators/simple/simple-docs.factor
extra/project-euler/117/117.factor
extra/raptor/raptor.factor
extra/system-info/authors.txt [new file with mode: 0644]
extra/system-info/backend/authors.txt [new file with mode: 0755]
extra/system-info/backend/backend.factor [new file with mode: 0644]
extra/system-info/linux/authors.txt [new file with mode: 0755]
extra/system-info/linux/linux.factor [new file with mode: 0644]
extra/system-info/linux/tags.txt [new file with mode: 0644]
extra/system-info/macosx/authors.txt [new file with mode: 0755]
extra/system-info/macosx/macosx.factor [new file with mode: 0644]
extra/system-info/macosx/tags.txt [new file with mode: 0644]
extra/system-info/summary.txt [new file with mode: 0644]
extra/system-info/system-info.factor [new file with mode: 0755]
extra/system-info/windows/authors.txt [new file with mode: 0755]
extra/system-info/windows/ce/authors.txt [new file with mode: 0755]
extra/system-info/windows/ce/ce.factor [new file with mode: 0755]
extra/system-info/windows/ce/tags.txt [new file with mode: 0644]
extra/system-info/windows/nt/authors.txt [new file with mode: 0755]
extra/system-info/windows/nt/nt.factor [new file with mode: 0755]
extra/system-info/windows/nt/tags.txt [new file with mode: 0644]
extra/system-info/windows/tags.txt [new file with mode: 0755]
extra/system-info/windows/windows.factor [new file with mode: 0755]
extra/taxes/usa/usa-tests.factor
extra/webapps/wiki/wiki.factor
unmaintained/README.libs.txt [deleted file]
unmaintained/README.txt [deleted file]
unmaintained/lint/authors.txt [deleted file]
unmaintained/lint/lint-tests.factor [deleted file]
unmaintained/lint/lint.factor [deleted file]
unmaintained/lint/summary.txt [deleted file]
vm/bignum.c
vm/math.c
vm/types.c
vm/types.h

diff --git a/basis/alien/prettyprint/prettyprint.factor b/basis/alien/prettyprint/prettyprint.factor
new file mode 100644 (file)
index 0000000..0794ab7
--- /dev/null
@@ -0,0 +1,14 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel combinators alien alien.strings alien.syntax
+prettyprint.backend prettyprint.custom prettyprint.sections ;
+IN: alien.prettyprint
+
+M: alien pprint*
+    {
+        { [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
+        { [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
+        [ \ ALIEN: [ alien-address pprint* ] pprint-prefix ]
+    } cond ;
+
+M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
index d10c97cd3ddd15033bd57dcf066e4c1eba48608f..b0ba10a316176e501699e8487a993e168d50f482 100644 (file)
@@ -3,8 +3,7 @@
 USING: accessors arrays alien alien.c-types alien.structs
 alien.arrays alien.strings kernel math namespaces parser
 sequences words quotations math.parser splitting grouping
-effects prettyprint prettyprint.sections prettyprint.backend
-assocs combinators lexer strings.parser alien.parser ;
+effects assocs combinators lexer strings.parser alien.parser ;
 IN: alien.syntax
 
 : DLL" lexer get skip-blank parse-string dlopen parsed ; parsing
@@ -34,12 +33,3 @@ IN: alien.syntax
     dup length
     [ [ create-in ] dip 1quotation define ] 2each ;
     parsing
-
-M: alien pprint*
-    {
-        { [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
-        { [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
-        [ \ ALIEN: [ alien-address pprint* ] pprint-prefix ]
-    } cond ;
-
-M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
index 4cb2032f4f27e8434dc3a8182a0c5efd9501ef79..d5e94f02389ea664eb1f48925d38aa027a4c0551 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.c-types accessors math alien.accessors kernel
 kernel.private locals sequences sequences.private byte-arrays
-parser prettyprint.backend fry ;
+parser prettyprint.custom fry ;
 IN: bit-arrays
 
 TUPLE: bit-array
index 404b26829b332b1f4d39ab8e4ec2713c1457ea79..85bea80b2dbadc239747c2a20fa22d65314a5c4e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: arrays kernel kernel.private math sequences\r
-sequences.private growable bit-arrays prettyprint.backend\r
+sequences.private growable bit-arrays prettyprint.custom\r
 parser accessors ;\r
 IN: bit-vectors\r
 \r
diff --git a/basis/bootstrap/bootstrap-error.factor b/basis/bootstrap/bootstrap-error.factor
new file mode 100644 (file)
index 0000000..01eb002
--- /dev/null
@@ -0,0 +1,8 @@
+USING: continuations kernel io debugger vocabs words system namespaces ;
+
+:c
+:error
+"listener" vocab
+[ restarts. vocab-main execute ]
+[ die ] if*
+1 exit
index dabdeea74148d28d25b54d7e9802d6b44bb6c12a..f0d9e8e131cb43afff4ad18349f235041890f51a 100644 (file)
@@ -5,17 +5,22 @@ sequences namespaces parser kernel kernel.private classes
 classes.private arrays hashtables vectors classes.tuple sbufs
 hashtables.private sequences.private math classes.tuple.private
 growable namespaces.private assocs words command-line vocabs io
-io.encodings.string prettyprint libc splitting math.parser
+io.encodings.string libc splitting math.parser
 compiler.units math.order compiler.tree.builder
 compiler.tree.optimizer compiler.cfg.optimizer ;
 IN: bootstrap.compiler
 
 ! Don't bring this in when deploying, since it will store a
 ! reference to 'eval' in a global variable
-"deploy-vocab" get [
+"deploy-vocab" get "staging" get or [
     "alien.remote-control" require
 ] unless
 
+"prettyprint" vocab [
+    "stack-checker.errors.prettyprint" require
+    "alien.prettyprint" require
+] when
+
 "cpu." cpu name>> append require
 
 enable-compiler
@@ -60,7 +65,7 @@ nl
 "." write flush
 
 {
-    new-sequence nth push pop peek
+    new-sequence nth push pop peek flip
 } compile-uncompiled
 
 "." write flush
@@ -86,7 +91,7 @@ nl
 "." write flush
 
 {
-    malloc calloc free memcpy
+    malloc calloc free memcpy
 } compile-uncompiled
 
 "." write flush
diff --git a/basis/bootstrap/finish-bootstrap.factor b/basis/bootstrap/finish-bootstrap.factor
new file mode 100644 (file)
index 0000000..133b64a
--- /dev/null
@@ -0,0 +1,16 @@
+USING: init command-line debugger system continuations
+namespaces eval kernel vocabs.loader io ;
+
+[
+    boot
+    do-init-hooks
+    [
+        (command-line) parse-command-line
+        load-vocab-roots
+        run-user-init
+        "e" get [ eval ] when*
+        ignore-cli-args? not script get and
+        [ run-script ] [ "run" get run ] if*
+        output-stream get [ stream-flush ] when*
+    ] [ print-error 1 exit ] recover
+] set-boot-quot
diff --git a/basis/bootstrap/finish-staging.factor b/basis/bootstrap/finish-staging.factor
new file mode 100644 (file)
index 0000000..a60ce04
--- /dev/null
@@ -0,0 +1,10 @@
+USING: init command-line system namespaces kernel vocabs.loader
+io ;
+
+[
+    boot
+    do-init-hooks
+    (command-line) parse-command-line
+    "run" get run
+    output-stream get [ stream-flush ] when*
+] set-boot-quot
index 380c9b2348a5bd61cacf29b0582433e10f9362ac..c7d87776a19b12a0e18ccbef0ea469c2afe6965e 100644 (file)
@@ -23,7 +23,7 @@ IN: bootstrap.image
     os name>> cpu name>> arch ;
 
 : boot-image-name ( arch -- string )
-    "boot." swap ".image" 3append ;
+    "boot." ".image" surround ;
 
 : my-boot-image-name ( -- string )
     my-arch boot-image-name ;
index a293efd33eae01d46d8c9c12c4dfe0d7cce6c10a..347969af0d6698cb65230ddaec7a8aa90efea2bf 100644 (file)
@@ -1,5 +1,7 @@
-USE: vocabs.loader
+USING: vocabs vocabs.loader kernel ;
 
 "math.ratios" require
 "math.floats" require
 "math.complex" require
+
+"prettyprint" vocab [ "math.complex.prettyprint" require ] when
index 4ab36ec94e9361a6efbf23a2a2550416735c9738..78355a46702b383edf3536450ae5e6856cb430ad 100644 (file)
@@ -2,10 +2,10 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors init namespaces words io
 kernel.private math memory continuations kernel io.files
-io.backend system parser vocabs sequences prettyprint
+io.backend system parser vocabs sequences
 vocabs.loader combinators splitting source-files strings
 definitions assocs compiler.errors compiler.units
-math.parser generic sets debugger command-line ;
+math.parser generic sets command-line ;
 IN: bootstrap.stage2
 
 SYMBOL: core-bootstrap-time
@@ -86,25 +86,18 @@ SYMBOL: bootstrap-time
     f error set-global
     f error-continuation set-global
 
+    millis swap - bootstrap-time set-global
+    print-report
+
     "deploy-vocab" get [
         "tools.deploy.shaker" run
     ] [
-        [
-            boot
-            do-init-hooks
-            handle-command-line
-        ] set-boot-quot
-
-        millis swap - bootstrap-time set-global
-        print-report
+        "staging" get [
+            "resource:basis/bootstrap/finish-staging.factor" run-file
+        ] [
+            "resource:basis/bootstrap/finish-bootstrap.factor" run-file
+        ] if
 
         "output-image" get save-image-and-exit
     ] if
-] [
-    :c
-    dup print-error flush
-    "listener" vocab
-    [ restarts. vocab-main execute ]
-    [ die ] if*
-    1 exit
-] recover
+] [ drop "resource:basis/bootstrap/bootstrap-error.factor" run-file ] recover
diff --git a/basis/byte-vectors/byte-vectors-docs.factor b/basis/byte-vectors/byte-vectors-docs.factor
new file mode 100644 (file)
index 0000000..3873f73
--- /dev/null
@@ -0,0 +1,37 @@
+USING: arrays byte-arrays help.markup help.syntax kernel\r
+byte-vectors.private combinators ;\r
+IN: byte-vectors\r
+\r
+ARTICLE: "byte-vectors" "Byte vectors"\r
+"A byte vector is a resizable mutable sequence of unsigned bytes. Byte vector words are found in the " { $vocab-link "byte-vectors" } " vocabulary."\r
+$nl\r
+"Byte vectors form a class:"\r
+{ $subsection byte-vector }\r
+{ $subsection byte-vector? }\r
+"Creating byte vectors:"\r
+{ $subsection >byte-vector }\r
+{ $subsection <byte-vector> }\r
+"Literal syntax:"\r
+{ $subsection POSTPONE: BV{ }\r
+"If you don't care about initial capacity, a more elegant way to create a new byte vector is to write:"\r
+{ $code "BV{ } clone" } ;\r
+\r
+ABOUT: "byte-vectors"\r
+\r
+HELP: byte-vector\r
+{ $description "The class of resizable byte vectors. See " { $link "byte-vectors" } " for information." } ;\r
+\r
+HELP: <byte-vector>\r
+{ $values { "n" "a positive integer specifying initial capacity" } { "byte-vector" byte-vector } }\r
+{ $description "Creates a new byte vector that can hold " { $snippet "n" } " bytes before resizing." } ;\r
+\r
+HELP: >byte-vector\r
+{ $values { "seq" "a sequence" } { "byte-vector" byte-vector } }\r
+{ $description "Outputs a freshly-allocated byte vector with the same elements as a given sequence." }\r
+{ $errors "Throws an error if the sequence contains elements other than integers." } ;\r
+\r
+HELP: BV{\r
+{ $syntax "BV{ elements... }" }\r
+{ $values { "elements" "a list of bytes" } }\r
+{ $description "Marks the beginning of a literal byte vector. Literal byte vectors are terminated by " { $link POSTPONE: } } "." } \r
+{ $examples { $code "BV{ 1 2 3 12 }" } } ;\r
diff --git a/basis/byte-vectors/byte-vectors-tests.factor b/basis/byte-vectors/byte-vectors-tests.factor
new file mode 100644 (file)
index 0000000..9a100d9
--- /dev/null
@@ -0,0 +1,17 @@
+IN: byte-vectors.tests\r
+USING: tools.test byte-vectors vectors sequences kernel\r
+prettyprint ;\r
+\r
+[ 0 ] [ 123 <byte-vector> length ] unit-test\r
+\r
+: do-it\r
+    123 [ over push ] each ;\r
+\r
+[ t ] [\r
+    3 <byte-vector> do-it\r
+    3 <vector> do-it sequence=\r
+] unit-test\r
+\r
+[ t ] [ BV{ } byte-vector? ] unit-test\r
+\r
+[ "BV{ }" ] [ BV{ } unparse ] unit-test\r
diff --git a/basis/byte-vectors/byte-vectors.factor b/basis/byte-vectors/byte-vectors.factor
new file mode 100644 (file)
index 0000000..e24c808
--- /dev/null
@@ -0,0 +1,51 @@
+! Copyright (C) 2008 Slava Pestov.\r
+! See http://factorcode.org/license.txt for BSD license.\r
+USING: arrays kernel kernel.private math sequences\r
+sequences.private growable byte-arrays accessors parser\r
+prettyprint.custom ;\r
+IN: byte-vectors\r
+\r
+TUPLE: byte-vector\r
+{ underlying byte-array }\r
+{ length array-capacity } ;\r
+\r
+: <byte-vector> ( n -- byte-vector )\r
+    <byte-array> 0 byte-vector boa ; inline\r
+\r
+: >byte-vector ( seq -- byte-vector )\r
+    T{ byte-vector f B{ } 0 } clone-like ;\r
+\r
+M: byte-vector like\r
+    drop dup byte-vector? [\r
+        dup byte-array?\r
+        [ dup length byte-vector boa ] [ >byte-vector ] if\r
+    ] unless ;\r
+\r
+M: byte-vector new-sequence\r
+    drop [ <byte-array> ] [ >fixnum ] bi byte-vector boa ;\r
+\r
+M: byte-vector equal?\r
+    over byte-vector? [ sequence= ] [ 2drop f ] if ;\r
+\r
+M: byte-array like\r
+    #! If we have an byte-array, we're done.\r
+    #! If we have a byte-vector, and it's at full capacity,\r
+    #! we're done. Otherwise, call resize-byte-array, which is a\r
+    #! relatively fast primitive.\r
+    drop dup byte-array? [\r
+        dup byte-vector? [\r
+            [ length ] [ underlying>> ] bi\r
+            2dup length eq?\r
+            [ nip ] [ resize-byte-array ] if\r
+        ] [ >byte-array ] if\r
+    ] unless ;\r
+\r
+M: byte-array new-resizable drop <byte-vector> ;\r
+\r
+: BV{ \ } [ >byte-vector ] parse-literal ; parsing\r
+\r
+M: byte-vector pprint* pprint-object ;\r
+M: byte-vector pprint-delims drop \ BV{ \ } ;\r
+M: byte-vector >pprint-sequence ;\r
+\r
+INSTANCE: byte-vector growable\r
diff --git a/basis/byte-vectors/summary.txt b/basis/byte-vectors/summary.txt
new file mode 100644 (file)
index 0000000..e914ebb
--- /dev/null
@@ -0,0 +1 @@
+Growable byte arrays
diff --git a/basis/byte-vectors/tags.txt b/basis/byte-vectors/tags.txt
new file mode 100644 (file)
index 0000000..42d711b
--- /dev/null
@@ -0,0 +1 @@
+collections
index 748f9d124c0a7ad3fdd5e5ba91d3997daef27997..433459cb24457823fd5b61c253f88132580c0d19 100644 (file)
@@ -99,48 +99,6 @@ HELP: seconds-per-year
 { $values { "integer" integer } }
 { $description "Returns the number of seconds in a year averaged over 400 years. Used internally for adding an arbitrary real number of seconds to a timestamp." } ;
 
-HELP: biweekly
-{ $values
-     { "x" number }
-     { "y" number }
-}
-{ $description "Divides a number by the number of two week periods in a year." } ;
-
-HELP: daily-360
-{ $values
-     { "x" number }
-     { "y" number }
-}
-{ $description "Divides a number by the number of days in a 360-day year." } ;
-
-HELP: daily-365
-{ $values
-     { "x" number }
-     { "y" number }
-}
-{ $description "Divides a number by the number of days in a 365-day year." } ;
-
-HELP: monthly
-{ $values
-     { "x" number }
-     { "y" number }
-}
-{ $description "Divides a number by the number of months in a year." } ;
-
-HELP: semimonthly
-{ $values
-     { "x" number }
-     { "y" number }
-}
-{ $description "Divides a number by the number of half-months in a year. Note that biweekly has two more periods than semimonthly." } ;
-
-HELP: weekly
-{ $values
-     { "x" number }
-     { "y" number }
-}
-{ $description "Divides a number by the number of weeks in a year." } ;
-
 HELP: julian-day-number
 { $values { "year" integer } { "month" integer } { "day" integer } { "n" integer } }
 { $description "Calculates the Julian day number from a year, month, and day.  The difference between two Julian day numbers is the number of days that have elapsed between the two corresponding dates." }
@@ -582,8 +540,6 @@ ARTICLE: "calendar" "Calendar"
 { $subsection "years" }
 { $subsection "months" }
 { $subsection "days" }
-"Calculating amounts per period of time:"
-{ $subsection "time-period-calculations" }
 "Meta-data about the calendar:"
 { $subsection "calendar-facts" }
 ;
@@ -670,18 +626,6 @@ ARTICLE: "calendar-facts" "Calendar facts"
 { $subsection day-of-week }
 ;
 
-ARTICLE: "time-period-calculations" "Calculations over periods of time"
-{ $subsection monthly }
-{ $subsection semimonthly }
-{ $subsection biweekly }
-{ $subsection weekly }
-{ $subsection daily-360 }
-{ $subsection daily-365 }
-{ $subsection biweekly }
-{ $subsection biweekly }
-{ $subsection biweekly }
-;
-
 ARTICLE: "years" "Year operations"
 "Leap year predicate:"
 { $subsection leap-year? }
index 943ba8c3d56eccb35a1f089f5d56a286e914e580..00d5730745728979aa94b2e49007e9e0f7327e07 100644 (file)
@@ -167,5 +167,3 @@ IN: calendar.tests
 [ t ] [ now 50 milliseconds sleep now before? ] unit-test
 [ t ] [ now 50 milliseconds sleep now swap after? ] unit-test
 [ t ] [ now 50 milliseconds sleep now 50 milliseconds sleep now swapd between? ] unit-test
-
-[ 4+1/6 ] [ 100 semimonthly ] unit-test
index e2564b5a28874f7294cb130b4eee0031aea16fa9..793c771b64a1eaab9090c5c50939e0a997e0e33e 100644 (file)
@@ -89,13 +89,6 @@ PRIVATE>
 : minutes-per-year ( -- ratio ) 5259492/10 ; inline
 : seconds-per-year ( -- integer ) 31556952 ; inline
 
-: monthly ( x -- y ) 12 / ; inline
-: semimonthly ( x -- y ) 24 / ; inline
-: biweekly ( x -- y ) 26 / ; inline
-: weekly ( x -- y ) 52 / ; inline
-: daily-360 ( x -- y ) 360 / ; inline
-: daily-365 ( x -- y ) 365 / ; inline
-
 :: julian-day-number ( year month day -- n )
     #! Returns a composite date number
     #! Not valid before year -4800
index 257fd930c46c08818d5d0830b50c4103c98f5d0c..d919b0e31305b366b1b05cb6691429d9cfc74856 100644 (file)
@@ -4,7 +4,7 @@ USING: kernel io io.binary io.files io.streams.byte-array math
 math.functions math.parser namespaces splitting grouping strings
 sequences byte-arrays locals sequences.private
 io.encodings.binary symbols math.bitwise checksums
-checksums.common ;
+checksums.common checksums.stream ;
 IN: checksums.md5
 
 ! See http://www.faqs.org/rfcs/rfc1321.html
@@ -180,7 +180,7 @@ PRIVATE>
 
 SINGLETON: md5
 
-INSTANCE: md5 checksum
+INSTANCE: md5 stream-checksum
 
 M: md5 checksum-stream ( stream -- byte-array )
     drop [ initialize-md5 stream>md5 get-md5 ] with-input-stream ;
index 821cbe2f3afe282195aacc66dbd075cdb8d7e0c5..4bc7a7964a11c6e0d46f7ad8f29701fe45e1945f 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors byte-arrays alien.c-types kernel continuations
-destructors sequences io openssl openssl.libcrypto checksums ;
+destructors sequences io openssl openssl.libcrypto checksums
+checksums.stream ;
 IN: checksums.openssl
 
 ERROR: unknown-digest name ;
@@ -12,7 +13,7 @@ TUPLE: openssl-checksum name ;
 
 : openssl-sha1 T{ openssl-checksum f "sha1" } ;
 
-INSTANCE: openssl-checksum checksum
+INSTANCE: openssl-checksum stream-checksum
 
 C: <openssl-checksum> openssl-checksum
 
index 3767af7c5590877907c9882380c8e58352e6edf6..6cdc9270aa7262b8057db66b94007975e359f2f7 100644 (file)
@@ -3,7 +3,8 @@
 USING: arrays combinators kernel io io.encodings.binary io.files
 io.streams.byte-array math.vectors strings sequences namespaces
 make math parser sequences assocs grouping vectors io.binary
-hashtables symbols math.bitwise checksums checksums.common ;
+hashtables symbols math.bitwise checksums checksums.common
+checksums.stream ;
 IN: checksums.sha1
 
 ! Implemented according to RFC 3174.
@@ -113,7 +114,7 @@ SYMBOLS: h0 h1 h2 h3 h4 A B C D E w K ;
 
 SINGLETON: sha1
 
-INSTANCE: sha1 checksum
+INSTANCE: sha1 stream-checksum
 
 M: sha1 checksum-stream ( stream -- sha1 )
     drop [ initialize-sha1 stream>sha1 get-sha1 ] with-input-stream ;
diff --git a/basis/checksums/stream/stream.factor b/basis/checksums/stream/stream.factor
new file mode 100644 (file)
index 0000000..e753467
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io.encodings.binary io.streams.byte-array kernel
+checksums ;
+IN: checksums.stream
+
+MIXIN: stream-checksum
+
+M: stream-checksum checksum-bytes
+    [ binary <byte-reader> ] dip checksum-stream ;
+
+INSTANCE: stream-checksum checksum
index 1b58053b64d2af681760f542902957fb147bd51f..7d5a041951a6320fbb2872afb9b2410e20e5c38e 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: init continuations debugger hashtables io
-io.encodings.utf8 io.files kernel kernel.private namespaces
-parser sequences strings system splitting eval vocabs.loader ;
+USING: init continuations hashtables io io.encodings.utf8
+io.files kernel kernel.private namespaces parser sequences
+strings system splitting vocabs.loader ;
 IN: command-line
 
 SYMBOL: script
@@ -31,8 +31,6 @@ SYMBOL: command-line
         ] [ drop ] if
     ] when ;
 
-<PRIVATE
-
 : var-param ( name value -- ) swap set-global ;
 
 : bool-param ( name -- ) "no-" ?head not var-param ;
@@ -43,8 +41,6 @@ SYMBOL: command-line
 : run-script ( file -- )
     t "quiet" set-global run-file ;
 
-PRIVATE>
-
 : parse-command-line ( args -- )
     [ command-line off script off ] [
         unclip "-" ?head
@@ -76,15 +72,4 @@ SYMBOL: main-vocab-hook
 
 : script-mode ( -- ) ;
 
-: handle-command-line ( -- )
-    [
-        (command-line) parse-command-line
-        load-vocab-roots
-        run-user-init
-        "e" get [ eval ] when*
-        ignore-cli-args? not script get and
-        [ run-script ] [ "run" get run ] if*
-        output-stream get [ stream-flush ] when*
-    ] [ print-error 1 exit ] recover ;
-
 [ default-cli-args ] "command-line" add-init-hook
index c7094c8c360e2d2b8100165a0858ca5ed88f1f34..d8bad5ec410a61f511759732f7cde7ab6a9a48a6 100644 (file)
@@ -1,6 +1,6 @@
 USING: compiler.cfg.instructions compiler.cfg.registers
-compiler.cfg.alias-analysis cpu.architecture tools.test
-kernel ;
+compiler.cfg.alias-analysis compiler.cfg.debugger
+cpu.architecture tools.test kernel ;
 IN: compiler.cfg.alias-analysis.tests
 
 [ ] [
index 98569d868c1c2ea6424edbab05cd854ea28dfeb5..90227bb5dae9ffd79c26355f18cfa3f639b7396f 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math namespaces assocs hashtables sequences
+USING: kernel math namespaces assocs hashtables sequences arrays
 accessors vectors combinators sets classes compiler.cfg
 compiler.cfg.registers compiler.cfg.instructions
 compiler.cfg.copy-prop ;
@@ -194,6 +194,7 @@ M: ##slot insn-slot# slot>> constant ;
 M: ##slot-imm insn-slot# slot>> ;
 M: ##set-slot insn-slot# slot>> constant ;
 M: ##set-slot-imm insn-slot# slot>> ;
+M: ##alien-global insn-slot# [ library>> ] [ symbol>> ] bi 2array ;
 
 M: ##peek insn-object loc>> class ;
 M: ##replace insn-object loc>> class ;
@@ -201,6 +202,7 @@ M: ##slot insn-object obj>> resolve ;
 M: ##slot-imm insn-object obj>> resolve ;
 M: ##set-slot insn-object obj>> resolve ;
 M: ##set-slot-imm insn-object obj>> resolve ;
+M: ##alien-global insn-object drop \ ##alien-global ;
 
 : init-alias-analysis ( -- )
     H{ } clone histories set
@@ -224,6 +226,9 @@ M: ##load-immediate analyze-aliases*
 M: ##load-indirect analyze-aliases*
     dup dst>> set-heap-ac ;
 
+M: ##alien-global analyze-aliases*
+    dup dst>> set-heap-ac ;
+
 M: ##allot analyze-aliases*
     #! A freshly allocated object is distinct from any other
     #! object.
index b9c3af521543a22a93cd3271dd727c6e8f83fc43..ee7d8d2a434688986b367ea668f1f8872cdfdf06 100644 (file)
@@ -1,5 +1,6 @@
 USING: compiler.cfg.dead-code compiler.cfg.instructions
-compiler.cfg.registers cpu.architecture tools.test ;
+compiler.cfg.registers compiler.cfg.debugger
+cpu.architecture tools.test ;
 IN: compiler.cfg.dead-code.tests
 
 [ { } ] [
index 7b1b9100c407df35eaa4eb86489038c70632d94d..ba58e60a4ad0c15f8df8f12f3ecc0cbd6f69d88b 100644 (file)
@@ -2,10 +2,12 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel words sequences quotations namespaces io
 classes.tuple accessors prettyprint prettyprint.config
-compiler.tree.builder compiler.tree.optimizer
+prettyprint.backend prettyprint.custom prettyprint.sections
+parser compiler.tree.builder compiler.tree.optimizer
 compiler.cfg.builder compiler.cfg.linearization
-compiler.cfg.stack-frame compiler.cfg.linear-scan
-compiler.cfg.two-operand compiler.cfg.optimizer ;
+compiler.cfg.registers compiler.cfg.stack-frame
+compiler.cfg.linear-scan compiler.cfg.two-operand
+compiler.cfg.optimizer ;
 IN: compiler.cfg.debugger
 
 GENERIC: test-cfg ( quot -- cfgs )
@@ -40,3 +42,15 @@ SYMBOL: allocate-registers?
         instructions>> [ insn. ] each
         nl
     ] each ;
+
+! Prettyprinting
+M: vreg pprint*
+    <block
+    \ V pprint-word [ reg-class>> pprint* ] [ n>> pprint* ] bi
+    block> ;
+
+: pprint-loc ( loc word -- ) <block pprint-word n>> pprint* block> ;
+
+M: ds-loc pprint* \ D pprint-loc ;
+
+M: rs-loc pprint* \ R pprint-loc ;
index 4b98ccb0ae4724badd8bcf3da29eaa09f473d931..c0d5bf79a6f7a24b993d546f91338f47c2c18666 100644 (file)
@@ -39,6 +39,7 @@ IN: compiler.cfg.hats
 : ^^shr-imm ( src1 src2 -- dst ) ^^i2 ##shr-imm ; inline
 : ^^sar-imm ( src1 src2 -- dst ) ^^i2 ##sar-imm ; inline
 : ^^not ( src -- dst ) ^^i1 ##not ; inline
+: ^^log2 ( src -- dst ) ^^i1 ##log2 ; inline
 : ^^bignum>integer ( src -- dst ) ^^i1 i ##bignum>integer ; inline
 : ^^integer>bignum ( src -- dst ) ^^i1 i ##integer>bignum ; inline
 : ^^add-float ( src1 src2 -- dst ) ^^d2 ##add-float ; inline
@@ -65,6 +66,7 @@ IN: compiler.cfg.hats
 : ^^alien-cell ( src -- dst ) ^^i1 ##alien-cell ; inline
 : ^^alien-float ( src -- dst ) ^^d1 ##alien-float ; inline
 : ^^alien-double ( src -- dst ) ^^d1 ##alien-double ; inline
+: ^^alien-global ( symbol library -- dst ) ^^i2 ##alien-global ; inline
 : ^^compare ( src1 src2 cc -- dst ) ^^i3 i ##compare ; inline
 : ^^compare-imm ( src1 src2 cc -- dst ) ^^i3 i ##compare-imm ; inline
 : ^^compare-float ( src1 src2 cc -- dst ) ^^i3 i ##compare-float ; inline
index 2e7e044739686ff768c76a7785e851de407435eb..5619a70740bef3632cd7dbb2a198420907ebfd0f 100644 (file)
@@ -92,6 +92,7 @@ INSN: ##shl-imm < ##binary-imm ;
 INSN: ##shr-imm < ##binary-imm ;
 INSN: ##sar-imm < ##binary-imm ;
 INSN: ##not < ##unary ;
+INSN: ##log2 < ##unary ;
 
 ! Overflowing arithmetic
 TUPLE: ##fixnum-overflow < insn src1 src2 ;
@@ -161,6 +162,8 @@ INSN: ##set-alien-double < ##alien-setter ;
 INSN: ##allot < ##flushable size class { temp vreg } ;
 INSN: ##write-barrier < ##effect card# table ;
 
+INSN: ##alien-global < ##read symbol library ;
+
 ! FFI
 INSN: ##alien-invoke params ;
 INSN: ##alien-indirect params ;
index 68ee7489f8a6d819875984af3519210ae9f8ab0a..3ad716d847f19a5066fb23b06b8f8e06d0278d55 100644 (file)
@@ -12,8 +12,7 @@ compiler.cfg.registers ;
 IN: compiler.cfg.intrinsics.fixnum
 
 : emit-both-fixnums? ( -- )
-    D 0 ^^peek
-    D 1 ^^peek
+    2inputs
     ^^or
     tag-mask get ^^and-imm
     0 cc= ^^compare-imm
@@ -54,6 +53,9 @@ IN: compiler.cfg.intrinsics.fixnum
 : emit-fixnum-bitnot ( -- )
     ds-pop ^^not tag-mask get ^^xor-imm ds-push ;
 
+: emit-fixnum-log2 ( -- )
+    ds-pop ^^log2 tag-bits get ^^sub-imm ^^tag-fixnum ds-push ;
+
 : (emit-fixnum*fast) ( -- dst )
     2inputs ^^untag-fixnum ^^mul ;
 
index cfc04fa036d7880a35b4f9c1e48f32e7fba7cf38..6656cd11f7646047e95e11317dfb6a7779a501c3 100644 (file)
@@ -9,6 +9,7 @@ compiler.cfg.intrinsics.allot
 compiler.cfg.intrinsics.fixnum
 compiler.cfg.intrinsics.float
 compiler.cfg.intrinsics.slots
+compiler.cfg.intrinsics.misc
 compiler.cfg.iterator ;
 QUALIFIED: kernel
 QUALIFIED: arrays
@@ -18,11 +19,13 @@ QUALIFIED: slots.private
 QUALIFIED: strings.private
 QUALIFIED: classes.tuple.private
 QUALIFIED: math.private
+QUALIFIED: math.integers.private
 QUALIFIED: alien.accessors
 IN: compiler.cfg.intrinsics
 
 {
     kernel.private:tag
+    kernel.private:getenv
     math.private:both-fixnums?
     math.private:fixnum+
     math.private:fixnum-
@@ -91,9 +94,13 @@ IN: compiler.cfg.intrinsics
         alien.accessors:set-alien-double
     } [ t "intrinsic" set-word-prop ] each ;
 
+: enable-fixnum-log2 ( -- )
+    \ math.integers.private:fixnum-log2 t "intrinsic" set-word-prop ;
+
 : emit-intrinsic ( node word -- node/f )
     {
         { \ kernel.private:tag [ drop emit-tag iterate-next ] }
+        { \ kernel.private:getenv [ emit-getenv iterate-next ] }
         { \ math.private:both-fixnums? [ drop emit-both-fixnums? iterate-next ] }
         { \ math.private:fixnum+ [ drop [ ##fixnum-add ] [ ##fixnum-add-tail ] emit-fixnum-overflow-op ] }
         { \ math.private:fixnum- [ drop [ ##fixnum-sub ] [ ##fixnum-sub-tail ] emit-fixnum-overflow-op ] }
@@ -105,6 +112,7 @@ IN: compiler.cfg.intrinsics
         { \ math.private:fixnum-bitxor [ [ ^^xor ] [ ^^xor-imm ] emit-fixnum-op iterate-next ] }
         { \ math.private:fixnum-shift-fast [ emit-fixnum-shift-fast iterate-next ] }
         { \ math.private:fixnum-bitnot [ drop emit-fixnum-bitnot iterate-next ] }
+        { \ math.integers.private:fixnum-log2 [ drop emit-fixnum-log2 iterate-next ] }
         { \ math.private:fixnum*fast [ emit-fixnum*fast iterate-next ] }
         { \ math.private:fixnum< [ cc< emit-fixnum-comparison iterate-next ] }
         { \ math.private:fixnum<= [ cc<= emit-fixnum-comparison iterate-next ] }
diff --git a/basis/compiler/cfg/intrinsics/misc/misc.factor b/basis/compiler/cfg/intrinsics/misc/misc.factor
new file mode 100644 (file)
index 0000000..f9f2182
--- /dev/null
@@ -0,0 +1,16 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces layouts sequences kernel
+accessors compiler.tree.propagation.info
+compiler.cfg.stacks compiler.cfg.hats
+compiler.cfg.instructions compiler.cfg.utilities ;
+IN: compiler.cfg.intrinsics.misc
+
+: emit-tag ( -- )
+    ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ;
+
+: emit-getenv ( node -- )
+    "userenv" f ^^alien-global
+    swap node-input-infos first literal>>
+    [ ds-drop 0 ^^slot-imm ] [ ds-pop ^^offset>slot 0 ^^slot ] if*
+    ds-push ;
index 60ae1d2d0a6b245957c1146e6ab901b2e8f9f205..bc46e6149c0d81dd8ed536b70b80ba8fa89957c8 100644 (file)
@@ -6,9 +6,6 @@ compiler.cfg.stacks compiler.cfg.hats compiler.cfg.instructions
 compiler.cfg.utilities ;
 IN: compiler.cfg.intrinsics.slots
 
-: emit-tag ( -- )
-    ds-pop tag-mask get ^^and-imm ^^tag-fixnum ds-push ;
-
 : value-tag ( info -- n ) class>> class-tag ; inline
 
 : (emit-slot) ( infos -- dst )
index 21572ec6153efcc9d033645781776aa680d6ac98..2b9d3df6f674896fb4e42a3a7759fb1e5eb17f9e 100644 (file)
@@ -1,7 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors namespaces kernel arrays
-parser prettyprint.backend prettyprint.sections ;
+USING: accessors namespaces kernel arrays parser ;
 IN: compiler.cfg.registers
 
 ! Virtual registers, used by CFG and machine IRs
@@ -18,20 +17,6 @@ C: <ds-loc> ds-loc
 TUPLE: rs-loc < loc ;
 C: <rs-loc> rs-loc
 
-! Prettyprinting
 : V scan-word scan-word vreg boa parsed ; parsing
-
-M: vreg pprint*
-    <block
-    \ V pprint-word [ reg-class>> pprint* ] [ n>> pprint* ] bi
-    block> ;
-
-: pprint-loc ( loc word -- ) <block pprint-word n>> pprint* block> ;
-
 : D scan-word <ds-loc> parsed ; parsing
-
-M: ds-loc pprint* \ D pprint-loc ;
-
 : R scan-word <rs-loc> parsed ; parsing
-
-M: rs-loc pprint* \ R pprint-loc ;
index e943fb48280c28b6ac79979401b1c6390bed3345..dabecaeec4623888fa4be920dad61d040a6c2b09 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel sequences sequences.deep
+USING: accessors arrays kernel sequences compiler.utilities
 compiler.cfg.instructions cpu.architecture ;
 IN: compiler.cfg.two-operand
 
@@ -55,6 +55,6 @@ M: insn convert-two-operand* ;
 : convert-two-operand ( mr -- mr' )
     [
         two-operand? [
-            [ convert-two-operand* ] map flatten
+            [ convert-two-operand* ] map-flat
         ] when
     ] change-instructions ;
index 8adeaa21f4ddd4485942102614a0d76542e21b9d..641ccceb5daee5f43514caaec892a28e9e45174b 100644 (file)
@@ -1,7 +1,8 @@
 IN: compiler.cfg.value-numbering.tests
 USING: compiler.cfg.value-numbering compiler.cfg.instructions
-compiler.cfg.registers cpu.architecture tools.test kernel math
-combinators.short-circuit accessors sequences ;
+compiler.cfg.registers compiler.cfg.debugger cpu.architecture
+tools.test kernel math combinators.short-circuit accessors
+sequences ;
 
 : trim-temps ( insns -- insns )
     [
index 7a4b1c488faa4f7ebce1d2387f0e889f5d214537..73748dbc37c33fa4d89f7f488b7e176bdbc6abe4 100644 (file)
@@ -1,5 +1,6 @@
 USING: compiler.cfg.write-barrier compiler.cfg.instructions
-compiler.cfg.registers cpu.architecture arrays tools.test ;
+compiler.cfg.registers compiler.cfg.debugger cpu.architecture
+arrays tools.test ;
 IN: compiler.cfg.write-barrier.tests
 
 [
index 21db464079f36fc638656765505230a48aaca0f2..9f134c02d7f0a0112d246993964f36becbb2d7cb 100644 (file)
@@ -163,6 +163,7 @@ M: ##shl-imm generate-insn dst/src1/src2 %shl-imm ;
 M: ##shr-imm generate-insn dst/src1/src2 %shr-imm ;
 M: ##sar-imm generate-insn dst/src1/src2 %sar-imm ;
 M: ##not     generate-insn dst/src       %not     ;
+M: ##log2    generate-insn dst/src       %log2    ;
 
 : src1/src2 ( insn -- src1 src2 )
     [ src1>> register ] [ src2>> register ] bi ; inline
@@ -236,6 +237,10 @@ M: _gc generate-insn drop %gc ;
 
 M: ##loop-entry generate-insn drop %loop-entry ;
 
+M: ##alien-global generate-insn
+    [ dst>> register ] [ symbol>> ] [ library>> ] tri
+    %alien-global ;
+
 ! ##alien-invoke
 GENERIC: reg-size ( register-class -- n )
 
index a56ae04a7b87de4248285afa0c7e426fe30f5bd8..e0f391deb5f925740c9f410253bb638701f32cd2 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays byte-arrays generic assocs hashtables io.binary
-kernel kernel.private math namespaces make sequences words
-quotations strings alien.accessors alien.strings layouts system
-combinators math.bitwise words.private math.order accessors
-growable cpu.architecture compiler.constants ;
+USING: arrays byte-arrays byte-vectors generic assocs hashtables
+io.binary kernel kernel.private math namespaces make sequences
+words quotations strings alien.accessors alien.strings layouts
+system combinators math.bitwise words.private math.order
+accessors growable cpu.architecture compiler.constants ;
 IN: compiler.codegen.fixup
 
 GENERIC: fixup* ( obj -- )
index e5cbd888d94f0ddc93127ce810380103882a2255..0d24daef7103220b2ced01f573a0f42fb2e52333 100644 (file)
@@ -1,15 +1,14 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel namespaces arrays sequences io debugger
-words fry continuations vocabs assocs dlists definitions
-math threads graphs generic combinators deques search-deques
-prettyprint io stack-checker stack-checker.state
-stack-checker.inlining compiler.errors compiler.units
-compiler.tree.builder compiler.tree.optimizer
-compiler.cfg.builder compiler.cfg.optimizer
-compiler.cfg.linearization compiler.cfg.two-operand
-compiler.cfg.linear-scan compiler.cfg.stack-frame
-compiler.codegen ;
+USING: accessors kernel namespaces arrays sequences io
+words fry continuations vocabs assocs dlists definitions math
+threads graphs generic combinators deques search-deques io
+stack-checker stack-checker.state stack-checker.inlining
+compiler.errors compiler.units compiler.tree.builder
+compiler.tree.optimizer compiler.cfg.builder
+compiler.cfg.optimizer compiler.cfg.linearization
+compiler.cfg.two-operand compiler.cfg.linear-scan
+compiler.cfg.stack-frame compiler.codegen ;
 IN: compiler
 
 SYMBOL: compile-queue
@@ -45,7 +44,7 @@ SYMBOL: +failed+
     2bi ;
 
 : start ( word -- )
-    "trace-compilation" get [ dup . flush ] when
+    "trace-compilation" get [ dup name>> print flush ] when
     H{ } clone dependencies set
     H{ } clone generic-dependencies set
     f swap compiler-error ;
index 41df6e7ae589d9f93a10c461da22853ddddce528..fa6a3c7b21647ff3282cdc2f974268f7df8cf80b 100644 (file)
@@ -375,3 +375,9 @@ DEFER: loop-bbb
 : loop-ccc ( -- ) loop-bbb ;
 
 [ 0 ] [ 0 counter set loop-ccc counter get ] unit-test
+
+! Type inference issue
+[ 4 3 ] [
+    1 >bignum 2 >bignum
+    [ { bignum integer } declare [ shift ] keep 1+ ] compile-call
+] unit-test
index becac01cd5355a957e857d47849dc68c912c71e4..1b0343faa991400e09a0c2b5799b1438b31c1851 100644 (file)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors sequences sequences.deep combinators fry
+USING: kernel accessors sequences combinators fry
 classes.algebra namespaces assocs words math math.private
 math.partial-dispatch math.intervals classes classes.tuple
 classes.tuple.private layouts definitions stack-checker.state
 stack-checker.branches
+compiler.utilities
 compiler.tree
 compiler.tree.combinators
 compiler.tree.propagation.info
@@ -33,7 +34,7 @@ GENERIC: cleanup* ( node -- node/nodes )
 : cleanup ( nodes -- nodes' )
     #! We don't recurse into children here, instead the methods
     #! do it since the logic is a bit more involved
-    [ cleanup* ] map flatten ;
+    [ cleanup* ] map-flat ;
 
 : cleanup-folding? ( #call -- ? )
     node-output-infos
index 40bbf81a03710a4ac7afa7c0c70258d0838f666d..030df8484fa164884320ec7345f80c744bf1b1df 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs fry kernel accessors sequences sequences.deep arrays
-stack-checker.inlining namespaces compiler.tree ;
+USING: assocs fry kernel accessors sequences compiler.utilities
+arrays stack-checker.inlining namespaces compiler.tree
+math.order ;
 IN: compiler.tree.combinators
 
 : each-node ( nodes quot: ( node -- ) -- )
@@ -27,7 +28,7 @@ IN: compiler.tree.combinators
                 [ _ map-nodes ] change-child
             ] when
         ] if
-    ] map flatten ; inline recursive
+    ] map-flat ; inline recursive
 
 : contains-node? ( nodes quot: ( node -- ? ) -- ? )
     dup dup '[
@@ -48,12 +49,6 @@ IN: compiler.tree.combinators
 : sift-children ( seq flags -- seq' )
     zip [ nip ] assoc-filter keys ;
 
-: (3each) [ 3array flip ] dip '[ first3 @ ] ; inline
-
-: 3each ( seq1 seq2 seq3 quot -- seq ) (3each) each ; inline
-
-: 3map ( seq1 seq2 seq3 quot -- seq ) (3each) map ; inline
-
 : until-fixed-point ( #recursive quot: ( node -- ) -- )
     over label>> t >>fixed-point drop
     [ with-scope ] 2keep
index 44b71935c8f0fea7a6be46e18bf409329cf6bc9f..9ece5d340b60d497c1ee91b65483d48f6e3b277e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry accessors namespaces assocs deques search-deques
-dlists kernel sequences sequences.deep words sets
+dlists kernel sequences compiler.utilities words sets
 stack-checker.branches compiler.tree compiler.tree.def-use
 compiler.tree.combinators ;
 IN: compiler.tree.dead-code.liveness
@@ -49,4 +49,4 @@ GENERIC: remove-dead-code* ( node -- node' )
 M: node remove-dead-code* ;
 
 : (remove-dead-code) ( nodes -- nodes' )
-    [ remove-dead-code* ] map flatten ;
+    [ remove-dead-code* ] map-flat ;
index 8d764a28333c81d7092163e8f51e4c7b9fe33132..8a2823010dc41ac54f5986ee9330bda54e211c0c 100644 (file)
@@ -2,8 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel assocs match fry accessors namespaces make effects
 sequences sequences.private quotations generic macros arrays
-prettyprint prettyprint.backend prettyprint.sections math words
-combinators combinators.short-circuit io sorting hints qualified
+prettyprint prettyprint.backend prettyprint.custom
+prettyprint.sections math words combinators
+combinators.short-circuit io sorting hints qualified
 compiler.tree
 compiler.tree.recursive
 compiler.tree.normalization
index edfe633057b72e99ad9f2b071581319f623f930f..9b2a2038da5a26512cce9a56aa09183fb7aaffba 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences sequences.deep kernel
+USING: sequences kernel fry vectors
 compiler.tree compiler.tree.def-use ;
 IN: compiler.tree.def-use.simplified
 
@@ -9,8 +9,6 @@ IN: compiler.tree.def-use.simplified
 ! A 'real' usage is a usage of a value that is not a #renaming.
 TUPLE: real-usage value node ;
 
-GENERIC: actually-used-by* ( value node -- real-usages )
-
 ! Def
 GENERIC: actually-defined-by* ( value node -- real-usage )
 
@@ -25,16 +23,18 @@ M: #return-recursive actually-defined-by* real-usage boa ;
 M: node actually-defined-by* real-usage boa ;
 
 ! Use
-: (actually-used-by) ( value -- real-usages )
-    dup used-by [ actually-used-by* ] with map ;
+GENERIC# actually-used-by* 1 ( value node accum -- )
+
+: (actually-used-by) ( value accum -- )
+    [ [ used-by ] keep ] dip '[ _ swap _ actually-used-by* ] each ;
 
 M: #renaming actually-used-by*
-    inputs/outputs [ indices ] dip nths
-    [ (actually-used-by) ] map ;
+    [ inputs/outputs [ indices ] dip nths ] dip
+    '[ _ (actually-used-by) ] each ;
 
-M: #return-recursive actually-used-by* real-usage boa ;
+M: #return-recursive actually-used-by* [ real-usage boa ] dip push ;
 
-M: node actually-used-by* real-usage boa ;
+M: node actually-used-by* [ real-usage boa ] dip push ;
 
 : actually-used-by ( value -- real-usages )
-    (actually-used-by) flatten ;
+    10 <vector> [ (actually-used-by) ] keep ;
index b728e9a1ba4b597def7482835d831f3e8b476303..2eee3e698bbfe9f428dcb868f5f3ec487a5a1eab 100644 (file)
@@ -33,4 +33,4 @@ M: #branch escape-analysis*
     2bi ;
 
 M: #phi escape-analysis*
-    [ phi-in-d>> <flipped> ] [ out-d>> ] bi merge-allocations ;
+    [ phi-in-d>> flip ] [ out-d>> ] bi merge-allocations ;
diff --git a/basis/compiler/tree/escape-analysis/check/check.factor b/basis/compiler/tree/escape-analysis/check/check.factor
new file mode 100644 (file)
index 0000000..333b3fa
--- /dev/null
@@ -0,0 +1,23 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: classes classes.tuple math math.private accessors
+combinators kernel compiler.tree compiler.tree.combinators
+compiler.tree.propagation.info ;
+IN: compiler.tree.escape-analysis.check
+
+GENERIC: run-escape-analysis* ( node -- ? )
+
+M: #push run-escape-analysis*
+    literal>> [ class immutable-tuple-class? ] [ complex? ] bi or ;
+
+M: #call run-escape-analysis*
+    {
+        { [ dup word>> \ <complex> eq? ] [ t ] }
+        { [ dup immutable-tuple-boa? ] [ t ] }
+        [ f ] 
+    } cond nip ;
+
+M: node run-escape-analysis* drop f ;
+
+: run-escape-analysis? ( nodes -- ? )
+    [ run-escape-analysis* ] contains-node? ;
index 16a27e020a13dfa6b8aab38619ba74638d1eedc5..ecd5429bafeb586e05d696ea0344a173eb3aba83 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors sequences words memoize classes.builtin
+USING: kernel accessors sequences words memoize combinators
+classes classes.builtin classes.tuple math.partial-dispatch
 fry assocs
 compiler.tree
 compiler.tree.combinators
@@ -12,7 +13,7 @@ IN: compiler.tree.finalization
 ! See the comment in compiler.tree.late-optimizations.
 
 ! This pass runs after propagation, so that it can expand
-! built-in type predicates; these cannot be expanded before
+! type predicates; these cannot be expanded before
 ! propagation since we need to see 'fixnum?' instead of
 ! 'tag 0 eq?' and so on, for semantic reasoning.
 
@@ -33,16 +34,24 @@ M: #shuffle finalize*
     [ [ in-r>> ] [ out-r>> ] [ mapping>> ] tri '[ _ at ] map sequence= ]
     bi and [ drop f ] when ;
 
-: builtin-predicate? ( #call -- ? )
-    word>> "predicating" word-prop builtin-class? ;
-
-MEMO: builtin-predicate-expansion ( word -- nodes )
+MEMO: cached-expansion ( word -- nodes )
     def>> splice-final ;
 
-: expand-builtin-predicate ( #call -- nodes )
-    word>> builtin-predicate-expansion ;
+GENERIC: finalize-word ( #call word -- nodes )
+
+M: predicate finalize-word
+    "predicating" word-prop {
+        { [ dup builtin-class? ] [ drop word>> cached-expansion ] }
+        { [ dup tuple-class? ] [ drop word>> def>> splice-final ] }
+        [ drop ]
+    } cond ;
+
+! M: math-partial finalize-word
+!     dup primitive? [ drop ] [ nip cached-expansion ] if ;
+
+M: word finalize-word drop ;
 
 M: #call finalize*
-    dup builtin-predicate? [ expand-builtin-predicate ] when ;
+    dup word>> finalize-word ;
 
 M: node finalize* ;
index bebe2e91b6521eb19ac1860566371f182b00c028..8c13de296a05952f9ebe1ff17c147981fde40682 100644 (file)
@@ -1,10 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry namespaces sequences math accessors kernel arrays
-combinators sequences.deep assocs
+combinators compiler.utilities assocs
 stack-checker.backend
 stack-checker.branches
 stack-checker.inlining
+compiler.utilities
 compiler.tree
 compiler.tree.combinators
 compiler.tree.normalization.introductions
@@ -46,7 +47,7 @@ M: #branch normalize*
     [
         [
             [
-                [ normalize* ] map flatten
+                [ normalize* ] map-flat
                 introduction-stack get
                 2array
             ] with-scope
@@ -70,7 +71,7 @@ M: #phi normalize*
 
 : (normalize) ( nodes introductions -- nodes )
     introduction-stack [
-        [ normalize* ] map flatten
+        [ normalize* ] map-flat
     ] with-variable ;
 
 M: #recursive normalize*
index e37323a2ec69c4991e5497a27e2e1f5e583adf94..54c6c2c117b9c48ba58355ed72c4b605ed6f7ce8 100644 (file)
@@ -6,6 +6,7 @@ compiler.tree.normalization
 compiler.tree.propagation
 compiler.tree.cleanup
 compiler.tree.escape-analysis
+compiler.tree.escape-analysis.check
 compiler.tree.tuple-unboxing
 compiler.tree.identities
 compiler.tree.def-use
@@ -22,8 +23,10 @@ SYMBOL: check-optimizer?
     normalize
     propagate
     cleanup
-    escape-analysis
-    unbox-tuples
+    dup run-escape-analysis? [
+        escape-analysis
+        unbox-tuples
+    ] when
     apply-identities
     compute-def-use
     remove-dead-code
index 424cd8a01c404c25ace5a54047621ee9764b4779..f2613022fc21be595dda41ae6bc06a48c2f5d3ed 100644 (file)
@@ -3,6 +3,7 @@
 USING: fry kernel sequences assocs accessors namespaces
 math.intervals arrays classes.algebra combinators columns
 stack-checker.branches
+compiler.utilities
 compiler.tree
 compiler.tree.combinators
 compiler.tree.propagation.info
@@ -78,7 +79,7 @@ SYMBOL: condition-value
 
 M: #phi propagate-before ( #phi -- )
     [ annotate-phi-inputs ]
-    [ [ phi-info-d>> <flipped> ] [ out-d>> ] bi merge-value-infos ]
+    [ [ phi-info-d>> flip ] [ out-d>> ] bi merge-value-infos ]
     bi ;
 
 : branch-phi-constraints ( output values booleans -- )
@@ -137,8 +138,8 @@ M: #phi propagate-before ( #phi -- )
 M: #phi propagate-after ( #phi -- )
     condition-value get [
         [ out-d>> ]
-        [ phi-in-d>> <flipped> ]
-        [ phi-info-d>> <flipped> ] tri
+        [ phi-in-d>> flip ]
+        [ phi-info-d>> flip ] tri
         [
             [ possible-boolean-values ] map
             branch-phi-constraints
index 2452aba4aa2e8e3ea706ee1b897796c368613cc6..53b7d17326bb2d90e60c42b014dd92818c90447a 100644 (file)
@@ -49,7 +49,7 @@ M: #renaming compute-copy-equiv* inputs/outputs are-copies-of ;
     ] 2each ;
 
 M: #phi compute-copy-equiv*
-    [ phi-in-d>> <flipped> ] [ out-d>> ] bi compute-phi-equiv ;
+    [ phi-in-d>> flip ] [ out-d>> ] bi compute-phi-equiv ;
 
 M: node compute-copy-equiv* drop ;
 
index 87a908041ef4c40e74b6bc274ff6fafe9fc8485e..fcc3b01dc046cdf818ac4c4df52f1b3ddc166962 100644 (file)
@@ -184,7 +184,7 @@ SYMBOL: history
     over in-d>> second value-info literal>> dup class?
     [ "predicate" word-prop '[ drop @ ] inline-word-def ] [ 3drop f ] if ;
 
-: do-inlining ( #call word -- ? )
+: (do-inlining) ( #call word -- ? )
     #! If the generic was defined in an outer compilation unit,
     #! then it doesn't have a definition yet; the definition
     #! is built at the end of the compilation unit. We do not
@@ -195,7 +195,6 @@ SYMBOL: history
     #! discouraged, but it should still work.)
     {
         { [ dup deferred? ] [ 2drop f ] }
-        { [ dup custom-inlining? ] [ inline-custom ] }
         { [ dup \ instance? eq? ] [ inline-instance-check ] }
         { [ dup always-inline-word? ] [ inline-word ] }
         { [ dup standard-generic? ] [ inline-standard-method ] }
@@ -203,3 +202,10 @@ SYMBOL: history
         { [ dup method-body? ] [ inline-method-body ] }
         [ 2drop f ]
     } cond ;
+
+: do-inlining ( #call word -- ? )
+    #! Note the logic here: if there's a custom inlining hook,
+    #! it is permitted to return f, which means that we try the
+    #! normal inlining heuristic.
+    dup custom-inlining? [ 2dup inline-custom ] [ f ] if
+    [ 2drop t ] [ (do-inlining) ] if ;
index c98ec24ea8f7728dee9714ae6b13d830ff0fe550..4d8d9354771ca406f23941d8c574b72f6454909b 100644 (file)
@@ -1,11 +1,12 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel effects accessors math math.private math.libm
-math.partial-dispatch math.intervals math.parser math.order
-layouts words sequences sequences.private arrays assocs classes
-classes.algebra combinators generic.math splitting fry locals
-classes.tuple alien.accessors classes.tuple.private slots.private
-definitions strings.private
+USING: kernel effects accessors math math.private
+math.integers.private math.partial-dispatch math.intervals
+math.parser math.order layouts words sequences sequences.private
+arrays assocs classes classes.algebra combinators generic.math
+splitting fry locals classes.tuple alien.accessors
+classes.tuple.private slots.private definitions strings.private
+vectors hashtables
 stack-checker.state
 compiler.tree.comparisons
 compiler.tree.propagation.info
@@ -76,14 +77,17 @@ most-negative-fixnum most-positive-fixnum [a,b]
         [ rational math-class-max ] dip
     ] unless ;
 
+: ensure-math-class ( class must-be -- class' )
+    [ class<= ] 2keep ? ;
+
 : number-valued ( class interval -- class' interval' )
-    [ number math-class-min ] dip ;
+    [ number ensure-math-class ] dip ;
 
 : integer-valued ( class interval -- class' interval' )
-    [ integer math-class-min ] dip ;
+    [ integer ensure-math-class ] dip ;
 
 : real-valued ( class interval -- class' interval' )
-    [ real math-class-min ] dip ;
+    [ real ensure-math-class ] dip ;
 
 : float-valued ( class interval -- class' interval' )
     over null-class? [
@@ -194,6 +198,11 @@ generic-comparison-ops [
     2bi and maybe-or-never
 ] "outputs" set-word-prop
 
+\ both-fixnums? [
+    [ class>> fixnum classes-intersect? not ] either?
+    f <literal-info> object-info ?
+] "outputs" set-word-prop
+
 {
     { >fixnum fixnum }
     { bignum>fixnum fixnum }
@@ -225,7 +234,7 @@ generic-comparison-ops [
 } [
     [
         in-d>> second value-info >literal<
-        [ power-of-2? [ 1- bitand ] f ? ] when
+        [ dup integer? [ power-of-2? [ 1- bitand ] f ? ] [ drop f ] if ] when
     ] "custom-inlining" set-word-prop
 ] each
 
@@ -242,6 +251,15 @@ generic-comparison-ops [
     ] "custom-inlining" set-word-prop
 ] each
 
+{ numerator denominator }
+[ [ drop integer <class-info> ] "outputs" set-word-prop ] each
+
+{ (log2) fixnum-log2 bignum-log2 } [
+    [
+        [ class>> ] [ interval>> interval-log2 ] bi <class/interval-info>
+    ] "outputs" set-word-prop
+] each
+
 \ string-nth [
     2drop fixnum 0 23 2^ [a,b] <class/interval-info>
 ] "outputs" set-word-prop
@@ -287,6 +305,15 @@ generic-comparison-ops [
     "outputs" set-word-prop
 ] each
 
+! Generate more efficient code for common idiom
+\ clone [
+    in-d>> first value-info literal>> {
+        { V{ } [ [ drop { } 0 vector boa ] ] }
+        { H{ } [ [ drop hashtable new ] ] }
+        [ drop f ]
+    } case
+] "custom-inlining" set-word-prop
+
 \ slot [
     dup literal?>>
     [ literal>> swap value-info-slot ] [ 2drop object-info ] if
index 2c4769abe02ef01e2b588938d39a1fdc84bf31dd..d95245fe8303ff8ce4b5efc748c35c08c7f60b28 100644 (file)
@@ -8,7 +8,8 @@ math.functions math.private strings layouts
 compiler.tree.propagation.info compiler.tree.def-use
 compiler.tree.debugger compiler.tree.checker
 slots.private words hashtables classes assocs locals
-specialized-arrays.double system sorting math.libm ;
+specialized-arrays.double system sorting math.libm
+math.intervals ;
 IN: compiler.tree.propagation.tests
 
 \ propagate must-infer
@@ -33,17 +34,57 @@ IN: compiler.tree.propagation.tests
 
 [ V{ fixnum } ] [ [ { fixnum } declare bitnot ] final-classes ] unit-test
 
-[ V{ number } ] [ [ + ] final-classes ] unit-test
+! Test type propagation for math ops
+: cleanup-math-class ( obj -- class )
+    { null fixnum bignum integer ratio rational float real complex number }
+    [ class= ] with find nip ;
 
-[ V{ float } ] [ [ { float integer } declare + ] final-classes ] unit-test
+: final-math-class ( quot -- class )
+    final-classes first cleanup-math-class ;
 
-[ V{ float } ] [ [ /f ] final-classes ] unit-test
+[ number ] [ [ + ] final-math-class ] unit-test
 
-[ V{ integer } ] [ [ /i ] final-classes ] unit-test
+[ bignum ] [ [ { fixnum bignum } declare + ] final-math-class ] unit-test
 
-[ V{ integer } ] [
-    [ { integer } declare bitnot ] final-classes
-] unit-test
+[ integer ] [ [ { fixnum integer } declare + ] final-math-class ] unit-test
+
+[ bignum ] [ [ { integer bignum } declare + ] final-math-class ] unit-test
+
+[ integer ] [ [ { fixnum fixnum } declare + ] final-math-class ] unit-test
+
+[ float ] [ [ { float integer } declare + ] final-math-class ] unit-test
+
+[ float ] [ [ { real float } declare + ] final-math-class ] unit-test
+
+[ float ] [ [ { float real } declare + ] final-math-class ] unit-test
+
+[ rational ] [ [ { ratio ratio } declare + ] final-math-class ] unit-test
+
+[ rational ] [ [ { rational ratio } declare + ] final-math-class ] unit-test
+
+[ number ] [ [ { complex complex } declare + ] final-math-class ] unit-test
+
+[ float ] [ [ /f ] final-math-class ] unit-test
+
+[ float ] [ [ { real real } declare /f ] final-math-class ] unit-test
+
+[ integer ] [ [ /i ] final-math-class ] unit-test
+
+[ integer ] [ [ { integer float } declare /i ] final-math-class ] unit-test
+
+[ integer ] [ [ { float float } declare /i ] final-math-class ] unit-test
+
+[ integer ] [ [ { integer } declare bitnot ] final-math-class ] unit-test
+
+[ null ] [ [ { null null } declare + ] final-math-class ] unit-test
+
+[ null ] [ [ { null fixnum } declare + ] final-math-class ] unit-test
+
+[ float ] [ [ { float fixnum } declare + ] final-math-class ] unit-test
+
+[ bignum ] [ [ { bignum bignum } declare bitxor ] final-math-class ] unit-test
+
+[ float ] [ [ { float float } declare mod ] final-math-class ] unit-test
 
 [ V{ integer } ] [ [ 255 bitand ] final-classes ] unit-test
 
@@ -65,18 +106,6 @@ IN: compiler.tree.propagation.tests
     [ { fixnum } declare 615949 * ] final-classes
 ] unit-test
 
-[ V{ null } ] [
-    [ { null null } declare + ] final-classes
-] unit-test
-
-[ V{ null } ] [
-    [ { null fixnum } declare + ] final-classes
-] unit-test
-
-[ V{ float } ] [
-    [ { float fixnum } declare + ] final-classes
-] unit-test
-
 [ V{ fixnum } ] [
     [ 255 bitand >fixnum 3 bitor ] final-classes
 ] unit-test
@@ -278,14 +307,6 @@ IN: compiler.tree.propagation.tests
     ] final-classes
 ] unit-test
 
-[ V{ float } ] [
-    [ { real float } declare + ] final-classes
-] unit-test
-
-[ V{ float } ] [
-    [ { float real } declare + ] final-classes
-] unit-test
-
 [ V{ fixnum } ] [
     [ { fixnum fixnum } declare 7 bitand neg shift ] final-classes
 ] unit-test
@@ -599,6 +620,26 @@ MIXIN: empty-mixin
 
 [ V{ t } ] [ [ { fixnum } declare 10 mod >float -20 > ] final-literals ] unit-test
 
+[ T{ interval f { 0 t } { 127 t } } ] [
+    [ { integer } declare 127 bitand ] final-info first interval>>
+] unit-test
+
+[ V{ bignum } ] [
+    [ { bignum } declare dup 1- bitxor ] final-classes
+] unit-test
+
+[ V{ bignum integer } ] [
+    [ { bignum integer } declare [ shift ] keep ] final-classes
+] unit-test
+
+[ V{ fixnum } ] [
+    [ { fixnum } declare log2 ] final-classes
+] unit-test
+
+[ V{ word } ] [
+    [ { fixnum } declare log2 0 >= ] final-classes
+] unit-test
+
 ! [ V{ string } ] [
 !     [ dup string? t xor [ "A" throw ] [ ] if ] final-classes
 ! ] unit-test
index 52903fce8de3064ba14d6fc322f3b908720488de..f6726e44040a9f44d6a8809592f3bb9d2fa174ae 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: namespaces assocs accessors kernel combinators
-classes.algebra sequences sequences.deep slots.private
+classes.algebra sequences slots.private fry vectors
 classes.tuple.private math math.private arrays
 stack-checker.branches
+compiler.utilities
 compiler.tree
 compiler.tree.combinators
 compiler.tree.propagation.info
@@ -21,7 +22,7 @@ GENERIC: unbox-tuples* ( node -- node/nodes )
 : (expand-#push) ( object value -- nodes )
     dup unboxed-allocation dup [
         [ object-slots ] [ drop ] [ ] tri*
-        [ (expand-#push) ] 2map
+        [ (expand-#push) ] 2map-flat
     ] [
         drop #push
     ] if ;
@@ -38,11 +39,16 @@ M: #push unbox-tuples* ( #push -- nodes )
 : unbox-<complex> ( #call -- nodes )
     dup unbox-output? [ drop { } ] when ;
 
-: (flatten-values) ( values -- values' )
-    [ dup unboxed-allocation [ (flatten-values) ] [ ] ?if ] map ;
+: (flatten-values) ( values accum -- )
+    dup '[
+        dup unboxed-allocation
+        [ _ (flatten-values) ] [ _ push ] ?if
+    ] each ;
 
 : flatten-values ( values -- values' )
-    dup empty? [ (flatten-values) flatten ] unless ;
+    dup empty? [
+        10 <vector> [ (flatten-values) ] keep
+    ] unless ;
 
 : prepare-slot-access ( #call -- tuple-values outputs slot-values )
     [ in-d>> flatten-values ]
diff --git a/basis/compiler/utilities/utilities.factor b/basis/compiler/utilities/utilities.factor
new file mode 100644 (file)
index 0000000..1f488b3
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences sequences.private arrays vectors fry
+math.order ;
+IN: compiler.utilities
+
+: flattener ( seq quot -- seq vector quot' )
+    over length <vector> [
+        dup
+        '[
+            @ [
+                dup array?
+                [ _ push-all ] [ _ push ] if
+            ] when*
+        ]
+    ] keep ; inline
+
+: flattening ( seq quot combinator -- seq' )
+    [ flattener ] dip dip { } like ; inline
+
+: map-flat ( seq quot -- seq' ) [ each ] flattening ; inline
+
+: 2map-flat ( seq quot -- seq' ) [ 2each ] flattening ; inline
+
+: (3each) ( seq1 seq2 seq3 quot -- n quot' )
+    [ [ [ length ] tri@ min min ] 3keep ] dip
+    '[ [ _ nth-unsafe ] [ _ nth-unsafe ] [ _ nth-unsafe ] tri @ ] ; inline
+
+: 3each ( seq1 seq2 seq3 quot -- seq ) (3each) each ; inline
+
+: 3map ( seq1 seq2 seq3 quot -- seq ) (3each) map ; inline
index 25538cd5948552a65771426f1f1c6102cc382fca..3bd2d330c36a39c57dd08cc6da8353ac8c0bd1cc 100644 (file)
@@ -8,20 +8,20 @@ HELP: send
 { $values { "message" object } 
           { "thread" thread } 
 }
-{ $description "Send the message to the thread by placing it in the threades mailbox. This is an asynchronous operation and will return immediately. The receving thread will act on the message the next time it retrieves that item from its mailbox (usually using the " { $link receive } " word. The message can be any Factor object. For destinations that are instances of remote-thread the message must be a serializable Factor type." } 
+{ $description "Send the message to the thread by placing it in the threads mailbox. This is an asynchronous operation and will return immediately. The receving thread will act on the message the next time it retrieves that item from its mailbox (usually using the " { $link receive } " word. The message can be any Factor object. For destinations that are instances of remote-thread the message must be a serializable Factor type." } 
 { $see-also receive receive-if } ;
 
 HELP: receive
 { $values { "message" object } 
 }
-{ $description "Return a message from the current threades mailbox. If the box is empty, suspend the thread until another thread places an item in the mailbox (usually via the " { $link send } " word." } 
+{ $description "Return a message from the current threads mailbox. If the box is empty, suspend the thread until another thread places an item in the mailbox (usually via the " { $link send } " word." } 
 { $see-also send receive-if } ;
 
 HELP: receive-if
 { $values { "pred" "a predicate with stack effect " { $snippet "( obj -- ? )" } }  
           { "message" object } 
 }
-{ $description "Return the first message from the current threades mailbox that satisfies the predicate. To satisfy the predicate, " { $snippet "pred" } " is called with the item on the stack and the predicate should leave a boolean indicating whether it was satisfied or not. If nothing in the mailbox satisfies the predicate then the thread will block until something does." } 
+{ $description "Return the first message from the current threads mailbox that satisfies the predicate. To satisfy the predicate, " { $snippet "pred" } " is called with the item on the stack and the predicate should leave a boolean indicating whether it was satisfied or not. If nothing in the mailbox satisfies the predicate then the thread will block until something does." } 
 { $see-also send receive } ;
 
 HELP: spawn-linked
@@ -29,7 +29,7 @@ HELP: spawn-linked
           { "name" string }
           { "thread" thread } 
 }
-{ $description "Start a thread which runs the given quotation. If that quotation throws an error which is not caught then the error will get propagated to the thread that spawned it. This can be used to set up 'supervisor' threades that restart child threades that crash due to uncaught errors.\n" } 
+{ $description "Start a thread which runs the given quotation. If that quotation throws an error which is not caught then the error will get propagated to the thread that spawned it. This can be used to set up 'supervisor' threads that restart child threads that crash due to uncaught errors.\n" } 
 { $see-also spawn } ;
 
 ARTICLE: { "concurrency" "messaging" } "Sending and receiving messages"
@@ -64,7 +64,7 @@ ARTICLE: { "concurrency" "synchronous-sends" } "Synchronous sends"
 ARTICLE: { "concurrency" "exceptions" } "Linked exceptions"
 "A thread can handle exceptions using the standard Factor exception handling mechanism. If an exception is uncaught the thread will terminate. For example:" 
 { $code "[ 1 0 / \"This will not print\" print ] \"division-by-zero\" spawn" } 
-"Processes can be linked so that a parent thread can receive the exception that caused the child thread to terminate. In this way 'supervisor' threades can be created that are notified when child threades terminate and possibly restart them."
+"Processes can be linked so that a parent thread can receive the exception that caused the child thread to terminate. In this way 'supervisor' threads can be created that are notified when child threads terminate and possibly restart them."
 { $subsection spawn-linked }
 "This will create a unidirectional link, such that if an uncaught exception causes the child to terminate, the parent thread can catch it:"
 { $code "["
@@ -74,11 +74,11 @@ ARTICLE: { "concurrency" "exceptions" } "Linked exceptions"
 "Exceptions are only raised in the parent when the parent does a " { $link receive } " or " { $link receive-if } ". This is because the exception is sent from the child to the parent as a message." ;
 
 ARTICLE: "concurrency.messaging" "Message-passing concurrency"
-"The " { $vocab-link "concurrency.messaging" } " vocabulary is based upon the style of concurrency used in systems like Erlang and Termite. It is built on top of the standard Factor lightweight thread system."
+"The " { $vocab-link "concurrency.messaging" } " vocabulary is based upon the style of concurrency used in systems like Erlang and Termite. It is built on top of " { $link "threads" } "."
 $nl
-"A concurrency oriented program is one in which multiple threades run simultaneously in a single Factor image or across multiple running Factor instances. The threades can communicate with each other by asynchronous message sends."
+"A concurrency-oriented program is one in which multiple threads run simultaneously in a single Factor image or across multiple running Factor instances. The threads can communicate with each other by asynchronous message sends."
 $nl
-"Although threades can share data via Factor's mutable data structures it is not recommended to mix shared state with message passing as it can lead to confusing code."
+"Although threads can share data via Factor's mutable data structures it is not recommended to mix shared state with message passing as it can lead to confusing code."
 { $subsection { "concurrency" "messaging" } }
 { $subsection { "concurrency" "synchronous-sends" } } 
 { $subsection { "concurrency" "exceptions" } } ;
index 8e5051e75dfbe727074175d39eecd7adb36a43d9..d63a66dbe7f0b9dca903b1bad80fa9819d1d20ec 100644 (file)
@@ -16,13 +16,17 @@ TYPEDEF: void* CFStringRef
 TYPEDEF: void* CFURLRef
 TYPEDEF: void* CFUUIDRef
 TYPEDEF: void* CFTypeRef
+TYPEDEF: void* CFFileDescriptorRef
 TYPEDEF: bool Boolean
 TYPEDEF: long CFIndex
 TYPEDEF: int SInt32
 TYPEDEF: uint UInt32
 TYPEDEF: ulong CFTypeID
+TYPEDEF: UInt32 CFOptionFlags
 TYPEDEF: double CFTimeInterval
 TYPEDEF: double CFAbsoluteTime
+TYPEDEF: int CFFileDescriptorNativeDescriptor
+TYPEDEF: void* CFFileDescriptorCallBack
 
 TYPEDEF: int CFNumberType
 : kCFNumberSInt8Type 1 ; inline
@@ -121,18 +125,35 @@ FUNCTION: CFTypeID CFGetTypeID ( CFTypeRef cf ) ;
     ] keep CFRelease ;
 
 GENERIC: <CFNumber> ( number -- alien )
+
 M: integer <CFNumber>
     [ f kCFNumberLongLongType ] dip <longlong> CFNumberCreate ;
+
 M: float <CFNumber>
     [ f kCFNumberDoubleType ] dip <double> CFNumberCreate ;
+
 M: t <CFNumber>
     drop f kCFNumberIntType 1 <int> CFNumberCreate ;
+
 M: f <CFNumber>
     drop f kCFNumberIntType 0 <int> CFNumberCreate ;
 
 : <CFData> ( byte-array -- alien )
     [ f ] dip dup length CFDataCreate ;
 
+FUNCTION: CFFileDescriptorRef CFFileDescriptorCreate (
+    CFAllocatorRef allocator,
+    CFFileDescriptorNativeDescriptor fd,
+    Boolean closeOnInvalidate,
+    CFFileDescriptorCallBack callout, 
+    CFFileDescriptorContext* context
+) ;
+
+FUNCTION: void CFFileDescriptorEnableCallBacks (
+    CFFileDescriptorRef f,
+    CFOptionFlags callBackTypes
+) ;
+
 : load-framework ( name -- )
     dup <CFBundle> [
         CFBundleLoadExecutable drop
@@ -141,8 +162,11 @@ M: f <CFNumber>
     ] ?if ;
 
 TUPLE: CFRelease-destructor alien disposed ;
+
 M: CFRelease-destructor dispose* alien>> CFRelease ;
+
 : &CFRelease ( alien -- alien )
     dup f CFRelease-destructor boa &dispose drop ; inline
+
 : |CFRelease ( alien -- alien )
     dup f CFRelease-destructor boa |dispose drop ; inline
index 9a5666b5d3b032b0c5be4e17594a9fd12a03cf6d..c334297122941f7a277a2778e1345a4992e8c0e6 100644 (file)
@@ -10,6 +10,7 @@ IN: core-foundation.run-loop
 : kCFRunLoopRunHandledSource 4 ; inline
 
 TYPEDEF: void* CFRunLoopRef
+TYPEDEF: void* CFRunLoopSourceRef
 
 FUNCTION: CFRunLoopRef CFRunLoopGetMain ( ) ;
 FUNCTION: CFRunLoopRef CFRunLoopGetCurrent ( ) ;
@@ -20,6 +21,18 @@ FUNCTION: SInt32 CFRunLoopRunInMode (
    Boolean returnAfterSourceHandled
 ) ;
 
+FUNCTION: CFRunLoopSourceRef CFFileDescriptorCreateRunLoopSource (
+    CFAllocatorRef allocator,
+    CFFileDescriptorRef f,
+    CFIndex order
+) ;
+
+FUNCTION: void CFRunLoopAddSource (
+   CFRunLoopRef rl,
+   CFRunLoopSourceRef source,
+   CFStringRef mode
+) ;
+
 : CFRunLoopDefaultMode ( -- alien )
     #! Ugly, but we don't have static NSStrings
     \ CFRunLoopDefaultMode get-global dup expired? [
index eb93a8dbb5618285fde8212c2cb19a8a732d4628..c609b9e98d6d011d635b6a5d0662d0365218d3f4 100644 (file)
@@ -77,6 +77,7 @@ HOOK: %shl-imm cpu ( dst src1 src2 -- )
 HOOK: %shr-imm cpu ( dst src1 src2 -- )
 HOOK: %sar-imm cpu ( dst src1 src2 -- )
 HOOK: %not     cpu ( dst src -- )
+HOOK: %log2    cpu ( dst src -- )
 
 HOOK: %fixnum-add cpu ( src1 src2 -- )
 HOOK: %fixnum-add-tail cpu ( src1 src2 -- )
@@ -120,6 +121,8 @@ HOOK: %set-alien-cell      cpu ( ptr value -- )
 HOOK: %set-alien-float     cpu ( ptr value -- )
 HOOK: %set-alien-double    cpu ( ptr value -- )
 
+HOOK: %alien-global cpu ( dst symbol library -- )
+
 HOOK: %allot cpu ( dst size class temp -- )
 HOOK: %write-barrier cpu ( src card# table -- )
 HOOK: %gc cpu ( -- )
index d22ff4d615401951d87756647555931177eb20c3..445c7082bcbce551b35a676a5fcbbf194f5d65b8 100644 (file)
@@ -329,14 +329,15 @@ big-endian on
 ! Math\r
 [\r
     3 ds-reg 0 LWZ\r
-    4 ds-reg -4 LWZ\r
+    ds-reg ds-reg 4 SUBI\r
+    4 ds-reg 0 LWZ\r
     3 3 4 OR\r
     3 3 tag-mask get ANDI\r
     \ f tag-number 4 LI\r
     0 3 0 CMPI\r
     2 BNE\r
     1 tag-fixnum 4 LI\r
-    4 ds-reg 4 STWU\r
+    4 ds-reg 0 STW\r
 ] f f f \ both-fixnums? define-sub-primitive\r
 \r
 : jit-math ( insn -- )\r
index 46986dc5e6231ed47961352c6f7084b282822920..c555c4b8090ba60779b5e0f097d54e5ce8b2a876 100644 (file)
@@ -37,8 +37,8 @@ M: ppc %load-immediate ( reg n -- ) swap LOAD ;
 M: ppc %load-indirect ( reg obj -- )
     [ 0 swap LOAD32 ] [ rc-absolute-ppc-2/2 rel-immediate ] bi* ;
 
-: %load-dlsym ( symbol dll register -- )
-    0 swap LOAD32 rc-absolute-ppc-2/2 rel-dlsym ;
+M: ppc %alien-global ( register symbol dll -- )
+    [ 0 swap LOAD32 ] 2dip rc-absolute-ppc-2/2 rel-dlsym ;
 
 : ds-reg 29 ; inline
 : rs-reg 30 ; inline
@@ -145,8 +145,8 @@ M:: ppc %string-nth ( dst src index temp -- )
         temp temp index ADD
         temp temp index ADD
         temp temp byte-array-offset LHZ
-        temp temp 8 SLWI
-        dst dst temp OR
+        temp temp 7 SLWI
+        dst dst temp XOR
         "end" resolve-label
     ] with-scope ;
 
@@ -172,7 +172,7 @@ M: ppc %sar-imm SRAWI ;
 M: ppc %not     NOT ;
 
 : %alien-invoke-tail ( func dll -- )
-    scratch-reg %load-dlsym scratch-reg MTCTR BCTR ;
+    [ scratch-reg ] 2dip %alien-global scratch-reg MTCTR BCTR ;
 
 :: exchange-regs ( r1 r2 -- )
     scratch-reg r1 MR
@@ -411,7 +411,7 @@ M: ppc %set-alien-float swap 0 STFS ;
 M: ppc %set-alien-double swap 0 STFD ;
 
 : load-zone-ptr ( reg -- )
-    [ "nursery" f ] dip %load-dlsym ;
+    "nursery" f %alien-global ;
 
 : load-allot-ptr ( nursery-ptr allot-ptr -- )
     [ drop load-zone-ptr ] [ swap 4 LWZ ] 2bi ;
@@ -433,14 +433,11 @@ M:: ppc %allot ( dst size class nursery-ptr -- )
     dst class store-header
     dst class store-tagged ;
 
-: %alien-global ( dst name -- )
-    [ f rot %load-dlsym ] [ drop dup 0 LWZ ] 2bi ;
-
 : load-cards-offset ( dst -- )
-    "cards_offset" %alien-global ;
+    [ "cards_offset" f %alien-global ] [ dup 0 LWZ ] bi ;
 
 : load-decks-offset ( dst -- )
-    "decks_offset" %alien-global ;
+    [ "decks_offset" f %alien-global ] [ dup 0 LWZ ] bi  ;
 
 M:: ppc %write-barrier ( src card# table -- )
     card-mark scratch-reg LI
@@ -627,14 +624,14 @@ M: ppc %prepare-alien-invoke
     #! Save Factor stack pointers in case the C code calls a
     #! callback which does a GC, which must reliably trace
     #! all roots.
-    "stack_chain" f scratch-reg %load-dlsym
+    scratch-reg "stack_chain" f %alien-global
     scratch-reg scratch-reg 0 LWZ
     1 scratch-reg 0 STW
     ds-reg scratch-reg 8 STW
     rs-reg scratch-reg 12 STW ;
 
 M: ppc %alien-invoke ( symbol dll -- )
-    11 %load-dlsym 11 MTLR BLRL ;
+    [ 11 ] 2dip %alien-global 11 MTLR BLRL ;
 
 M: ppc %alien-callback ( quot -- )
     3 swap %load-indirect "c_to_factor" f %alien-invoke ;
index 3df072208d9bc6cfa9fd6574458d0274a63ea87d..5e06e721187bfcc0c4e63658023f4695abfe1e6d 100755 (executable)
@@ -44,8 +44,6 @@ M: x86.32 param-reg-2 EDX ;
 
 M: x86.32 reserved-area-size 0 ;
 
-M: x86.32 %alien-global 0 [] MOV rc-absolute-cell rel-dlsym ;
-
 M: x86.32 %alien-invoke (CALL) rel-dlsym ;
 
 M: x86.32 %alien-invoke-tail (JMP) rel-dlsym ;
index 6472ec0edf3cbf4df863313903e441c1f85dcb4c..2077f51e0a7c8b5b1302bfb7ddf58f556d6e92f7 100644 (file)
@@ -158,9 +158,6 @@ M: x86.64 %prepare-box-struct ( -- )
 
 M: x86.64 %prepare-var-args RAX RAX XOR ;
 
-M: x86.64 %alien-global
-    [ 0 MOV rc-absolute-cell rel-dlsym ] [ dup [] MOV ] bi ;
-
 M: x86.64 %alien-invoke
     R11 0 MOV
     rc-absolute-cell rel-dlsym
index 27c00cb3c0f2b1a88c39ee7fa01e9e225961a63b..2bea8872959c25e721db740bcd4de08c99878dfd 100644 (file)
@@ -384,6 +384,8 @@ M: operand CMP OCT: 070 2-operand ;
 
 : XCHG ( dst src -- ) OCT: 207 2-operand ;
 
+: BSR ( dst src -- ) swap { HEX: 0f HEX: bd } (2-operand) ;
+
 : NOT  ( dst -- ) { BIN: 010 t HEX: f7 } 1-operand ;
 : NEG  ( dst -- ) { BIN: 011 t HEX: f7 } 1-operand ;
 : MUL  ( dst -- ) { BIN: 100 t HEX: f7 } 1-operand ;
index 42df1c8437a42e24dbe276c6159e424c1cf0c1ea..597a2c9d319963f2c20730686a5f62c0f1a9a5de 100644 (file)
@@ -381,8 +381,8 @@ big-endian off
 
 [
     arg0 ds-reg [] MOV
-    arg0 ds-reg bootstrap-cell neg [+] OR
-    ds-reg bootstrap-cell ADD
+    ds-reg bootstrap-cell SUB
+    arg0 ds-reg [] OR
     arg0 tag-mask get AND
     arg0 \ f tag-number MOV
     arg1 1 tag-fixnum MOV
index 8dac1efed606366e8fe9ba12e4250d8ae6f999d9..44300a75f97368194ab5b0e0d60c7dc663525cb4 100644 (file)
@@ -5,10 +5,12 @@ cpu.x86.assembler cpu.x86.assembler.private cpu.architecture
 kernel kernel.private math memory namespaces make sequences
 words system layouts combinators math.order fry locals
 compiler.constants compiler.cfg.registers
-compiler.cfg.instructions compiler.codegen
-compiler.codegen.fixup ;
+compiler.cfg.instructions compiler.cfg.intrinsics
+compiler.codegen compiler.codegen.fixup ;
 IN: cpu.x86
 
+<< enable-fixnum-log2 >>
+
 M: x86 two-operand? t ;
 
 HOOK: temp-reg-1 cpu ( -- reg )
@@ -92,6 +94,7 @@ M: x86 %shl-imm nip SHL ;
 M: x86 %shr-imm nip SHR ;
 M: x86 %sar-imm nip SAR ;
 M: x86 %not     drop NOT ;
+M: x86 %log2    BSR ;
 
 : ?MOV ( dst src -- )
     2dup = [ 2drop ] [ MOV ] if ; inline
@@ -458,19 +461,19 @@ M:: x86 %allot ( dst size class nursery-ptr -- )
     dst class store-tagged
     nursery-ptr size inc-allot-ptr ;
 
-HOOK: %alien-global cpu ( symbol dll register -- )
-
 M:: x86 %write-barrier ( src card# table -- )
     #! Mark the card pointed to by vreg.
     ! Mark the card
     card# src MOV
     card# card-bits SHR
-    "cards_offset" f table %alien-global
+    table "cards_offset" f %alien-global
+    table table [] MOV
     table card# [+] card-mark <byte> MOV
 
     ! Mark the card deck
     card# deck-bits card-bits - SHR
-    "decks_offset" f table %alien-global
+    table "decks_offset" f %alien-global
+    table table [] MOV
     table card# [+] card-mark <byte> MOV ;
 
 M: x86 %gc ( -- )
@@ -485,6 +488,9 @@ M: x86 %gc ( -- )
     "minor_gc" f %alien-invoke
     "end" resolve-label ;
 
+M: x86 %alien-global
+    [ 0 MOV ] 2dip rc-absolute-cell rel-dlsym ;
+
 HOOK: stack-reg cpu ( -- reg )
 
 : decr-stack-reg ( n -- )
@@ -595,7 +601,8 @@ M: x86 %prepare-alien-invoke
     #! Save Factor stack pointers in case the C code calls a
     #! callback which does a GC, which must reliably trace
     #! all roots.
-    "stack_chain" f temp-reg-1 %alien-global
+    temp-reg-1 "stack_chain" f %alien-global
+    temp-reg-1 temp-reg-1 [] MOV
     temp-reg-1 [] stack-reg MOV
     temp-reg-1 [] cell SUB
     temp-reg-1 2 cells [+] ds-reg MOV
index 4e96fb5a4deea6d48893ddc61b2234d005eed7a7..32c5ca00752149fd24a07266188cc8083dc6f6f5 100644 (file)
@@ -164,7 +164,7 @@ M: sqlite-db <insert-user-assigned-statement> ( tuple -- statement )
 
 M: sqlite-db bind# ( spec obj -- )
     [
-        [ column-name>> ":" swap next-sql-counter 3append dup 0% ]
+        [ column-name>> ":" next-sql-counter surround dup 0% ]
         [ type>> ] bi
     ] dip <literal-bind> 1, ;
 
index 35b09713d3c7da0558e9db448e3f2bd24d87955a..4e0c4e88405d05d9daa852ff9c4973b2693f09c1 100644 (file)
@@ -22,9 +22,6 @@ M: tuple error-help class ;
 
 M: string error. print ;
 
-: :error ( -- )
-    error get error. ;
-
 : :s ( -- )
     error-continuation get data>> stack. ;
 
@@ -63,6 +60,9 @@ M: string error. print ;
     [ global [ "Error in print-error!" print drop ] bind ]
     recover ;
 
+: :error ( -- )
+    error get print-error ;
+
 : print-error-and-restarts ( error -- )
     print-error
     restarts.
index dc3d970fbf5dddd3b25c0f8758b6f8beb86cee10..cfcc65377610431c8de32ae2347b3317039bfbe9 100644 (file)
@@ -5,7 +5,7 @@ IN: grouping.tests
 
 [ { "hell" "o wo" "rld" } ] [ "hello world" 4 group ] unit-test
 
-[ { V{ "a" "b" } V{ f f } } ] [
+[ { V{ "a" "b" } V{ 0 0 } } ] [
     V{ "a" "b" } clone 2 <groups>
     2 over set-length
     >array
index e5202e13064b0bdbc2b397516351cb3b531f4804..3e4066d8b75bfdf5c0332654546f16321188cb76 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors definitions help help.topics help.syntax
-prettyprint.backend prettyprint words kernel effects ;
+prettyprint.backend prettyprint.custom prettyprint words kernel
+effects ;
 IN: help.definitions
 
 ! Definition protocol implementation
index 0a392733acc12d02cc575a4ab8415e5ad383f4d2..fbebc7f0f6b0661bc35f649f51425c9c7dbf2442 100644 (file)
@@ -150,7 +150,7 @@ M: help-error error.
     ] [
         [
             swap vocab-heading.
-            [ error. nl ] each
+            [ print-error nl ] each
         ] assoc-each
     ] if-empty ;
 
index fa92f18d3480e0e238fde94992c3991e8ed7965c..2149bf7bf68cafd6d8157b6cd26675bd2f2dd774 100644 (file)
@@ -26,7 +26,7 @@ SYMBOL: html
     #! dynamically creating words.
     [ elements-vocab create ] 2dip define-declared ;
 
-: <foo> ( str -- <str> ) "<" swap ">" 3append ;
+: <foo> ( str -- <str> ) "<" ">" surround ;
 
 : def-for-html-word-<foo> ( name -- )
     #! Return the name and code for the <foo> patterned
@@ -49,14 +49,14 @@ SYMBOL: html
     #! word.
     foo> [ ">" write-html ] (( -- )) html-word ;
 
-: </foo> ( str -- </str> ) "</" swap ">" 3append ;
+: </foo> ( str -- </str> ) "</" ">" surround ;
 
 : def-for-html-word-</foo> ( name -- )
     #! Return the name and code for the </foo> patterned
     #! word.
     </foo> dup '[ _ write-html ] (( -- )) html-word ;
 
-: <foo/> ( str -- <str/> ) "<" swap "/>" 3append ;
+: <foo/> ( str -- <str/> ) "<" "/>" surround ;
 
 : def-for-html-word-<foo/> ( name -- )
     #! Return the name and code for the <foo/> patterned
diff --git a/basis/io/streams/byte-array/byte-array-docs.factor b/basis/io/streams/byte-array/byte-array-docs.factor
new file mode 100644 (file)
index 0000000..7b27621
--- /dev/null
@@ -0,0 +1,34 @@
+USING: help.syntax help.markup io byte-arrays quotations ;
+IN: io.streams.byte-array
+
+ABOUT: "io.streams.byte-array"
+
+ARTICLE: "io.streams.byte-array" "Byte-array streams"
+"Byte array streams:"
+{ $subsection <byte-reader> }
+{ $subsection <byte-writer> }
+"Utility combinators:"
+{ $subsection with-byte-reader }
+{ $subsection with-byte-writer } ;
+
+HELP: <byte-reader>
+{ $values { "byte-array" byte-array }
+    { "encoding" "an encoding descriptor" }
+    { "stream" "a new byte reader" } }
+{ $description "Creates an input stream reading from a byte array using an encoding." } ;
+
+HELP: <byte-writer>
+{ $values { "encoding" "an encoding descriptor" }
+    { "stream" "a new byte writer" } }
+{ $description "Creates an output stream writing data to a byte array using an encoding." } ;
+
+HELP: with-byte-reader
+{ $values { "encoding" "an encoding descriptor" }
+    { "quot" quotation } { "byte-array" byte-array } }
+{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream for reading from a byte array using an encoding." } ;
+
+HELP: with-byte-writer
+{ $values  { "encoding" "an encoding descriptor" }
+    { "quot" quotation }
+    { "byte-array" byte-array } }
+{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to an output stream writing data to a byte array using an encoding." } ;
diff --git a/basis/io/streams/byte-array/byte-array-tests.factor b/basis/io/streams/byte-array/byte-array-tests.factor
new file mode 100644 (file)
index 0000000..77a9126
--- /dev/null
@@ -0,0 +1,9 @@
+USING: tools.test io.streams.byte-array io.encodings.binary
+io.encodings.utf8 io kernel arrays strings ;
+
+[ B{ 1 2 3 } ] [ binary [ { 1 2 3 } write ] with-byte-writer ] unit-test
+[ B{ 1 2 3 } ] [ { 1 2 3 } binary [ 3 read ] with-byte-reader ] unit-test
+
+[ B{ BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 BIN: 11101111 BIN: 10000000 BIN: 10111111 BIN: 11011111 BIN: 10000000 CHAR: x } ]
+[ { BIN: 101111111000000111111 BIN: 1111000000111111 BIN: 11111000000 CHAR: x } utf8 [ write ] with-byte-writer ] unit-test
+[ { BIN: 101111111000000111111 } t ] [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 } utf8 <byte-reader> contents dup >array swap string? ] unit-test
diff --git a/basis/io/streams/byte-array/byte-array.factor b/basis/io/streams/byte-array/byte-array.factor
new file mode 100644 (file)
index 0000000..9d89c3d
--- /dev/null
@@ -0,0 +1,16 @@
+USING: byte-arrays byte-vectors kernel io.encodings io.streams.string
+sequences io namespaces io.encodings.private accessors ;
+IN: io.streams.byte-array
+
+: <byte-writer> ( encoding -- stream )
+    512 <byte-vector> swap <encoder> ;
+
+: with-byte-writer ( encoding quot -- byte-array )
+    [ <byte-writer> ] dip [ output-stream get ] compose with-output-stream*
+    dup encoder? [ stream>> ] when >byte-array ; inline
+
+: <byte-reader> ( byte-array encoding -- stream )
+    [ >byte-vector dup reverse-here ] dip <decoder> ;
+
+: with-byte-reader ( byte-array encoding quot -- )
+    [ <byte-reader> ] dip with-input-stream* ; inline
index c9ba8f66dfe0a82ff6c5d5fedd8e2635aa596f12..e07753c64076990032f20991523f05ac79f12cdc 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: hashtables io colors ;
+USING: hashtables io colors summary make accessors splitting
+kernel ;
 IN: io.styles
 
 SYMBOL: plain
@@ -43,4 +44,11 @@ TUPLE: input string ;
 
 C: <input> input
 
+M: input summary
+    [
+        "Input: " %
+        string>> "\n" split1 swap %
+        "..." "" ? %
+    ] "" make ;
+
 : write-object ( str obj -- ) presented associate format ;
index 5b128143d9b5fb464538699d593abf5dc26ba074..322358ba14129e86f517af4e15b7d4058a3d44f7 100644 (file)
@@ -13,7 +13,8 @@ M: macosx file-systems ( -- array )
     f <void*> dup 0 getmntinfo64 dup io-error
     [ *void* ] dip
     "statfs64" heap-size [ * memory>byte-array ] keep group
-    [ [ new-file-system-info ] dip statfs>file-system-info ] map ;
+    [ statfs64-f_mntonname utf8 alien>string file-system-info ] map ;
+    ! [ [ new-file-system-info ] dip statfs>file-system-info ] map ;
 
 M: macosx new-file-system-info macosx-file-system-info new ;
 
index ba4240de7ff8d94b3835ae391cf5732b4c204fdd..6b687a8afb06a7eb9e8e9c7933d81df254e756c9 100644 (file)
@@ -1,11 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types kernel math math.bitwise namespaces
-locals accessors combinators threads vectors hashtables
-sequences assocs continuations sets
-unix unix.time unix.kqueue unix.process
-io.ports io.unix.backend io.launcher io.unix.launcher
-io.monitors ;
+USING: accessors alien.c-types combinators io.unix.backend
+kernel math.bitwise sequences struct-arrays unix unix.kqueue
+unix.time ;
 IN: io.unix.kqueue
 
 TUPLE: kqueue-mx < mx events monitors ;
@@ -19,131 +16,66 @@ TUPLE: kqueue-mx < mx events monitors ;
     kqueue-mx new-mx
         H{ } clone >>monitors
         kqueue dup io-error >>fd
-        max-events "kevent" <c-array> >>events ;
+        max-events "kevent" <struct-array> >>events ;
 
-GENERIC: io-task-filter ( task -- n )
-
-M: input-task io-task-filter drop EVFILT_READ ;
-
-M: output-task io-task-filter drop EVFILT_WRITE ;
-
-GENERIC: io-task-fflags ( task -- n )
-
-M: io-task io-task-fflags drop 0 ;
-
-: make-kevent ( task flags -- event )
+: make-kevent ( fd filter flags -- event )
     "kevent" <c-object>
-    tuck set-kevent-flags
-    over io-task-fd over set-kevent-ident
-    over io-task-fflags over set-kevent-fflags
-    swap io-task-filter over set-kevent-filter ;
+    [ set-kevent-flags ] keep
+    [ set-kevent-filter ] keep
+    [ set-kevent-ident ] keep ;
 
 : register-kevent ( kevent mx -- )
-    fd>> swap 1 f 0 f kevent
-    0 < [ err_no ESRCH = [ (io-error) ] unless ] when ;
+    fd>> swap 1 f 0 f kevent io-error ;
 
-M: kqueue-mx register-io-task ( task mx -- )
-    [ >r EV_ADD make-kevent r> register-kevent ]
-    [ call-next-method ]
-    2bi ;
+M: kqueue-mx add-input-callback ( thread fd mx -- )
+    [ call-next-method ] [
+        [ EVFILT_READ { EV_ADD EV_ONESHOT } flags make-kevent ] dip
+        register-kevent
+    ] 2bi ;
 
-M: kqueue-mx unregister-io-task ( task mx -- )
-    [ call-next-method ]
-    [ >r EV_DELETE make-kevent r> register-kevent ]
-    2bi ;
+M: kqueue-mx add-output-callback ( thread fd mx -- )
+    [ call-next-method ] [
+        [ EVFILT_WRITE EV_DELETE make-kevent ] dip
+        register-kevent
+    ] 2bi ;
 
-: wait-kevent ( mx timespec -- n )
-    >r [ fd>> f 0 ] keep events>> max-events r> kevent
-    dup multiplexer-error ;
-
-:: kevent-read-task ( mx fd kevent -- )
-    mx fd mx reads>> at perform-io-task ;
-
-:: kevent-write-task ( mx fd kevent -- )
-    mx fd mx writes>> at perform-io-task ;
-
-:: kevent-proc-task ( mx pid kevent -- )
-    pid wait-for-pid
-    pid find-process
-    dup [ swap notify-exit ] [ 2drop ] if ;
+: cancel-input-callbacks ( fd mx -- seq )
+    [
+        [ EVFILT_READ EV_DELETE make-kevent ] dip
+        register-kevent
+    ] [ remove-input-callbacks ] 2bi ;
 
-: parse-action ( mask -- changed )
+: cancel-output-callbacks ( fd mx -- seq )
     [
-        NOTE_DELETE +remove-file+ ?flag
-        NOTE_WRITE +modify-file+ ?flag
-        NOTE_EXTEND +modify-file+ ?flag
-        NOTE_ATTRIB +modify-file+ ?flag
-        NOTE_RENAME +rename-file+ ?flag
-        NOTE_REVOKE +remove-file+ ?flag
-        drop
-    ] { } make prune ;
+        [ EVFILT_WRITE EV_DELETE make-kevent ] dip
+        register-kevent
+    ] [ remove-output-callbacks ] 2bi ;
+
+M: fd cancel-operation ( fd -- )
+    dup disposed>> [ drop ] [
+        fd>>
+        mx get-global
+        [ cancel-input-callbacks [ t swap resume-with ] each ]
+        [ cancel-output-callbacks [ t swap resume-with ] each ]
+        2bi
+    ] if ;
 
-:: kevent-vnode-task ( mx kevent fd -- )
-    ""
-    kevent kevent-fflags parse-action
-    fd mx monitors>> at queue-change ;
+: wait-kevent ( mx timespec -- n )
+    [
+        [ fd>> f 0 ]
+        [ events>> [ underlying>> ] [ length ] bi ] bi
+    ] dip kevent
+    dup multiplexer-error ;
 
 : handle-kevent ( mx kevent -- )
-    [ ] [ kevent-ident ] [ kevent-filter ] tri {
-        { [ dup EVFILT_READ = ] [ drop kevent-read-task ] }
-        { [ dup EVFILT_WRITE = ] [ drop kevent-write-task ] }
-        { [ dup EVFILT_PROC = ] [ drop kevent-proc-task ] }
-        { [ dup EVFILT_VNODE = ] [ drop kevent-vnode-task ] }
-    } cond ;
+    [ kevent-ident swap ] [ kevent-filter ] bi {
+        { EVFILT_READ [ input-available ] }
+        { EVFILT_WRITE [ output-available ] }
+    } case ;
 
 : handle-kevents ( mx n -- )
-    [ over events>> kevent-nth handle-kevent ] with each ;
+    [ dup events>> ] dip head-slice [ handle-kevent ] with each ;
 
 M: kqueue-mx wait-for-events ( us mx -- )
     swap dup [ make-timespec ] when
     dupd wait-kevent handle-kevents ;
-
-! Procs
-: make-proc-kevent ( pid -- kevent )
-    "kevent" <c-object>
-    tuck set-kevent-ident
-    EV_ADD over set-kevent-flags
-    EVFILT_PROC over set-kevent-filter
-    NOTE_EXIT over set-kevent-fflags ;
-
-: register-pid-task ( pid mx -- )
-    swap make-proc-kevent swap register-kevent ;
-
-! VNodes
-TUPLE: vnode-monitor < monitor fd ;
-
-: vnode-fflags ( -- n )
-    {
-        NOTE_DELETE
-        NOTE_WRITE
-        NOTE_EXTEND
-        NOTE_ATTRIB
-        NOTE_LINK
-        NOTE_RENAME
-        NOTE_REVOKE
-    } flags ;
-
-: make-vnode-kevent ( fd flags -- kevent )
-    "kevent" <c-object>
-    tuck set-kevent-flags
-    tuck set-kevent-ident
-    EVFILT_VNODE over set-kevent-filter
-    vnode-fflags over set-kevent-fflags ;
-
-: register-monitor ( monitor mx -- )
-    >r dup fd>> r>
-    [ >r EV_ADD EV_CLEAR bitor make-vnode-kevent r> register-kevent drop ]
-    [ monitors>> set-at ] 3bi ;
-
-: unregister-monitor ( monitor mx -- )
-    >r fd>> r>
-    [ monitors>> delete-at ]
-    [ >r EV_DELETE make-vnode-kevent r> register-kevent ] 2bi ;
-
-: <vnode-monitor> ( path mailbox -- monitor )
-    >r [ O_RDONLY 0 open dup io-error ] keep r>
-    vnode-monitor new-monitor swap >>fd
-    [ dup kqueue-mx get register-monitor ] [ ] [ fd>> close ] cleanup ;
-
-M: vnode-monitor dispose
-    [ kqueue-mx get unregister-monitor ] [ fd>> close ] bi ;
index 212b405a54e0413da03d91495c0d3711bfd6f667..fd31ca999f2db3514bd124634af7135c7770943c 100644 (file)
@@ -56,7 +56,7 @@ TUPLE: CreateProcess-args
 
 : escape-argument ( str -- newstr )
     CHAR: \s over member? [
-        "\"" swap fix-trailing-backslashes "\"" 3append
+        fix-trailing-backslashes "\"" dup surround
     ] when ;
 
 : join-arguments ( args -- cmd-line )
index 494c72bc03b7eb0fc753930ebff53803787a11cf..20602224723af67832a19eb292ab8ae7ad142cd5 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: lexer locals.parser locals.types macros memoize parser
-sequences vocabs.loader words ;
+sequences vocabs vocabs.loader words kernel ;
 IN: locals
 
 : :> scan <local> <def> parsed ; parsing
@@ -29,8 +29,11 @@ IN: locals
 : MEMO:: (::) define-memoized ; parsing
 
 {
-    "locals.prettyprint"
-    "locals.definitions"
     "locals.macros"
     "locals.fry"
 } [ require ] each
+
+"prettyprint" vocab [
+    "locals.definitions" require
+    "locals.prettyprint" require
+] when
index 255917a0a5d1ab8be20e43b5e4d81103a826d7a6..187b663c3c60f9888da19da695a3072d22926b13 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors assocs kernel locals locals.types
-prettyprint.backend prettyprint.sections sequences words ;
+prettyprint.backend prettyprint.sections prettyprint.custom
+sequences words ;
 IN: locals.prettyprint
 
 SYMBOL: |
index c228684e321f1ae61ef091af4bf16793aee5abdd..90713cd40fe7aa07102c40a0e39424561a553483 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel kernel.private math math.private
-math.libm math.functions prettyprint.backend arrays
-math.functions.private sequences parser ;
+math.libm math.functions arrays math.functions.private sequences
+parser ;
 IN: math.complex.private
 
 M: real real-part ;
@@ -47,7 +47,3 @@ M: complex sqrt >polar [ fsqrt ] [ 2.0 / ] bi* polar> ;
 IN: syntax
 
 : C{ \ } [ first2 rect> ] parse-literal ; parsing
-
-M: complex pprint-delims drop \ C{ \ } ;
-M: complex >pprint-sequence >rect 2array ;
-M: complex pprint* pprint-object ;
diff --git a/basis/math/complex/prettyprint/prettyprint.factor b/basis/math/complex/prettyprint/prettyprint.factor
new file mode 100644 (file)
index 0000000..09eeb80
--- /dev/null
@@ -0,0 +1,8 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: math math.functions arrays prettyprint.custom kernel ;
+IN: math.complex.prettyprint
+
+M: complex pprint* pprint-object ;
+M: complex pprint-delims drop \ C{ \ } ;
+M: complex >pprint-sequence >rect 2array ;
index 5a96c7aceba076d6474996e7e5cec16bf1cd605c..d8a80340ba5773375e323039eef5a552d89ebc8a 100644 (file)
@@ -44,7 +44,8 @@ ARTICLE: "math-intervals-arithmetic" "Interval arithmetic"
 { $subsection interval-bitnot }
 { $subsection interval-recip }
 { $subsection interval-2/ }
-{ $subsection interval-abs } ;
+{ $subsection interval-abs }
+{ $subsection interval-log2 } ;
 
 ARTICLE: "math-intervals-sets" "Set-theoretic operations on intervals"
 { $subsection interval-contains? }
@@ -203,6 +204,10 @@ HELP: interval-abs
 { $values { "i1" interval } { "i2" interval } }
 { $description "Absolute value of an interval." } ;
 
+HELP: interval-log2
+{ $values { "i1" interval } { "i2" interval } }
+{ $description "Integer-valued Base-2 logarithm of an interval." } ;
+
 HELP: interval-intersect
 { $values { "i1" interval } { "i2" interval } { "i3" "an " { $link interval  } " or " { $link f } } }
 { $description "Outputs the set-theoretic intersection of " { $snippet "i1" } " and " { $snippet "i2" } ". If " { $snippet "i1" } " and " { $snippet "i2" } " do not intersect, outputs " { $link f } "." } ;
index 4182d25524e16a497e0e90829cdb6749b3ac6b65..ed76ccaedd1e6cc6a6d0f9181537bfe8cb069556 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 ! Based on Slate's src/unfinished/interval.slate by Brian Rice.
 USING: accessors kernel sequences arrays math math.order
-combinators generic ;
+combinators generic layouts ;
 IN: math.intervals
 
 SYMBOL: empty-interval
@@ -365,7 +365,7 @@ SYMBOL: incomparable
         2dup [ interval-nonnegative? ] both?
         [
             [ interval>points [ first ] bi@ ] bi@
-            4array supremum 0 swap next-power-of-2 [a,b]
+            4array supremum 0 swap >integer next-power-of-2 [a,b]
         ] [ 2drop [-inf,inf] ] if
     ] do-empty-interval ;
 
@@ -373,6 +373,18 @@ SYMBOL: incomparable
     #! Inaccurate.
     interval-bitor ;
 
+: interval-log2 ( i1 -- i2 )
+    {
+        { empty-interval [ empty-interval ] }
+        { full-interval [ 0 [a,inf] ] }
+        [
+            to>> first 1 max dup most-positive-fixnum >
+            [ drop full-interval interval-log2 ]
+            [ 1+ >integer log2 0 swap [a,b] ]
+            if
+        ]
+    } case ;
+
 : assume< ( i1 i2 -- i3 )
     dup special-interval? [ drop ] [
         to>> first [-inf,a) interval-intersect
index 56da09ccddc76a5a212b5d9089150839615a812d..19715357eec1c77c03349820ea1e33bc36e13e08 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel kernel.private math math.private words
-sequences parser namespaces make assocs quotations arrays locals
+sequences parser namespaces make assocs quotations arrays
 generic generic.math hashtables effects compiler.units
-classes.algebra ;
+classes.algebra fry combinators ;
 IN: math.partial-dispatch
 
 PREDICATE: math-partial < word
@@ -45,60 +45,62 @@ M: word integer-op-input-classes
         { bitnot fixnum-bitnot }
     } at swap or ;
 
-:: fixnum-integer-op ( a b fix-word big-word -- c )
-    b tag 0 eq? [
-        a b fix-word execute
-    ] [
-       a fixnum>bignum b big-word execute
-    ] if ; inline
-
-:: integer-fixnum-op ( a b fix-word big-word -- c )
-    a tag 0 eq? [
-        a b fix-word execute
-    ] [
-        a b fixnum>bignum big-word execute
-    ] if ; inline
+: integer-fixnum-op-quot ( fix-word big-word -- quot )
+    [
+        [ over fixnum? ] %
+        [ '[ _ execute ] , ]
+        [ '[ fixnum>bignum _ execute ] , ] bi*
+        \ if ,
+    ] [ ] make ;
 
-:: integer-integer-op ( a b fix-word big-word -- c )
-    b tag 0 eq? [
-        a b fix-word big-word integer-fixnum-op
-    ] [
-        a dup tag 0 eq? [ fixnum>bignum ] when
-        b big-word execute
-    ] if ; inline
+: fixnum-integer-op-quot ( fix-word big-word -- quot )
+    [
+        [ dup fixnum? ] %
+        [ '[ _ execute ] , ]
+        [ '[ [ fixnum>bignum ] dip _ execute ] , ] bi*
+        \ if ,
+    ] [ ] make ;
 
-: integer-op-combinator ( triple -- word )
+: integer-integer-op-quot ( fix-word big-word -- quot )
     [
-        [ second name>> % "-" % ]
-        [ third name>> % "-op" % ]
-        bi
-    ] "" make "math.partial-dispatch" lookup ;
+        [ dup fixnum? ] %
+        2dup integer-fixnum-op-quot ,
+        [
+            [ over fixnum? [ [ fixnum>bignum ] dip ] when ] %
+            nip ,
+        ] [ ] make ,
+        \ if ,
+    ] [ ] make ;
 
 : integer-op-word ( triple -- word )
     [ name>> ] map "-" join "math.partial-dispatch" create ;
 
-: integer-op-quot ( triple fix-word big-word -- quot )
-    rot integer-op-combinator 1quotation 2curry ;
+: integer-op-quot ( fix-word big-word triple -- quot )
+    [ second ] [ third ] bi 2array {
+        { { fixnum integer } [ fixnum-integer-op-quot ] }
+        { { integer fixnum } [ integer-fixnum-op-quot ] }
+        { { integer integer } [ integer-integer-op-quot ] }
+    } case ;
 
-: define-integer-op-word ( triple fix-word big-word -- )
+: define-integer-op-word ( fix-word big-word triple -- )
     [
-        [ 2drop integer-op-word ] [ integer-op-quot ] 3bi
+        [ 2nip integer-op-word ] [ integer-op-quot ] 3bi
         (( x y -- z )) define-declared
     ] [
-        2drop
+        2nip
         [ integer-op-word ] keep
         "derived-from" set-word-prop
     ] 3bi ;
 
 : define-integer-op-words ( triples fix-word big-word -- )
-    [ define-integer-op-word ] 2curry each ;
+    '[ [ _ _ ] dip define-integer-op-word ] each ;
 
 : integer-op-triples ( word -- triples )
     {
         { fixnum integer }
         { integer fixnum }
         { integer integer }
-    } swap [ prefix ] curry map ;
+    } swap '[ _ prefix ] map ;
 
 : define-integer-ops ( word fix-word big-word -- )
     [
@@ -138,7 +140,7 @@ SYMBOL: fast-math-ops
     [ drop math-class-max swap specific-method >boolean ] if ;
 
 : (derived-ops) ( word assoc -- words )
-    swap [ rot first eq? nip ] curry assoc-filter ;
+    swap '[ swap first _ eq? nip ] assoc-filter ;
 
 : derived-ops ( word -- words )
     [ 1array ] [ math-ops get (derived-ops) values ] bi append ;
index c753d0fb78589c9662188f479a0b3b29d00d5982..82643bef154a72488ca922931ef95acb344eeb05 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: math kernel sequences sequences.private byte-arrays
-alien.c-types prettyprint.backend parser accessors ;
+alien.c-types prettyprint.custom parser accessors ;
 IN: nibble-arrays
 
 TUPLE: nibble-array
index e50fd52c1051eb52391929295546f852deb2475b..8c80782a2e5da3d8dfcda6d3e91ee63aa798848f 100644 (file)
@@ -1,7 +1,7 @@
 ! Based on Clojure's PersistentHashMap by Rich Hickey.
 
 USING: kernel math accessors assocs fry combinators parser
-prettyprint.backend make
+prettyprint.custom make
 persistent.assocs
 persistent.hashtables.nodes
 persistent.hashtables.nodes.empty
index 92b3f82a54c00d08ddc49e8624d2b54db5e284b6..cd8e7c49e0b29c090c3e9b9f8fc6868e907522a1 100644 (file)
@@ -1,7 +1,7 @@
 ! Based on Clojure's PersistentVector by Rich Hickey.
 
 USING: math accessors kernel sequences.private sequences arrays
-combinators combinators.short-circuit parser prettyprint.backend
+combinators combinators.short-circuit parser prettyprint.custom
 persistent.sequences ;
 IN: persistent.vectors
 
index 64e1fd45ff1b3c51532aa01d0707185d005deec5..165621887fd77a5c496bf9b795dfa31edcd94060 100644 (file)
@@ -1,14 +1,10 @@
 USING: help.markup help.syntax io kernel
-prettyprint.config prettyprint.sections words strings ;
+prettyprint.config prettyprint.sections prettyprint.custom
+words strings ;
 IN: prettyprint.backend
 
 ABOUT: "prettyprint-extension"
 
-HELP: pprint*
-{ $values { "obj" "an object" } }
-{ $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." }
-$prettyprinting-note ;
-
 HELP: pprint-word
 { $values { "word" "a word" } }
 { $description "Adds a text section for the word. Unlike the " { $link word } " method of " { $link pprint* } ", this does not add a " { $link POSTPONE: POSTPONE: } " prefix to parsing words." }
index 7a5b16a3c2d999329438b585525adfa715e0ff09..92d039a15df894293dc23138870352ac9302820a 100644 (file)
@@ -1,16 +1,14 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays byte-arrays byte-vectors generic
-hashtables io assocs kernel math namespaces make sequences
-strings sbufs io.styles vectors words prettyprint.config
+USING: accessors arrays byte-arrays generic hashtables io assocs
+kernel math namespaces make sequences strings sbufs io.styles
+vectors words prettyprint.config prettyprint.custom
 prettyprint.sections quotations io io.files math.parser effects
 classes.tuple math.order classes.tuple.private classes
 combinators colors ;
 IN: prettyprint.backend
 
-GENERIC: pprint* ( obj -- )
-
-M: effect pprint* effect>string "(" swap ")" 3append text ;
+M: effect pprint* effect>string "(" ")" surround text ;
 
 : ?effect-height ( word -- n )
     stack-effect [ effect-height ] [ 0 ] if* ;
@@ -161,26 +159,19 @@ M: tuple pprint*
     [ [ pprint* ] each ] dip
     [ "~" swap number>string " more~" 3append text ] when* ;
 
-GENERIC: pprint-delims ( obj -- start end )
-
 M: quotation pprint-delims drop \ [ \ ] ;
 M: curry pprint-delims drop \ [ \ ] ;
 M: compose pprint-delims drop \ [ \ ] ;
 M: array pprint-delims drop \ { \ } ;
 M: byte-array pprint-delims drop \ B{ \ } ;
-M: byte-vector pprint-delims drop \ BV{ \ } ;
 M: vector pprint-delims drop \ V{ \ } ;
 M: hashtable pprint-delims drop \ H{ \ } ;
 M: tuple pprint-delims drop \ T{ \ } ;
 M: wrapper pprint-delims drop \ W{ \ } ;
 M: callstack pprint-delims drop \ CS{ \ } ;
 
-GENERIC: >pprint-sequence ( obj -- seq )
-
 M: object >pprint-sequence ;
-
 M: vector >pprint-sequence ;
-M: byte-vector >pprint-sequence ;
 M: curry >pprint-sequence ;
 M: compose >pprint-sequence ;
 M: hashtable >pprint-sequence >alist ;
@@ -191,16 +182,13 @@ M: tuple >pprint-sequence
     [ class ] [ tuple-slots ] bi
     [ 1array ] [ [ f 2array ] dip append ] if-empty ;
 
-GENERIC: pprint-narrow? ( obj -- ? )
-
 M: object pprint-narrow? drop f ;
-
 M: array pprint-narrow? drop t ;
 M: vector pprint-narrow? drop t ;
 M: hashtable pprint-narrow? drop t ;
 M: tuple pprint-narrow? drop t ;
 
-: pprint-object ( obj -- )
+M: object pprint-object ( obj -- )
     [
         <flow
         dup pprint-delims [
@@ -213,7 +201,6 @@ M: tuple pprint-narrow? drop t ;
 
 M: object pprint* pprint-object ;
 M: vector pprint* pprint-object ;
-M: byte-vector pprint* pprint-object ;
 M: hashtable pprint* pprint-object ;
 M: curry pprint* pprint-object ;
 M: compose pprint* pprint-object ;
diff --git a/basis/prettyprint/custom/custom-docs.factor b/basis/prettyprint/custom/custom-docs.factor
new file mode 100644 (file)
index 0000000..60557e6
--- /dev/null
@@ -0,0 +1,9 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel help.markup help.syntax ;
+IN: prettyprint.custom
+
+HELP: pprint*
+{ $values { "obj" object } }
+{ $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." }
+$prettyprinting-note ;
diff --git a/basis/prettyprint/custom/custom.factor b/basis/prettyprint/custom/custom.factor
new file mode 100644 (file)
index 0000000..9fd940c
--- /dev/null
@@ -0,0 +1,9 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+IN: prettyprint.custom
+
+GENERIC: pprint* ( obj -- )
+GENERIC: pprint-object ( obj -- )
+GENERIC: pprint-delims ( obj -- start end )
+GENERIC: >pprint-sequence ( obj -- seq )
+GENERIC: pprint-narrow? ( obj -- ? )
index 3c004e5b305c6837955f0025903d0ef1cb845e79..46d4e6e5ff5dbcd31ac4b78864effb8b585a41c2 100644 (file)
@@ -1,4 +1,4 @@
-USING: prettyprint.backend prettyprint.config
+USING: prettyprint.backend prettyprint.config prettyprint.custom
 prettyprint.sections prettyprint.private help.markup help.syntax
 io kernel words definitions quotations strings generic classes ;
 IN: prettyprint
index 7c4de1e973764081efc51b1f15cb6d23e88085f8..9d5af9e6a5afaeb47499a88cd248460d884d16d2 100644 (file)
@@ -2,12 +2,13 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic generic.standard assocs io kernel math
 namespaces make sequences strings io.styles io.streams.string
-vectors words prettyprint.backend prettyprint.sections
-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 parser ;
+vectors words prettyprint.backend prettyprint.custom
+prettyprint.sections 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 parser summary ;
 IN: prettyprint
 
 : make-pprint ( obj quot -- block in use )
@@ -231,6 +232,8 @@ M: pathname synopsis* pprint* ;
         [ synopsis* ] with-in
     ] with-string-writer ;
 
+M: word summary synopsis ;
+
 : synopsis-alist ( definitions -- alist )
     [ dup synopsis swap ] { } map>assoc ;
 
index 25d04ed929efaf7d62c1606c89dadc4f1bd6729e..2cd64e90bf99f1ded6984031203f4766618059eb 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences assocs hashtables parser lexer
-vocabs words namespaces vocabs.loader debugger sets fry ;
+vocabs words namespaces vocabs.loader sets fry ;
 IN: qualified
 
 : define-qualified ( vocab-name prefix-name -- )
index b41e4d271e8f22d4074356240da8551231b0a0eb..c615719cc4da86e7cb3792965a63702c990274a4 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators kernel math sequences strings
-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 splitting
-sorting ;
+USING: accessors combinators kernel math sequences strings sets
+assocs prettyprint.backend prettyprint.custom make lexer
+namespaces parser arrays fry regexp.backend regexp.utils
+regexp.parser regexp.nfa regexp.dfa regexp.traversal
+regexp.transition-tables splitting sorting ;
 IN: regexp
 
 : default-regexp ( string -- regexp )
index 7f14945633b82f2b2201959ede17856d2086b209..f689ad08586627d403e4149a9646e8499ee422dd 100644 (file)
@@ -72,10 +72,12 @@ ERROR: bad-email-address email ;
     [ bad-email-address ] unless ;
 
 : mail-from ( fromaddr -- )
-    "MAIL FROM:<" swap validate-address ">" 3append command ;
+    validate-address
+    "MAIL FROM:<" ">" surround command ;
 
 : rcpt-to ( to -- )
-    "RCPT TO:<" swap validate-address ">" 3append command ;
+    validate-address
+    "RCPT TO:<" ">" surround command ;
 
 : data ( -- )
     "DATA" command ;
index 52977dc22ad8d767fb33540c99903661eb3d8305..28946494282ec6ef777a91aa0931f511033ab39c 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: functors sequences sequences.private prettyprint.backend
+USING: functors sequences sequences.private prettyprint.custom
 kernel words classes math parser alien.c-types byte-arrays
 accessors summary ;
 IN: specialized-arrays.functor
index 0628f8b48465c5364afdeee85033b5572a294e4b..8ba5354dc40c79f17783dc0493d630029de12f58 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: functors sequences sequences.private growable
-prettyprint.backend kernel words classes math parser ;
+prettyprint.custom kernel words classes math parser ;
 IN: specialized-vectors.functor
 
 FUNCTOR: define-vector ( T -- )
index 7f8c920b199878fd95a06fbf200aa4065b9ea2b3..147749864d23d2daf5ef41923fb8ec8f72fb34b6 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry arrays generic io io.streams.string kernel math
-namespaces parser prettyprint sequences strings vectors words
-quotations effects classes continuations debugger assocs
-combinators compiler.errors accessors math.order definitions
-sets generic.standard.engines.tuple hints stack-checker.state
-stack-checker.visitor stack-checker.errors
-stack-checker.values stack-checker.recursive-state ;
+namespaces parser sequences strings vectors words quotations
+effects classes continuations assocs combinators
+compiler.errors accessors math.order definitions sets
+generic.standard.engines.tuple hints stack-checker.state
+stack-checker.visitor stack-checker.errors stack-checker.values
+stack-checker.recursive-state ;
 IN: stack-checker.backend
 
 : push-d ( obj -- ) meta-d push ;
index 5b6b3c089379446056f197d84137f6776f22d492..58944e7bc42bbcdd744800527c50440780f71466 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel generic sequences prettyprint io words arrays
-summary effects debugger assocs accessors namespaces
-compiler.errors stack-checker.values
+USING: kernel generic sequences io words arrays summary effects
+assocs accessors namespaces compiler.errors stack-checker.values
 stack-checker.recursive-state ;
 IN: stack-checker.errors
 
@@ -10,8 +9,6 @@ TUPLE: inference-error error type word ;
 
 M: inference-error compiler-error-type type>> ;
 
-M: inference-error error-help error>> error-help ;
-
 : (inference-error) ( ... class type -- * )
     [ boa ] dip
     recursive-state get word>>
@@ -23,14 +20,8 @@ M: inference-error error-help error>> error-help ;
 : inference-warning ( ... class -- * )
     +warning+ (inference-error) ; inline
 
-M: inference-error error.
-    [ word>> [ "In word: " write . ] when* ] [ error>> error. ] bi ;
-
 TUPLE: literal-expected ;
 
-M: literal-expected summary
-    drop "Literal value expected" ;
-
 M: object (literal) \ literal-expected inference-warning ;
 
 TUPLE: unbalanced-branches-error branches quots ;
@@ -38,79 +29,25 @@ TUPLE: unbalanced-branches-error branches quots ;
 : unbalanced-branches-error ( branches quots -- * )
     \ unbalanced-branches-error inference-error ;
 
-M: unbalanced-branches-error error.
-    "Unbalanced branches:" print
-    [ quots>> ] [ branches>> [ length <effect> ] { } assoc>map ] bi zip
-    [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ;
-
 TUPLE: too-many->r ;
 
-M: too-many->r summary
-    drop
-    "Quotation pushes elements on retain stack without popping them" ;
-
 TUPLE: too-many-r> ;
 
-M: too-many-r> summary
-    drop
-    "Quotation pops retain stack elements which it did not push" ;
-
 TUPLE: missing-effect word ;
 
-M: missing-effect error.
-    "The word " write
-    word>> pprint
-    " must declare a stack effect" print ;
-
 TUPLE: effect-error word inferred declared ;
 
 : effect-error ( word inferred declared -- * )
     \ effect-error inference-error ;
 
-M: effect-error error.
-    "Stack effects of the word " write
-    [ word>> pprint " do not match." print ]
-    [ "Inferred: " write inferred>> . ]
-    [ "Declared: " write declared>> . ] tri ;
-
 TUPLE: recursive-quotation-error quot ;
 
-M: recursive-quotation-error error.
-    "The quotation " write
-    quot>> pprint
-    " calls itself." print
-    "Stack effect inference is undecidable when quotation-level recursion is permitted." print ;
-
 TUPLE: undeclared-recursion-error word ;
 
-M: undeclared-recursion-error error.
-    "The inline recursive word " write
-    word>> pprint
-    " must be declared recursive" print ;
-
 TUPLE: diverging-recursion-error word ;
 
-M: diverging-recursion-error error.
-    "The recursive word " write
-    word>> pprint
-    " digs arbitrarily deep into the stack" print ;
-
 TUPLE: unbalanced-recursion-error word height ;
 
-M: unbalanced-recursion-error error.
-    "The recursive word " write
-    word>> pprint
-    " leaves with the stack having the wrong height" print ;
-
 TUPLE: inconsistent-recursive-call-error word ;
 
-M: inconsistent-recursive-call-error error.
-    "The recursive word " write
-    word>> pprint
-    " calls itself with a different set of quotation parameters than were input" print ;
-
 TUPLE: unknown-primitive-error ;
-
-M: unknown-primitive-error error.
-    drop
-    "Cannot determine stack effect statically" print ;
diff --git a/basis/stack-checker/errors/prettyprint/prettyprint.factor b/basis/stack-checker/errors/prettyprint/prettyprint.factor
new file mode 100644 (file)
index 0000000..21c6d64
--- /dev/null
@@ -0,0 +1,67 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel prettyprint io debugger
+sequences assocs stack-checker.errors summary effects ;
+IN: stack-checker.errors.prettyprint
+
+M: inference-error error-help error>> error-help ;
+
+M: inference-error error.
+    [ word>> [ "In word: " write . ] when* ] [ error>> error. ] bi ;
+
+M: literal-expected summary
+    drop "Literal value expected" ;
+
+M: unbalanced-branches-error error.
+    "Unbalanced branches:" print
+    [ quots>> ] [ branches>> [ length <effect> ] { } assoc>map ] bi zip
+    [ [ first pprint-short bl ] [ second effect>string print ] bi ] each ;
+
+M: too-many->r summary
+    drop
+    "Quotation pushes elements on retain stack without popping them" ;
+
+M: too-many-r> summary
+    drop
+    "Quotation pops retain stack elements which it did not push" ;
+
+M: missing-effect error.
+    "The word " write
+    word>> pprint
+    " must declare a stack effect" print ;
+
+M: effect-error error.
+    "Stack effects of the word " write
+    [ word>> pprint " do not match." print ]
+    [ "Inferred: " write inferred>> . ]
+    [ "Declared: " write declared>> . ] tri ;
+
+M: recursive-quotation-error error.
+    "The quotation " write
+    quot>> pprint
+    " calls itself." print
+    "Stack effect inference is undecidable when quotation-level recursion is permitted." print ;
+
+M: undeclared-recursion-error error.
+    "The inline recursive word " write
+    word>> pprint
+    " must be declared recursive" print ;
+
+M: diverging-recursion-error error.
+    "The recursive word " write
+    word>> pprint
+    " digs arbitrarily deep into the stack" print ;
+
+M: unbalanced-recursion-error error.
+    "The recursive word " write
+    word>> pprint
+    " leaves with the stack having the wrong height" print ;
+
+M: inconsistent-recursive-call-error error.
+    "The recursive word " write
+    word>> pprint
+    " calls itself with a different set of quotation parameters than were input" print ;
+
+M: unknown-primitive-error error.
+    drop
+    "Cannot determine stack effect statically" print ;
index 2cb3d1f006fd91f513626843b9b2e468c818f304..0442d4c2276a54eedac3d6f828e10301fff83dfe 100644 (file)
@@ -5,7 +5,7 @@ classes sequences.private continuations.private effects generic
 hashtables hashtables.private io io.backend io.files
 io.files.private io.streams.c kernel kernel.private math
 math.private memory namespaces namespaces.private parser
-prettyprint quotations quotations.private sbufs sbufs.private
+quotations quotations.private sbufs sbufs.private
 sequences sequences.private slots.private strings
 strings.private system threads.private classes.tuple
 classes.tuple.private vectors vectors.private words definitions
@@ -99,21 +99,18 @@ M: object infer-call*
     3 infer->r infer-call 3 infer-r> ;
 
 : infer-dip ( -- )
-    commit-literals
     literals get
     [ \ dip def>> infer-quot-here ]
     [ pop 1 infer->r infer-quot-here 1 infer-r>  ]
     if-empty ;
 
 : infer-2dip ( -- )
-    commit-literals
     literals get
     [ \ 2dip def>> infer-quot-here ]
     [ pop 2 infer->r infer-quot-here 2 infer-r>  ]
     if-empty ;
 
 : infer-3dip ( -- )
-    commit-literals
     literals get
     [ \ 3dip def>> infer-quot-here ]
     [ pop 3 infer->r infer-quot-here 3 infer-r>  ]
@@ -307,7 +304,7 @@ M: object infer-call*
 \ <complex> { real real } { complex } define-primitive
 \ <complex> make-foldable
 
-\ both-fixnums? { object object } { object object object } define-primitive
+\ both-fixnums? { object object } { object } define-primitive
 
 \ fixnum+ { fixnum fixnum } { integer } define-primitive
 \ fixnum+ make-foldable
index ea2c19fd6df6198746803128a5a0e9b3c3d434c2..44e5374dc52d7a6cd53f2ebddc25aaa4ca1eb899 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors classes sequences splitting kernel namespaces
-make words math math.parser io.styles prettyprint assocs ;
+USING: accessors classes sequences kernel namespaces
+make words math math.parser assocs ;
 IN: summary
 
 GENERIC: summary ( object -- string )
@@ -11,15 +11,6 @@ GENERIC: summary ( object -- string )
 
 M: object summary object-summary ;
 
-M: input summary
-    [
-        "Input: " %
-        string>> "\n" split1 swap %
-        "..." "" ? %
-    ] "" make ;
-
-M: word summary synopsis ;
-
 M: sequence summary
     [
         dup class name>> %
index 18713c7b0c12c9a8ba685f57a8f73141fff91f2f..f33e4840ebb04fdd7c42f68d3d74e2998cdc6a81 100644 (file)
@@ -5,8 +5,8 @@ assocs kernel vocabs words sequences memory io system arrays
 continuations math definitions mirrors splitting parser classes
 summary layouts vocabs.loader prettyprint.config prettyprint
 debugger io.streams.c io.files io.backend quotations io.launcher
-words.private tools.deploy.config bootstrap.image
-io.encodings.utf8 destructors accessors ;
+words.private tools.deploy.config tools.deploy.config.editor
+bootstrap.image io.encodings.utf8 destructors accessors ;
 IN: tools.deploy.backend
 
 : copy-vm ( executable bundle-name extension -- vm )
@@ -88,6 +88,10 @@ DEFER: ?make-staging-image
     dup staging-image-name exists?
     [ drop ] [ make-staging-image ] if ;
 
+: make-deploy-config ( vocab -- file )
+    [ deploy-config unparse-use ] [ "deploy-config-" prepend ] bi
+    [ utf8 set-file-contents ] keep ;
+
 : deploy-command-line ( image vocab config -- flags )
     [
         bootstrap-profile ?make-staging-image
@@ -99,7 +103,8 @@ DEFER: ?make-staging-image
 
             "-run=tools.deploy.shaker" ,
 
-            "-deploy-vocab=" prepend ,
+            [ "-deploy-vocab=" prepend , ]
+            [ make-deploy-config "-deploy-config=" prepend , ] bi
 
             "-output-image=" prepend ,
 
index e8dcd2b90efea45d68af2f582c77df2dead7c1af..c8249e4e41c89522eedd5473fc38bc8b4e5bd805 100644 (file)
@@ -2,16 +2,6 @@ USING: help.markup help.syntax words alien.c-types assocs
 kernel math ;
 IN: tools.deploy.config
 
-ARTICLE: "deploy-config" "Deployment configuration"
-"The deployment configuration is a key/value mapping stored in the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If this file does not exist, the default deployment configuration is used:"
-{ $subsection default-config }
-"The deployment configuration can be read and written with a pair of words:"
-{ $subsection deploy-config }
-{ $subsection set-deploy-config }
-"A utility word is provided to load the configuration, change a flag, and store it back to disk:"
-{ $subsection set-deploy-flag }
-"The " { $link "ui.tools.deploy" } " provides a graphical way of editing the configuration." ;
-
 ARTICLE: "deploy-flags" "Deployment flags"
 "There are two sets of deployment flags. The first set controls the major subsystems which are to be included in the deployment image:"
 { $subsection deploy-math?     }
@@ -25,12 +15,7 @@ ARTICLE: "deploy-flags" "Deployment flags"
 { $subsection deploy-word-props? }
 { $subsection deploy-c-types?    } ;
 
-ARTICLE: "prepare-deploy" "Preparing to deploy an application"
-"In order to deploy an application as a stand-alone image, the application's vocabulary must first be given a " { $link POSTPONE: MAIN: } " hook. Then, a " { $emphasis "deployment configuration" } " must be created."
-{ $subsection "deploy-config" }
-{ $subsection "deploy-flags" } ;
-
-ABOUT: "prepare-deploy"
+ABOUT: "deploy-flags"
 
 HELP: deploy-name
 { $description "Deploy setting. The name of the executable."
@@ -114,15 +99,3 @@ HELP: deploy-reflection
 HELP: default-config
 { $values { "vocab" "a vocabulary specifier" } { "assoc" assoc } }
 { $description "Outputs the default deployment configuration for a vocabulary." } ;
-
-HELP: deploy-config
-{ $values { "vocab" "a vocabulary specifier" } { "assoc" assoc } }
-{ $description "Loads a vocabulary's deployment configuration from the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If the file does not exist, the " { $link default-config } " is output." } ;
-
-HELP: set-deploy-config
-{ $values { "assoc" assoc } { "vocab" "a vocabulary specifier" } }
-{ $description "Stores a vocabulary's deployment configuration to the " { $snippet "deploy.factor" } " file in the vocabulary's directory." } ;
-
-HELP: set-deploy-flag
-{ $values { "value" object } { "key" object } { "vocab" "a vocabulary specifier" } }
-{ $description "Modifies an entry in a vocabulary's deployment configuration on disk." } ;
index 84bfab682be2dc4457fa4db93123d45442b1a24b..1d9761e885c9582dde124d0545fa0eacb121a09f 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: vocabs.loader io.files io kernel sequences assocs
-splitting parser prettyprint namespaces math vocabs
-hashtables tools.vocabs ;
+USING: io.files io kernel sequences assocs splitting parser
+namespaces math vocabs hashtables ;
 IN: tools.deploy.config
 
 SYMBOL: deploy-name
@@ -66,18 +65,3 @@ SYMBOL: deploy-image
         ! default value for deploy.macosx
         { "stop-after-last-window?" t }
     } assoc-union ;
-
-: deploy-config-path ( vocab -- string )
-    vocab-dir "deploy.factor" append-path ;
-
-: deploy-config ( vocab -- assoc )
-    dup default-config swap
-    dup deploy-config-path vocab-file-contents
-    parse-fresh [ first assoc-union ] unless-empty ;
-
-: set-deploy-config ( assoc vocab -- )
-    [ unparse-use string-lines ] dip
-    dup deploy-config-path set-vocab-file-contents ;
-
-: set-deploy-flag ( value key vocab -- )
-    [ deploy-config [ set-at ] keep ] keep set-deploy-config ;
diff --git a/basis/tools/deploy/config/editor/editor-docs.factor b/basis/tools/deploy/config/editor/editor-docs.factor
new file mode 100644 (file)
index 0000000..b677d37
--- /dev/null
@@ -0,0 +1,27 @@
+USING: assocs help.markup help.syntax kernel
+tools.deploy.config ;
+IN: tools.deploy.config.editor
+
+ARTICLE: "deploy-config" "Deployment configuration"
+"The deployment configuration is a key/value mapping stored in the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If this file does not exist, the default deployment configuration is used:"
+{ $subsection default-config }
+"The deployment configuration can be read and written with a pair of words:"
+{ $subsection deploy-config }
+{ $subsection set-deploy-config }
+"A utility word is provided to load the configuration, change a flag, and store it back to disk:"
+{ $subsection set-deploy-flag }
+"The " { $link "ui.tools.deploy" } " provides a graphical way of editing the configuration." ;
+
+HELP: deploy-config
+{ $values { "vocab" "a vocabulary specifier" } { "assoc" assoc } }
+{ $description "Loads a vocabulary's deployment configuration from the " { $snippet "deploy.factor" } " file in the vocabulary's directory. If the file does not exist, the " { $link default-config } " is output." } ;
+
+HELP: set-deploy-config
+{ $values { "assoc" assoc } { "vocab" "a vocabulary specifier" } }
+{ $description "Stores a vocabulary's deployment configuration to the " { $snippet "deploy.factor" } " file in the vocabulary's directory." } ;
+
+HELP: set-deploy-flag
+{ $values { "value" object } { "key" object } { "vocab" "a vocabulary specifier" } }
+{ $description "Modifies an entry in a vocabulary's deployment configuration on disk." } ;
+
+ABOUT: "deploy-config"
diff --git a/basis/tools/deploy/config/editor/editor.factor b/basis/tools/deploy/config/editor/editor.factor
new file mode 100644 (file)
index 0000000..2b5788a
--- /dev/null
@@ -0,0 +1,20 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs io.files kernel parser prettyprint sequences
+splitting tools.deploy.config tools.vocabs vocabs.loader ;
+IN: tools.deploy.config.editor
+
+: deploy-config-path ( vocab -- string )
+    vocab-dir "deploy.factor" append-path ;
+
+: deploy-config ( vocab -- assoc )
+    dup default-config swap
+    dup deploy-config-path vocab-file-contents
+    parse-fresh [ first assoc-union ] unless-empty ;
+
+: set-deploy-config ( assoc vocab -- )
+    [ unparse-use string-lines ] dip
+    dup deploy-config-path set-vocab-file-contents ;
+
+: set-deploy-flag ( value key vocab -- )
+    [ deploy-config [ set-at ] keep ] keep set-deploy-config ;
index eccb3982c7c3342399b7797c6a179b89a67294da..00e747cf0076aaf298890f16ad09d26228d8519f 100644 (file)
@@ -2,6 +2,11 @@ USING: help.markup help.syntax words alien.c-types assocs
 kernel ;
 IN: tools.deploy
 
+ARTICLE: "prepare-deploy" "Preparing to deploy an application"
+"In order to deploy an application as a stand-alone image, the application's vocabulary must first be given a " { $link POSTPONE: MAIN: } " hook. Then, a " { $emphasis "deployment configuration" } " must be created."
+{ $subsection "deploy-config" }
+{ $subsection "deploy-flags" } ;
+
 ARTICLE: "tools.deploy" "Application deployment"
 "The stand-alone application deployment tool compiles a vocabulary down to a native executable which runs the vocabulary's " { $link POSTPONE: MAIN: } " hook. Deployed executables do not depend on Factor being installed, and do not expose any source code, and thus are suitable for delivering commercial end-user applications."
 $nl
index e3fd9b9a7c159ea044a62211b6d601c387271862..9cc48972fab1754385aba254462982adc31793e9 100644 (file)
@@ -14,34 +14,22 @@ urls math.parser ;
 : small-enough? ( n -- ? )\r
     [ "test.image" temp-file file-info size>> ] [ cell 4 / * ] bi* <= ;\r
 \r
-[ ] [ "hello-world" shake-and-bake ] unit-test\r
+[ t ] [ "hello-world" shake-and-bake 500000 small-enough? ] unit-test\r
 \r
-[ t ] [ 500000 small-enough? ] unit-test\r
+[ t ] [ "sudoku" shake-and-bake 800000 small-enough? ] unit-test\r
 \r
-[ ] [ "sudoku" shake-and-bake ] unit-test\r
-\r
-[ t ] [ 800000 small-enough? ] unit-test\r
-\r
-[ ] [ "hello-ui" shake-and-bake ] unit-test\r
-\r
-[ t ] [ 1300000 small-enough? ] unit-test\r
+[ t ] [ "hello-ui" shake-and-bake 1300000 small-enough? ] unit-test\r
 \r
 [ "staging.math-compiler-threads-ui-strip.image" ] [\r
     "hello-ui" deploy-config\r
     [ bootstrap-profile staging-image-name file-name ] bind\r
 ] unit-test\r
 \r
-[ ] [ "maze" shake-and-bake ] unit-test\r
-\r
-[ t ] [ 1200000 small-enough? ] unit-test\r
-\r
-[ ] [ "tetris" shake-and-bake ] unit-test\r
+[ t ] [ "maze" shake-and-bake 1200000 small-enough? ] unit-test\r
 \r
-[ t ] [ 1500000 small-enough? ] unit-test\r
+[ t ] [ "tetris" shake-and-bake 1500000 small-enough? ] unit-test\r
 \r
-! [ ] [ "bunny" shake-and-bake ] unit-test\r
-\r
-! [ t ] [ 2500000 small-enough? ] unit-test\r
+[ t ] [ "bunny" shake-and-bake 2500000 small-enough? ] unit-test\r
 \r
 : run-temp-image ( -- )\r
     vm\r
@@ -110,3 +98,8 @@ M: quit-responder call-responder*
     "tools.deploy.test.7" shake-and-bake\r
     run-temp-image\r
 ] unit-test\r
+\r
+[ ] [\r
+    "tools.deploy.test.8" shake-and-bake\r
+    run-temp-image\r
+] unit-test\r
index 15fd2a37d792588c06adda429643746d291f7481..01cc80e90d020eb0a70c4cd8e672e3be4a02702b 100755 (executable)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors qualified io.backend io.streams.c init fry
-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 generic generic.standard ;
+namespaces make assocs kernel parser lexer strings.parser vocabs
+sequences words words.private memory kernel.private
+continuations io vocabs.loader system strings sets
+vectors quotations byte-arrays sorting compiler.units
+definitions generic generic.standard tools.deploy.config ;
 QUALIFIED: bootstrap.stage2
 QUALIFIED: classes
 QUALIFIED: command-line
@@ -14,7 +14,6 @@ QUALIFIED: continuations
 QUALIFIED: definitions
 QUALIFIED: init
 QUALIFIED: layouts
-QUALIFIED: prettyprint.config
 QUALIFIED: source-files
 QUALIFIED: vocabs
 IN: tools.deploy.shaker
@@ -41,7 +40,7 @@ IN: tools.deploy.shaker
     ] when ;
 
 : strip-debugger ( -- )
-    strip-debugger? [
+    strip-debugger? "debugger" vocab and [
         "Stripping debugger" show
         "resource:basis/tools/deploy/shaker/strip-debugger.factor"
         run-file
@@ -81,14 +80,11 @@ IN: tools.deploy.shaker
                 >alist f like
             ] change-props drop
         ] each
-    ] [
-        "Remaining word properties:\n" show
-        [ props>> keys ] gather unparse show
     ] [
         H{ } clone '[
             [ [ _ [ ] cache ] map ] change-props drop
         ] each
-    ] tri ;
+    ] bi ;
 
 : stripped-word-props ( -- seq )
     [
@@ -275,12 +271,7 @@ IN: tools.deploy.shaker
         ] when
 
         strip-prettyprint? [
-            {
-                prettyprint.config:margin
-                prettyprint.config:string-limit?
-                prettyprint.config:boa-tuples?
-                prettyprint.config:tab-size
-            } %
+            { } { "prettyprint.config" } strip-vocab-globals %
         ] when
 
         strip-debugger? [
@@ -308,7 +299,6 @@ IN: tools.deploy.shaker
         '[ drop _ member? not ] assoc-filter
         [ drop string? not ] assoc-filter ! strip CLI args
         sift-assoc
-        dup keys unparse show
         21 setenv
     ] [ drop ] if ;
 
@@ -362,7 +352,7 @@ SYMBOL: deploy-vocab
         init-hooks get values concat %
         ,
         strip-io? [ \ flush , ] unless
-    ] [ ] make "Boot quotation: " show dup unparse show
+    ] [ ] make
     set-boot-quot ;
 
 : init-stripper ( -- )
@@ -405,16 +395,14 @@ SYMBOL: deploy-vocab
             deploy-vocab get require
             strip
             finish-deploy
-        ] [
-            print-error flush 1 exit
-        ] recover
+        ] [ die 1 exit ] recover
     ] bind ;
 
 : do-deploy ( -- )
     "output-image" get
     "deploy-vocab" get
     "Deploying " write dup write "..." print
-    dup deploy-config dup .
+    "deploy-config" get parse-file first
     (deploy) ;
 
 MAIN: do-deploy
diff --git a/basis/tools/deploy/test/8/8.factor b/basis/tools/deploy/test/8/8.factor
new file mode 100644 (file)
index 0000000..c495928
--- /dev/null
@@ -0,0 +1,11 @@
+USING: kernel ;
+IN: tools.deploy.test.8
+
+: literal-merge-test-1 ( -- x ) H{ { "lil" "wayne" } } ;
+: literal-merge-test-2 ( -- x ) H{ { "lil" "wayne" } } ;
+
+: literal-merge-test ( -- )
+    literal-merge-test-1
+    literal-merge-test-2 eq? t assert= ;
+
+MAIN: literal-merge-test
diff --git a/basis/tools/deploy/test/8/deploy.factor b/basis/tools/deploy/test/8/deploy.factor
new file mode 100644 (file)
index 0000000..3bea1ed
--- /dev/null
@@ -0,0 +1,15 @@
+USING: tools.deploy.config ;
+H{
+    { deploy-name "tools.deploy.test.8" }
+    { deploy-c-types? f }
+    { deploy-word-props? f }
+    { deploy-ui? f }
+    { deploy-reflection 1 }
+    { deploy-compiler? f }
+    { deploy-unicode? f }
+    { deploy-io 1 }
+    { deploy-word-defs? f }
+    { deploy-threads? f }
+    { "stop-after-last-window?" t }
+    { deploy-math? f }
+}
index 782f244c6874d9560755f5b0787461a45dc6738a..96f5a043788c83f6113bfeddbb347c513aabf709 100644 (file)
@@ -1,6 +1,6 @@
 IN: tools.disassembler.tests\r
-USING: math classes.tuple prettyprint.backend tools.disassembler\r
-tools.test strings ;\r
+USING: math classes.tuple prettyprint.custom \r
+tools.disassembler tools.test strings ;\r
 \r
 [ ] [ \ + disassemble ] unit-test\r
 [ ] [ { string pprint* } disassemble ] unit-test\r
index 4cd5653ab460dbb98c784695ae9e18a1c4c39e06..e9e8d27870704378c223bc9e53acbbd7e71937c3 100644 (file)
@@ -289,7 +289,7 @@ M: vocab-spec article-parent drop "vocab-index" ;
 M: vocab-tag >link ;
 
 M: vocab-tag article-title
-    name>> "Vocabularies tagged ``" swap "''" 3append ;
+    name>> "Vocabularies tagged ``" "''" surround ;
 
 M: vocab-tag article-name name>> ;
 
index b0d152fc880fa557663f711a2d7f134a7b60f852..22a4f1722db1f3f5a8ab6c89d854b668c1a48bf1 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.accessors alien.c-types arrays io kernel libc
-math math.vectors namespaces opengl opengl.gl prettyprint assocs
+math math.vectors namespaces opengl opengl.gl assocs
 sequences io.files io.styles continuations freetype
 ui.gadgets.worlds ui.render ui.backend byte-arrays accessors
 locals specialized-arrays.direct.uchar ;
@@ -61,7 +61,7 @@ M: freetype-renderer free-fonts ( world -- )
     } at ;
 
 : ttf-path ( name -- string )
-    "resource:fonts/" swap ".ttf" 3append ;
+    "resource:fonts/" ".ttf" surround ;
 
 : (open-face) ( path length -- face )
     #! We use FT_New_Memory_Face, not FT_New_Face, since
index 108c5ae461d1b3a25c38647383f02f96eb5fa4ed..636e25cea5967bbdd18dcbef55cdced281784efa 100644 (file)
@@ -3,7 +3,7 @@
 USING: arrays ui.gadgets.buttons ui.gadgets.borders
 ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers
 ui.gadgets.tracks ui.gadgets.theme ui.gadgets.frames
-ui.gadgets.grids io kernel math models namespaces prettyprint
+ui.gadgets.grids io kernel math models namespaces
 sequences sequences words classes.tuple ui.gadgets ui.render
 colors accessors ;
 IN: ui.gadgets.labelled
index 33ef3bbe3afbbc007feef35d98557987fdfe5a27..61a55e926bb44e5525b9e2ae2e5ebb41f8c00749 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays accessors definitions hashtables io kernel
-prettyprint sequences strings io.styles words help math models
+sequences strings io.styles words help math models
 namespaces quotations
 ui.gadgets ui.gadgets.borders ui.gadgets.buttons
 ui.gadgets.labels ui.gadgets.menus ui.gadgets.worlds
index 9e13e5ad7cb14378d932c9dcd7897ae60bf88952..1c2055156ea346020159fb51e1d0ea1ab21aa0f5 100644 (file)
@@ -36,8 +36,9 @@ TUPLE: slider < frame elevator thumb saved line ;
     #! A scaling factor such that if x is a slider co-ordinate,
     #! x*n is the screen position of the thumb, and conversely
     #! for x/n. The '1 max' calls avoid division by zero.
-    dup elevator-length over thumb-dim - 1 max
-    swap slider-max* 1 max / ;
+    [ [ elevator-length ] [ thumb-dim ] bi - 1 max ]
+    [ slider-max* 1 max ]
+    bi / ;
 
 : slider>screen ( m scale -- n ) slider-scale * ;
 : screen>slider ( m scale -- n ) slider-scale / ;
index 68a2a18210109adf47d1094c106f63a0188d4650..3b9b2fa1f374157b15ef922675539140d032d0ca 100644 (file)
@@ -3,7 +3,7 @@
 USING: accessors arrays assocs continuations kernel math models
 namespaces opengl sequences io combinators fry math.vectors
 ui.gadgets ui.gestures ui.render ui.backend ui.gadgets.tracks
-debugger math.geometry.rect ;
+math.geometry.rect ;
 IN: ui.gadgets.worlds
 
 TUPLE: world < track
@@ -76,7 +76,7 @@ C: <world-error> world-error
 SYMBOL: ui-error-hook
 
 : ui-error ( error -- )
-    ui-error-hook get [ call ] [ print-error ] if* ;
+    ui-error-hook get [ call ] [ die ] if* ;
 
 ui-error-hook global [ [ rethrow ] or ] change-at
 
index 127269b325ce8be2b73de65b1aae810d81d3bba0..f023b0959ab703fd88547d5e42b807a6ad6ec8c5 100644 (file)
@@ -119,5 +119,5 @@ deploy-gadget "toolbar" f {
 : deploy-tool ( vocab -- )
     vocab-name
     [ <deploy-gadget> 10 <border> ]
-    [ "Deploying \"" swap "\"" 3append ] bi
+    [ "Deploying \"" "\"" surround ] bi
     open-window ;
index de2eb713072989a25b8af0c592c0415df46ba51d..88f0a353b94d76f7308968d7de2e1a7a77cc55b5 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs io kernel math models namespaces make
-prettyprint dlists deques sequences threads sequences words
-debugger ui.gadgets ui.gadgets.worlds ui.gadgets.tracks
-ui.gestures ui.backend ui.render continuations init combinators
-hashtables concurrency.flags sets accessors calendar ;
+dlists deques sequences threads sequences words ui.gadgets
+ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend
+ui.render continuations init combinators hashtables
+concurrency.flags sets accessors calendar ;
 IN: ui
 
 ! Assoc mapping aliens to gadgets
index b65236d1f9b8734a94c716f4dbf283b322572097..a532a13b697055ca1ab31719a24612c1ff99f82f 100755 (executable)
@@ -5,7 +5,7 @@ ui.gestures ui.backend ui.clipboards ui.gadgets.worlds ui.render
 assocs kernel math namespaces opengl sequences strings x11.xlib
 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
+io.encodings.utf8 combinators command-line qualified
 math.vectors classes.tuple opengl.gl threads math.geometry.rect
 environment ascii ;
 IN: ui.x11
index 6401ce201e1543f98fa909a7c0ab118ef9f92f06..0083e49672f79dfe2bdc76e962e85319aad855b5 100644 (file)
@@ -16,3 +16,9 @@ USING: unicode.case tools.test namespaces ;
     "lt" locale set
     ! Lithuanian casing tests
 ] with-scope
+
+[ t ] [ "asdf" lower? ] unit-test
+[ f ] [ "asdF" lower? ] unit-test
+
+[ t ] [ "ASDF" upper? ] unit-test
+[ f ] [ "ASDf" upper? ] unit-test
index 932f72960a1aa847bf14d401d6495880aeaffedf..ea1baa6e9c6e5f7f62367f0e88afda6eae148b2f 100644 (file)
@@ -100,11 +100,10 @@ SYMBOL: locale ! Just casing locale, or overall?
 : >case-fold ( string -- fold )
     >upper >lower ;
 
-: lower? ( string -- ? )
-    dup >lower = ;
-: upper? ( string -- ? )
-    dup >lower = ;
-: title? ( string -- ? )
-    dup >title = ;
-: case-fold? ( string -- ? )
-    dup >case-fold = ;
+: lower? ( string -- ? ) dup >lower = ;
+
+: upper? ( string -- ? ) dup >upper = ;
+
+: title? ( string -- ? ) dup >title = ;
+
+: case-fold? ( string -- ? ) dup >case-fold = ;
index c0fb1695c3358603e6abbd3fa1bcdb5a32358a81..5f6d04a54f55cff58e6b8fa96eed11c0e4c39207 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel ascii combinators combinators.short-circuit
 sequences splitting fry namespaces make assocs arrays strings
-io.sockets io.encodings.string
-io.encodings.utf8 math math.parser accessors parser
-strings.parser lexer prettyprint.backend hashtables present
+io.sockets io.encodings.string io.encodings.utf8 math
+math.parser accessors parser strings.parser lexer
+prettyprint.backend prettyprint.custom hashtables present
 peg.ebnf urls.encoding ;
 IN: urls
 
index e0f7e555541e28bfd87e40afedc64a095c44978d..ea40594964760773e50c6efe0ccb165abd5d80f8 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays accessors sequences sequences.private
 persistent.sequences assocs persistent.assocs kernel math
-vectors parser prettyprint.backend ;
+vectors parser prettyprint.custom ;
 IN: vlists
 
 TUPLE: vlist
index 157ac013e3308b0ad384290e5e2b12083906050a..4a998a1ebb118d7e15a9bcb4f04681ff640d0471 100644 (file)
@@ -12,9 +12,9 @@ M: array resize resize-array ;
 
 : >array ( seq -- array ) { } clone-like ;
 
-M: object new-sequence drop f <array> ;
+M: object new-sequence drop 0 <array> ;
 
-M: f new-sequence drop dup zero? [ drop f ] [ f <array> ] if ;
+M: f new-sequence drop dup zero? [ drop f ] [ 0 <array> ] if ;
 
 M: array equal?
     over array? [ sequence= ] [ 2drop f ] if ;
index a0d16084b1ba1a666f08cdb6aa2c43744509bf60..76745cc0151f99055c778d87e5861ddf2f85be4e 100644 (file)
@@ -90,7 +90,7 @@ M: assoc assoc-clone-like ( assoc exemplar -- newassoc )
     ] if ; inline recursive
 
 : assoc-stack ( key seq -- value )
-    dup length 1- swap (assoc-stack) ;
+    dup length 1- swap (assoc-stack) ; flushable
 
 : assoc-subset? ( assoc1 assoc2 -- ? )
     [ swapd at* [ = ] [ 2drop f ] if ] curry assoc-all? ;
index 0a7e5fe23331a72a4379dfb23275118b80b23bc2..42e1de19ee044b196ca5dfa4a31ae47cecc88722 100644 (file)
@@ -68,7 +68,6 @@ bootstrapping? on
     "alien.accessors"
     "arrays"
     "byte-arrays"
-    "byte-vectors"
     "classes.private"
     "classes.tuple"
     "classes.tuple.private"
@@ -109,9 +108,6 @@ bootstrapping? on
 } [ create-vocab drop ] each
 
 ! Builtin classes
-: define-builtin-predicate ( class -- )
-    dup class>type [ builtin-instance? ] curry define-predicate ;
-
 : lookup-type-number ( word -- n )
     global [ target-word ] bind type-number ;
 
@@ -192,6 +188,10 @@ define-union-class
 ] [ ] make
 define-predicate-class
 
+"array-capacity" "sequences.private" lookup
+[ >fixnum ] bootstrap-max-array-capacity [ fixnum-bitand ] curry append
+"coercer" set-word-prop
+
 ! Catch-all class for providing a default method.
 "object" "kernel" create
 [ f f { } intersection-class define-class ]
index 26a27ecefb76fc465a28334cb7478f2f87effaad..874a9dd0d215dd418ebc04263b125ed981d29c64 100644 (file)
@@ -31,7 +31,7 @@ load-help? off
     "math.integers" require
     "math.floats" require
     "memory" require
-
+    
     "io.streams.c" require
     "vocabs.loader" require
     
index e7dd333ed8e90e03592d5c520d5237904b0fb963..badc1f5218165ab1686ad9b8f7883e07f06c043f 100644 (file)
@@ -16,7 +16,6 @@ IN: bootstrap.syntax
     "<PRIVATE"
     "BIN:"
     "B{"
-    "BV{"
     "C:"
     "CHAR:"
     "DEFER:"
diff --git a/core/byte-vectors/byte-vectors-docs.factor b/core/byte-vectors/byte-vectors-docs.factor
deleted file mode 100644 (file)
index 3873f73..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-USING: arrays byte-arrays help.markup help.syntax kernel\r
-byte-vectors.private combinators ;\r
-IN: byte-vectors\r
-\r
-ARTICLE: "byte-vectors" "Byte vectors"\r
-"A byte vector is a resizable mutable sequence of unsigned bytes. Byte vector words are found in the " { $vocab-link "byte-vectors" } " vocabulary."\r
-$nl\r
-"Byte vectors form a class:"\r
-{ $subsection byte-vector }\r
-{ $subsection byte-vector? }\r
-"Creating byte vectors:"\r
-{ $subsection >byte-vector }\r
-{ $subsection <byte-vector> }\r
-"Literal syntax:"\r
-{ $subsection POSTPONE: BV{ }\r
-"If you don't care about initial capacity, a more elegant way to create a new byte vector is to write:"\r
-{ $code "BV{ } clone" } ;\r
-\r
-ABOUT: "byte-vectors"\r
-\r
-HELP: byte-vector\r
-{ $description "The class of resizable byte vectors. See " { $link "byte-vectors" } " for information." } ;\r
-\r
-HELP: <byte-vector>\r
-{ $values { "n" "a positive integer specifying initial capacity" } { "byte-vector" byte-vector } }\r
-{ $description "Creates a new byte vector that can hold " { $snippet "n" } " bytes before resizing." } ;\r
-\r
-HELP: >byte-vector\r
-{ $values { "seq" "a sequence" } { "byte-vector" byte-vector } }\r
-{ $description "Outputs a freshly-allocated byte vector with the same elements as a given sequence." }\r
-{ $errors "Throws an error if the sequence contains elements other than integers." } ;\r
-\r
-HELP: BV{\r
-{ $syntax "BV{ elements... }" }\r
-{ $values { "elements" "a list of bytes" } }\r
-{ $description "Marks the beginning of a literal byte vector. Literal byte vectors are terminated by " { $link POSTPONE: } } "." } \r
-{ $examples { $code "BV{ 1 2 3 12 }" } } ;\r
diff --git a/core/byte-vectors/byte-vectors-tests.factor b/core/byte-vectors/byte-vectors-tests.factor
deleted file mode 100644 (file)
index 9a100d9..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-IN: byte-vectors.tests\r
-USING: tools.test byte-vectors vectors sequences kernel\r
-prettyprint ;\r
-\r
-[ 0 ] [ 123 <byte-vector> length ] unit-test\r
-\r
-: do-it\r
-    123 [ over push ] each ;\r
-\r
-[ t ] [\r
-    3 <byte-vector> do-it\r
-    3 <vector> do-it sequence=\r
-] unit-test\r
-\r
-[ t ] [ BV{ } byte-vector? ] unit-test\r
-\r
-[ "BV{ }" ] [ BV{ } unparse ] unit-test\r
diff --git a/core/byte-vectors/byte-vectors.factor b/core/byte-vectors/byte-vectors.factor
deleted file mode 100644 (file)
index 6938d02..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.\r
-! See http://factorcode.org/license.txt for BSD license.\r
-USING: arrays kernel kernel.private math sequences\r
-sequences.private growable byte-arrays accessors ;\r
-IN: byte-vectors\r
-\r
-TUPLE: byte-vector\r
-{ underlying byte-array }\r
-{ length array-capacity } ;\r
-\r
-: <byte-vector> ( n -- byte-vector )\r
-    <byte-array> 0 byte-vector boa ; inline\r
-\r
-: >byte-vector ( seq -- byte-vector )\r
-    T{ byte-vector f B{ } 0 } clone-like ;\r
-\r
-M: byte-vector like\r
-    drop dup byte-vector? [\r
-        dup byte-array?\r
-        [ dup length byte-vector boa ] [ >byte-vector ] if\r
-    ] unless ;\r
-\r
-M: byte-vector new-sequence\r
-    drop [ <byte-array> ] [ >fixnum ] bi byte-vector boa ;\r
-\r
-M: byte-vector equal?\r
-    over byte-vector? [ sequence= ] [ 2drop f ] if ;\r
-\r
-M: byte-array like\r
-    #! If we have an byte-array, we're done.\r
-    #! If we have a byte-vector, and it's at full capacity,\r
-    #! we're done. Otherwise, call resize-byte-array, which is a\r
-    #! relatively fast primitive.\r
-    drop dup byte-array? [\r
-        dup byte-vector? [\r
-            [ length ] [ underlying>> ] bi\r
-            2dup length eq?\r
-            [ nip ] [ resize-byte-array ] if\r
-        ] [ >byte-array ] if\r
-    ] unless ;\r
-\r
-M: byte-array new-resizable drop <byte-vector> ;\r
-\r
-INSTANCE: byte-vector growable\r
diff --git a/core/byte-vectors/summary.txt b/core/byte-vectors/summary.txt
deleted file mode 100644 (file)
index e914ebb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Growable byte arrays
diff --git a/core/byte-vectors/tags.txt b/core/byte-vectors/tags.txt
deleted file mode 100644 (file)
index 42d711b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-collections
index 4b0d9e5072658b35e4f976801a4e313b866bb6da..699d93b8b4f994a9fbaa186b3ab03e74ae4f9b07 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: sequences math.parser io io.streams.byte-array
-io.encodings.binary io.files kernel ;
+USING: sequences math.parser io io.encodings.binary io.files
+kernel ;
 IN: checksums
 
 MIXIN: checksum
@@ -12,9 +12,6 @@ GENERIC: checksum-stream ( stream checksum -- value )
 
 GENERIC: checksum-lines ( lines checksum -- value )
 
-M: checksum checksum-bytes
-    [ binary <byte-reader> ] dip checksum-stream ;
-
 M: checksum checksum-stream
     [ contents ] dip checksum-bytes ;
 
index 810bdbe10fc23ae0c4eb26e0b5880182403e188f..2730e4683bc06b8215270c9ac51bd6845854311a 100644 (file)
@@ -4,6 +4,7 @@ IN: classes.algebra
 \r
 ARTICLE: "class-operations" "Class operations"\r
 "Set-theoretic operations on classes:"\r
+{ $subsection class= }\r
 { $subsection class< }\r
 { $subsection class<= }\r
 { $subsection class-and }\r
index ee687c2939abd1e49a7118eca546e4686582995b..0e4a3b56fde4218ae824fa275becf8547b513e39 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors classes classes.algebra words kernel
 kernel.private namespaces sequences math math.private
-combinators assocs ;
+combinators assocs quotations ;
 IN: classes.builtin
 
 SYMBOL: builtins
@@ -10,10 +10,14 @@ SYMBOL: builtins
 PREDICATE: builtin-class < class
     "metaclass" word-prop builtin-class eq? ;
 
-: type>class ( n -- class ) builtins get-global nth ;
-
 : class>type ( class -- n ) "type" word-prop ; foldable
 
+PREDICATE: lo-tag-class < builtin-class class>type 7 <= ;
+
+PREDICATE: hi-tag-class < builtin-class class>type 7 > ;
+
+: type>class ( n -- class ) builtins get-global nth ;
+
 : bootstrap-type>class ( n -- class ) builtins get nth ;
 
 M: hi-tag class hi-tag type>class ;
@@ -22,16 +26,20 @@ M: object class tag type>class ;
 
 M: builtin-class rank-class drop 0 ;
 
-: builtin-instance? ( object n -- ? )
-    #! 7 == tag-mask get
-    #! 3 == hi-tag tag-number
-    dup 7 fixnum<= [ swap tag eq? ] [
-        swap dup tag 3 eq?
-        [ hi-tag eq? ] [ 2drop f ] if
-    ] if ; inline
+GENERIC: define-builtin-predicate ( class -- )
+
+M: lo-tag-class define-builtin-predicate
+    dup class>type [ eq? ] curry [ tag ] prepend define-predicate ;
+
+M: hi-tag-class define-builtin-predicate
+    dup class>type [ eq? ] curry [ hi-tag ] prepend 1quotation
+    [ dup tag 3 eq? ] [ [ drop f ] if ] surround
+    define-predicate ;
+
+M: lo-tag-class instance? [ tag ] [ class>type ] bi* eq? ;
 
-M: builtin-class instance?
-    class>type builtin-instance? ;
+M: hi-tag-class instance?
+    over tag 3 eq? [ [ hi-tag ] [ class>type ] bi* eq? ] [ 2drop f ] if ;
 
 M: builtin-class (flatten-class) dup set ;
 
index fffb172204d7057a9f5f23fdc58b2d8746f72466..43018f6358afc25549f606a74e146f7076b76ad2 100644 (file)
@@ -12,7 +12,7 @@ PREDICATE: intersection-class < class
         [ drop t ]
     ] [
         unclip "predicate" word-prop swap [
-            "predicate" word-prop [ dup ] swap [ not ] 3append
+            "predicate" word-prop [ dup ] [ not ] surround
             [ drop f ]
         ] { } map>assoc alist>quot
     ] if-empty ;
index 6f8021f7336a2325f2b6500a1f6611aa52b712f0..9d748d665d9ae927c1dea776feed91c57efea654 100644 (file)
@@ -90,10 +90,10 @@ ERROR: bad-superclass class ;
         2drop f
     ] if ; inline
 
-: tuple-instance-1? ( object class -- ? )
-    swap dup tuple? [
-        layout-of 7 slot eq?
-    ] [ 2drop f ] if ; inline
+: tuple-predicate-quot/1 ( class -- quot )
+    #! Fast path for tuples with no superclass
+    [ ] curry [ layout-of 7 slot ] [ eq? ] surround 1quotation
+    [ dup tuple? ] [ [ drop f ] if ] surround ;
 
 : tuple-instance? ( object class offset -- ? )
     rot dup tuple? [
@@ -105,13 +105,16 @@ ERROR: bad-superclass class ;
 : layout-class-offset ( echelon -- n )
     2 * 5 + ;
 
+: tuple-predicate-quot ( class echelon -- quot )
+    layout-class-offset [ tuple-instance? ] 2curry ;
+
 : echelon-of ( class -- n )
     tuple-layout third ;
 
 : define-tuple-predicate ( class -- )
     dup dup echelon-of {
-        { 1 [ [ tuple-instance-1? ] curry ] }
-        [ layout-class-offset [ tuple-instance? ] 2curry ]
+        { 1 [ tuple-predicate-quot/1 ] }
+        [ tuple-predicate-quot ]
     } case define-predicate ;
 
 : class-size ( class -- n )
index 0acbdac8f832224a38c50b5b97449d5e4a2a3cf0..66f2da7191515435d9d05fd7eac3d53b06209015 100644 (file)
@@ -28,9 +28,6 @@ PREDICATE: math-class < class
 : math-class-max ( class1 class2 -- class )
     [ math-class<=> ] most ;
 
-: math-class-min ( class1 class2 -- class )
-    [ swap math-class<=> ] most ;
-
 : (math-upgrade) ( max class -- quot )
     dupd = [ drop [ ] ] [ "coercer" word-prop [ ] or ] if ;
 
@@ -83,7 +80,7 @@ M: math-combination perform-combination
     drop
     dup
     [
-        \ both-fixnums? ,
+        [ 2dup both-fixnums? ] %
         dup fixnum bootstrap-word dup math-method ,
         \ over [
             dup math-class? [
index dbdc6e0742b94fe76c4d3bacfa92bcf48de45162..5ed33009c099d37106c9d258ad092f0cad377705 100644 (file)
@@ -3,7 +3,7 @@
 USING: classes.private generic.standard.engines namespaces make
 arrays assocs sequences.private quotations kernel.private
 math slots.private math.private kernel accessors words
-layouts sorting sequences ;
+layouts sorting sequences combinators ;
 IN: generic.standard.engines.tag
 
 TUPLE: lo-tag-dispatch-engine methods ;
@@ -24,15 +24,21 @@ C: <lo-tag-dispatch-engine> lo-tag-dispatch-engine
 
 : sort-tags ( assoc -- alist ) >alist sort-keys reverse ;
 
+: tag-dispatch-test ( tag# -- quot )
+    picker [ tag ] append swap [ eq? ] curry append ;
+
+: tag-dispatch-quot ( alist -- quot )
+    [ default get ] dip
+    [ [ tag-dispatch-test ] dip ] assoc-map
+    alist>quot ;
+
 M: lo-tag-dispatch-engine engine>quot
     methods>> engines>quots*
     [ [ lo-tag-number ] dip ] assoc-map
     [
-        picker % [ tag ] % [
-            sort-tags linear-dispatch-quot
-        ] [
-            num-tags get direct-dispatch-quot
-        ] if-small? %
+        [ sort-tags tag-dispatch-quot ]
+        [ picker % [ tag ] % num-tags get direct-dispatch-quot ]
+        if-small? %
     ] [ ] make ;
 
 TUPLE: hi-tag-dispatch-engine methods ;
index 9f950aa36c9fc3a938b268d82cd2a8e6d3107c55..e1ab50cdcd8b340f09ed4d9dec29b0cb4f5fa696 100644 (file)
@@ -14,7 +14,7 @@ $nl
 }
 "The underlying sequence must implement a generic word:"
 { $subsection resize }
-{ $link "vectors" } ", " { $link "byte-vectors" } " and " { $link "sbufs" } " are implemented using the resizable sequence facility." ;
+{ $link "vectors" } " and " { $link "sbufs" } " are implemented using the resizable sequence facility." ;
 
 ABOUT: "growable"
 
index 474cf4c9d60b40b65ed3733ae53e487077a71987..8663f25a7032ba919833130355f5ff6f77486bfc 100644 (file)
@@ -40,7 +40,7 @@ TUPLE: hashtable
     0 >>count 0 >>deleted drop ; inline
 
 : reset-hash ( n hash -- )
-    swap <hash-array> >>array init-hash ;
+    swap <hash-array> >>array init-hash ; inline
 
 : (new-key@) ( key keys i -- keys n empty? )
     3dup swap array-nth dup ((empty)) eq? [
@@ -133,7 +133,7 @@ M: hashtable set-at ( value key hash -- )
 : push-unsafe ( elt seq -- )
     [ length ] keep
     [ underlying>> set-array-nth ]
-    [ [ 1+ ] dip (>>length) ]
+    [ [ 1 fixnum+fast { array-capacity } declare ] dip (>>length) ]
     2bi ; inline
 
 PRIVATE>
diff --git a/core/io/streams/byte-array/byte-array-docs.factor b/core/io/streams/byte-array/byte-array-docs.factor
deleted file mode 100644 (file)
index 7b27621..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-USING: help.syntax help.markup io byte-arrays quotations ;
-IN: io.streams.byte-array
-
-ABOUT: "io.streams.byte-array"
-
-ARTICLE: "io.streams.byte-array" "Byte-array streams"
-"Byte array streams:"
-{ $subsection <byte-reader> }
-{ $subsection <byte-writer> }
-"Utility combinators:"
-{ $subsection with-byte-reader }
-{ $subsection with-byte-writer } ;
-
-HELP: <byte-reader>
-{ $values { "byte-array" byte-array }
-    { "encoding" "an encoding descriptor" }
-    { "stream" "a new byte reader" } }
-{ $description "Creates an input stream reading from a byte array using an encoding." } ;
-
-HELP: <byte-writer>
-{ $values { "encoding" "an encoding descriptor" }
-    { "stream" "a new byte writer" } }
-{ $description "Creates an output stream writing data to a byte array using an encoding." } ;
-
-HELP: with-byte-reader
-{ $values { "encoding" "an encoding descriptor" }
-    { "quot" quotation } { "byte-array" byte-array } }
-{ $description "Calls the quotation in a new dynamic scope with " { $link input-stream } " rebound to an input stream for reading from a byte array using an encoding." } ;
-
-HELP: with-byte-writer
-{ $values  { "encoding" "an encoding descriptor" }
-    { "quot" quotation }
-    { "byte-array" byte-array } }
-{ $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to an output stream writing data to a byte array using an encoding." } ;
diff --git a/core/io/streams/byte-array/byte-array-tests.factor b/core/io/streams/byte-array/byte-array-tests.factor
deleted file mode 100644 (file)
index 77a9126..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-USING: tools.test io.streams.byte-array io.encodings.binary
-io.encodings.utf8 io kernel arrays strings ;
-
-[ B{ 1 2 3 } ] [ binary [ { 1 2 3 } write ] with-byte-writer ] unit-test
-[ B{ 1 2 3 } ] [ { 1 2 3 } binary [ 3 read ] with-byte-reader ] unit-test
-
-[ B{ BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 BIN: 11101111 BIN: 10000000 BIN: 10111111 BIN: 11011111 BIN: 10000000 CHAR: x } ]
-[ { BIN: 101111111000000111111 BIN: 1111000000111111 BIN: 11111000000 CHAR: x } utf8 [ write ] with-byte-writer ] unit-test
-[ { BIN: 101111111000000111111 } t ] [ { BIN: 11110101 BIN: 10111111 BIN: 10000000 BIN: 10111111 } utf8 <byte-reader> contents dup >array swap string? ] unit-test
diff --git a/core/io/streams/byte-array/byte-array.factor b/core/io/streams/byte-array/byte-array.factor
deleted file mode 100644 (file)
index 9d89c3d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-USING: byte-arrays byte-vectors kernel io.encodings io.streams.string
-sequences io namespaces io.encodings.private accessors ;
-IN: io.streams.byte-array
-
-: <byte-writer> ( encoding -- stream )
-    512 <byte-vector> swap <encoder> ;
-
-: with-byte-writer ( encoding quot -- byte-array )
-    [ <byte-writer> ] dip [ output-stream get ] compose with-output-stream*
-    dup encoder? [ stream>> ] when >byte-array ; inline
-
-: <byte-reader> ( byte-array encoding -- stream )
-    [ >byte-vector dup reverse-here ] dip <decoder> ;
-
-: with-byte-reader ( byte-array encoding quot -- )
-    [ <byte-reader> ] dip with-input-stream* ; inline
index 98dc0e50fad4dd06ed9c7ea44c45e832432a3581..564600d322bab63c3dd16fb3f62fdd56db3d6b75 100644 (file)
@@ -154,8 +154,11 @@ TUPLE: identity-tuple ;
 
 M: identity-tuple equal? 2drop f ;
 
+USE: math.private
 : = ( obj1 obj2 -- ? )
-    2dup eq? [ 2drop t ] [ equal? ] if ; inline
+    2dup eq? [ 2drop t ] [
+        2dup both-fixnums? [ 2drop f ] [ equal? ] if
+    ] if ; inline
 
 GENERIC: clone ( obj -- cloned )
 
index fcb1b65d80c466bd4dc57fd1b1dd83dba39c81e7..b229ea175da44d39b0bc6bf109d673b1041485a3 100644 (file)
@@ -40,11 +40,10 @@ M: fixnum bitnot fixnum-bitnot ;
 
 M: fixnum bit? neg shift 1 bitand 0 > ;
 
-: (fixnum-log2) ( accum n -- accum )
-    dup 1 number= [ drop ] [ [ 1+ ] [ 2/ ] bi* (fixnum-log2) ] if ;
-    inline recursive
+: fixnum-log2 ( x -- n )
+    0 swap [ dup 1 eq? not ] [ [ 1+ ] [ 2/ ] bi* ] [ ] while drop ;
 
-M: fixnum (log2) 0 swap (fixnum-log2) ;
+M: fixnum (log2) fixnum-log2 ;
 
 M: bignum >fixnum bignum>fixnum ;
 M: bignum >bignum ;
@@ -74,7 +73,7 @@ M: bignum /mod bignum/mod ;
 M: bignum bitand bignum-bitand ;
 M: bignum bitor bignum-bitor ;
 M: bignum bitxor bignum-bitxor ;
-M: bignum shift bignum-shift ;
+M: bignum shift >fixnum bignum-shift ;
 
 M: bignum bitnot bignum-bitnot ;
 M: bignum bit? bignum-bit? ;
index 5c53d99cff566a31f604fd4ae81bedd58b899e30..2434bf8ec6c7b29c7dcfd291510c94d3c5a9e484 100644 (file)
@@ -53,7 +53,7 @@ PRIVATE>
         "log2 expects positive inputs" throw
     ] [
         (log2)
-    ] if ; foldable
+    ] if ; inline
 
 : zero? ( x -- ? ) 0 number= ; inline
 : 1+ ( x -- y ) 1 + ; inline
@@ -103,14 +103,8 @@ M: float fp-infinity? ( float -- ? )
         drop f
     ] if ;
 
-: (next-power-of-2) ( i n -- n )
-    2dup >= [
-        drop
-    ] [
-        [ 1 shift ] dip (next-power-of-2)
-    ] if ;
-
-: next-power-of-2 ( m -- n ) 2 swap (next-power-of-2) ; foldable
+: next-power-of-2 ( m -- n )
+    dup 2 <= [ drop 2 ] [ 1- log2 1+ 2^ ] if ; inline
 
 : power-of-2? ( n -- ? )
     dup 0 <= [ drop f ] [ dup 1- bitand zero? ] if ; foldable
index 427c294759bb570d2836f3a3b20672232dd61ec3..36559095cba3902b824c842c39dd31231d4bfb45 100644 (file)
@@ -12,12 +12,12 @@ IN: namespaces
 
 PRIVATE>
 
-: namespace ( -- namespace ) namestack* peek ;
+: namespace ( -- namespace ) namestack* peek ; inline
 : namestack ( -- namestack ) namestack* clone ;
 : set-namestack ( namestack -- ) >vector 0 setenv ;
 : global ( -- g ) 21 getenv { hashtable } declare ; inline
 : init-namespaces ( -- ) global 1array set-namestack ;
-: get ( variable -- value ) namestack* assoc-stack ; flushable
+: get ( variable -- value ) namestack* assoc-stack ; inline
 : set ( value variable -- ) namespace set-at ;
 : on ( variable -- ) t swap set ; inline
 : off ( variable -- ) f swap set ; inline
@@ -28,7 +28,7 @@ PRIVATE>
 : inc ( variable -- ) 1 swap +@ ; inline
 : dec ( variable -- ) -1 swap +@ ; inline
 : bind ( ns quot -- ) swap >n call ndrop ; inline
-: counter ( variable -- n ) global [ dup inc get ] bind ;
+: counter ( variable -- n ) global [ 0 or 1+ dup ] change-at ;
 
 : make-assoc ( quot exemplar -- hash )
     20 swap new-assoc [ >n call ndrop ] keep ; inline
index 3f3af935b66eace173b3eafe986ac959e8d496c4..4586cfe34ec4614f055547815c2f6ca05c6ee073 100644 (file)
@@ -71,7 +71,7 @@ TUPLE: no-current-vocab ;
 
 : word-restarts ( name possibilities -- restarts )
     natural-sort
-    [ [ "Use the " swap vocabulary>> " vocabulary" 3append ] keep ] { } map>assoc
+    [ [ vocabulary>> "Use the " " vocabulary" surround ] keep ] { } map>assoc
     swap "Defer word in current vocabulary" swap 2array
     suffix ;
 
@@ -89,7 +89,7 @@ SYMBOL: auto-use?
         dup vocabulary>>
         [ (use+) ]
         [ amended-use get dup [ push ] [ 2drop ] if ]
-        [ "Added ``" swap "'' vocabulary to search path" 3append note. ]
+        [ "Added ``" "'' vocabulary to search path" surround note. ]
         tri
     ] [ create-in ] if ;
 
@@ -292,7 +292,7 @@ print-use-hook global [ [ ] or ] change-at
     ] with-compilation-unit ;
 
 : parse-file-restarts ( file -- restarts )
-    "Load " swap " again" 3append t 2array 1array ;
+    "Load " " again" surround t 2array 1array ;
 
 : parse-file ( file -- quot )
     [
index 08831579bb4c977fada07f422946c348f54a6970..0b3e0003ac90ec40ca9897a05a2e48185731d36c 100644 (file)
@@ -416,11 +416,6 @@ HELP: interleave
 { $description "Applies " { $snippet "quot" } " to each element in turn, also invoking " { $snippet "between" } " in-between each pair of elements." }
 { $example "USING: io sequences ;" "{ \"a\" \"b\" \"c\" } [ \"X\" write ] [ write ] interleave" "aXbXc" } ;
 
-HELP: cache-nth
-{ $values { "i" "a non-negative integer" } { "seq" "a mutable sequence" } { "quot" { $quotation "( i -- elt )" } } { "elt" object } }
-{ $description "If the sequence does not contain at least " { $snippet "i" } " elements or if the " { $snippet "i" } "th element of the sequence is " { $link f } ", calls the quotation to produce a new value, and stores it back into the sequence. Otherwise, this word outputs the " { $snippet "i" } "th element of the sequence." }
-{ $side-effects "seq" } ;
-
 HELP: index
 { $values { "obj" object } { "seq" sequence } { "n" "an index" } }
 { $description "Outputs the index of the first element in the sequence equal to " { $snippet "obj" } ". If no element is found, outputs " { $link f } "." } ;
@@ -1497,7 +1492,6 @@ ARTICLE: "sequences-destructive" "Destructive operations"
 "Changing elements:"
 { $subsection change-each }
 { $subsection change-nth }
-{ $subsection cache-nth }
 "Deleting elements:"
 { $subsection delete }
 { $subsection delq }
index 0d795d453aa44a5b6c6acd2d1838204fb41463e0..dcca525e2bbf1626ac037a1e2d347778e672adaf 100644 (file)
@@ -190,16 +190,6 @@ unit-test
 
 [ V{ "a" "b" } V{ } ] [ { "X" "a" "b" } { "X" } drop-prefix [ >vector ] bi@ ] unit-test
 
-[ 1 4 9 16 16 V{ f 1 4 9 16 } ] [
-    V{ } clone "cache-test" set
-    1 "cache-test" get [ sq ] cache-nth
-    2 "cache-test" get [ sq ] cache-nth
-    3 "cache-test" get [ sq ] cache-nth
-    4 "cache-test" get [ sq ] cache-nth
-    4 "cache-test" get [ "wrong" ] cache-nth
-    "cache-test" get
-] unit-test
-
 [ 1 ] [ 0.5 { 1 2 3 } nth ] unit-test
 
 ! Pathological case
index 3461266081d9de2ac0d1529500d0656fe78c0cea..8c9eff94f514d2dfc1f52d3c915f478c0b74bd15 100644 (file)
@@ -523,13 +523,6 @@ PRIVATE>
 : harvest ( seq -- newseq )
     [ empty? not ] filter ;
 
-: cache-nth ( i seq quot -- elt )
-    2over ?nth dup [
-        [ 3drop ] dip
-    ] [
-        drop swap [ over [ call dup ] dip ] dip set-nth
-    ] if ; inline
-
 : mismatch ( seq1 seq2 -- i )
     [ min-length ] 2keep
     [ 2nth-unsafe = not ] 2curry
@@ -835,12 +828,35 @@ PRIVATE>
 
 : supremum ( seq -- n ) dup first [ max ] reduce ;
 
-: flip ( matrix -- newmatrix )
-    dup empty? [
-        dup [ length ] map infimum
-        swap [ [ nth-unsafe ] with { } map-as ] curry { } map-as
-    ] unless ;
-
 : sigma ( seq quot -- n ) [ + ] compose 0 swap reduce ; inline
 
 : count ( seq quot -- n ) [ 1 0 ? ] compose sigma ; inline
+
+! We hand-optimize flip to such a degree because type hints
+! cannot express that an array is an array of arrays yet, and
+! this word happens to be performance-critical since the compiler
+! itself uses it. Optimizing it like this reduced compile time.
+<PRIVATE
+
+: generic-flip ( matrix -- newmatrix )
+    [ dup first length [ length min ] reduce ] keep
+    [ [ nth-unsafe ] with { } map-as ] curry { } map-as ; inline
+
+USE: arrays
+
+: array-length ( array -- len )
+    { array } declare length>> ;
+
+: array-flip ( matrix -- newmatrix )
+    [ dup first array-length [ array-length min ] reduce ] keep
+    [ [ array-nth ] with { } map-as ] curry { } map-as ;
+
+PRIVATE>
+
+: flip ( matrix -- newmatrix )
+    dup empty? [
+        dup array? [
+            dup [ array? ] all?
+            [ array-flip ] [ generic-flip ] if
+        ] [ generic-flip ] if
+    ] unless ;
index 35aa49d0534c6ede10b45bba61a6395d87b469d6..187db02c5cb2e0dc8d6d845f9f60ac5723d6e032 100644 (file)
@@ -50,7 +50,7 @@ PREDICATE: writer < word "writer" word-prop ;
     define-typecheck ;
 
 : writer-word ( name -- word )
-    "(>>" swap ")" 3append (( value object -- )) create-accessor
+    "(>>" ")" surround (( value object -- )) create-accessor
     dup t "writer" set-word-prop ;
 
 ERROR: bad-slot-value value class ;
index c951750b342a6cc09f9316bd2840f3ceaa0cc428..0b7d9d008f0bce0138e14ebb66957e0b8871c6eb 100644 (file)
@@ -1,14 +1,13 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien arrays byte-arrays byte-vectors
-definitions generic hashtables kernel math namespaces parser
-lexer sequences strings strings.parser sbufs vectors
-words quotations io assocs splitting classes.tuple
-generic.standard generic.math generic.parser classes io.files
-vocabs classes.parser classes.union
-classes.intersection classes.mixin classes.predicate
-classes.singleton classes.tuple.parser compiler.units
-combinators effects.parser slots ;
+USING: accessors alien arrays byte-arrays definitions generic
+hashtables kernel math namespaces parser lexer sequences strings
+strings.parser sbufs vectors words quotations io assocs
+splitting classes.tuple generic.standard generic.math
+generic.parser classes io.files vocabs classes.parser
+classes.union classes.intersection classes.mixin
+classes.predicate classes.singleton classes.tuple.parser
+compiler.units combinators effects.parser slots ;
 IN: bootstrap.syntax
 
 ! These words are defined as a top-level form, instead of with
@@ -81,7 +80,6 @@ IN: bootstrap.syntax
     "{" [ \ } [ >array ] parse-literal ] define-syntax
     "V{" [ \ } [ >vector ] parse-literal ] define-syntax
     "B{" [ \ } [ >byte-array ] parse-literal ] define-syntax
-    "BV{" [ \ } [ >byte-vector ] parse-literal ] define-syntax
     "H{" [ \ } [ >hashtable ] parse-literal ] define-syntax
     "T{" [ parse-tuple-literal parsed ] define-syntax
     "W{" [ \ } [ first <wrapper> ] parse-literal ] define-syntax
index b4cade44db6d0e2ac567251e6c5bce27ab38ce62..a6bfef71d016a656b1abe56bb483970eb62c3280 100644 (file)
@@ -8,7 +8,7 @@ TUPLE: vector
 { underlying array }
 { length array-capacity } ;
 
-: <vector> ( n -- vector ) f <array> 0 vector boa ; inline
+: <vector> ( n -- vector ) 0 <array> 0 vector boa ; inline
 
 : >vector ( seq -- vector ) V{ } clone-like ;
 
index b36f8be6775c5eac3a0cfdf1e5308f103714bd5a..8c144b03a2bac8f3ac3b7eb96d80ce0832b8050a 100644 (file)
@@ -239,7 +239,7 @@ ERROR: bad-create name vocab ;
     dup [ 2nip ] [ drop <word> dup reveal ] if ;
 
 : constructor-word ( name vocab -- word )
-    [ "<" swap ">" 3append ] dip create ;
+    [ "<" ">" surround ] dip create ;
 
 PREDICATE: parsing-word < word "parsing" word-prop ;
 
index 838bb08b92b5bdc0d722b042aad19380bafe2638..9489798b9b379175b505ca5b3c1a264511d034ad 100755 (executable)
@@ -16,7 +16,7 @@ IN: combinators.lib.tests
 
 [ { "foo" "xbarx" } ]
 [
-    { "oof" "bar" } { [ reverse ] [ "x" swap "x" 3append ] } parallel-call
+    { "oof" "bar" } { [ reverse ] [ "x" dup surround ] } parallel-call
 ] unit-test
 
 { 1 1 } [
index 25e67d01ce1e3687e759dd91e45e75be539bc8e0..9d5c65aa94da179f01580122d64af8dadcccc793 100644 (file)
@@ -8,5 +8,3 @@ IN: crypto.barrett
     #! size = word size in bits (8, 16, 32, 64, ...)
     [ [ log2 1+ ] [ / 2 * ] bi* ]
     [ 2^ rot ^ swap /i ] 2bi ;
-
-
index d98e8a97988b1c47b20de749313e75d4cfc5ea2e..b480c18913200d47f76145dd31222cfc68a8c0a2 100755 (executable)
@@ -1,3 +1,5 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
 USING: arrays combinators checksums checksums.md5
 checksums.sha1 checksums.md5.private io io.binary io.files
 io.streams.byte-array kernel math math.vectors memoize sequences
index 8fdb807c6a7a87df104c10f9c939811e55fa9da4..b2a59a1851630525fb4a19cdc06efd3404464f4f 100644 (file)
@@ -1,3 +1,5 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math threads system calendar ;
 IN: crypto.timing
 
index 6e3a605f5cef362c0e5344f891c7fc1cfa72040d..662881f8cc4dc61a511d02067d6e16f64566ba07 100644 (file)
@@ -8,5 +8,5 @@ IN: crypto.xor
 ERROR: empty-xor-key ;
 
 : xor-crypt ( seq key -- seq' )
-    dup empty? [ empty-xor-key ] when
+    [ empty-xor-key ] when-empty
     [ dup length ] dip '[ _ mod-nth bitxor ] 2map ;
diff --git a/extra/hardware-info/authors.txt b/extra/hardware-info/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/backend/authors.txt b/extra/hardware-info/backend/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/backend/backend.factor b/extra/hardware-info/backend/backend.factor
deleted file mode 100644 (file)
index 283fea6..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-USING: system ;
-IN: hardware-info.backend
-
-HOOK: cpus os ( -- n )
-HOOK: cpu-mhz os ( -- n )
-HOOK: memory-load os ( -- n )
-HOOK: physical-mem os ( -- n )
-HOOK: available-mem os ( -- n )
-HOOK: total-page-file os ( -- n )
-HOOK: available-page-file os ( -- n )
-HOOK: total-virtual-mem os ( -- n )
-HOOK: available-virtual-mem os ( -- n )
-HOOK: available-virtual-extended-mem os ( -- n )
diff --git a/extra/hardware-info/hardware-info.factor b/extra/hardware-info/hardware-info.factor
deleted file mode 100755 (executable)
index cc345c7..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-USING: alien.syntax kernel math prettyprint io math.parser
-combinators vocabs.loader hardware-info.backend system ;
-IN: hardware-info
-
-: write-unit ( x n str -- )
-    [ 2^ /f number>string write bl ] [ write ] bi* ;
-
-: kb ( x -- ) 10 "kB" write-unit ;
-: megs ( x -- ) 20 "MB" write-unit ;
-: gigs ( x -- ) 30 "GB" write-unit ;
-: ghz ( x -- ) 1000000000 /f number>string write bl "GHz" write ;
-
-<< {
-    { [ os windows? ] [ "hardware-info.windows" ] }
-    { [ os linux? ] [ "hardware-info.linux" ] }
-    { [ os macosx? ] [ "hardware-info.macosx" ] }
-    [ f ]
-} cond [ require ] when* >>
-
-: hardware-report. ( -- )
-    "CPUs: " write cpus number>string write nl
-    "CPU Speed: " write cpu-mhz ghz nl
-    "Physical RAM: " write physical-mem megs nl ;
diff --git a/extra/hardware-info/linux/authors.txt b/extra/hardware-info/linux/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/linux/linux.factor b/extra/hardware-info/linux/linux.factor
deleted file mode 100644 (file)
index ba0cb0c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-USING: unix alien alien.c-types kernel math sequences strings
-io.unix.backend splitting ;
-IN: hardware-info.linux
-
-: (uname) ( buf -- int )
-    "int" f "uname" { "char*" } alien-invoke ;
-
-: uname ( -- seq )
-    65536 "char" <c-array> [ (uname) io-error ] keep
-    "\0" split harvest [ >string ] map
-    6 "" pad-right ;
-
-: sysname ( -- string ) uname first ;
-: nodename ( -- string ) uname second ;
-: release ( -- string ) uname third ;
-: version ( -- string ) uname fourth ;
-: machine ( -- string ) uname 4 swap nth ;
-: domainname ( -- string ) uname 5 swap nth ;
-
-: kernel-version ( -- seq )
-    release ".-" split harvest 5 "" pad-right ;
diff --git a/extra/hardware-info/linux/tags.txt b/extra/hardware-info/linux/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/hardware-info/macosx/authors.txt b/extra/hardware-info/macosx/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/macosx/macosx.factor b/extra/hardware-info/macosx/macosx.factor
deleted file mode 100644 (file)
index e3c604f..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-USING: alien alien.c-types alien.strings alien.syntax
-byte-arrays kernel namespaces sequences unix
-hardware-info.backend system io.unix.backend io.encodings.ascii
-;
-IN: hardware-info.macosx
-
-! See /usr/include/sys/sysctl.h for constants
-
-LIBRARY: libc
-FUNCTION: int sysctl ( int* name, uint namelen, void* oldp, size_t* oldlenp, void* newp, size_t newlen ) ;
-
-: make-int-array ( seq -- byte-array )
-    [ <int> ] map concat ;
-
-: (sysctl-query) ( name namelen oldp oldlenp -- oldp )
-    over [ f 0 sysctl io-error ] dip ;
-
-: sysctl-query ( seq n -- byte-array )
-    [ [ make-int-array ] [ length ] bi ] dip
-    [ <byte-array> ] [ <uint> ] bi (sysctl-query) ;
-
-: sysctl-query-string ( seq -- n )
-    4096 sysctl-query ascii malloc-string ;
-
-: sysctl-query-uint ( seq -- n )
-    4 sysctl-query *uint ;
-
-: sysctl-query-ulonglong ( seq -- n )
-    8 sysctl-query *ulonglong ;
-
-: machine ( -- str ) { 6 1 } sysctl-query-string ;
-: model ( -- str ) { 6 2 } sysctl-query-string ;
-M: macosx cpus ( -- n ) { 6 3 } sysctl-query-uint ;
-: byte-order ( -- n ) { 6 4 } sysctl-query-uint ;
-M: macosx physical-mem ( -- n ) { 6 5 } sysctl-query-uint ;
-: user-mem ( -- n ) { 6 6 } sysctl-query-uint ;
-: page-size ( -- n ) { 6 7 } sysctl-query-uint ;
-: disknames ( -- n ) { 6 8 } 8 sysctl-query ;
-: diskstats ( -- n ) { 6 9 } 8 sysctl-query ;
-: epoch ( -- n ) { 6 10 } sysctl-query-uint ;
-: floating-point ( -- n ) { 6 11 } sysctl-query-uint ;
-: machine-arch ( -- n ) { 6 12 } sysctl-query-string ;
-: vector-unit ( -- n ) { 6 13 } sysctl-query-uint ;
-: bus-frequency ( -- n ) { 6 14 } sysctl-query-uint ;
-M: macosx cpu-mhz ( -- n ) { 6 15 } sysctl-query-uint ;
-: cacheline-size ( -- n ) { 6 16 } sysctl-query-uint ;
-: l1-icache-size ( -- n ) { 6 17 } sysctl-query-uint ;
-: l1-dcache-size ( -- n ) { 6 18 } sysctl-query-uint ;
-: l2-cache-settings ( -- n ) { 6 19 } sysctl-query-uint ;
-: l2-cache-size ( -- n ) { 6 20 } sysctl-query-uint ;
-: l3-cache-settings ( -- n ) { 6 21 } sysctl-query-uint ;
-: l3-cache-size ( -- n ) { 6 22 } sysctl-query-uint ;
-: tb-frequency ( -- n ) { 6 23 } sysctl-query-uint ;
-: mem-size ( -- n ) { 6 24 } sysctl-query-ulonglong ;
-: available-cpus ( -- n ) { 6 25 } sysctl-query-uint ;
-
diff --git a/extra/hardware-info/macosx/tags.txt b/extra/hardware-info/macosx/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/hardware-info/summary.txt b/extra/hardware-info/summary.txt
deleted file mode 100644 (file)
index 404da13..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Query the operating system for hardware information in a platform-independent way
diff --git a/extra/hardware-info/windows/authors.txt b/extra/hardware-info/windows/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/windows/ce/authors.txt b/extra/hardware-info/windows/ce/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/windows/ce/ce.factor b/extra/hardware-info/windows/ce/ce.factor
deleted file mode 100755 (executable)
index 6537661..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-USING: alien.c-types hardware-info kernel math namespaces
-windows windows.kernel32 hardware-info.backend system ;
-IN: hardware-info.windows.ce
-
-: memory-status ( -- MEMORYSTATUS )
-    "MEMORYSTATUS" <c-object>
-    "MEMORYSTATUS" heap-size over set-MEMORYSTATUS-dwLength
-    dup GlobalMemoryStatus ;
-
-M: wince cpus ( -- n ) 1 ;
-
-M: wince memory-load ( -- n )
-    memory-status MEMORYSTATUS-dwMemoryLoad ;
-
-M: wince physical-mem ( -- n )
-    memory-status MEMORYSTATUS-dwTotalPhys ;
-
-M: wince available-mem ( -- n )
-    memory-status MEMORYSTATUS-dwAvailPhys ;
-
-M: wince total-page-file ( -- n )
-    memory-status MEMORYSTATUS-dwTotalPageFile ;
-
-M: wince available-page-file ( -- n )
-    memory-status MEMORYSTATUS-dwAvailPageFile ;
-
-M: wince total-virtual-mem ( -- n )
-    memory-status MEMORYSTATUS-dwTotalVirtual ;
-
-M: wince available-virtual-mem ( -- n )
-    memory-status MEMORYSTATUS-dwAvailVirtual ;
diff --git a/extra/hardware-info/windows/ce/tags.txt b/extra/hardware-info/windows/ce/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/hardware-info/windows/nt/authors.txt b/extra/hardware-info/windows/nt/authors.txt
deleted file mode 100755 (executable)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/extra/hardware-info/windows/nt/nt.factor b/extra/hardware-info/windows/nt/nt.factor
deleted file mode 100755 (executable)
index 6274e79..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-USING: alien alien.c-types alien.strings
-kernel libc math namespaces hardware-info.backend
-hardware-info.windows windows windows.advapi32
-windows.kernel32 system byte-arrays ;
-IN: hardware-info.windows.nt
-
-M: winnt cpus ( -- n )
-    system-info SYSTEM_INFO-dwNumberOfProcessors ;
-
-: memory-status ( -- MEMORYSTATUSEX )
-    "MEMORYSTATUSEX" <c-object>
-    "MEMORYSTATUSEX" heap-size over set-MEMORYSTATUSEX-dwLength
-    dup GlobalMemoryStatusEx win32-error=0/f ;
-
-M: winnt memory-load ( -- n )
-    memory-status MEMORYSTATUSEX-dwMemoryLoad ;
-
-M: winnt physical-mem ( -- n )
-    memory-status MEMORYSTATUSEX-ullTotalPhys ;
-
-M: winnt available-mem ( -- n )
-    memory-status MEMORYSTATUSEX-ullAvailPhys ;
-
-M: winnt total-page-file ( -- n )
-    memory-status MEMORYSTATUSEX-ullTotalPageFile ;
-
-M: winnt available-page-file ( -- n )
-    memory-status MEMORYSTATUSEX-ullAvailPageFile ;
-
-M: winnt total-virtual-mem ( -- n )
-    memory-status MEMORYSTATUSEX-ullTotalVirtual ;
-
-M: winnt available-virtual-mem ( -- n )
-    memory-status MEMORYSTATUSEX-ullAvailVirtual ;
-
-: computer-name ( -- string )
-    MAX_COMPUTERNAME_LENGTH 1+
-    [ <byte-array> dup ] keep <uint>
-    GetComputerName win32-error=0/f alien>native-string ;
-: username ( -- string )
-    UNLEN 1+
-    [ <byte-array> dup ] keep <uint>
-    GetUserName win32-error=0/f alien>native-string ;
diff --git a/extra/hardware-info/windows/nt/tags.txt b/extra/hardware-info/windows/nt/tags.txt
deleted file mode 100644 (file)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/hardware-info/windows/tags.txt b/extra/hardware-info/windows/tags.txt
deleted file mode 100755 (executable)
index 6bf6830..0000000
+++ /dev/null
@@ -1 +0,0 @@
-unportable
diff --git a/extra/hardware-info/windows/windows.factor b/extra/hardware-info/windows/windows.factor
deleted file mode 100755 (executable)
index d3ebe87..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-USING: alien alien.c-types kernel libc math namespaces
-windows windows.kernel32 windows.advapi32
-words combinators vocabs.loader hardware-info.backend
-system alien.strings ;
-IN: hardware-info.windows
-
-: system-info ( -- SYSTEM_INFO )
-    "SYSTEM_INFO" <c-object> [ GetSystemInfo ] keep ;
-
-: page-size ( -- n )
-    system-info SYSTEM_INFO-dwPageSize ;
-
-! 386, 486, 586, 2200 (IA64), 8664 (AMD_X8664)
-: processor-type ( -- n )
-    system-info SYSTEM_INFO-dwProcessorType ;
-
-! 0 = x86, 6 = Intel Itanium, 9 = x64 (AMD or Intel), 10 = WOW64, 0xffff = Unk
-: processor-architecture ( -- n )
-    system-info SYSTEM_INFO-dwOemId HEX: ffff0000 bitand ;
-
-: os-version ( -- os-version )
-    "OSVERSIONINFO" <c-object>
-    "OSVERSIONINFO" heap-size over set-OSVERSIONINFO-dwOSVersionInfoSize
-    dup GetVersionEx win32-error=0/f ;
-
-: windows-major ( -- n )
-    os-version OSVERSIONINFO-dwMajorVersion ;
-
-: windows-minor ( -- n )
-    os-version OSVERSIONINFO-dwMinorVersion ;
-
-: windows-build# ( -- n )
-    os-version OSVERSIONINFO-dwBuildNumber ;
-
-: windows-platform-id ( -- n )
-    os-version OSVERSIONINFO-dwPlatformId ;
-
-: windows-service-pack ( -- string )
-    os-version OSVERSIONINFO-szCSDVersion alien>native-string ;
-
-: feature-present? ( n -- ? )
-    IsProcessorFeaturePresent zero? not ;
-
-: sse2? ( -- ? )
-    PF_XMMI64_INSTRUCTIONS_AVAILABLE feature-present? ;
-
-: sse3? ( -- ? )
-    PF_SSE3_INSTRUCTIONS_AVAILABLE feature-present? ;
-
-: <u16-string-object> ( n -- obj )
-    "ushort" <c-array> ;
-
-: get-directory ( word -- str )
-    [ MAX_UNICODE_PATH [ <u16-string-object> ] keep dupd ] dip
-    execute win32-error=0/f alien>native-string ; inline
-
-: windows-directory ( -- str )
-    \ GetWindowsDirectory get-directory ;
-
-: system-directory ( -- str )
-    \ GetSystemDirectory get-directory ;
-
-: system-windows-directory ( -- str )
-    \ GetSystemWindowsDirectory get-directory ;
-
-<<
-{
-    { [ os wince? ] [ "hardware-info.windows.ce" ] }
-    { [ os winnt? ] [ "hardware-info.windows.nt" ] }
-} cond require >>
index 976a5ba91f6ca8fdf9e108b7bf614f5d2af4639d..2f414d2aa537614c5ac03d4eb8871ee332981d89 100644 (file)
@@ -16,10 +16,10 @@ IN: html.parser.utils
     [ ?head drop ] [ ?tail drop ] bi ;
 
 : single-quote ( str -- newstr )
-    "'" swap "'" 3append ;
+    "'" dup surround ;
 
 : double-quote ( str -- newstr )
-    "\"" swap "\"" 3append ;
+    "\"" dup surround ;
 
 : quote ( str -- newstr )
     CHAR: ' over member?
index 61c5da6bca2147376e4f2e251d4a00be4466e1aa..0e3d48fe5bace99e55fa3e192e3a477f0fff4c2e 100755 (executable)
@@ -9,14 +9,12 @@ combinators.short-circuit fry qualified ;
 RENAME: _ fry => __
 IN: inverse
 
-TUPLE: fail ;
-: fail ( -- * ) \ fail new throw ;
+ERROR: fail ;
 M: fail summary drop "Unification failed" ;
 
 : assure ( ? -- ) [ fail ] unless ;
 
-: =/fail ( obj1 obj2 -- )
-    = assure ;
+: =/fail ( obj1 obj2 -- ) = assure ;
 
 ! Inverse of a quotation
 
@@ -26,25 +24,26 @@ M: fail summary drop "Unification failed" ;
     pick 1quotation 3array "math-inverse" set-word-prop ;
 
 : define-pop-inverse ( word n quot -- )
-    >r dupd "pop-length" set-word-prop r>
+    [ dupd "pop-length" set-word-prop ] dip
     "pop-inverse" set-word-prop ;
 
-TUPLE: no-inverse word ;
-: no-inverse ( word -- * ) \ no-inverse new throw ;
+ERROR: no-inverse word ;
 M: no-inverse summary
     drop "The word cannot be used in pattern matching" ;
 
+ERROR: bad-math-inverse ;
+
 : next ( revquot -- revquot* first )
-    [ "Badly formed math inverse" throw ]
+    [ bad-math-inverse ]
     [ unclip-slice ] if-empty ;
 
 : constant-word? ( word -- ? )
     stack-effect
-    [ out>> length 1 = ] keep
-    in>> length 0 = and ;
+    [ out>> length 1 = ]
+    [ in>> empty? ] bi and ;
 
 : assure-constant ( constant -- quot )
-    dup word? [ "Badly formed math inverse" throw ] when 1quotation ;
+    dup word? [ bad-math-inverse ] when 1quotation ;
 
 : swap-inverse ( math-inverse revquot -- revquot* quot )
     next assure-constant rot second '[ @ swap @ ] ;
@@ -55,8 +54,7 @@ M: no-inverse summary
 : ?word-prop ( word/object name -- value/f )
     over word? [ word-prop ] [ 2drop f ] if ;
 
-: undo-literal ( object -- quot )
-    [ =/fail ] curry ;
+: undo-literal ( object -- quot ) [ =/fail ] curry ;
 
 PREDICATE: normal-inverse < word "inverse" word-prop ;
 PREDICATE: math-inverse < word "math-inverse" word-prop ;
@@ -65,13 +63,13 @@ UNION: explicit-inverse normal-inverse math-inverse pop-inverse ;
 
 : enough? ( stack word -- ? )
     dup deferred? [ 2drop f ] [
-        [ >r length r> 1quotation infer in>> >= ]
+        [ [ length ] dip 1quotation infer in>> >= ]
         [ 3drop f ] recover
     ] if ;
 
 : fold-word ( stack word -- stack )
     2dup enough?
-    [ 1quotation with-datastack ] [ >r % r> , { } ] if ;
+    [ 1quotation with-datastack ] [ [ % ] dip , { } ] if ;
 
 : fold ( quot -- folded-quot )
     [ { } swap [ fold-word ] each % ] [ ] make ; 
@@ -95,13 +93,15 @@ UNION: explicit-inverse normal-inverse math-inverse pop-inverse ;
         throw
     ] recover ;
 
+ERROR: undefined-inverse ;
+
 GENERIC: inverse ( revquot word -- revquot* quot )
 
 M: object inverse undo-literal ;
 
 M: symbol inverse undo-literal ;
 
-M: word inverse drop "Inverse is undefined" throw ;
+M: word inverse undefined-inverse ;
 
 M: normal-inverse inverse
     "inverse" word-prop ;
@@ -112,8 +112,8 @@ M: math-inverse inverse
     [ drop swap-inverse ] [ pull-inverse ] if ;
 
 M: pop-inverse inverse
-    [ "pop-length" word-prop cut-slice swap >quotation ] keep
-    "pop-inverse" word-prop compose call ;
+    [ "pop-length" word-prop cut-slice swap >quotation ]
+    [ "pop-inverse" word-prop ] bi compose call ;
 
 : (undo) ( revquot -- )
     [ unclip-slice inverse % (undo) ] unless-empty ;
@@ -129,7 +129,7 @@ MACRO: undo ( quot -- ) [undo] ;
 \ dup [ [ =/fail ] keep ] define-inverse
 \ 2dup [ over =/fail over =/fail ] define-inverse
 \ 3dup [ pick =/fail pick =/fail pick =/fail ] define-inverse
-\ pick [ >r pick r> =/fail ] define-inverse
+\ pick [ [ pick ] dip =/fail ] define-inverse
 \ tuck [ swapd [ =/fail ] keep ] define-inverse
 
 \ not [ not ] define-inverse
@@ -151,9 +151,12 @@ MACRO: undo ( quot -- ) [undo] ;
 \ sq [ sqrt ] define-inverse
 \ sqrt [ sq ] define-inverse
 
+ERROR: missing-literal ;
+
 : assert-literal ( n -- n )
-    dup [ word? ] keep symbol? not and
-    [ "Literal missing in pattern matching" throw ] when ;
+    dup
+    [ word? ] [ symbol? not ] bi and
+    [ missing-literal ] when ;
 \ + [ - ] [ - ] define-math-inverse
 \ - [ + ] [ - ] define-math-inverse
 \ * [ / ] [ / ] define-math-inverse
@@ -162,7 +165,7 @@ MACRO: undo ( quot -- ) [undo] ;
 
 \ ? 2 [
     [ assert-literal ] bi@
-    [ swap >r over = r> swap [ 2drop f ] [ = [ t ] [ fail ] if ] if ]
+    [ swap [ over = ] dip swap [ 2drop f ] [ = [ t ] [ fail ] if ] if ]
     2curry
 ] define-pop-inverse
 
@@ -217,7 +220,7 @@ DEFER: _
     dup wrapper? [ wrapped>> ] when ;
 
 : boa-inverse ( class -- quot )
-    [ deconstruct-pred ] keep slot-readers compose ;
+    [ deconstruct-pred ] [ slot-readers ] bi compose ;
 
 \ boa 1 [ ?wrapped boa-inverse ] define-pop-inverse
 
@@ -232,7 +235,7 @@ DEFER: _
 
 : recover-fail ( try fail -- )
     [ drop call ] [
-        >r nip r> dup fail?
+        [ nip ] dip dup fail?
         [ drop call ] [ nip throw ] if
     ] recover ; inline
 
@@ -243,12 +246,11 @@ DEFER: _
     in>> [ ndrop f ] curry [ recover-fail ] curry ;
 
 : [matches?] ( quot -- undoes?-quot )
-    [undo] dup infer [ true-out ] keep false-recover curry ;
+    [undo] dup infer [ true-out ] [ false-recover ] bi curry ;
 
 MACRO: matches? ( quot -- ? ) [matches?] ;
 
-TUPLE: no-match ;
-: no-match ( -- * ) \ no-match new throw ;
+ERROR: no-match ;
 M: no-match summary drop "Fall through in switch" ;
 
 : recover-chain ( seq -- quot )
@@ -256,7 +258,7 @@ M: no-match summary drop "Fall through in switch" ;
 
 : [switch]  ( quot-alist -- quot )
     [ dup quotation? [ [ ] swap 2array ] when ] map
-    reverse [ >r [undo] r> compose ] { } assoc>map
+    reverse [ [ [undo] ] dip compose ] { } assoc>map
     recover-chain ;
 
 MACRO: switch ( quot-alist -- ) [switch] ;
index bea9bf37b1527d3b9857c4a67e98da8162789734..8054dc8075665a4b72e873d087a13bb6e2f6a6b6 100755 (executable)
@@ -90,11 +90,11 @@ M: end-of-names >>command-parameters ( names-reply params -- names-reply )
     first2 [ >>who ] [ >>channel ] bi* ;
 
 M: mode >>command-parameters ( mode params -- mode )
-    dup length 3 = [
-        first3 [ >>name ] [ >>mode ] [ >>parameter ] tri*
-    ] [
-        first2 [ >>name ] [ >>mode ] bi*
-    ] if ;
+    dup length {
+        { 3 [ first3 [ >>name ] [ >>mode ] [ >>parameter ] tri* ] }
+        { 2 [ first2 [ >>name ] [ >>mode ] bi* ] }
+        [ drop first >>name dup trailing>> >>mode ]
+    } case ;
 
 PRIVATE>
 
@@ -135,12 +135,12 @@ M: irc-message irc-message>server-line ( irc-message -- string )
 
 : copy-message-in ( command irc-message -- command )
     {
-        [ parameters>> [ >>parameters ] [ >>command-parameters ] bi ]
         [ line>>      >>line ]
         [ prefix>>    >>prefix ]
         [ command>>   >>command ]
         [ trailing>>  >>trailing ]
         [ timestamp>> >>timestamp ]
+        [ parameters>> [ >>parameters ] [ >>command-parameters ] bi ]
     } cleave ;
 
 PRIVATE>
index b96d3e1bdc3ada1173d99dfe73a0ff2730306e0c..fd64e9a07e7355b6839fc91a440d3f532e626ef9 100755 (executable)
@@ -9,7 +9,7 @@ USING: accessors kernel threads combinators concurrency.mailboxes
        ui.gadgets.tabs ui.gadgets.grids ui.gadgets.packs ui.gadgets.labels\r
        io io.styles namespaces calendar calendar.format models continuations\r
        irc.client irc.client.private irc.messages\r
-       irc.ui.commandparser irc.ui.load vocabs.loader ;\r
+       irc.ui.commandparser irc.ui.load vocabs.loader classes prettyprint ;\r
 \r
 RENAME: join sequences => sjoin\r
 \r
@@ -30,6 +30,7 @@ TUPLE: irc-tab < frame chat client window ;
     foreground associate format ;\r
 : dark-red T{ rgba f 0.5 0.0 0.0 1 } ;\r
 : dark-green T{ rgba f 0.0 0.5 0.0 1 } ;\r
+: dark-blue T{ rgba f 0.0 0.0 0.5 1 } ;\r
 \r
 : dot-or-parens ( string -- string )\r
     [ "." ]\r
@@ -41,14 +42,14 @@ M: ping write-irc
     drop "* Ping" blue write-color ;\r
 \r
 M: privmsg write-irc\r
-    "<" blue write-color\r
+    "<" dark-blue write-color\r
     [ irc-message-sender write ] keep\r
-    "> " blue write-color\r
+    "> " dark-blue write-color\r
     trailing>> write ;\r
 \r
 M: notice write-irc\r
-    [ type>> blue write-color ] keep\r
-    ": " blue write-color\r
+    [ type>> dark-blue write-color ] keep\r
+    ": " dark-blue write-color\r
     trailing>> write ;\r
 \r
 TUPLE: own-message message nick timestamp ;\r
@@ -57,9 +58,9 @@ TUPLE: own-message message nick timestamp ;
     now own-message boa ;\r
 \r
 M: own-message write-irc\r
-    "<" blue write-color\r
+    "<" dark-blue write-color\r
     [ nick>> bold font-style associate format ] keep\r
-    "> " blue write-color\r
+    "> " dark-blue write-color\r
     message>> write ;\r
 \r
 M: join write-irc\r
@@ -87,26 +88,23 @@ M: kick write-irc
     " from the channel" dark-red write-color\r
     trailing>> dot-or-parens dark-red write-color ;\r
 \r
-: full-mode ( message -- mode )\r
-    parameters>> rest " " sjoin ;\r
-\r
 M: mode write-irc\r
-    "* " blue write-color\r
-    [ irc-message-sender write ] keep\r
-    " has applied mode " blue write-color\r
-    [ full-mode write ] keep\r
-    " to " blue write-color\r
-    channel>> write ;\r
+    "* " dark-blue write-color\r
+    [ name>> write ] keep\r
+    " has applied mode " dark-blue write-color\r
+    [ mode>> write ] keep\r
+    " to " dark-blue write-color\r
+    parameter>> write ;\r
 \r
 M: nick write-irc\r
-    "* " blue write-color\r
+    "* " dark-blue write-color\r
     [ irc-message-sender write ] keep\r
     " is now known as " blue write-color\r
     trailing>> write ;\r
 \r
 M: unhandled write-irc\r
     "UNHANDLED: " write\r
-    line>> blue write-color ;\r
+    line>> dark-blue write-color ;\r
 \r
 M: irc-end write-irc\r
     drop "* You have left IRC" dark-red write-color ;\r
@@ -121,7 +119,10 @@ M: irc-chat-end write-irc
     drop ;\r
 \r
 M: irc-message write-irc\r
-    drop ; ! catch all unimplemented writes, THIS WILL CHANGE    \r
+    "UNIMPLEMENTED" write\r
+    [ class pprint ] keep\r
+    ": " write\r
+    line>> dark-blue write-color ;\r
 \r
 GENERIC: time-happened ( message -- timestamp )\r
 \r
diff --git a/extra/lint/authors.txt b/extra/lint/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/lint/lint-tests.factor b/extra/lint/lint-tests.factor
new file mode 100644 (file)
index 0000000..e2ca881
--- /dev/null
@@ -0,0 +1,14 @@
+USING: io lint kernel math tools.test ;
+IN: lint.tests
+
+! Don't write code like this
+: lint1 ( -- ) [ "hi" print ] [ ] if ; ! when
+
+[ { { lint1 { [ [ ] if ] } } } ] [ \ lint1 lint-word ] unit-test
+
+: lint2 ( n -- n' ) 1 + ; ! 1+
+[ { [ 1 + ] } ] [ \ lint2 lint ] unit-test
+
+: lint3 dup -rot ; ! tuck
+
+[ { { lint3 { [ dup -rot ] } } } ] [ \ lint3 lint-word ] unit-test
diff --git a/extra/lint/lint.factor b/extra/lint/lint.factor
new file mode 100644 (file)
index 0000000..a8320c1
--- /dev/null
@@ -0,0 +1,171 @@
+! Copyright (C) 2007, 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors alien alien.accessors arrays assocs
+combinators.short-circuit fry hashtables html.elements io
+kernel math namespaces prettyprint quotations sequences
+sequences.deep sets slots.private vectors vocabs words
+kernel.private ;
+IN: lint
+
+SYMBOL: def-hash
+SYMBOL: def-hash-keys
+
+: set-hash-vector ( val key hash -- )
+    2dup at -rot [ ?push ] 2dip set-at ;
+
+: more-defs ( hash -- )
+    {
+        { -rot [ swap >r swap r> ] }
+        { -rot [ swap swapd ] }
+        { rot [ >r swap r> swap ] }
+        { rot [ swapd swap ] }
+        { over [ dup swap ] }
+        { tuck [ dup -rot ] }
+        { swapd [ >r swap r> ] }
+        { 2nip [ nip nip ] }
+        { 2drop [ drop drop ] }
+        { 3drop [ drop drop drop ] }
+        { pop* [ pop drop ] }
+        { when [ [ ] if ] }
+        { >boolean [ f = not ] }
+    } swap '[ first2 _ set-hash-vector ] each ;
+
+: accessor-words ( -- seq )
+{
+    alien-signed-1 alien-signed-2 alien-signed-4 alien-signed-8
+    alien-unsigned-1 alien-unsigned-2 alien-unsigned-4 alien-unsigned-8
+    <displaced-alien> alien-unsigned-cell set-alien-signed-cell
+    set-alien-unsigned-1 set-alien-signed-1 set-alien-unsigned-2
+    set-alien-signed-2 set-alien-unsigned-4 set-alien-signed-4
+    set-alien-unsigned-8 set-alien-signed-8
+    alien-cell alien-signed-cell set-alien-cell set-alien-unsigned-cell
+    set-alien-float alien-float
+} ;
+
+: trivial-defs
+    {
+        [ . ]
+        [ get ]
+        [ t ] [ f ]
+        [ { } ]
+        [ drop ] ! because of declare
+        [ drop f ]
+        [ "cdecl" ]
+        [ first ] [ second ] [ third ] [ fourth ]
+        [ ">" write-html ] [ "/>" write-html ]
+    } ;
+
+! ! Add definitions
+H{ } clone def-hash set-global
+
+all-words [
+    dup def>> dup callable?
+    [ def-hash get-global set-hash-vector ] [ drop ] if
+] each
+
+! ! Remove definitions
+
+! Remove empty word defs
+def-hash get-global [ drop empty? not ] assoc-filter
+
+! Remove constants [ 1 ]
+[ drop { [ length 1 = ] [ first number? ] } 1&& not ] assoc-filter
+
+! Remove words that are their own definition
+[ [ [ def>> ] [ 1quotation ] bi = not ] filter ] assoc-map
+
+! Remove set-alien-cell, etc.
+[ drop [ accessor-words diff ] keep [ length ] bi@ = ] assoc-filter
+
+! Remove trivial defs
+[ drop trivial-defs member? not ] assoc-filter
+
+! Remove tag defs
+[
+    drop {
+            [ length 3 = ]
+            [ first \ tag = ] [ second number? ] [ third \ eq? = ]
+    } 1&& not
+] assoc-filter
+
+[
+    drop {
+        [ [ wrapper? ] deep-contains? ]
+        [ [ hashtable? ] deep-contains? ]
+    } 1|| not
+] assoc-filter
+
+! Remove n m shift defs
+[
+    drop dup length 3 = [
+        [ first2 [ number? ] both? ]
+        [ third \ shift = ] bi and not
+    ] [ drop t ] if
+] assoc-filter 
+
+! Remove [ n slot ]
+[
+    drop dup length 2 =
+    [ first2 [ number? ] [ \ slot = ] bi* and not ] [ drop t ] if
+] assoc-filter
+
+
+dup more-defs
+
+[ def-hash set-global ] [ keys def-hash-keys set-global ] bi
+
+: find-duplicates ( -- seq )
+    def-hash get-global [ nip length 1 > ] assoc-filter ;
+
+GENERIC: lint ( obj -- seq )
+
+M: object lint ( obj -- seq ) drop f ;
+
+: subseq/member? ( subseq/member seq -- ? )
+    { [ start ] [ member? ] } 2|| ;
+
+M: callable lint ( quot -- seq )
+    [ def-hash-keys get-global ] dip '[ _ subseq/member? ] filter ;
+
+M: word lint ( word -- seq )
+    def>> dup callable? [ lint ] [ drop f ] if ;
+
+: word-path. ( word -- )
+    [ vocabulary>> ] [ unparse ] bi ":" glue print ;
+
+: 4bl ( -- ) bl bl bl bl ;
+
+: (lint.) ( pair -- )
+    first2 [ word-path. ] dip [
+        [ 4bl .  "-----------------------------------" print ]
+        [ def-hash get-global at [ 4bl word-path. ] each nl ] bi
+    ] each nl nl ;
+
+: lint. ( alist -- ) [ (lint.) ] each ;
+
+GENERIC: run-lint ( obj -- obj )
+
+: (trim-self) ( val key -- obj ? )
+    def-hash get-global at*
+    [ dupd remove empty? not ] [ drop f ] if ;
+
+: trim-self ( seq -- newseq )
+    [ [ (trim-self) ] filter ] assoc-map ;
+
+: filter-symbols ( alist -- alist )
+    [
+        nip first dup def-hash get-global at
+        [ first ] bi@ literalize = not
+    ] assoc-filter ;
+
+M: sequence run-lint ( seq -- seq )
+    [ dup lint ] { } map>assoc trim-self
+    [ second empty? not ] filter filter-symbols ;
+
+M: word run-lint ( word -- seq ) 1array run-lint ;
+
+: lint-all ( -- seq ) all-words run-lint dup lint. ;
+
+: lint-vocab ( vocab -- seq ) words run-lint dup lint. ;
+
+: lint-word ( word -- seq ) 1array run-lint dup lint. ;
diff --git a/extra/lint/summary.txt b/extra/lint/summary.txt
new file mode 100755 (executable)
index 0000000..943869d
--- /dev/null
@@ -0,0 +1 @@
+Finds potential mistakes in code
index 5024e83bffdf3296afc7f2c102560905003dff76..a1e81bf66595038e2c3289b27869b995fbdb09f9 100644 (file)
@@ -1,8 +1,6 @@
-! Copyright (C) 2008 John Benediktsson
+! Copyright (C) 2008 John Benediktsson, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license
-
-USING: help.markup help.syntax ;
-
+USING: help.markup help.syntax math ;
 IN: math.finance
 
 HELP: sma
@@ -32,3 +30,59 @@ HELP: momentum
     { $list "MOM[t] = SEQ[t] - SEQ[t-n]" }
 } ;
 
+HELP: biweekly
+{ $values
+     { "x" number }
+     { "y" number }
+}
+{ $description "Divides a number by the number of two week periods in a year." } ;
+
+HELP: daily-360
+{ $values
+     { "x" number }
+     { "y" number }
+}
+{ $description "Divides a number by the number of days in a 360-day year." } ;
+
+HELP: daily-365
+{ $values
+     { "x" number }
+     { "y" number }
+}
+{ $description "Divides a number by the number of days in a 365-day year." } ;
+
+HELP: monthly
+{ $values
+     { "x" number }
+     { "y" number }
+}
+{ $description "Divides a number by the number of months in a year." } ;
+
+HELP: semimonthly
+{ $values
+     { "x" number }
+     { "y" number }
+}
+{ $description "Divides a number by the number of half-months in a year. Note that biweekly has two more periods than semimonthly." } ;
+
+HELP: weekly
+{ $values
+     { "x" number }
+     { "y" number }
+}
+{ $description "Divides a number by the number of weeks in a year." } ;
+
+ARTICLE: "time-period-calculations" "Calculations over periods of time"
+{ $subsection monthly }
+{ $subsection semimonthly }
+{ $subsection biweekly }
+{ $subsection weekly }
+{ $subsection daily-360 }
+{ $subsection daily-365 } ;
+
+ARTICLE: "math.finance" "Financial math"
+"The " { $vocab-link "math.finance" } " vocabulary contains financial calculation words." $nl
+"Calculating payroll over periods of time:"
+{ $subsection "time-period-calculations" } ;
+
+ABOUT: "math.finance"
index dce701bb2f984fd3a139887ad38aaed0caa9b1a0..fc4ad0d07e928244d253fd5fa257be263c933d79 100644 (file)
@@ -6,3 +6,4 @@ IN: math.finance.tests
 
 [ { 1 3 1 } ] [ { 1 3 2 6 3 } 2 momentum ] unit-test
 
+[ 4+1/6 ] [ 100 semimonthly ] unit-test
index e02f4be6240b6dfd07f4bc73fa7696072961da76..4823e358b007137783752f7258d3998eb9727daa 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 John Benediktsson.
+! Copyright (C) 2008 John Benediktsson, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs kernel grouping sequences shuffle
 math math.functions math.statistics math.vectors ;
@@ -26,3 +26,14 @@ PRIVATE>
 : momentum ( seq n -- newseq )
     [ tail-slice ] 2keep [ dup length ] dip - head-slice v- ;
 
+: monthly ( x -- y ) 12 / ; inline
+
+: semimonthly ( x -- y ) 24 / ; inline
+
+: biweekly ( x -- y ) 26 / ; inline
+
+: weekly ( x -- y ) 52 / ; inline
+
+: daily-360 ( x -- y ) 360 / ; inline
+
+: daily-365 ( x -- y ) 365 / ; inline
index dfaa618b536f27b2ea0b4cb8e4e1e2d823cab5c6..6b46ba02430a6e78464ba76bed93907128296957 100644 (file)
@@ -4,15 +4,16 @@ USING: arrays kernel sequences namespaces make math math.ranges
 math.vectors vectors ;
 IN: math.numerical-integration
 
-SYMBOL: num-steps 180 num-steps set-global
+SYMBOL: num-steps
+
+180 num-steps set-global
 
 : setup-simpson-range ( from to -- frange )
     2dup swap - num-steps get / <range> ;
 
 : generate-simpson-weights ( seq -- seq )
-    { 1 4 }
-    swap length 2 / 2 - { 2 4 } <repetition> concat
-    { 1 } 3append ;
+    length 2 / 2 - { 2 4 } <repetition> concat
+    { 1 4 } { 1 } surround ;
 
 : integrate-simpson ( from to f -- x )
     [ setup-simpson-range dup ] dip 
index 682abf3a5d0d9342c2415005f2dee93c6b7472f4..14062b15db683157dfb214d5cc036da4904023ae 100755 (executable)
@@ -102,7 +102,7 @@ SYMBOL: total
         { 0 [ [ dup ] ] }
         { 1 [ [ over ] ] }
         { 2 [ [ pick ] ] }
-        [ 1- picker [ >r ] swap [ r> swap ] 3append ]
+        [ 1- picker [ >r ] [ r> swap ] surround ]
     } case ;
 
 : (multi-predicate) ( class picker -- quot )
index fdf32bddb14c06c6481e3d41da12f9a0f561e4bf..be6c01aab80bc2606932d5dd1300f269d626a548 100755 (executable)
@@ -41,7 +41,7 @@ HELP: 'bold'
     "commonly used in markup languages to indicate bold "
     "faced text." }
 { $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"*foo*\" 'bold' parse-1 ." "\"foo\"" }
-{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" 'bold' [ \"<strong>\" swap \"</strong>\" 3append ] <@ parse-1 ." "\"<strong>foo</strong>\"" } ;
+{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"*foo*\" 'bold' [ \"<strong>\" \"</strong>\" surround ] <@ parse-1 ." "\"<strong>foo</strong>\"" } ;
 
 HELP: 'italic'
 { $values 
@@ -53,7 +53,7 @@ HELP: 'italic'
     "faced text." }
 { $examples
 { $example "USING: parser-combinators parser-combinators.simple prettyprint ;" "\"_foo_\" 'italic' parse-1 ." "\"foo\"" }
-{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" 'italic' [ \"<emphasis>\" swap \"</emphasis>\" 3append ] <@ parse-1 ." "\"<emphasis>foo</emphasis>\"" } } ;
+{ $example "USING: kernel parser-combinators parser-combinators.simple prettyprint sequences ;" "\"_foo_\" 'italic' [ \"<emphasis>\" \"</emphasis>\" surround ] <@ parse-1 ." "\"<emphasis>foo</emphasis>\"" } } ;
 HELP: comma-list
 { $values 
   { "element" "a parser object" } { "parser" "a parser object" } }
index 7174066227c2a9351b4fe06bdc5c9b08271d031d..b90a98173ee887f8286e56ac9c586734c19310c9 100644 (file)
@@ -27,9 +27,6 @@ IN: project-euler.117
 
 <PRIVATE
 
-: short ( seq n -- seq n )
-    over length min ;
-
 : next ( seq -- )
     [ 4 short tail* sum ] keep push ;
 
index 933275e5bfc9a1e25a78d1382c418496ebbc5643..c0605fe83743c672b603be17bb60035a90902f47 100755 (executable)
@@ -32,8 +32,8 @@ SYMBOL: networking-hook
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: start-service ( name -- ) "/etc/init.d/" swap " start" 3append system drop ;
-: stop-service  ( name -- ) "/etc/init.d/" swap " stop"  3append system drop ;
+: start-service ( name -- ) "/etc/init.d/" " start" surround system drop ;
+: stop-service  ( name -- ) "/etc/init.d/" " stop"  surround system drop ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
diff --git a/extra/system-info/authors.txt b/extra/system-info/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/backend/authors.txt b/extra/system-info/backend/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/backend/backend.factor b/extra/system-info/backend/backend.factor
new file mode 100644 (file)
index 0000000..6e6715f
--- /dev/null
@@ -0,0 +1,15 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: system ;
+IN: system-info.backend
+
+HOOK: cpus os ( -- n )
+HOOK: cpu-mhz os ( -- n )
+HOOK: memory-load os ( -- n )
+HOOK: physical-mem os ( -- n )
+HOOK: available-mem os ( -- n )
+HOOK: total-page-file os ( -- n )
+HOOK: available-page-file os ( -- n )
+HOOK: total-virtual-mem os ( -- n )
+HOOK: available-virtual-mem os ( -- n )
+HOOK: available-virtual-extended-mem os ( -- n )
diff --git a/extra/system-info/linux/authors.txt b/extra/system-info/linux/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/linux/linux.factor b/extra/system-info/linux/linux.factor
new file mode 100644 (file)
index 0000000..d7f53fb
--- /dev/null
@@ -0,0 +1,23 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: unix alien alien.c-types kernel math sequences strings
+io.unix.backend splitting ;
+IN: system-info.linux
+
+: (uname) ( buf -- int )
+    "int" f "uname" { "char*" } alien-invoke ;
+
+: uname ( -- seq )
+    65536 "char" <c-array> [ (uname) io-error ] keep
+    "\0" split harvest [ >string ] map
+    6 "" pad-right ;
+
+: sysname ( -- string ) uname first ;
+: nodename ( -- string ) uname second ;
+: release ( -- string ) uname third ;
+: version ( -- string ) uname fourth ;
+: machine ( -- string ) uname 4 swap nth ;
+: domainname ( -- string ) uname 5 swap nth ;
+
+: kernel-version ( -- seq )
+    release ".-" split harvest 5 "" pad-right ;
diff --git a/extra/system-info/linux/tags.txt b/extra/system-info/linux/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/system-info/macosx/authors.txt b/extra/system-info/macosx/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/macosx/macosx.factor b/extra/system-info/macosx/macosx.factor
new file mode 100644 (file)
index 0000000..a06c01b
--- /dev/null
@@ -0,0 +1,56 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien alien.c-types alien.strings alien.syntax
+byte-arrays kernel namespaces sequences unix
+system-info.backend system io.unix.backend io.encodings.utf8 ;
+IN: system-info.macosx
+
+! See /usr/include/sys/sysctl.h for constants
+
+LIBRARY: libc
+FUNCTION: int sysctl ( int* name, uint namelen, void* oldp, size_t* oldlenp, void* newp, size_t newlen ) ;
+
+: make-int-array ( seq -- byte-array )
+    [ <int> ] map concat ;
+
+: (sysctl-query) ( name namelen oldp oldlenp -- oldp )
+    over [ f 0 sysctl io-error ] dip ;
+
+: sysctl-query ( seq n -- byte-array )
+    [ [ make-int-array ] [ length ] bi ] dip
+    [ <byte-array> ] [ <uint> ] bi (sysctl-query) ;
+
+: sysctl-query-string ( seq -- n )
+    4096 sysctl-query utf8 alien>string ;
+
+: sysctl-query-uint ( seq -- n )
+    4 sysctl-query *uint ;
+
+: sysctl-query-ulonglong ( seq -- n )
+    8 sysctl-query *ulonglong ;
+
+: machine ( -- str ) { 6 1 } sysctl-query-string ;
+: model ( -- str ) { 6 2 } sysctl-query-string ;
+M: macosx cpus ( -- n ) { 6 3 } sysctl-query-uint ;
+: byte-order ( -- n ) { 6 4 } sysctl-query-uint ;
+M: macosx physical-mem ( -- n ) { 6 5 } sysctl-query-uint ;
+: user-mem ( -- n ) { 6 6 } sysctl-query-uint ;
+: page-size ( -- n ) { 6 7 } sysctl-query-uint ;
+: disknames ( -- n ) { 6 8 } 8 sysctl-query ;
+: diskstats ( -- n ) { 6 9 } 8 sysctl-query ;
+: epoch ( -- n ) { 6 10 } sysctl-query-uint ;
+: floating-point ( -- n ) { 6 11 } sysctl-query-uint ;
+: machine-arch ( -- n ) { 6 12 } sysctl-query-string ;
+: vector-unit ( -- n ) { 6 13 } sysctl-query-uint ;
+: bus-frequency ( -- n ) { 6 14 } sysctl-query-uint ;
+M: macosx cpu-mhz ( -- n ) { 6 15 } sysctl-query-uint ;
+: cacheline-size ( -- n ) { 6 16 } sysctl-query-uint ;
+: l1-icache-size ( -- n ) { 6 17 } sysctl-query-uint ;
+: l1-dcache-size ( -- n ) { 6 18 } sysctl-query-uint ;
+: l2-cache-settings ( -- n ) { 6 19 } sysctl-query-uint ;
+: l2-cache-size ( -- n ) { 6 20 } sysctl-query-uint ;
+: l3-cache-settings ( -- n ) { 6 21 } sysctl-query-uint ;
+: l3-cache-size ( -- n ) { 6 22 } sysctl-query-uint ;
+: tb-frequency ( -- n ) { 6 23 } sysctl-query-uint ;
+: mem-size ( -- n ) { 6 24 } sysctl-query-ulonglong ;
+: available-cpus ( -- n ) { 6 25 } sysctl-query-uint ;
diff --git a/extra/system-info/macosx/tags.txt b/extra/system-info/macosx/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/system-info/summary.txt b/extra/system-info/summary.txt
new file mode 100644 (file)
index 0000000..404da13
--- /dev/null
@@ -0,0 +1 @@
+Query the operating system for hardware information in a platform-independent way
diff --git a/extra/system-info/system-info.factor b/extra/system-info/system-info.factor
new file mode 100755 (executable)
index 0000000..5bf886a
--- /dev/null
@@ -0,0 +1,25 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.syntax kernel math prettyprint io math.parser
+combinators vocabs.loader system-info.backend system ;
+IN: system-info
+
+: write-unit ( x n str -- )
+    [ 2^ /f number>string write bl ] [ write ] bi* ;
+
+: kb ( x -- ) 10 "kB" write-unit ;
+: megs ( x -- ) 20 "MB" write-unit ;
+: gigs ( x -- ) 30 "GB" write-unit ;
+: ghz ( x -- ) 1000000000 /f number>string write bl "GHz" write ;
+
+<< {
+    { [ os windows? ] [ "system-info.windows" ] }
+    { [ os linux? ] [ "system-info.linux" ] }
+    { [ os macosx? ] [ "system-info.macosx" ] }
+    [ f ]
+} cond [ require ] when* >>
+
+: system-report. ( -- )
+    "CPUs: " write cpus number>string write nl
+    "CPU Speed: " write cpu-mhz ghz nl
+    "Physical RAM: " write physical-mem megs nl ;
diff --git a/extra/system-info/windows/authors.txt b/extra/system-info/windows/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/windows/ce/authors.txt b/extra/system-info/windows/ce/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/windows/ce/ce.factor b/extra/system-info/windows/ce/ce.factor
new file mode 100755 (executable)
index 0000000..13c7cb9
--- /dev/null
@@ -0,0 +1,33 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types system-info kernel math namespaces
+windows windows.kernel32 system-info.backend system ;
+IN: system-info.windows.ce
+
+: memory-status ( -- MEMORYSTATUS )
+    "MEMORYSTATUS" <c-object>
+    "MEMORYSTATUS" heap-size over set-MEMORYSTATUS-dwLength
+    dup GlobalMemoryStatus ;
+
+M: wince cpus ( -- n ) 1 ;
+
+M: wince memory-load ( -- n )
+    memory-status MEMORYSTATUS-dwMemoryLoad ;
+
+M: wince physical-mem ( -- n )
+    memory-status MEMORYSTATUS-dwTotalPhys ;
+
+M: wince available-mem ( -- n )
+    memory-status MEMORYSTATUS-dwAvailPhys ;
+
+M: wince total-page-file ( -- n )
+    memory-status MEMORYSTATUS-dwTotalPageFile ;
+
+M: wince available-page-file ( -- n )
+    memory-status MEMORYSTATUS-dwAvailPageFile ;
+
+M: wince total-virtual-mem ( -- n )
+    memory-status MEMORYSTATUS-dwTotalVirtual ;
+
+M: wince available-virtual-mem ( -- n )
+    memory-status MEMORYSTATUS-dwAvailVirtual ;
diff --git a/extra/system-info/windows/ce/tags.txt b/extra/system-info/windows/ce/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/system-info/windows/nt/authors.txt b/extra/system-info/windows/nt/authors.txt
new file mode 100755 (executable)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/extra/system-info/windows/nt/nt.factor b/extra/system-info/windows/nt/nt.factor
new file mode 100755 (executable)
index 0000000..7f71e08
--- /dev/null
@@ -0,0 +1,46 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien alien.c-types alien.strings
+kernel libc math namespaces system-info.backend
+system-info.windows windows windows.advapi32
+windows.kernel32 system byte-arrays ;
+IN: system-info.windows.nt
+
+M: winnt cpus ( -- n )
+    system-info SYSTEM_INFO-dwNumberOfProcessors ;
+
+: memory-status ( -- MEMORYSTATUSEX )
+    "MEMORYSTATUSEX" <c-object>
+    "MEMORYSTATUSEX" heap-size over set-MEMORYSTATUSEX-dwLength
+    dup GlobalMemoryStatusEx win32-error=0/f ;
+
+M: winnt memory-load ( -- n )
+    memory-status MEMORYSTATUSEX-dwMemoryLoad ;
+
+M: winnt physical-mem ( -- n )
+    memory-status MEMORYSTATUSEX-ullTotalPhys ;
+
+M: winnt available-mem ( -- n )
+    memory-status MEMORYSTATUSEX-ullAvailPhys ;
+
+M: winnt total-page-file ( -- n )
+    memory-status MEMORYSTATUSEX-ullTotalPageFile ;
+
+M: winnt available-page-file ( -- n )
+    memory-status MEMORYSTATUSEX-ullAvailPageFile ;
+
+M: winnt total-virtual-mem ( -- n )
+    memory-status MEMORYSTATUSEX-ullTotalVirtual ;
+
+M: winnt available-virtual-mem ( -- n )
+    memory-status MEMORYSTATUSEX-ullAvailVirtual ;
+
+: computer-name ( -- string )
+    MAX_COMPUTERNAME_LENGTH 1+
+    [ <byte-array> dup ] keep <uint>
+    GetComputerName win32-error=0/f alien>native-string ;
+: username ( -- string )
+    UNLEN 1+
+    [ <byte-array> dup ] keep <uint>
+    GetUserName win32-error=0/f alien>native-string ;
diff --git a/extra/system-info/windows/nt/tags.txt b/extra/system-info/windows/nt/tags.txt
new file mode 100644 (file)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/system-info/windows/tags.txt b/extra/system-info/windows/tags.txt
new file mode 100755 (executable)
index 0000000..6bf6830
--- /dev/null
@@ -0,0 +1 @@
+unportable
diff --git a/extra/system-info/windows/windows.factor b/extra/system-info/windows/windows.factor
new file mode 100755 (executable)
index 0000000..66abb59
--- /dev/null
@@ -0,0 +1,72 @@
+! Copyright (C) 2008 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien alien.c-types kernel libc math namespaces
+windows windows.kernel32 windows.advapi32
+words combinators vocabs.loader system-info.backend
+system alien.strings ;
+IN: system-info.windows
+
+: system-info ( -- SYSTEM_INFO )
+    "SYSTEM_INFO" <c-object> [ GetSystemInfo ] keep ;
+
+: page-size ( -- n )
+    system-info SYSTEM_INFO-dwPageSize ;
+
+! 386, 486, 586, 2200 (IA64), 8664 (AMD_X8664)
+: processor-type ( -- n )
+    system-info SYSTEM_INFO-dwProcessorType ;
+
+! 0 = x86, 6 = Intel Itanium, 9 = x64 (AMD or Intel), 10 = WOW64, 0xffff = Unk
+: processor-architecture ( -- n )
+    system-info SYSTEM_INFO-dwOemId HEX: ffff0000 bitand ;
+
+: os-version ( -- os-version )
+    "OSVERSIONINFO" <c-object>
+    "OSVERSIONINFO" heap-size over set-OSVERSIONINFO-dwOSVersionInfoSize
+    dup GetVersionEx win32-error=0/f ;
+
+: windows-major ( -- n )
+    os-version OSVERSIONINFO-dwMajorVersion ;
+
+: windows-minor ( -- n )
+    os-version OSVERSIONINFO-dwMinorVersion ;
+
+: windows-build# ( -- n )
+    os-version OSVERSIONINFO-dwBuildNumber ;
+
+: windows-platform-id ( -- n )
+    os-version OSVERSIONINFO-dwPlatformId ;
+
+: windows-service-pack ( -- string )
+    os-version OSVERSIONINFO-szCSDVersion alien>native-string ;
+
+: feature-present? ( n -- ? )
+    IsProcessorFeaturePresent zero? not ;
+
+: sse2? ( -- ? )
+    PF_XMMI64_INSTRUCTIONS_AVAILABLE feature-present? ;
+
+: sse3? ( -- ? )
+    PF_SSE3_INSTRUCTIONS_AVAILABLE feature-present? ;
+
+: <u16-string-object> ( n -- obj )
+    "ushort" <c-array> ;
+
+: get-directory ( word -- str )
+    [ MAX_UNICODE_PATH [ <u16-string-object> ] keep dupd ] dip
+    execute win32-error=0/f alien>native-string ; inline
+
+: windows-directory ( -- str )
+    \ GetWindowsDirectory get-directory ;
+
+: system-directory ( -- str )
+    \ GetSystemDirectory get-directory ;
+
+: system-windows-directory ( -- str )
+    \ GetSystemWindowsDirectory get-directory ;
+
+<<
+{
+    { [ os wince? ] [ "system-info.windows.ce" ] }
+    { [ os winnt? ] [ "system-info.windows.nt" ] }
+} cond require >>
index 002299fef17ef281ab7be7550f0508aee4dc020e..6c12a423eb85c7499a3ec888da6db6d6c4b0cf97 100644 (file)
@@ -1,6 +1,6 @@
 USING: kernel money tools.test
 taxes.usa taxes.usa.federal taxes.usa.mn
-calendar taxes.usa.w4 usa-cities ;
+calendar taxes.usa.w4 usa-cities math.finance ;
 IN: taxes.usa.tests
 
 [
index b78dc25d7997fb074d331012800c6b2e4ff7db57..f2c0600ed5a31bf53e03ed44d85067963c39942f 100644 (file)
@@ -230,7 +230,7 @@ M: revision feed-entry-url id>> revision-url ;
         [ list-revisions ] >>entries ;
 
 : rollback-description ( description -- description' )
-    [ "Rollback of '" swap "'" 3append ] [ "Rollback" ] if* ;
+    [ "Rollback of '" "'" surround ] [ "Rollback" ] if* ;
 
 : <rollback-action> ( -- action )
     <action>
diff --git a/unmaintained/README.libs.txt b/unmaintained/README.libs.txt
deleted file mode 100644 (file)
index fb5430a..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-This directory contains Factor code that is not part of the core
-library, but is useful enough to ship with the Factor distribution.
-
-Modules can be loaded from the listener:
-
-  "libs/modulename" require
-
-Available libraries:
-
-- alarms -- call a quotation at a calendar date (Doug Coleman)
-- alien -- Alien utility words (Eduardo Cavazos)
-- base64 -- base64 encoding/decoding (Doug Coleman)
-- basic-authentication -- basic authentication implementation for HTTP server (Chris Double)
-- cairo -- cairo bindings (Sampo Vuori)
-- calendar -- timestamp/calendar with timezones (Doug Coleman)
-- canvas -- Gadget which renders an OpenGL display list (Slava Pestov)
-- cocoa-callbacks -- Allows you to use Factor quotations as actions (Slava Pestov)
-- concurrency -- Erlang/Termite-style distibuted concurrency (Chris Double)
-- coroutines -- coroutines (Chris Double)
-- cryptlib -- cryptlib binding (Elie Chaftari)
-- crypto -- Various cryptographic algorithms (Doug Coleman)
-- csv -- Comma-separated values parser (Daniel Ehrenberg)
-- dlists -- double-linked-lists (Mackenzie Straight)
-- editpadpro -- EditPadPro integration for Windows (Ryan Murphy)
-- emacs -- emacs integration (Eduardo Cavazos)
-- farkup -- Wiki-style markup (Matthew Willis)
-- file-appender -- append to existing files (Doug Coleman)
-- fjsc -- Factor to Javascript compiler (Chris Double)
-- furnace -- Web framework (Slava Pestov)
-- gap-buffer -- Efficient text editor buffer (Alex Chapman)
-- graphics -- Graphics library in Factor (Doug Coleman)
-- hardware-info -- Information about your computer (Doug Coleman)
-- handler -- Gesture handler mixin (Eduardo Cavazos)
-- heap -- Binary min heap implementation (Ryan Murphy)
-- hexdump -- Hexdump routine (Doug Coleman)
-- http -- Code shared by HTTP server and client (Slava Pestov)
-- http-client -- HTTP client (Slava Pestov)
-- id3 -- ID3 parser (Adam Wendt)
-- io -- mmap, filesystem utils (Doug Coleman)
-- jedit -- jEdit editor integration (Slava Pestov)
-- jni -- Java Native Interface Wrapper (Chris Double)
-- json -- JSON reader and writer (Chris Double)
-- koszul -- Lie algebra cohomology and central representation (Slava Pestov)
-- lazy-lists -- Lazy evaluation lists (Chris Double, Matthew Willis)
-- locals -- Crappy local variables (Slava Pestov)
-- mad -- Wrapper for libmad MP3 decoder (Adam Wendt)
-- match -- pattern matching (Chris Double)
-- math -- extended math library (Doug Coleman, Slava Pestov)
-- matrices -- Matrix math (Slava Pestov)
-- memoize -- memoization (caching word results) (Slava Pestov)
-- mmap -- memory mapped files (Doug Coleman)
-- mysql -- MySQL binding (Berlin Brown)
-- null-stream -- Something akin to /dev/null (Slava Pestov)
-- odbc -- Wrapper for ODBC library (Chris Double)
-- ogg -- Wrapper for libogg library (Chris Double)
-- openal -- Wrapper for OpenAL and alut sound libraries (Chris Double)
-- oracle -- Oracle binding (Elie Chaftari)
-- parser-combinators -- Haskell-style parser combinators (Chris Double)
-- porter-stemmer -- Porter stemming algorithm (Slava Pestov)
-- postgresql -- PostgreSQL binding (Doug Coleman)
-- process -- Run external programs (Slava Pestov, Doug Coleman)
-- qualified -- Qualified names for words in other vocabularies (Daniel Ehrenberg)
-- rewrite-closures -- Turn quotations into closures (Eduardo Cavazos)
-- scite -- SciTE editor integration (Clemens F. Hofreither)
-- sequences -- Non-core sequence words (Eduardo Cavazos)
-- serialize -- Binary object serialization (Chris Double)
-- server -- The with-server combinator formely found in the core (Slava Pestov)
-- slate -- Framework for graphical demos (Eduardo Cavazos)
-- shuffle -- Shuffle words not in the core library (Chris Double)
-- smtp -- SMTP client library (Elie Chaftari)
-- splay-trees -- Splay trees (Mackenzie Straight)
-- sqlite -- SQLite binding (Chris Double)
-- state-machine -- Finite state machine abstraction (Daniel Ehrenberg)
-- state-parser -- State-based parsing mechanism (Daniel Ehrenberg)
-- textmate -- TextMate integration (Benjamin Pollack)
-- theora -- Wrapper for libtheora library (Chris Double)
-- trees -- Binary search and AVL (balanced) trees (Alex Chapman)
-- usb -- Wrapper for libusb (Chris Double)
-- unicode -- Partial Unicode support beyond the core (Daniel Ehrenberg)
-- units -- Unit conversion (Doug Coleman)
-- vars -- Alternative syntax for variables (Eduardo Cavazos)
-- vim -- VIM integration (Alex Chapman)
-- visitor -- Double dispatch through the visitor pattern (Daniel Ehrenberg)
-- vorbis -- Wrapper for Ogg Vorbis library (Chris Double)
-- x11 -- X Window System client library (Eduardo Cavazos)
-- xml -- XML parser (Daniel Ehrenberg)
-- xml-rpc -- XML-RPC client and server (Daniel Ehrenberg)
-- yahoo -- Yahoo! automated search (Daniel Ehrenberg)
diff --git a/unmaintained/README.txt b/unmaintained/README.txt
deleted file mode 100644 (file)
index 91b1c5f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-This directory contains Factor code that is not part of the core
-library, but is useful enough to ship with the Factor distribution.
-
-Modules can be loaded from the listener:
-
-  "apps/modulename" require
-
-Available applications:
-
-- article-manager -- Web-based content management system (Chris Double)
-- automata -- Graphics demo for the UI (Eduardo Cavazos)
-- benchmarks -- Various performance benchmarks (Slava Pestov)
-- boids -- Graphics demo for the UI (Eduardo Cavazos)
-- factory -- X11 window manager (Eduardo Cavazos)
-- furnace-fjsc -- Web frontend for libs/fjsc (Chris Double)
-- furnace-onigiri -- Weblog engine (Matthew Willis)
-- furnace-pastebin -- demo app for Furnace (Slava Pestov)
-- help-lint -- online documentation typo checker (Slava Pestov)
-- icfp-2006 -- implements the icfp 2006 vm, boundvariable.org (Gavin Harrison)
-- http-server -- HTTP server (Slava Pestov, Chris Double)
-- lindenmayer -- L-systems tool (Eduardo Cavazos)
-- lisppaste -- Lisppaste XML-RPC demo (Slava Pestov)
-- ogg-player -- Ogg Vorbis (audio) and Theora (video) player (Chris Double)
-- print-dataflow -- Code to print compiler dataflow IR to the console, or show it in the UI (Slava Pestov)
-- random-tester -- Random compiler tester (Doug Coleman)
-- rss -- An RSS1, RSS2 and Atom parser and aggregator (Chris Double, Daniel Ehrenberg)
-- space-invaders -- Intel 8080-based Space Invaders arcade machine emulator (Chris Double)
-- tetris -- Tetris game (Alex Chapman)
-- turing -- Turing machine demo (Slava Pestov)
-- wee-url -- Web app to make short URLs from long ones (Doug Coleman)
diff --git a/unmaintained/lint/authors.txt b/unmaintained/lint/authors.txt
deleted file mode 100644 (file)
index 7c1b2f2..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
diff --git a/unmaintained/lint/lint-tests.factor b/unmaintained/lint/lint-tests.factor
deleted file mode 100644 (file)
index 9a39980..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-USING: io lint kernel math tools.test ;
-IN: lint.tests
-
-! Don't write code like this
-: lint1
-    [ "hi" print ] [ ] if ; ! when
-
-[ { [ [ ] if ] } ] [ \ lint1 lint ] unit-test
-
-: lint2
-    1 + ; ! 1+
-[ { [ 1 + ] } ] [ \ lint2 lint ] unit-test
-
-: lint3
-    dup -rot ; ! tuck
-
-[ { [ dup -rot ] } ] [ \ lint3 lint ] unit-test
-
diff --git a/unmaintained/lint/lint.factor b/unmaintained/lint/lint.factor
deleted file mode 100644 (file)
index ab1a67a..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-! Copyright (C) 2007 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.accessors arrays assocs
-combinators.lib io kernel macros math namespaces prettyprint
-quotations sequences vectors vocabs words html.elements sets
-slots.private combinators.short-circuit math.order hashtables
-sequences.deep ;
-IN: lint
-
-SYMBOL: def-hash
-SYMBOL: def-hash-keys
-
-: set-hash-vector ( val key hash -- )
-    2dup at -rot [ ?push ] 2dip set-at ;
-
-: add-word-def ( word quot -- )
-    dup callable? [
-        def-hash get-global set-hash-vector
-    ] [
-        2drop
-    ] if ;
-
-: more-defs ( -- )
-    {
-        { [ swap >r swap r> ] -rot }
-        { [ swap swapd ] -rot }
-        { [ >r swap r> swap ] rot }
-        { [ swapd swap ] rot }
-        { [ dup swap ] over }
-        { [ dup -rot ] tuck }
-        { [ >r swap r> ] swapd }
-        { [ nip nip ] 2nip }
-        { [ drop drop ] 2drop }
-        { [ drop drop drop ] 3drop }
-        { [ 0 = ] zero? }
-        { [ pop drop ] pop* }
-        { [ [ ] if ] when }
-        { [ f = not ] >boolean }
-    } [ first2 swap add-word-def ] each ;
-
-: accessor-words ( -- seq )
-{
-    alien-signed-1 alien-signed-2 alien-signed-4 alien-signed-8
-    alien-unsigned-1 alien-unsigned-2 alien-unsigned-4 alien-unsigned-8
-    <displaced-alien> alien-unsigned-cell set-alien-signed-cell
-    set-alien-unsigned-1 set-alien-signed-1 set-alien-unsigned-2
-    set-alien-signed-2 set-alien-unsigned-4 set-alien-signed-4
-    set-alien-unsigned-8 set-alien-signed-8
-    alien-cell alien-signed-cell set-alien-cell set-alien-unsigned-cell
-    set-alien-float alien-float
-} ;
-
-: trivial-defs
-    {
-        [ get ] [ t ] [ { } ] [ . ] [ drop f ]
-        [ drop ] [ f ] [ first ] [ second ] [ third ] [ fourth ]
-        [ ">" write-html ] [ "/>" write-html ]
-    } ;
-
-H{ } clone def-hash set-global
-all-words [ dup def>> add-word-def ] each
-more-defs
-
-! Remove empty word defs
-def-hash get-global [
-    drop empty? not
-] assoc-filter
-
-! Remove constants [ 1 ]
-[
-    drop { [ length 1 = ] [ first number? ] } 1&& not
-] assoc-filter
-
-! Remove set-alien-cell, etc.
-[
-    drop [ accessor-words diff ] keep [ length ] bi@ =
-] assoc-filter
-
-! Remove trivial defs
-[
-    drop trivial-defs member? not
-] assoc-filter
-
-[
-    drop {
-        [ [ wrapper? ] deep-contains? ]
-        [ [ hashtable? ] deep-contains? ]
-    } 1|| not
-] assoc-filter
-
-! Remove n m shift defs
-[
-    drop dup length 3 = [
-        dup first2 [ number? ] both?
-        swap third \ shift = and not
-    ] [ drop t ] if
-] assoc-filter 
-
-! Remove [ n slot ]
-[
-    drop dup length 2 = [
-        first2 \ slot = swap number? and not
-    ] [ drop t ] if
-] assoc-filter def-hash set-global
-
-: find-duplicates ( -- seq )
-    def-hash get-global [
-        nip length 1 >
-    ] assoc-filter ;
-
-def-hash get-global keys def-hash-keys set-global
-
-GENERIC: lint ( obj -- seq )
-
-M: object lint ( obj -- seq )
-    drop f ;
-
-: subseq/member? ( subseq/member seq -- ? )
-    { [ start ] [ member? ] } 2|| ;
-
-M: callable lint ( quot -- seq )
-    def-hash-keys get [
-        swap subseq/member?
-    ] with filter ;
-
-M: word lint ( word -- seq )
-    def>> dup callable? [ lint ] [ drop f ] if ;
-
-: word-path. ( word -- )
-    [ vocabulary>> ":" ] keep unparse 3append write nl ;
-
-: (lint.) ( pair -- )
-    first2 >r word-path. r> [
-        bl bl bl bl
-        dup .
-        "-----------------------------------" print
-        def-hash get at [ bl bl bl bl word-path. ] each
-        nl
-    ] each nl nl ;
-
-: lint. ( alist -- )
-    [ (lint.) ] each ;
-    
-
-GENERIC: run-lint ( obj -- obj )
-
-: (trim-self) ( val key -- obj ? )
-    def-hash get-global at* [
-        dupd remove empty? not
-    ] [
-        drop f
-    ] if ;
-
-: trim-self ( seq -- newseq )
-    [ [ (trim-self) ] filter ] assoc-map ;
-
-: filter-symbols ( alist -- alist )
-    [
-        nip first dup def-hash get at
-        [ first ] bi@ literalize = not
-    ] assoc-filter ;
-
-M: sequence run-lint ( seq -- seq )
-    [
-        global [ dup . flush ] bind
-        dup lint
-    ] { } map>assoc
-    trim-self
-    [ second empty? not ] filter
-    filter-symbols ;
-
-M: word run-lint ( word -- seq )
-    1array run-lint ;
-
-: lint-all ( -- seq )
-    all-words run-lint dup lint. ;
-
-: lint-vocab ( vocab -- seq )
-    words run-lint dup lint. ;
-
-: lint-word ( word -- seq )
-    1array run-lint dup lint. ;
diff --git a/unmaintained/lint/summary.txt b/unmaintained/lint/summary.txt
deleted file mode 100755 (executable)
index 943869d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Finds potential mistakes in code
index 72616afbc5ace7bf9d5598a3437474e56d2f23a4..1f4bc3ce7693f0435c41792bf884422eb5b6cf89 100644 (file)
@@ -1396,7 +1396,7 @@ allot_bignum_zeroed(bignum_length_type length, int negative_p)
 }
 
 #define BIGNUM_REDUCE_LENGTH(source, length) \
-     source = reallot_array(source,length + 1,0)
+     source = reallot_array(source,length + 1)
 
 /* allocates memory */
 bignum_type
index dd01e852ad0d68107688286645b43d0e6392cc81..f0aa8748862f4ac4e0ad0ebe2c5dcd30b58a2ebf 100644 (file)
--- a/vm/math.c
+++ b/vm/math.c
@@ -197,7 +197,7 @@ void primitive_bignum_xor(void)
 
 void primitive_bignum_shift(void)
 {
-       F_FIXNUM y = to_fixnum(dpop());
+       F_FIXNUM y = untag_fixnum_fast(dpop());
         F_ARRAY* x = untag_object(dpop());
        dpush(tag_bignum(bignum_arithmetic_shift(x,y)));
 }
index a614011e7eef760ea9490aa77992e37a2808ccb0..1afbcd3a4062fb2ef7597851fad0274a658b599c 100755 (executable)
@@ -157,27 +157,18 @@ CELL allot_array_4(CELL v1, CELL v2, CELL v3, CELL v4)
        return tag_object(a);
 }
 
-F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity, CELL fill)
+F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity)
 {
-       int i;
-       F_ARRAY* new_array;
-
        CELL to_copy = array_capacity(array);
        if(capacity < to_copy)
                to_copy = capacity;
 
        REGISTER_UNTAGGED(array);
-       REGISTER_ROOT(fill);
-
-       new_array = allot_array_internal(untag_header(array->header),capacity);
-
-       UNREGISTER_ROOT(fill);
+       F_ARRAY* new_array = allot_array_internal(untag_header(array->header),capacity);
        UNREGISTER_UNTAGGED(array);
 
        memcpy(new_array + 1,array + 1,to_copy * CELLS);
-
-       for(i = to_copy; i < capacity; i++)
-               put(AREF(new_array,i),fill);
+       memset((char *)AREF(new_array,to_copy),'\0',(capacity - to_copy) * CELLS);
 
        return new_array;
 }
@@ -186,7 +177,7 @@ void primitive_resize_array(void)
 {
        F_ARRAY* array = untag_array(dpop());
        CELL capacity = unbox_array_size();
-       dpush(tag_object(reallot_array(array,capacity,F)));
+       dpush(tag_object(reallot_array(array,capacity)));
 }
 
 F_ARRAY *growable_array_add(F_ARRAY *result, CELL elt, CELL *result_count)
@@ -195,8 +186,7 @@ F_ARRAY *growable_array_add(F_ARRAY *result, CELL elt, CELL *result_count)
 
        if(*result_count == array_capacity(result))
        {
-               result = reallot_array(result,
-                       *result_count * 2,F);
+               result = reallot_array(result,*result_count * 2);
        }
 
        UNREGISTER_ROOT(elt);
@@ -214,7 +204,7 @@ F_ARRAY *growable_array_append(F_ARRAY *result, F_ARRAY *elts, CELL *result_coun
        CELL new_size = *result_count + elts_size;
 
        if(new_size >= array_capacity(result))
-               result = reallot_array(result,new_size * 2,F);
+               result = reallot_array(result,new_size * 2);
 
        UNREGISTER_UNTAGGED(elts);
 
@@ -433,7 +423,7 @@ void primitive_string(void)
        dpush(tag_object(allot_string(length,initial)));
 }
 
-F_STRING* reallot_string(F_STRING* string, CELL capacity, CELL fill)
+F_STRING* reallot_string(F_STRING* string, CELL capacity)
 {
        CELL to_copy = string_capacity(string);
        if(capacity < to_copy)
@@ -462,7 +452,7 @@ F_STRING* reallot_string(F_STRING* string, CELL capacity, CELL fill)
 
        REGISTER_UNTAGGED(string);
        REGISTER_UNTAGGED(new_string);
-       fill_string(new_string,to_copy,capacity,fill);
+       fill_string(new_string,to_copy,capacity,'\0');
        UNREGISTER_UNTAGGED(new_string);
        UNREGISTER_UNTAGGED(string);
 
@@ -473,7 +463,7 @@ void primitive_resize_string(void)
 {
        F_STRING* string = untag_string(dpop());
        CELL capacity = unbox_array_size();
-       dpush(tag_object(reallot_string(string,capacity,0)));
+       dpush(tag_object(reallot_string(string,capacity)));
 }
 
 /* Some ugly macros to prevent a 2x code duplication */
index 242939c502dc6bff6e36dcbf88f458e4b93c65fe..ba8d9689fe8b810c5c02ddc25944b2cebc44fba2 100755 (executable)
@@ -118,7 +118,7 @@ void primitive_tuple_layout(void);
 void primitive_byte_array(void);
 void primitive_clone(void);
 
-F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity, CELL fill);
+F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity);
 F_BYTE_ARRAY *reallot_byte_array(F_BYTE_ARRAY *array, CELL capacity);
 void primitive_resize_array(void);
 void primitive_resize_byte_array(void);
@@ -126,7 +126,7 @@ void primitive_resize_byte_array(void);
 F_STRING* allot_string_internal(CELL capacity);
 F_STRING* allot_string(CELL capacity, CELL fill);
 void primitive_string(void);
-F_STRING *reallot_string(F_STRING *string, CELL capacity, CELL fill);
+F_STRING *reallot_string(F_STRING *string, CELL capacity);
 void primitive_resize_string(void);
 
 F_STRING *memory_to_char_string(const char *string, CELL length);
@@ -177,7 +177,7 @@ F_ARRAY *growable_array_append(F_ARRAY *result, F_ARRAY *elts, CELL *result_coun
        result = tag_object(growable_array_append(untag_object(result),elts,&result##_count))
 
 #define GROWABLE_ARRAY_TRIM(result) \
-       result = tag_object(reallot_array(untag_object(result),result##_count,F))
+       result = tag_object(reallot_array(untag_object(result),result##_count))
 
 /* Macros to simulate a byte vector in C */
 #define GROWABLE_BYTE_ARRAY(result) \