]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'master' of git://factorcode.org/git/factor
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 11 Sep 2008 05:37:21 +0000 (00:37 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 11 Sep 2008 05:37:21 +0000 (00:37 -0500)
359 files changed:
basis/alien/arrays/arrays.factor
basis/alien/c-types/c-types.factor
basis/alien/structs/fields/fields.factor
basis/bootstrap/image/image.factor
basis/bootstrap/image/upload/upload.factor
basis/channels/remote/remote.factor
basis/checksums/common/common.factor
basis/checksums/sha1/sha1.factor
basis/checksums/sha2/sha2.factor
basis/cocoa/enumeration/enumeration.factor
basis/cocoa/messages/messages.factor
basis/cocoa/subclassing/subclassing.factor
basis/cocoa/views/views.factor
basis/combinators/short-circuit/short-circuit.factor
basis/compiler/compiler.factor
basis/compiler/generator/fixup/fixup.factor
basis/compiler/generator/generator.factor
basis/compiler/generator/registers/registers.factor
basis/compiler/tests/curry.factor
basis/compiler/tests/templates-early.factor
basis/compiler/tree/cleanup/cleanup-tests.factor
basis/compiler/tree/cleanup/cleanup.factor
basis/compiler/tree/combinators/combinators.factor
basis/compiler/tree/dead-code/branches/branches.factor
basis/compiler/tree/dead-code/simple/simple.factor
basis/compiler/tree/debugger/debugger.factor
basis/compiler/tree/escape-analysis/recursive/recursive.factor
basis/compiler/tree/finalization/finalization.factor
basis/compiler/tree/normalization/normalization.factor
basis/compiler/tree/propagation/branches/branches.factor
basis/compiler/tree/propagation/known-words/known-words.factor
basis/compiler/tree/propagation/simple/simple.factor
basis/compiler/tree/tree.factor
basis/concurrency/messaging/messaging-tests.factor
basis/core-foundation/fsevents/fsevents.factor
basis/cpu/architecture/architecture.factor
basis/cpu/ppc/assembler/assembler-tests.factor
basis/cpu/ppc/assembler/backend/backend.factor
basis/cpu/x86/architecture/architecture.factor
basis/cpu/x86/assembler/assembler-tests.factor
basis/cpu/x86/assembler/assembler.factor
basis/csv/csv.factor
basis/db/postgresql/postgresql.factor
basis/db/queries/queries.factor
basis/db/tuples/tuples-docs.factor
basis/db/tuples/tuples-tests.factor
basis/debugger/debugger.factor
basis/debugger/threads/threads.factor
basis/delegate/delegate.factor
basis/disjoint-sets/disjoint-sets.factor
basis/documents/documents.factor
basis/fry/fry-docs.factor
basis/fry/fry-tests.factor
basis/fry/fry.factor
basis/furnace/actions/actions.factor
basis/furnace/alloy/alloy.factor
basis/furnace/auth/auth.factor
basis/furnace/auth/basic/basic.factor
basis/furnace/auth/features/recover-password/recover-password.factor
basis/furnace/chloe-tags/chloe-tags.factor
basis/furnace/conversations/conversations.factor
basis/furnace/furnace.factor
basis/furnace/redirection/redirection.factor
basis/furnace/sessions/sessions-tests.factor
basis/furnace/syndication/syndication.factor
basis/generalizations/generalizations.factor
basis/help/handbook/handbook.factor
basis/help/help.factor
basis/help/lint/lint.factor
basis/help/markup/markup.factor
basis/help/topics/topics.factor
basis/hints/hints.factor
basis/html/components/components.factor
basis/html/elements/elements.factor
basis/html/forms/forms.factor
basis/html/streams/streams.factor
basis/html/templates/chloe/chloe.factor
basis/html/templates/chloe/compiler/compiler.factor
basis/html/templates/chloe/components/components.factor
basis/html/templates/fhtml/fhtml.factor
basis/http/client/client.factor
basis/http/http.factor
basis/http/parsers/parsers.factor
basis/http/server/cgi/cgi.factor
basis/http/server/server.factor
basis/http/server/static/static.factor
basis/interval-maps/interval-maps.factor
basis/io/servers/connection/connection.factor
basis/io/servers/packet/datagram.factor
basis/io/unix/backend/backend.factor
basis/io/unix/unix-tests.factor
basis/json/reader/reader.factor
basis/json/writer/writer.factor
basis/lcs/lcs.factor
basis/locals/locals.factor
basis/logging/insomniac/insomniac.factor
basis/logging/logging.factor
basis/logging/parser/parser.factor
basis/macros/expander/expander.factor
basis/match/match.factor
basis/math/bitwise/bitwise.factor
basis/math/partial-dispatch/partial-dispatch.factor
basis/memoize/memoize.factor
basis/mime-types/mime-types.factor
basis/multiline/multiline.factor
basis/peg/ebnf/ebnf.factor
basis/peg/parsers/parsers.factor
basis/peg/peg-tests.factor
basis/peg/peg.factor
basis/persistent/hashtables/hashtables-tests.factor
basis/persistent/hashtables/hashtables.factor
basis/persistent/hashtables/nodes/collision/collision.factor
basis/persistent/hashtables/nodes/leaf/leaf.factor
basis/prettyprint/backend/backend.factor
basis/prettyprint/prettyprint-tests.factor
basis/prettyprint/prettyprint.factor
basis/prettyprint/sections/sections.factor
basis/random/mersenne-twister/mersenne-twister-docs.factor.bak [deleted file]
basis/random/mersenne-twister/mersenne-twister-tests.factor
basis/sequences/deep/deep-tests.factor
basis/smtp/smtp.factor
basis/stack-checker/backend/backend.factor
basis/stack-checker/branches/branches.factor
basis/stack-checker/inlining/inlining.factor
basis/stack-checker/state/state.factor
basis/stack-checker/transforms/transforms.factor
basis/state-parser/state-parser.factor
basis/summary/summary.factor
basis/syndication/syndication.factor
basis/tools/deploy/backend/backend.factor
basis/tools/deploy/macosx/macosx.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/disassembler/disassembler.factor
basis/tools/vocabs/vocabs.factor
basis/tools/walker/walker.factor
basis/tr/tr.factor
basis/ui/commands/commands-docs.factor
basis/ui/commands/commands.factor
basis/ui/gadgets/editors/editors.factor
basis/ui/gadgets/gadgets.factor
basis/ui/gadgets/grids/grids.factor
basis/ui/gadgets/labels/labels.factor
basis/ui/gadgets/tracks/tracks.factor
basis/ui/gestures/gestures.factor
basis/ui/operations/operations.factor
basis/ui/tools/walker/walker.factor
basis/ui/traverse/traverse-tests.factor
basis/ui/traverse/traverse.factor
basis/ui/ui-docs.factor
basis/ui/ui.factor
basis/unicode/breaks/breaks.factor
basis/unicode/case/case.factor
basis/unicode/collation/collation.factor
basis/unicode/normalize/normalize.factor
basis/unicode/script/script.factor
basis/unicode/syntax/syntax.factor
basis/urls/urls.factor
basis/validators/validators.factor
basis/windows/com/syntax/syntax.factor
basis/windows/com/wrapper/wrapper.factor
basis/windows/dinput/constants/constants.factor
basis/wrap/wrap.factor
basis/x11/glx/glx.factor
basis/xml/entities/entities.factor
basis/xml/generator/generator.factor
basis/xml/tests/test.factor
basis/xml/tokenize/tokenize.factor
basis/xmode/code2html/responder/responder.factor
basis/xmode/loader/syntax/syntax.factor
basis/xmode/marker/marker.factor
basis/xmode/marker/state/state.factor
core/assocs/assocs-tests.factor
core/classes/classes.factor
core/classes/predicate/predicate.factor
core/classes/tuple/parser/parser.factor
core/classes/tuple/tuple.factor
core/compiler/errors/errors.factor
core/continuations/continuations.factor
core/destructors/destructors.factor
core/effects/effects.factor
core/generic/generic.factor
core/generic/math/math.factor
core/generic/standard/engines/tag/tag.factor
core/generic/standard/engines/tuple/tuple.factor
core/generic/standard/standard-tests.factor
core/generic/standard/standard.factor
core/hashtables/hashtables-tests.factor
core/io/io-tests.factor
core/io/io.factor
core/io/streams/c/c.factor
core/io/streams/string/string-tests.factor
core/make/make-docs.factor [new file with mode: 0644]
core/make/make.factor [new file with mode: 0644]
core/math/math-tests.factor
core/math/parser/parser-docs.factor
core/math/parser/parser.factor
core/namespaces/namespaces-docs.factor
core/namespaces/namespaces.factor
core/slots/slots.factor
core/splitting/splitting.factor
core/strings/parser/parser.factor
core/strings/strings-tests.factor
core/vocabs/loader/loader.factor
extra/asn1/asn1.factor
extra/backtrack/backtrack.factor
extra/bank/bank-tests.factor
extra/benchmark/dispatch2/dispatch2.factor
extra/benchmark/dispatch3/dispatch3.factor
extra/benchmark/mandel/mandel.factor
extra/benchmark/nsieve-bits/nsieve-bits.factor
extra/benchmark/nsieve/nsieve.factor
extra/benchmark/raytracer/raytracer.factor
extra/bitfields/bitfields.factor
extra/builder/release/upload/upload.factor
extra/cfdg/cfdg.factor
extra/combinators/cleave/cleave.factor
extra/combinators/conditional/conditional.factor
extra/combinators/lib/lib.factor
extra/coroutines/coroutines.factor
extra/ctags/ctags.factor
extra/ctags/etags/etags.factor
extra/demos/demos.factor
extra/display-stack/display-stack.factor
extra/dns/server/server.factor
extra/dns/util/util.factor
extra/faq/faq.factor
extra/fjsc/fjsc.factor
extra/ftp/client/client.factor
extra/ftp/server/server.factor
extra/graph-theory/graph-theory.factor
extra/graph-theory/sparse/sparse.factor
extra/html/parser/analyzer/analyzer.factor
extra/html/parser/parser.factor
extra/inverse/inverse.factor
extra/irc/client/client.factor
extra/irc/messages/messages.factor
extra/irc/ui/ui.factor
extra/joystick-demo/joystick-demo.factor
extra/key-caps/key-caps.factor
extra/lisp/lisp.factor
extra/lists/lazy/lazy.factor
extra/math/blas/vectors/vectors.factor
extra/math/combinatorics/combinatorics.factor
extra/math/numerical-integration/numerical-integration.factor
extra/math/polynomials/polynomials.factor
extra/math/primes/factors/factors.factor
extra/monads/monads.factor
extra/money/money.factor
extra/morse/morse.factor
extra/multi-methods/multi-methods.factor
extra/odbc/odbc.factor
extra/opengl/capabilities/capabilities.factor
extra/ori/ori.factor
extra/pack/pack-tests.factor
extra/pack/pack.factor
extra/processing/processing.factor
extra/project-euler/009/009.factor
extra/project-euler/011/011.factor
extra/project-euler/014/014.factor
extra/project-euler/042/042.factor
extra/project-euler/059/059.factor
extra/project-euler/079/079.factor
extra/project-euler/ave-time/ave-time.factor
extra/project-euler/common/common.factor
extra/promises/promises.factor
extra/random-weighted/random-weighted.factor
extra/regexp/regexp.factor
extra/rewrite-closures/rewrite-closures.factor
extra/roman/roman.factor
extra/sequences/lib/lib.factor
extra/state-machine/state-machine.factor
extra/state-tables/state-tables.factor
extra/synth/example/example.factor
extra/ui/gadgets/tabs/tabs.factor
extra/ui/gadgets/tiling/tiling.factor
extra/webapps/counter/counter.factor
extra/webapps/planet/planet.factor
extra/webapps/wee-url/wee-url.factor
extra/webapps/wiki/wiki.factor
extra/websites/concatenative/concatenative.factor
extra/wordtimer/wordtimer.factor
extra/xml/syntax/syntax.factor
unfinished/compiler/alien/alien.factor [new file with mode: 0644]
unfinished/compiler/backend/alien/alien.factor [new file with mode: 0644]
unfinished/compiler/backend/backend.factor [new file with mode: 0644]
unfinished/compiler/backend/x86/32/32.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/alias/alias.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/authors.txt [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/builder/builder-tests.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/builder/builder.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/cfg.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/elaboration/elaboration.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/kill-nops/kill-nops.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/live-ranges/live-ranges.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/predecessors/predecessors.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/simplifier/simplifier.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/stack/stack.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/summary.txt [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/conditions/conditions.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/constant-fold/constant-fold.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/expressions/expressions.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/graph/graph.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/liveness/liveness.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/propagate/propagate.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/simplify/simplify.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/vn/vn.factor [new file with mode: 0644]
unfinished/compiler/cfg.bluesky/write-barrier/write-barrier.factor [new file with mode: 0644]
unfinished/compiler/cfg/alias/alias.factor [deleted file]
unfinished/compiler/cfg/authors.txt [deleted file]
unfinished/compiler/cfg/builder/authors.txt [new file with mode: 0644]
unfinished/compiler/cfg/builder/builder-tests.factor
unfinished/compiler/cfg/builder/builder.factor [changed mode: 0644->0755]
unfinished/compiler/cfg/builder/summary.txt [new file with mode: 0644]
unfinished/compiler/cfg/builder/tags.txt [new file with mode: 0644]
unfinished/compiler/cfg/cfg.factor
unfinished/compiler/cfg/elaboration/elaboration.factor [deleted file]
unfinished/compiler/cfg/iterator/iterator.factor [new file with mode: 0644]
unfinished/compiler/cfg/kill-nops/kill-nops.factor [deleted file]
unfinished/compiler/cfg/live-ranges/live-ranges.factor [deleted file]
unfinished/compiler/cfg/predecessors/predecessors.factor [deleted file]
unfinished/compiler/cfg/simplifier/simplifier.factor [deleted file]
unfinished/compiler/cfg/stack/stack.factor [deleted file]
unfinished/compiler/cfg/stacks/authors.txt [new file with mode: 0644]
unfinished/compiler/cfg/stacks/stacks.factor [new file with mode: 0755]
unfinished/compiler/cfg/summary.txt [deleted file]
unfinished/compiler/cfg/templates/templates.factor [new file with mode: 0644]
unfinished/compiler/cfg/vn/conditions/conditions.factor [deleted file]
unfinished/compiler/cfg/vn/constant-fold/constant-fold.factor [deleted file]
unfinished/compiler/cfg/vn/expressions/expressions.factor [deleted file]
unfinished/compiler/cfg/vn/graph/graph.factor [deleted file]
unfinished/compiler/cfg/vn/liveness/liveness.factor [deleted file]
unfinished/compiler/cfg/vn/propagate/propagate.factor [deleted file]
unfinished/compiler/cfg/vn/simplify/simplify.factor [deleted file]
unfinished/compiler/cfg/vn/vn.factor [deleted file]
unfinished/compiler/cfg/write-barrier/write-barrier.factor [deleted file]
unfinished/compiler/codegen/fixup/authors.txt [new file with mode: 0644]
unfinished/compiler/codegen/fixup/fixup.factor [new file with mode: 0755]
unfinished/compiler/codegen/fixup/summary.txt [new file with mode: 0644]
unfinished/compiler/instructions/instructions.factor [new file with mode: 0644]
unfinished/compiler/instructions/syntax/syntax.factor [new file with mode: 0644]
unfinished/compiler/lvops.bluesky/lvops.factor [new file with mode: 0644]
unfinished/compiler/lvops/lvops.factor [deleted file]
unfinished/compiler/machine.bluesky/builder/builder.factor [new file with mode: 0644]
unfinished/compiler/machine.bluesky/debugger/debugger.factor [new file with mode: 0644]
unfinished/compiler/machine.bluesky/simplifier/simplifier.factor [new file with mode: 0644]
unfinished/compiler/machine/builder/builder.factor
unfinished/compiler/machine/debugger/debugger.factor [deleted file]
unfinished/compiler/machine/linear-scan/allocation/allocation.factor [new file with mode: 0644]
unfinished/compiler/machine/linear-scan/linear-scan.factor [new file with mode: 0644]
unfinished/compiler/machine/linear-scan/live-intervals/live-intervals.factor [new file with mode: 0644]
unfinished/compiler/machine/machine.factor [new file with mode: 0644]
unfinished/compiler/machine/optimizer/optimizer-tests.factor [new file with mode: 0644]
unfinished/compiler/machine/optimizer/optimizer.factor [new file with mode: 0644]
unfinished/compiler/machine/simplifier/simplifier.factor [deleted file]
unfinished/compiler/registers/registers.factor [new file with mode: 0644]
unfinished/compiler/vops.bluesky/builder/builder.factor [new file with mode: 0644]
unfinished/compiler/vops.bluesky/vops.factor [new file with mode: 0644]
unfinished/compiler/vops/builder/builder.factor [deleted file]
unfinished/compiler/vops/vops.factor [deleted file]

index 71c3fd6ff2bf53cd7b4146ddd429952e626820a6..94472e8261b092718bd7170c0912ba5e03722714 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien arrays alien.c-types alien.structs
-sequences math kernel namespaces libc cpu.architecture ;
+sequences math kernel namespaces make libc cpu.architecture ;
 IN: alien.arrays
 
 UNION: value-type array struct-type ;
index f44941d88f1ca66a38ee04d403904ee5e3de7e93..6a88441be915ae1f88f71c063a8ce24c14e90edb 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: byte-arrays arrays assocs kernel kernel.private libc math
-namespaces parser sequences strings words assocs splitting
+namespaces make parser sequences strings words assocs splitting
 math.parser cpu.architecture alien alien.accessors quotations
 layouts system compiler.units io.files io.encodings.binary
 accessors combinators effects continuations ;
index 5273c2c7bac6e3032ce40c694b533645f026c7e0..19e5b8c326e17bd8043bd4504d2eabf9b1857548 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays kernel kernel.private math namespaces
-sequences strings words effects combinators alien.c-types ;
+make sequences strings words effects combinators alien.c-types ;
 IN: alien.structs.fields
 
 TUPLE: field-spec name offset type reader writer ;
index edfd82dae2419f51d38c1bbc059d1127a31c2f36..9284728a7a8ee0a72d5db303fab605d5ea7f5ec2 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien arrays byte-arrays generic assocs hashtables assocs
-hashtables.private io kernel kernel.private math namespaces
+hashtables.private io kernel kernel.private math namespaces make
 parser prettyprint sequences sequences.private strings sbufs
 vectors words quotations assocs system layouts splitting
 grouping growable classes classes.builtin classes.tuple
index de13b4aed43fc28b2e6e0d2908b2cbbe5f7d06ee..f0edf85e653e3a12d0d65d9e0814784f5f8935f7 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: checksums checksums.openssl splitting assocs
-kernel io.files bootstrap.image sequences io namespaces
+kernel io.files bootstrap.image sequences io namespaces make
 io.launcher math io.encodings.ascii ;
 IN: bootstrap.image.upload
 
index 9c1878e14d03309ae522d13f5f6f2aa263d951e3..1a7addac12583fcb5646e529951d40336f76db7a 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 ! Remote Channels
-USING: kernel init namespaces assocs arrays random
+USING: kernel init namespaces make assocs arrays random
 sequences channels match concurrency.messaging
 concurrency.distributed threads accessors ;
 IN: channels.remote
index ea1c6f5b39935a63a45c840a163c7683a37f5e4e..1f25efef24c72e6a5c03de1a3790bed5d902a642 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math math.bitwise strings io.binary namespaces
-grouping ;
+make grouping ;
 IN: checksums.common
 
 SYMBOL: bytes-read
index 6aa2cfa2eb64cbf2405aa8055790c67c90dca107..bbae421b16fe0d1d86e86c9d44e3be955ec8a5d7 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays combinators kernel io io.encodings.binary io.files
 io.streams.byte-array math.vectors strings sequences namespaces
-math parser sequences assocs grouping vectors io.binary hashtables
-symbols math.bitwise checksums checksums.common ;
+make math parser sequences assocs grouping vectors io.binary
+hashtables symbols math.bitwise checksums checksums.common ;
 IN: checksums.sha1
 
 ! Implemented according to RFC 3174.
index ac93c052609950dc9011db999082266bb34877d8..0a6d8c26ab335c53b69f1af41e9da3e18355d766 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel splitting grouping math sequences namespaces
+USING: kernel splitting grouping math sequences namespaces make
 io.binary symbols math.bitwise checksums checksums.common
 sbufs strings ;
 IN: checksums.sha2
index 765fb65ef2a43c527ebaa13c3075c219d83ad6ae..7de1f24a3c6e04b1f0c57e287675a0e268d6cf6b 100644 (file)
@@ -15,7 +15,7 @@ IN: cocoa.enumeration
     object state stackbuf count -> countByEnumeratingWithState:objects:count:
     dup zero? [ drop ] [
         state NSFastEnumerationState-itemsPtr [ stackbuf ] unless*
-        '[ , void*-nth quot call ] each
+        '[ _ void*-nth quot call ] each
         object quot state stackbuf count (NSFastEnumeration-each)
     ] if ; inline recursive
 
@@ -24,7 +24,7 @@ IN: cocoa.enumeration
 
 : NSFastEnumeration-map ( object quot -- vector )
     NS-EACH-BUFFER-SIZE <vector>
-    [ '[ @ , push ] NSFastEnumeration-each ] keep ; inline
+    [ '[ @ _ push ] NSFastEnumeration-each ] keep ; inline
 
 : NSFastEnumeration>vector ( object -- vector )
     [ ] NSFastEnumeration-map ;
index 7be649416c7f0cbdb805cc1984df633f3752900d..7977485b02c2245a34e0b2c40fcf2b01d88327d2 100755 (executable)
@@ -1,11 +1,10 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.c-types alien.strings
-arrays assocs combinators compiler kernel
-math namespaces parser prettyprint prettyprint.sections
-quotations sequences strings words cocoa.runtime io macros
-memoize debugger io.encodings.ascii effects compiler.generator
-libc libc.private ;
+USING: accessors alien alien.c-types alien.strings arrays assocs
+combinators compiler kernel math namespaces make parser
+prettyprint prettyprint.sections quotations sequences strings
+words cocoa.runtime io macros memoize debugger
+io.encodings.ascii effects compiler.generator libc libc.private ;
 IN: cocoa.messages
 
 : make-sender ( method function -- quot )
index 1ee39c35d512c373e6589410d34d1ca82e85af20..3f8e709df0e779dc0d88855aba3177feb0329b0a 100755 (executable)
@@ -4,7 +4,7 @@ USING: alien alien.c-types alien.strings arrays assocs
 combinators compiler hashtables kernel libc math namespaces
 parser sequences words cocoa.messages cocoa.runtime
 compiler.units io.encodings.ascii generalizations
-continuations ;
+continuations make ;
 IN: cocoa.subclassing
 
 : init-method ( method -- sel imp types )
index 8bfbe330b279f25b6a2a3d5123c196ac0cf28e80..d03688b2be701cc2c865e8fed622a7955de20854 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types arrays kernel math namespaces cocoa
+USING: alien.c-types arrays kernel math namespaces make cocoa
 cocoa.messages cocoa.classes cocoa.types sequences
 continuations ;
 IN: cocoa.views
index a484e09de17b2af3d77946aee31308794c61394e..7b6c1d126da8fadc4c1fad0cb9d48b2599dc64eb 100755 (executable)
@@ -11,7 +11,7 @@ IN: combinators.short-circuit
      [ '[ drop N ndup @ dup not ] [ drop N ndrop f ] 2array ]
    map
    [ t ] [ N nnip ] 2array suffix
-   '[ f , cond ] ;
+   '[ f _ cond ] ;
 
 MACRO: 0&& ( quots -- quot ) 0 n&&-rewrite ;
 MACRO: 1&& ( quots -- quot ) 1 n&&-rewrite ;
@@ -25,7 +25,7 @@ MACRO: 3&& ( quots -- quot ) 3 n&&-rewrite ;
      [ '[ drop N ndup @ dup ] [ N nnip ] 2array ]
    map
    [ drop N ndrop t ] [ f ] 2array suffix
-   '[ f , cond ] ;
+   '[ f _ cond ] ;
 
 MACRO: 0|| ( quots -- quot ) 0 n||-rewrite ;
 MACRO: 1|| ( quots -- quot ) 1 n||-rewrite ;
index 2dd6e440d5d1f4a22f43a46ff129817337a24344..1558127293b6dac2a52e40e4da8dc77cc395320b 100755 (executable)
@@ -54,7 +54,7 @@ SYMBOL: +failed+
         H{ } clone dependencies set
         H{ } clone generic-dependencies set
 
-        , {
+        _ {
             [ compile-begins ]
             [
                 [ build-tree-from-word ] [ compile-failed return ] recover
index 5a3337fb32e8239e3f0429f8ba495bc5d150c3a4..ecc88a7a5e1ba16fe8c53699cea91b9e60299ba0 100755 (executable)
@@ -1,7 +1,7 @@
 ! 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 sequences words
+kernel kernel.private math namespaces make sequences words
 quotations strings alien.accessors alien.strings layouts system
 combinators math.bitwise words.private cpu.architecture
 math.order accessors growable ;
index da120ce4320f0b4fd5d1d30fa6a8b693f8e56c40..939d6e2276f82472940e6638a7f50de7742fcbfc 100755 (executable)
@@ -1,15 +1,15 @@
- ! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs classes combinators
 cpu.architecture effects generic hashtables io kernel
-kernel.private layouts math math.parser namespaces prettyprint
-quotations sequences system threads words vectors sets deques
-continuations.private summary alien alien.c-types
+kernel.private layouts math math.parser namespaces make
+prettyprint quotations sequences system threads words vectors
+sets deques continuations.private summary alien alien.c-types
 alien.structs alien.strings alien.arrays libc compiler.errors
-stack-checker.inlining
-compiler.tree compiler.tree.builder compiler.tree.combinators
-compiler.tree.propagation.info compiler.generator.fixup
-compiler.generator.registers compiler.generator.iterator ;
+stack-checker.inlining compiler.tree compiler.tree.builder
+compiler.tree.combinators compiler.tree.propagation.info
+compiler.generator.fixup compiler.generator.registers
+compiler.generator.iterator ;
 IN: compiler.generator
 
 SYMBOL: compile-queue
index e909db3f8341f8b5c2b1a1defda1a0c5e4e261ee..76d3c325947720ef3e69eaaca4268286dc528806 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs classes classes.private classes.algebra
-combinators hashtables kernel layouts math namespaces quotations
-sequences system vectors words effects alien byte-arrays
-accessors sets math.order cpu.architecture
+combinators hashtables kernel layouts math namespaces make
+quotations sequences system vectors words effects alien
+byte-arrays accessors sets math.order cpu.architecture
 compiler.generator.fixup ;
 IN: compiler.generator.registers
 
index 61d20fd8abfc96098dcc5b41b86798e719540b4a..ecc2d87b7330f1910c431477f509a1a47d04f4f1 100755 (executable)
@@ -1,5 +1,5 @@
 USING: tools.test quotations math kernel sequences
-assocs namespaces compiler.units ;
+assocs namespaces make compiler.units ;
 IN: compiler.tests
 
 [ 3 ] [ 5 [ [ 2 - ] curry call ] compile-call ] unit-test
index 6b2eed078964c3f6a80fb418309e278b1ff1e6e5..d3bc4a8a08f74f72ad5c60c771b08fad5b44bf98 100755 (executable)
@@ -3,7 +3,7 @@ IN: compiler.tests
 USING: compiler compiler.generator compiler.generator.registers
 compiler.generator.registers.private tools.test namespaces
 sequences words kernel math effects definitions compiler.units
-accessors cpu.architecture ;
+accessors cpu.architecture make ;
 
 : <int-vreg> ( n -- vreg ) int-regs <vreg> ;
 
index bb30cda68567c1d2f1f75aaee10926d4100444fd..a761c8ec1e13b1591f5b700e9b98f6d7c5a7e69f 100644 (file)
@@ -36,7 +36,7 @@ compiler.tree.checker ;
 : inlined? ( quot seq/word -- ? )
     [ cleaned-up-tree ] dip
     dup word? [ 1array ] when
-    '[ dup #call? [ word>> , member? ] [ drop f ] if ]
+    '[ dup #call? [ word>> _ member? ] [ drop f ] if ]
     contains-node? not ;
 
 [ f ] [
@@ -457,3 +457,24 @@ cell-bits 32 = [
     [ [ >r "A" throw r> ] [ "B" throw ] if ]
     cleaned-up-tree drop
 ] unit-test
+
+! Regression from benchmark.nsieve
+: chicken-fingers ( i seq -- )
+    2dup < [
+        2drop
+    ] [
+        chicken-fingers
+    ] if ; inline recursive
+
+: buffalo-wings ( i seq -- )
+    2dup < [
+        2dup chicken-fingers
+        >r 1+ r> buffalo-wings
+    ] [
+        2drop
+    ] if ; inline recursive
+
+[ t ] [
+    [ 2 swap >fixnum buffalo-wings ]
+    { <-integer-fixnum +-integer-fixnum } inlined?
+] unit-test
index 44a6a11802d28ecf6cc464f301c32d6ee90a4b4d..58dc07d868d79f28a34391dfd62aedd627dabf68 100644 (file)
@@ -101,7 +101,7 @@ M: #declare cleanup* drop f ;
 
 : delete-unreachable-branches ( #branch -- )
     dup live-branches>> '[
-        ,
+        _
         [ [ [ drop ] [ delete-nodes ] if ] 2each ]
         [ select-children ]
         2bi
@@ -148,9 +148,9 @@ M: #branch cleanup*
 M: #phi cleanup*
     #! Remove #phi function inputs which no longer exist.
     live-branches get
-    [ '[ , sift-children ] change-phi-in-d ]
-    [ '[ , sift-children ] change-phi-info-d ]
-    [ '[ , sift-children ] change-terminated ] tri
+    [ '[ _ sift-children ] change-phi-in-d ]
+    [ '[ _ sift-children ] change-phi-info-d ]
+    [ '[ _ sift-children ] change-terminated ] tri
     eliminate-phi
     live-branches off ;
 
index 0f4dc3f2a348a2ce74a9c332b1767466128fef9f..f284a06a88d8873b5ff050b474dbdfd30b982b3f 100644 (file)
@@ -6,12 +6,12 @@ IN: compiler.tree.combinators
 
 : each-node ( nodes quot: ( node -- ) -- )
     dup dup '[
-        , [
+        _ [
             dup #branch? [
-                children>> [ , each-node ] each
+                children>> [ _ each-node ] each
             ] [
                 dup #recursive? [
-                    child>> , each-node
+                    child>> _ each-node
                 ] [ drop ] if
             ] if
         ] bi
@@ -21,22 +21,22 @@ IN: compiler.tree.combinators
     dup dup '[
         @
         dup #branch? [
-            [ [ , map-nodes ] map ] change-children
+            [ [ _ map-nodes ] map ] change-children
         ] [
             dup #recursive? [
-                [ , map-nodes ] change-child
+                [ _ map-nodes ] change-child
             ] when
         ] if
     ] map flatten ; inline recursive
 
 : contains-node? ( nodes quot: ( node -- ? ) -- ? )
     dup dup '[
-        , keep swap [ drop t ] [
+        _ keep swap [ drop t ] [
             dup #branch? [
-                children>> [ , contains-node? ] contains?
+                children>> [ _ contains-node? ] contains?
             ] [
                 dup #recursive? [
-                    child>> , contains-node?
+                    child>> _ contains-node?
                 ] [ drop f ] if
             ] if
         ] if
index 0014a1d4d74d2dd31194d7416a65f32350803a07..a19e49494ef6f37e6a5bd4db52bf76378de04a9f 100644 (file)
@@ -33,7 +33,7 @@ M: #branch remove-dead-code*
 
 : live-value-indices ( values -- indices )
     [ length ] keep live-values get
-    '[ , nth , key? ] filter ; inline
+    '[ _ nth _ key? ] filter ; inline
 
 : drop-indexed-values ( values indices -- node )
     [ drop filter-live ] [ nths ] 2bi
@@ -44,13 +44,13 @@ M: #branch remove-dead-code*
 : insert-drops ( nodes values indices -- nodes' )
     '[
         over ends-with-terminate?
-        [ drop ] [ , drop-indexed-values suffix ] if
+        [ drop ] [ _ drop-indexed-values suffix ] if
     ] 2map ;
 
 : hoist-drops ( #phi -- )
     if-node get swap
     [ phi-in-d>> ] [ out-d>> live-value-indices ] bi
-    '[ , , insert-drops ] change-children drop ;
+    '[ _ _ insert-drops ] change-children drop ;
 
 : remove-phi-outputs ( #phi -- )
     [ filter-live ] change-out-d drop ;
index 9ebf064f79725338e9ba03b5720fcf3cae88c897..addb13ced3a2e8462e012899631aeca39545daeb 100755 (executable)
@@ -53,7 +53,7 @@ M: #alien-invoke compute-live-values* nip look-at-inputs ;
 M: #alien-indirect compute-live-values* nip look-at-inputs ;
 
 : filter-mapping ( assoc -- assoc' )
-    live-values get '[ drop , key? ] assoc-filter ;
+    live-values get '[ drop _ key? ] assoc-filter ;
 
 : filter-corresponding ( new old -- old' )
     #! Remove elements from 'old' if the element with the same
index db742197a55975477ecbf490e3b5a0652a3b4f9a..691c564661b415c18544f2922b69fb9c4d1c3d95 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel assocs fry match accessors namespaces effects
+USING: kernel assocs fry match accessors namespaces make effects
 sequences sequences.private quotations generic macros arrays
 prettyprint prettyprint.backend prettyprint.sections math words
 combinators io sorting hints
@@ -16,7 +16,7 @@ IN: compiler.tree.debugger
 GENERIC: node>quot ( node -- )
 
 MACRO: match-choose ( alist -- )
-    [ '[ , ] ] assoc-map '[ , match-cond ] ;
+    [ [ ] curry ] assoc-map [ match-cond ] curry ;
 
 MATCH-VARS: ?a ?b ?c ;
 
index 059ac1de02ba74fd037f64569e1bb59aa7ecc667..5aece23d1784a8933a8245b77ec86325ba50ae9a 100644 (file)
@@ -28,7 +28,7 @@ IN: compiler.tree.escape-analysis.recursive
 
 : recursive-stacks ( #enter-recursive -- stacks )
     recursive-phi-in
-    escaping-values get '[ [ , disjoint-set-member? ] all? ] filter
+    escaping-values get '[ [ _ disjoint-set-member? ] all? ] filter
     flip ;
 
 : analyze-recursive-phi ( #enter-recursive -- )
@@ -67,5 +67,5 @@ M: #return-recursive escape-analysis* ( #return-recursive -- )
     [ call-next-method ]
     [
         [ in-d>> ] [ label>> calls>> ] bi
-        [ out-d>> escaping-values get '[ , equate ] 2each ] with each
+        [ out-d>> escaping-values get '[ _ equate ] 2each ] with each
     ] bi ;
index 5aaeed360a397d70c2aa149a317bbd17dbeab7b7..dafe032ab6afb68d57e7b08c725f1b4f2ddb3830 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel arrays accessors sequences sequences.private words
-fry namespaces math math.order memoize classes.builtin
+fry namespaces make math math.order memoize classes.builtin
 classes.tuple.private slots.private combinators layouts
 byte-arrays alien.accessors
 compiler.intrinsics
@@ -68,7 +68,7 @@ MEMO: builtin-predicate-expansion ( word -- nodes )
 MEMO: (tuple-boa-expansion) ( n -- quot )
     [
         [ 2 + ] map <reversed>
-        [ '[ [ , set-slot ] keep ] % ] each
+        [ '[ [ _ set-slot ] keep ] % ] each
     ] [ ] make ;
 
 : tuple-boa-expansion ( layout -- quot )
index 587dd6938b2eca6f7491b67093e63957568d0d98..b826a1590bfc09c0473b1f8169b2eb485f2489ee 100644 (file)
@@ -81,7 +81,7 @@ SYMBOL: rename-map
     [ rename-map get at ] keep or ;
 
 : rename-values ( values -- values' )
-    rename-map get '[ [ , at ] keep or ] map ;
+    rename-map get '[ [ _ at ] keep or ] map ;
 
 GENERIC: rename-node-values* ( node -- node )
 
@@ -127,7 +127,7 @@ SYMBOL: introduction-stack
 
 : add-renamings ( old new -- )
     [ rename-values ] dip
-    rename-map get '[ , set-at ] 2each ;
+    rename-map get '[ _ set-at ] 2each ;
 
 M: #introduce normalize*
     out-d>> [ length pop-introductions ] keep add-renamings f ;
@@ -158,7 +158,7 @@ M: #branch normalize*
 
 M: #phi normalize*
     remaining-introductions get swap dup terminated>>
-    '[ , eliminate-phi-introductions ] change-phi-in-d ;
+    '[ _ eliminate-phi-introductions ] change-phi-in-d ;
 
 : (normalize) ( nodes introductions -- nodes )
     introduction-stack [
@@ -168,7 +168,7 @@ M: #phi normalize*
 M: #recursive normalize*
     dup label>> introductions>>
     [ drop [ child>> first ] [ in-d>> ] bi >>in-d drop ]
-    [ make-values '[ , (normalize) ] change-child ]
+    [ make-values '[ _ (normalize) ] change-child ]
     2bi ;
 
 M: #enter-recursive normalize*
@@ -181,14 +181,14 @@ M: #enter-recursive normalize*
 
 : call<return ( #call-recursive n -- nodes )
     neg dup make-values [
-        [ pop-introductions '[ , prepend ] change-in-d ]
-        [ '[ , prepend ] change-out-d ]
+        [ pop-introductions '[ _ prepend ] change-in-d ]
+        [ '[ _ prepend ] change-out-d ]
         bi*
     ] [ introduction-stack [ prepend ] change ] bi ;
 
 : call>return ( #call-recursive n -- #call-recursive )
-    [ [ [ in-d>> ] [ out-d>> ] bi ] [ '[ , head ] ] bi* bi@ add-renamings ]
-    [ '[ , tail ] [ change-in-d ] [ change-out-d ] bi ]
+    [ [ [ in-d>> ] [ out-d>> ] bi ] [ '[ _ head ] ] bi* bi@ add-renamings ]
+    [ '[ _ tail ] [ change-in-d ] [ change-out-d ] bi ]
     2bi ;
 
 M: #call-recursive normalize*
index f06f6792c78c00df22cee3078ecad6c2fb5ce6ac..c76217f8aed6bd171359baa33f7cd3253ee4ec18 100644 (file)
@@ -32,7 +32,7 @@ M: #if live-branches
 
 M: #dispatch live-branches
     [ children>> length ] [ in-d>> first value-info interval>> ] bi
-    '[ , interval-contains? ] map ;
+    '[ _ interval-contains? ] map ;
 
 : live-children ( #branch -- children )
     [ children>> ] [ live-branches>> ] bi select-children ;
@@ -61,7 +61,7 @@ SYMBOL: infer-children-data
     infer-children-data get
     [
         '[
-            , [
+            _ [
                 dup +bottom+ eq?
                 [ drop null-info ] [ value-info ] if
             ] bind
index d31de354d12687a920d62cce35dbef29e0f7bf5b..d208d3138909668457e1ae2d5b57a4deeda9e392 100644 (file)
@@ -118,7 +118,7 @@ most-negative-fixnum most-positive-fixnum [a,b]
 
 : binary-op ( word interval-quot post-proc-quot -- )
     '[
-        [ binary-op-class ] [ , binary-op-interval ] 2bi
+        [ binary-op-class ] [ _ binary-op-interval ] 2bi
         @
         <class/interval-info>
     ] "outputs" set-word-prop ;
@@ -159,14 +159,14 @@ most-negative-fixnum most-positive-fixnum [a,b]
     in1 in2 op negate-comparison (comparison-constraints) out f--> /\ ;
 
 : define-comparison-constraints ( word op -- )
-    '[ , comparison-constraints ] "constraints" set-word-prop ;
+    '[ _ comparison-constraints ] "constraints" set-word-prop ;
 
 comparison-ops
-[ dup '[ , define-comparison-constraints ] each-derived-op ] each
+[ dup '[ _ define-comparison-constraints ] each-derived-op ] each
 
 generic-comparison-ops [
     dup specific-comparison
-    '[ , , define-comparison-constraints ] each-derived-op
+    '[ _ _ define-comparison-constraints ] each-derived-op
 ] each
 
 ! Remove redundant comparisons
@@ -179,13 +179,13 @@ generic-comparison-ops [
 
 comparison-ops [
     dup '[
-        [ , fold-comparison ] "outputs" set-word-prop
+        [ _ fold-comparison ] "outputs" set-word-prop
     ] each-derived-op
 ] each
 
 generic-comparison-ops [
     dup specific-comparison
-    '[ , fold-comparison ] "outputs" set-word-prop
+    '[ _ fold-comparison ] "outputs" set-word-prop
 ] each
 
 : maybe-or-never ( ? -- info )
@@ -221,7 +221,7 @@ generic-comparison-ops [
     { >float float }
 } [
     '[
-        ,
+        _
         [ nip ] [
             [ interval>> ] [ class-interval ] bi*
             interval-intersect
index 809a85a51fd3ba032e13325cb20c433b494ec18a..7fc38239f1cfb56f2e247b4116c00602d3a9485d 100644 (file)
@@ -68,8 +68,8 @@ M: #declare propagate-before
     [ in-d>> [ value-info literal?>> ] all? ] [ drop f ] if ;
 
 : (fold-call) ( #call word -- info )
-    [ [ out-d>> ] [ in-d>> [ value-info literal>> ] map ] bi ] [ '[ , execute ] ] bi*
-    '[ , , with-datastack [ <literal-info> ] map nip ]
+    [ [ out-d>> ] [ in-d>> [ value-info literal>> ] map ] bi ] [ '[ _ execute ] ] bi*
+    '[ _ _ with-datastack [ <literal-info> ] map nip ]
     [ drop [ object-info ] replicate ]
     recover ;
 
index b6c798ca3ca840ecb105d6ea96ed4a3b4a31ada2..05f33902ecd805b6d52c90a14e16f52d181e871f 100755 (executable)
@@ -178,7 +178,7 @@ M: #return-recursive inputs/outputs [ in-d>> ] [ out-d>> ] bi ;
 
 : shuffle-effect ( #shuffle -- effect )
     [ in-d>> ] [ out-d>> ] [ mapping>> ] tri
-    '[ , at ] map
+    '[ _ at ] map
     <effect> ;
 
 : recursive-phi-in ( #enter-recursive -- seq )
index 0f9f97c4cc6bcb1e83c163ee90ba76ec1e7b7886..dd94ad15b32dfae78ae7857f661743e13fd4b006 100755 (executable)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2005 Chris Double. All Rights Reserved.
 ! See http://factorcode.org/license.txt for BSD license.
-!
-USING: kernel threads vectors arrays sequences
-namespaces tools.test continuations deques strings math words
-match quotations concurrency.messaging concurrency.mailboxes
+USING: kernel threads vectors arrays sequences namespaces make
+tools.test continuations deques strings math words match
+quotations concurrency.messaging concurrency.mailboxes
 concurrency.count-downs accessors ;
 IN: concurrency.messaging.tests
 
index f14dba643377d94250b5cd7a93591ed4f8961ae5..bb21391f0a875d0d42586dee73f518c99b7639f6 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien alien.c-types alien.strings alien.syntax kernel
-math sequences namespaces assocs init accessors continuations
-combinators core-foundation core-foundation.run-loop
-io.encodings.utf8 destructors ;
+math sequences namespaces make assocs init accessors
+continuations combinators core-foundation
+core-foundation.run-loop io.encodings.utf8 destructors ;
 IN: core-foundation.fsevents
 
 ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
index fc11e0a7317b89de4e15496efd51daa7d244552e..432e748cbf58ea3de8f58f6ffaf70ba72c898e75 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic kernel kernel.private math memory
-namespaces sequences layouts system hashtables classes alien
-byte-arrays combinators words sets ;
+namespaces make sequences layouts system hashtables classes
+alien byte-arrays combinators words sets ;
 IN: cpu.architecture
 
 ! Register classes
index 9fdaaf712f64f4e59fe615ff16574d5315e838e8..f35a5cfca81c0fabb94425d8a58fba1c0150b110 100644 (file)
@@ -1,6 +1,6 @@
 IN: cpu.ppc.assembler.tests
 USING: cpu.ppc.assembler tools.test arrays kernel namespaces
-vocabs sequences ;
+make vocabs sequences ;
 
 : test-assembler ( expected quot -- )
     [ 1array ] [ [ { } make ] curry ] bi* unit-test ;
index b881f5a974ee096e1c19b47326a7edd090526966..1b442662d57c9d19380880d977733a541853201f 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: compiler.generator.fixup kernel namespaces sequences
+USING: compiler.generator.fixup kernel namespaces make sequences
 words math math.bitwise io.binary parser lexer ;
 IN: cpu.ppc.assembler.backend
 
index 69bc685364d18994aeb1ab330810e44ba273a39f..13524aecc4084a03490522f734af73436ac51235 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien alien.c-types arrays cpu.x86.assembler
 cpu.x86.assembler.private cpu.architecture kernel kernel.private
-math memory namespaces sequences words compiler.generator
+math memory namespaces make sequences words compiler.generator
 compiler.generator.registers compiler.generator.fixup system
 layouts combinators compiler.constants math.order ;
 IN: cpu.x86.architecture
index 4c0f04fcc2a1061fdae76602de921f623ae62b5d..941bbe5b73ff165532e1c5fba40ccb1fe62d5a1c 100644 (file)
@@ -1,4 +1,4 @@
-USING: cpu.x86.assembler kernel tools.test namespaces ;
+USING: cpu.x86.assembler kernel tools.test namespaces make ;
 IN: cpu.x86.assembler.tests
 
 [ { HEX: 49 HEX: 89 HEX: 04 HEX: 24 } ] [ [ R12 [] RAX MOV ] { } make ] unit-test
index d9c25d8492b495bc9a2ee316bd94bf1de13aeaab..f557bb4adc48ce61dbe7c7a781ba71d90b163250 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays compiler.generator.fixup io.binary kernel
-combinators kernel.private math namespaces sequences
+combinators kernel.private math namespaces make sequences
 words system layouts math.order accessors
 cpu.x86.assembler.syntax ;
 IN: cpu.x86.assembler
index 59a3f218634f3fea71f8c78a13de7144f6902282..133223b6e4787c0c37b0a8a2e2410a68b087dea6 100644 (file)
@@ -4,7 +4,8 @@
 ! Simple CSV Parser
 ! Phil Dawes phil@phildawes.net
 
-USING: kernel sequences io namespaces combinators unicode.categories ;
+USING: kernel sequences io namespaces make
+combinators unicode.categories ;
 IN: csv
 
 SYMBOL: delimiter
index ae31b168cb0916b88a410915a8bd831055934a98..38fa4cc715227d59ca01ad11a634f56ec2908db3 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs alien alien.syntax continuations io
-kernel math math.parser namespaces prettyprint quotations
+kernel math math.parser namespaces make prettyprint quotations
 sequences debugger db db.postgresql.lib db.postgresql.ffi
 db.tuples db.types tools.annotations math.ranges
 combinators classes locals words tools.walker
index ede7612942948d544afff8d2cb3c1c1f6a33bb00..89c28b52623d627876c9648038d4b30be425c370 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel math namespaces sequences random strings
-math.parser math.intervals combinators math.bitwise nmake db
-db.tuples db.types db.sql classes words shuffle arrays destructors
-continuations ;
+USING: accessors kernel math namespaces make sequences random
+strings math.parser math.intervals combinators math.bitwise
+nmake db db.tuples db.types db.sql classes words shuffle arrays
+destructors continuations ;
 IN: db.queries
 
 GENERIC: where ( specs obj -- )
index ed605da25f97d05a4d74725fa7f39773fd8c2c8d..26ecec03656dd3d3a04db21a53a0c945b0316a5d 100644 (file)
@@ -154,7 +154,7 @@ T{ book
 "Now we've created a book. Let's save it to the database."
 { $code <" USING: db db.sqlite fry io.files ;
 : with-book-tutorial ( quot -- )
-     '[ "book-tutorial.db" temp-file sqlite-db , with-db ] call ;
+     '[ "book-tutorial.db" temp-file sqlite-db _ with-db ] call ;
 
 [
     book recreate-table
index 3b044549959e1288c0a874f55275054bbe0fd4be..67e46f9e1825651d1989c55dfa114cedb28371fb 100755 (executable)
@@ -201,10 +201,10 @@ TUPLE: annotation n paste-id summary author mode contents ;
 ! ] with-db
 
 : test-sqlite ( quot -- )
-    [ ] swap '[ "tuples-test.db" temp-file sqlite-db , with-db ] unit-test ;
+    [ ] swap '[ "tuples-test.db" temp-file sqlite-db _ with-db ] unit-test ;
 
 : test-postgresql ( quot -- )
-    [ ] swap '[ { "localhost" "postgres" "foob" "factor-test" } postgresql-db , with-db ] unit-test ;
+    [ ] swap '[ { "localhost" "postgres" "foob" "factor-test" } postgresql-db _ with-db ] unit-test ;
 
 : test-repeated-insert
     [ ] [ person ensure-table ] unit-test
index 4d01567131f47ac19bf81c01c73587285fa7254c..b7fd34c5be90313df0f4d50956c5cc7242c6e9c5 100755 (executable)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: slots arrays definitions generic hashtables summary io
-kernel math namespaces prettyprint prettyprint.config sequences
-assocs sequences.private strings io.styles io.files vectors
-words system splitting math.parser classes.tuple continuations
-continuations.private combinators generic.math classes.builtin
-classes compiler.units generic.standard vocabs init
-kernel.private io.encodings accessors math.order
+kernel math namespaces make prettyprint prettyprint.config
+sequences assocs sequences.private strings io.styles io.files
+vectors words system splitting math.parser classes.tuple
+continuations continuations.private combinators generic.math
+classes.builtin classes compiler.units generic.standard vocabs
+init kernel.private io.encodings accessors math.order
 destructors source-files parser classes.tuple.parser
 effects.parser lexer compiler.errors generic.parser
 strings.parser ;
index 7bb240859e8abf3d2c05e3859b7fe2cc63161479..27ffdc629bbd4453631e51ec8caea9828514139d 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors debugger continuations threads threads.private
-io io.styles prettyprint kernel math.parser namespaces ;
+io io.styles prettyprint kernel math.parser namespaces make ;
 IN: debugger.threads
 
 : error-in-thread. ( thread -- )
index fd9b9977e11759d2f3563bb4268a85745c0e116f..45cc214792e671b7e20010a8a03c05373fd1c7d7 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors parser generic kernel classes classes.tuple
 words slots assocs sequences arrays vectors definitions
-prettyprint math hashtables sets macros namespaces ;
+prettyprint math hashtables sets macros namespaces make ;
 IN: delegate
 
 : protocol-words ( protocol -- words )
index 4ef787d33b7a98f3fa1808561404976f4959a249..ea246cfa28e73859e7062f7725b6dcabbf72f9b4 100644 (file)
@@ -64,7 +64,7 @@ M: disjoint-set add-atom
     [ 1 -rot counts>> set-at ]
     2tri ;
 
-: add-atoms ( seq disjoint-set -- ) '[ , add-atom ] each ;
+: add-atoms ( seq disjoint-set -- ) '[ _ add-atom ] each ;
 
 GENERIC: disjoint-set-member? ( a disjoint-set -- ? )
 
@@ -89,7 +89,7 @@ M:: disjoint-set equate ( a b disjoint-set -- )
     ] if ;
 
 : equate-all-with ( seq a disjoint-set -- )
-    '[ , , equate ] each ;
+    '[ _ _ equate ] each ;
 
 : equate-all ( seq disjoint-set -- )
     over empty? [ 2drop ] [
@@ -102,7 +102,7 @@ M: disjoint-set clone
 
 : assoc>disjoint-set ( assoc -- disjoint-set )
     <disjoint-set>
-    [ '[ drop , add-atom ] assoc-each ]
-    [ '[ , equate ] assoc-each ]
+    [ '[ drop _ add-atom ] assoc-each ]
+    [ '[ _ equate ] assoc-each ]
     [ nip ]
     2tri ;
index cac7574e35aed3541aba7f0d57b104220f6b8b36..54bc85284a14bfb22e6cfa96f6c48e5a6dc72d4b 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays io kernel math models namespaces
+USING: accessors arrays io kernel math models namespaces make
 sequences strings splitting combinators unicode.categories
 math.order ;
 IN: documents
index 05cde62c1fa6771851b995c4f9f8d463637af384..286dbb469ef98eded169bab8b8ca981a1e6e06e2 100755 (executable)
@@ -1,15 +1,12 @@
 USING: help.markup help.syntax quotations kernel ;\r
 IN: fry\r
 \r
-HELP: ,\r
+HELP: _\r
 { $description "Fry specifier. Inserts a literal value into the fried quotation." } ;\r
 \r
 HELP: @\r
 { $description "Fry specifier. Splices a quotation into the fried quotation." } ;\r
 \r
-HELP: _\r
-{ $description "Fry specifier. Shifts all fry specifiers to the left down by one stack position." } ;\r
-\r
 HELP: fry\r
 { $values { "quot" quotation } { "quot'" quotation } }\r
 { $description "Outputs a quotation that when called, fries " { $snippet "quot" } " by taking values from the stack and substituting them in." }\r
@@ -19,7 +16,7 @@ HELP: fry
 \r
 HELP: '[\r
 { $syntax "code... ]" }\r
-{ $description "Literal fried quotation. Expands into code which takes values from the stack and substitutes them in place of the fry specifiers " { $link , } " and " { $link @ } "." }\r
+{ $description "Literal fried quotation. Expands into code which takes values from the stack and substitutes them in place of the fry specifiers " { $link _ } " and " { $link @ } "." }\r
 { $examples "See " { $link "fry.examples" } "." } ;\r
 \r
 ARTICLE: "fry.examples" "Examples of fried quotations"\r
@@ -27,69 +24,50 @@ ARTICLE: "fry.examples" "Examples of fried quotations"
 $nl\r
 "If a quotation does not contain any fry specifiers, then " { $link POSTPONE: '[ } " behaves just like " { $link POSTPONE: [ } ":"\r
 { $code "{ 10 20 30 } '[ . ] each" }\r
-"Occurrences of " { $link , } " on the left map directly to " { $link curry } ". That is, the following three lines are equivalent:"\r
+"Occurrences of " { $link _ } " on the left map directly to " { $link curry } ". That is, the following three lines are equivalent:"\r
 { $code \r
-    "{ 10 20 30 } 5 '[ , + ] map"\r
+    "{ 10 20 30 } 5 '[ _ + ] map"\r
     "{ 10 20 30 } 5 [ + ] curry map"\r
     "{ 10 20 30 } [ 5 + ] map"\r
 }\r
-"Occurrences of " { $link , } " in the middle of a quotation map to more complex quotation composition patterns. The following three lines are equivalent:"\r
+"Occurrences of " { $link _ } " in the middle of a quotation map to more complex quotation composition patterns. The following three lines are equivalent:"\r
 { $code \r
-    "{ 10 20 30 } 5 '[ 3 , / ] map"\r
+    "{ 10 20 30 } 5 '[ 3 _ / ] map"\r
     "{ 10 20 30 } 5 [ 3 ] swap [ / ] curry compose map"\r
     "{ 10 20 30 } [ 3 5 / ] map"\r
 }\r
-"Occurrences of " { $link @ } " are simply syntax sugar for " { $snippet ", call" } ". The following four lines are equivalent:"\r
+"Occurrences of " { $link @ } " are simply syntax sugar for " { $snippet "_ call" } ". The following four lines are equivalent:"\r
 { $code \r
     "{ 10 20 30 } [ sq ] '[ @ . ] each"\r
     "{ 10 20 30 } [ sq ] [ call . ] curry each"\r
     "{ 10 20 30 } [ sq ] [ . ] compose each"\r
     "{ 10 20 30 } [ sq . ] each"\r
 }\r
-"The " { $link , } " and " { $link @ } " specifiers may be freely mixed:"\r
+"The " { $link _ } " and " { $link @ } " specifiers may be freely mixed:"\r
 { $code\r
-    "{ 8 13 14 27 } [ even? ] 5 '[ @ dup , ? ] map"\r
+    "{ 8 13 14 27 } [ even? ] 5 '[ @ dup _ ? ] map"\r
     "{ 8 13 14 27 } [ even? ] 5 [ dup ] swap [ ? ] curry 3compose map"\r
     "{ 8 13 14 27 } [ even? dup 5 ? ] map"\r
 }\r
-"Occurrences of " { $link _ } " have the effect of enclosing all code to their left in a quotation passed to " { $link dip } ". The following four lines are equivalent:"\r
-{ $code \r
-    "{ 10 20 30 } 1 '[ , _ / ] map"\r
-    "{ 10 20 30 } 1 [ [ ] curry dip / ] curry map"\r
-    "{ 10 20 30 } 1 [ swap / ] curry map"\r
-    "{ 10 20 30 } [ 1 swap / ] map"\r
-}\r
-"For any quotation body " { $snippet "X" } ", the following two are equivalent:"\r
-{ $code\r
-    "[ [ X ] dip ]"\r
-    "'[ X _ ]"\r
-}\r
 "Here are some built-in combinators rewritten in terms of fried quotations:"\r
 { $table\r
-    { { $link literalize } { $snippet ": literalize '[ , ] ;" } }\r
-    { { $link slip } { $snippet ": slip '[ @ , ] call ;" } }\r
-    { { $link dip } { $snippet ": dip '[ @ _ ] call ;" } }\r
-    { { $link curry } { $snippet ": curry '[ , @ ] ;" } }\r
-    { { $link with } { $snippet ": with swapd '[ , _ @ ] ;" } }\r
+    { { $link literalize } { $snippet ": literalize '[ _ ] ;" } }\r
+    { { $link slip } { $snippet ": slip '[ @ _ ] call ;" } }\r
+    { { $link curry } { $snippet ": curry '[ _ @ ] ;" } }\r
     { { $link compose } { $snippet ": compose '[ @ @ ] ;" } }\r
-    { { $link bi@ } { $snippet ": bi@ tuck '[ , @ , @ ] call ;" } }\r
+    { { $link bi@ } { $snippet ": bi@ tuck '[ _ @ _ @ ] call ;" } }\r
 } ;\r
 \r
 ARTICLE: "fry.philosophy" "Fried quotation philosophy"\r
 "Fried quotations generalize quotation-building words such as " { $link curry } " and " { $link compose } ". They can clean up code with lots of currying and composition, particularly when quotations are nested:"\r
 { $code\r
-    "'[ [ , key? ] all? ] filter"\r
+    "'[ [ _ key? ] all? ] filter"\r
     "[ [ key? ] curry all? ] curry filter"\r
 }\r
 "There is a mapping from fried quotations to lexical closures as defined in the " { $vocab-link "locals" } " vocabulary. Namely, a fried quotation is equivalent to a ``let'' form where each local binding is only used once, and bindings are used in the same order in which they are defined. The following two lines are equivalent:"\r
 { $code\r
-    "'[ 3 , + 4 , / ]"\r
+    "'[ 3 _ + 4 _ / ]"\r
     "[let | a [ ] b [ ] | [ 3 a + 4 b / ] ]"\r
-}\r
-"The " { $link _ } " fry specifier has no direct analogue in " { $vocab-link "locals" } ", however closure conversion together with the " { $link dip } " combinator achieve the same effect:"\r
-{ $code\r
-    "'[ , 2 + , * _ / ]"\r
-    "[let | a [ ] b [ ] | [ [ a 2 + b * ] dip / ] ]"\r
 } ;\r
 \r
 ARTICLE: "fry.limitations" "Fried quotation limitations"\r
@@ -101,9 +79,8 @@ $nl
 "Fried quotations are denoted with a special parsing word:"\r
 { $subsection POSTPONE: '[ }\r
 "Fried quotations contain zero or more " { $emphasis "fry specifiers" } ":"\r
-{ $subsection , }\r
-{ $subsection @ }\r
 { $subsection _ }\r
+{ $subsection @ }\r
 "When a fried quotation is being evaluated, values are consumed from the stack and spliced into the quotation from right to left."\r
 { $subsection "fry.examples" }\r
 { $subsection "fry.philosophy" }\r
index 6d6abba23c7cb02bc57b7ce10d2de96a242b623b..d4a3b8b734a13e29ba4dbd43aa01c218ac7c8d69 100755 (executable)
@@ -2,63 +2,59 @@ IN: fry.tests
 USING: fry tools.test math prettyprint kernel io arrays
 sequences ;
 
-[ [ 3 + ] ] [ 3 '[ , + ] ] unit-test
+[ [ 3 + ] ] [ 3 '[ _ + ] ] unit-test
 
-[ [ 1 3 + ] ] [ 1 3 '[ , , + ] ] unit-test
+[ [ 1 3 + ] ] [ 1 3 '[ _ _ + ] ] unit-test
 
-[ [ 1 + ] ] [ 1 [ + ] '[ , @ ] ] unit-test
+[ [ 1 + ] ] [ 1 [ + ] '[ _ @ ] ] unit-test
 
-[ [ 1 + . ] ] [ 1 [ + ] '[ , @ . ] ] unit-test
+[ [ 1 + . ] ] [ 1 [ + ] '[ _ @ . ] ] unit-test
 
 [ [ + - ] ] [ [ + ] [ - ] '[ @ @ ] ] unit-test
 
 [ [ "a" write "b" print ] ]
-[ "a" "b" '[ , write , print ] ] unit-test
+[ "a" "b" '[ _ write _ print ] ] unit-test
 
 [ [ 1 2 + 3 4 - ] ]
 [ [ + ] [ - ] '[ 1 2 @ 3 4 @ ] ] unit-test
 
 [ 1/2 ] [
-    1 '[ , _ / ] 2 swap call
+    1 '[ [ _ ] dip / ] 2 swap call
 ] unit-test
 
 [ { { 1 "a" "A" } { 1 "b" "B" } { 1 "c" "C" } } ] [
-    1 '[ , _ _ 3array ]
+    1 '[ [ _ ] 2dip 3array ]
     { "a" "b" "c" } { "A" "B" "C" } rot 2map
 ] unit-test
 
 [ { { 1 "a" } { 1 "b" } { 1 "c" } } ] [
-    '[ 1 _ 2array ]
+    '[ [ 1 ] dip 2array ]
     { "a" "b" "c" } swap map
 ] unit-test
 
-[ 1 2 ] [
-    1 2 '[ _ , ] call
-] unit-test
-
 [ { { 1 "a" 2 } { 1 "b" 2 } { 1 "c" 2 } } ] [
-    1 2 '[ , _ , 3array ]
+    1 2 '[ [ _ ] dip _ 3array ]
     { "a" "b" "c" } swap map
 ] unit-test
 
-: funny-dip '[ @ _ ] call ; inline
+: funny-dip '[ [ @ ] dip ] call ; inline
 
 [ "hi" 3 ] [ "h" "i" 3 [ append ] funny-dip ] unit-test
 
 [ { 1 2 3 } ] [
-    3 1 '[ , [ , + ] map ] call
+    3 1 '[ _ [ _ + ] map ] call
 ] unit-test
 
 [ { 1 { 2 { 3 } } } ] [
-    1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call
+    1 2 3 '[ _ [ _ [ _ 1array ] call 2array ] call 2array ] call
 ] unit-test
 
-{ 1 1 } [ '[ [ [ , ] ] ] ] must-infer-as
+{ 1 1 } [ '[ [ [ _ ] ] ] ] must-infer-as
 
 [ { { { 3 } } } ] [
-    3 '[ [ [ , 1array ] call 1array ] call 1array ] call
+    3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
 ] unit-test
 
 [ { { { 3 } } } ] [
-    3 '[ [ [ , 1array ] call 1array ] call 1array ] call
+    3 '[ [ [ _ 1array ] call 1array ] call 1array ] call
 ] unit-test
index 2b84d58d068ef88b04b8c67c728ff61105a4c932..395d5c3cafda80e4607c852cd7d321d5066f8c92 100755 (executable)
@@ -1,13 +1,13 @@
 ! Copyright (C) 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel sequences combinators parser splitting math
-quotations arrays namespaces qualified ;
-QUALIFIED: namespaces
+quotations arrays make qualified words ;
 IN: fry
 
-: , ( -- * ) "Only valid inside a fry" throw ;
-: @ ( -- * ) "Only valid inside a fry" throw ;
 : _ ( -- * ) "Only valid inside a fry" throw ;
+: @ ( -- * ) "Only valid inside a fry" throw ;
+
+<PRIVATE
 
 DEFER: (shallow-fry)
 DEFER: shallow-fry
@@ -19,48 +19,33 @@ DEFER: shallow-fry
     ] unless-empty ; inline
 
 : (shallow-fry) ( accum quot -- result )
-    [
-        1quotation
-    ] [
+    [ 1quotation ] [
         unclip {
-            { \ , [ [ curry ] ((shallow-fry)) ] }
+            { \ _ [ [ curry ] ((shallow-fry)) ] }
             { \ @ [ [ compose ] ((shallow-fry)) ] }
-
-            ! to avoid confusion, remove if fry goes core
-            { \ namespaces:, [ [ curry ] ((shallow-fry)) ] }
-
             [ swap >r suffix r> (shallow-fry) ]
         } case
     ] if-empty ;
 
 : shallow-fry ( quot -- quot' ) [ ] swap (shallow-fry) ;
 
-: deep-fry ( quot -- quot )
-    { _ } last-split1 dup [
-      shallow-fry [ >r ] rot
-      deep-fry    [ [ dip ] curry r> compose ] 4array concat
-    ] [
-        drop shallow-fry
-    ] if ;
+PREDICATE: fry-specifier < word { _ @ } memq? ;
 
-: fry-specifier? ( obj -- ? ) { , namespaces:, @ } member? ;
+GENERIC: count-inputs ( quot -- n )
+
+M: callable count-inputs [ count-inputs ] sigma ;
+M: fry-specifier count-inputs drop 1 ;
+M: object count-inputs drop 0 ;
+
+PRIVATE>
 
-: count-inputs ( quot -- n )
-    [
-        {
-            { [ dup callable?      ] [ count-inputs ] }
-            { [ dup fry-specifier? ] [ drop 1       ] }
-                                     [ drop 0       ]
-        } cond
-    ] map sum ;
-    
 : fry ( quot -- quot' )
     [
         [
             dup callable? [
-                [ count-inputs \ , <repetition> % ] [ fry % ] bi
-            ] [ namespaces:, ] if
+                [ count-inputs \ _ <repetition> % ] [ fry % ] bi
+            ] [ , ] if
         ] each
-    ] [ ] make deep-fry ;
+    ] [ ] make shallow-fry ;
 
 : '[ \ ] parse-until fry over push-all ; parsing
index 1370ae95b2f02653e6d201e0ce138f328bbca688..cce098f208cfe9ab5c018eec2cf176a46d953f84 100755 (executable)
@@ -60,7 +60,7 @@ TUPLE: action rest authorize init display validate submit ;
 \r
 : handle-get ( action -- response )\r
     '[\r
-        , dup display>> [\r
+        _ dup display>> [\r
             {\r
                 [ init>> call ]\r
                 [ authorize>> call ]\r
@@ -90,7 +90,7 @@ TUPLE: action rest authorize init display validate submit ;
 \r
 : handle-post ( action -- response )\r
     '[\r
-        , dup submit>> [\r
+        _ dup submit>> [\r
             [ validate>> call ]\r
             [ authorize>> call ]\r
             [ submit>> call ]\r
@@ -133,4 +133,4 @@ TUPLE: page-action < action template ;
 \r
 : <page-action> ( -- page )\r
     page-action new-action\r
-        dup '[ , template>> <chloe-content> ] >>display ;\r
+        dup '[ _ template>> <chloe-content> ] >>display ;\r
index 29cb37b557d79eb17a6683d2480fc3b3aa8f6c9a..6f5f6fdbf61ba6f6f3d514b7d43f9e26cab17d88 100644 (file)
@@ -14,7 +14,7 @@ IN: furnace.alloy
     '[
         <conversations>
         <sessions>
-        , , <db-persistence>
+        _ _ <db-persistence>
         <check-form-submissions>
     ] call ;
 
@@ -26,5 +26,5 @@ IN: furnace.alloy
 
 : start-expiring ( db params -- )
     '[
-        , , [ state-classes [ expire-state ] each ] with-db
+        _ _ [ state-classes [ expire-state ] each ] with-db
     ] 5 minutes every drop ;
index 54e936a3138f5bc104cbf670dd9903d429273dce..8e18c18df9fdd744025767565ce5af0df67c5e43 100755 (executable)
@@ -125,7 +125,7 @@ TUPLE: secure-realm-only < filter-responder ;
 C: <secure-realm-only> secure-realm-only\r
 \r
 M: secure-realm-only call-responder*\r
-    '[ , , call-next-method ] if-secure-realm ;\r
+    '[ _ _ call-next-method ] if-secure-realm ;\r
 \r
 TUPLE: protected < filter-responder description capabilities ;\r
 \r
index ff3c302b40addc7d4d5f59e205b424cd2cad21de..a9b367c5c99b1c07c33ecd9b6ee1980a61bce8e2 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2007 Chris Double.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: accessors kernel splitting base64 namespaces strings\r
+USING: accessors kernel splitting base64 namespaces make strings\r
 http http.server.responses furnace.auth ;\r
 IN: furnace.auth.basic\r
 \r
index 77915f10831c8d1cbee20a5b983dd46be5e994e6..a0fd05c6d49d62d5af59623e05b8214c0b59d307 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces accessors kernel assocs arrays io.sockets threads
-fry urls smtp validators html.forms present
+USING: namespaces make accessors kernel assocs arrays io.sockets
+threads fry urls smtp validators html.forms present
 http http.server.responses http.server.redirection
 http.server.dispatchers
 furnace furnace.actions furnace.auth furnace.auth.providers
@@ -43,7 +43,7 @@ SYMBOL: lost-password-from
         ] "" make >>body ;
 
 : send-password-email ( user -- )
-    '[ , password-email send-email ]
+    '[ _ password-email send-email ]
     "E-mail send thread" spawn drop ;
 
 : <recover-action-1> ( -- action )
index 8822bca519ce7a96e36a1a0268dd083d83c7d927..4e619ad534b191eba8530527b821a3e41a46174c 100644 (file)
@@ -56,7 +56,7 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
 
 : compile-link-attrs ( tag -- )
     #! Side-effects current namespace.
-    attrs>> '[ [ , _ link-attr ] each-responder ] [code] ;
+    attrs>> '[ [ [ _ ] dip link-attr ] each-responder ] [code] ;
 
 : a-start-tag ( tag -- )
     [ compile-link-attrs ] [ compile-a-url ] bi
@@ -72,7 +72,7 @@ CHLOE: a
 
 : compile-hidden-form-fields ( for -- )
     '[
-        , [ "," split [ hidden render ] each ] when*
+        _ [ "," split [ hidden render ] each ] when*
         nested-forms get " " join f like nested-forms-key hidden-form-field
         [ modify-form ] each-responder
     ] [code] ;
index 26b62f9b0778431e3d6a049524a316734796945a..1c28193de8e98b383fc227dddbb840d392a22119 100644 (file)
@@ -109,8 +109,8 @@ M: conversations call-responder*
 : restore-conversation ( seq -- )
     conversation get dup [
         namespace>>
-        [ '[ , key? ] filter ]
-        [ '[ [ , at ] keep set ] each ]
+        [ '[ _ key? ] filter ]
+        [ '[ [ _ at ] keep set ] each ]
         bi
     ] [ 2drop ] if ;
 
index b90587fba8ae10e3cd715aceaee62bdd72b72da0..6a798abb9fb5c6583fd9e5793abdc0c4805831d8 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces assocs sequences kernel classes splitting
+USING: namespaces make assocs sequences kernel classes splitting
 vocabs.loader accessors strings combinators arrays
 continuations present fry
 urls html.elements
index 942cafd21a62d554d059ec99d1e8b41dc6bbee7a..ff3ce951cb2a69d72ac7af1921d5340e1cf2604e 100644 (file)
@@ -42,4 +42,4 @@ C: <secure-only> secure-only
     } cond ; inline
 
 M: secure-only call-responder*
-    '[ , , call-next-method ] if-secure ;
+    '[ _ _ call-next-method ] if-secure ;
index 98d1bbdfc96db96f2e549717bc961aaa26f7dfc4..ff089a92b22265719bc15d9e377c5578f4a1dc82 100755 (executable)
@@ -1,10 +1,9 @@
 IN: furnace.sessions.tests\r
-USING: tools.test http furnace.sessions\r
-furnace.actions http.server http.server.responses\r
-math namespaces kernel accessors io.sockets io.servers.connection\r
-prettyprint io.streams.string io.files splitting destructors\r
-sequences db db.tuples db.sqlite continuations urls math.parser\r
-furnace ;\r
+USING: tools.test http furnace.sessions furnace.actions\r
+http.server http.server.responses math namespaces make kernel\r
+accessors io.sockets io.servers.connection prettyprint\r
+io.streams.string io.files splitting destructors sequences db\r
+db.tuples db.sqlite continuations urls math.parser furnace ;\r
 \r
 : with-session\r
     [\r
index 31a978aef3d00c6fc524b439e7366cd5eb14cbb8..396296bfac27c9c84de49f83d7127f2ad54767d3 100644 (file)
@@ -44,7 +44,7 @@ TUPLE: feed-action < action title url entries ;
     feed-action new-action
         dup '[
             feed new
-                ,
+                _
                 [ title>> call >>title ]
                 [ url>> call adjust-url relative-to-request >>url ]
                 [ entries>> call process-entries >>entries ]
index c97e9c7b914e20ded0b17cf0b175fc1399026a63..069d59cee192a9ba2b60f7baa6fdcb702213abe2 100755 (executable)
@@ -6,24 +6,24 @@ math.ranges combinators macros quotations fry arrays ;
 IN: generalizations\r
 \r
 MACRO: nsequence ( n seq -- quot )\r
-    [ drop <reversed> ] [ '[ , , new-sequence ] ] 2bi\r
-    [ '[ @ [ , swap set-nth-unsafe ] keep ] ] reduce ;\r
+    [ drop <reversed> ] [ '[ _ _ new-sequence ] ] 2bi\r
+    [ '[ @ [ _ swap set-nth-unsafe ] keep ] ] reduce ;\r
 \r
 MACRO: narray ( n -- quot )\r
-    '[ , { } nsequence ] ;\r
+    '[ _ { } nsequence ] ;\r
 \r
 MACRO: firstn ( n -- )\r
     dup zero? [ drop [ drop ] ] [\r
-        [ [ '[ , _ nth-unsafe ] ] map ]\r
-        [ 1- '[ , _ bounds-check 2drop ] ]\r
-        bi prefix '[ , cleave ]\r
+        [ [ '[ [ _ ] dip nth-unsafe ] ] map ]\r
+        [ 1- '[ [ _ ] dip bounds-check 2drop ] ]\r
+        bi prefix '[ _ cleave ]\r
     ] if ;\r
 \r
 MACRO: npick ( n -- )\r
     1- dup saver [ dup ] rot [ r> swap ] n*quot 3append ;\r
 \r
 MACRO: ndup ( n -- )\r
-    dup '[ , npick ] n*quot ;\r
+    dup '[ _ npick ] n*quot ;\r
 \r
 MACRO: nrot ( n -- )\r
     1- dup saver swap [ r> swap ] n*quot append ;\r
@@ -41,7 +41,7 @@ MACRO: ntuck ( n -- )
     2 + [ dupd -nrot ] curry ;\r
 \r
 MACRO: nrev ( n -- quot )\r
-    1 [a,b] [ ] [ '[ @ , -nrot ] ] reduce ;\r
+    1 [a,b] [ ] [ '[ @ _ -nrot ] ] reduce ;\r
 \r
 MACRO: ndip ( quot n -- )\r
     dup saver -rot restorer 3append ;\r
@@ -51,7 +51,7 @@ MACRO: nslip ( n -- )
 \r
 MACRO: nkeep ( n -- )\r
     [ ] [ 1+ ] [ ] tri\r
-    '[ [ , ndup ] dip , -nrot , nslip ] ;\r
+    '[ [ _ ndup ] dip _ -nrot _ nslip ] ;\r
 \r
 MACRO: ncurry ( n -- )\r
     [ curry ] n*quot ;\r
@@ -61,5 +61,5 @@ MACRO: nwith ( n -- )
 \r
 MACRO: napply ( n -- )\r
     2 [a,b]\r
-    [ [ 1- ] keep '[ , ntuck , nslip ] ]\r
+    [ [ 1- ] keep '[ _ ntuck _ nslip ] ]\r
     map concat >quotation [ call ] append ;\r
index 1b488b1d481853f63db1393a9efe1d7f6aa61140..9d57e758c1abacfea0dca8d1234b45a2b7923ee1 100755 (executable)
@@ -108,6 +108,7 @@ USE: io.buffers
 ARTICLE: "collections" "Collections" 
 { $heading "Sequences" }
 { $subsection "sequences" }
+{ $subsection "namespaces-make" }
 "Fixed-length sequences:"
 { $subsection "arrays" }
 { $subsection "quotations" }
index b2fff2237222ed283b1602a113e2b9f426467f5d..686578f1b61e31343f527c7be5d0d9a5aac39d6b 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays io io.styles kernel namespaces parser
-prettyprint sequences words assocs definitions generic
+USING: accessors arrays io io.styles kernel namespaces make
+parser prettyprint sequences words assocs definitions generic
 quotations effects slots continuations classes.tuple debugger
 combinators vocabs help.stylesheet help.topics help.crossref
 help.markup sorting classes vocabs.loader ;
index 4ad9067457f7eb10b6531ad56a3689a416329ab4..d49262e7c8e248572aaebdda9709cba38ecbc873 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry accessors sequences parser kernel help help.markup
-help.topics words strings classes tools.vocabs namespaces io
-io.streams.string prettyprint definitions arrays vectors
+help.topics words strings classes tools.vocabs namespaces make
+io io.streams.string prettyprint definitions arrays vectors
 combinators combinators.short-circuit splitting debugger
 hashtables sorting effects vocabs vocabs.loader assocs editors
 continuations classes.predicate macros math sets eval ;
@@ -39,7 +39,7 @@ IN: help.lint
         $predicate
         $class-description
         $error-description
-    } swap '[ , elements empty? not ] contains? ;
+    } swap '[ _ elements empty? not ] contains? ;
 
 : check-values ( word element -- )
     {
@@ -110,7 +110,7 @@ M: help-error error.
     H{ } clone [
         '[
             dup >link where dup
-            [ first , at , push-at ] [ 2drop ] if
+            [ first _ at _ push-at ] [ 2drop ] if
         ] each
     ] keep ;
 
index 3077a93ed4b6983b0213df7e5ab98ee46601bfbd..b5e074b598c9fcc282d21d74c6f9be641d2c0b3c 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions generic io kernel assocs
-hashtables namespaces parser prettyprint sequences strings
+hashtables namespaces make parser prettyprint sequences strings
 io.styles vectors words math sorting splitting classes slots
 vocabs help.stylesheet help.topics vocabs.loader alias ;
 IN: help.markup
index cdb32b18eec94331d2fcd98d3a51459f17376c5c..e6b19d5baae1866acd6e84bb1c299a2e4ff9a2c1 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.x
 USING: accessors arrays definitions generic assocs
-io kernel namespaces prettyprint prettyprint.sections
+io kernel namespaces make prettyprint prettyprint.sections
 sequences words summary classes strings vocabs ;
 IN: help.topics
 
index da6ab9695988bf824b5951f829255a82d2d634d4..499267de7c265ff790db4e5d40b57d7427242f9e 100644 (file)
@@ -21,7 +21,7 @@ IN: hints
 : specializer-cases ( quot word -- default alist )
     dup [ array? ] all? [ 1array ] unless [
         [ make-specializer ] keep
-        '[ , declare ] pick append
+        '[ _ declare ] pick append
     ] { } map>assoc ;
 
 : method-declaration ( method -- quot )
@@ -30,7 +30,7 @@ IN: hints
     bi prefix ;
 
 : specialize-method ( quot method -- quot' )
-    method-declaration '[ , declare ] prepend ;
+    method-declaration '[ _ declare ] prepend ;
 
 : specialize-quot ( quot specializer -- quot' )
     specializer-cases alist>quot ;
index 0969dd7ef3e49be75e9570d2ef864bcc26540565..6965cb582a03a1801fba5ca3055d63aea3e4a638 100644 (file)
@@ -88,7 +88,7 @@ TUPLE: choice size multiple choices ;
     </option> ;
 
 : render-options ( options selected -- )
-    '[ dup , member? render-option ] each ;
+    '[ dup _ member? render-option ] each ;
 
 M: choice render*
     <select
index 89f8b01a1979f75a3d331db0796b33aa0be0b9e2..ab9d987b6744f6643e5c3313bafc67fc2db8184f 100644 (file)
@@ -70,7 +70,7 @@ SYMBOL: html
 : def-for-html-word-<foo> ( name -- )
     #! Return the name and code for the <foo> patterned
     #! word.
-    dup <foo> swap '[ , <foo> write-html ]
+    dup <foo> swap '[ _ <foo> write-html ]
     (( -- )) html-word ;
 
 : <foo ( str -- <str ) "<" prepend ;
@@ -78,7 +78,7 @@ SYMBOL: html
 : def-for-html-word-<foo ( name -- )
     #! Return the name and code for the <foo patterned
     #! word.
-    <foo dup '[ , write-html ]
+    <foo dup '[ _ write-html ]
     (( -- )) html-word ;
 
 : foo> ( str -- foo> ) ">" append ;
@@ -93,14 +93,14 @@ SYMBOL: html
 : def-for-html-word-</foo> ( name -- )
     #! Return the name and code for the </foo> patterned
     #! word.
-    </foo> dup '[ , write-html ] (( -- )) html-word ;
+    </foo> dup '[ _ write-html ] (( -- )) html-word ;
 
 : <foo/> ( str -- <str/> ) "<" swap "/>" 3append ;
 
 : def-for-html-word-<foo/> ( name -- )
     #! Return the name and code for the <foo/> patterned
     #! word.
-    dup <foo/> swap '[ , <foo/> write-html ]
+    dup <foo/> swap '[ _ <foo/> write-html ]
     (( -- )) html-word ;
 
 : foo/> ( str -- str/> ) "/>" append ;
@@ -134,7 +134,7 @@ SYMBOL: html
 
 : define-attribute-word ( name -- )
     dup "=" prepend swap
-    '[ , write-attr ] (( string -- )) html-word ;
+    '[ _ write-attr ] (( string -- )) html-word ;
 
 ! Define some closed HTML tags
 [
index 911e545f87330b346e46629d0e990df80643595c..7dd4b6146bee69be4bef25d24343641d3f4e0752 100644 (file)
@@ -63,7 +63,7 @@ SYMBOL: nested-forms
 
 : with-form ( name quot -- )
     '[
-        ,
+        _
         [ nested-forms [ swap prefix ] change ]
         [ value form set ]
         bi
@@ -103,4 +103,4 @@ C: <validation-error> validation-error
     swap set-value ;
 
 : validate-values ( assoc validators -- assoc' )
-    swap '[ dup , at _ validate-value ] assoc-each ;
+    swap '[ [ dup _ at ] dip validate-value ] assoc-each ;
index 6a15b76bd3ab1b32718b5c5dd9535b06e2732f44..7d90296fcbfdc7dac29ed4fdca5f31afcdc42c83 100755 (executable)
@@ -1,11 +1,10 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-
-USING: combinators generic assocs help http io io.styles io.files
-       continuations io.streams.string kernel math math.order math.parser
-       namespaces quotations assocs sequences strings words html.elements
-       xml.entities sbufs continuations destructors accessors arrays ;
-
+USING: combinators generic assocs help http io io.styles
+io.files continuations io.streams.string kernel math math.order
+math.parser namespaces make quotations assocs sequences strings
+words html.elements xml.entities sbufs continuations destructors
+accessors arrays ;
 IN: html.streams
 
 GENERIC: browser-link-href ( presented -- href )
index 45e59c3b6d06e880d95cf6db785111dbf2891071..5fe53fc7a503868b703a65c47d57e57d06df9e35 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel sequences combinators kernel fry
-namespaces classes.tuple assocs splitting words arrays memoize
-io io.files io.encodings.utf8 io.streams.string unicode.case
-mirrors math urls present multiline quotations xml xml.data
+namespaces make classes.tuple assocs splitting words arrays
+memoize io io.files io.encodings.utf8 io.streams.string
+unicode.case mirrors math urls present multiline quotations xml
+xml.data
 html.forms
 html.elements
 html.components
index 044d2edb90b79bd76738059b05424cfdac3bb355..f32923f6207e922d8c7bd72489b5dd6d43a53f4c 100644 (file)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs namespaces kernel sequences accessors combinators
-strings splitting io io.streams.string present xml.writer
-xml.data xml.entities html.forms html.templates.chloe.syntax ;
+USING: assocs namespaces make kernel sequences accessors
+combinators strings splitting io io.streams.string present
+xml.writer xml.data xml.entities html.forms
+html.templates.chloe.syntax ;
 IN: html.templates.chloe.compiler
 
 : chloe-attrs-only ( assoc -- assoc' )
index e8703a123529ddf8a6fac2dd9cb17a29b8b5e7c4..77d7c937be5a29bb1ba0b0cf4c1042b343c1e72a 100644 (file)
@@ -14,13 +14,13 @@ IN: html.templates.chloe.components
 
 : CHLOE-SINGLETON:
     scan-word
-    [ name>> ] [ '[ , singleton-component-tag ] ] bi
+    [ name>> ] [ '[ _ singleton-component-tag ] ] bi
     define-chloe-tag ;
     parsing
 
 : compile-component-attrs ( tag class -- )
     [ attrs>> [ drop main>> "name" = not ] assoc-filter ] dip
-    [ all-slots swap '[ name>> , at compile-attr ] each ]
+    [ all-slots swap '[ name>> _ at compile-attr ] each ]
     [ [ boa ] [code-with] ]
     bi ;
 
@@ -30,6 +30,6 @@ IN: html.templates.chloe.components
 
 : CHLOE-TUPLE:
     scan-word
-    [ name>> ] [ '[ , tuple-component-tag ] ] bi
+    [ name>> ] [ '[ _ tuple-component-tag ] ] bi
     define-chloe-tag ;
     parsing
index e435fdce5f0b93987b29e51e0a7e5dfe58b765b0..7742ff9bc6369aa303ae48fe2545f929fc5963d7 100755 (executable)
@@ -74,6 +74,6 @@ TUPLE: fhtml path ;
 C: <fhtml> fhtml
 
 M: fhtml call-template* ( filename -- )
-    '[ , path>> utf8 file-contents eval-template ] assert-depth ;
+    '[ _ path>> utf8 file-contents eval-template ] assert-depth ;
 
 INSTANCE: fhtml template
index 8dc1924a12163d3c2650cc40e340d961b66aec5f..5e22f5144d15e6879416a369631e2bf72770f7c9 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs kernel math math.parser namespaces
+USING: accessors assocs kernel math math.parser namespaces make
 sequences io io.sockets io.streams.string io.files io.timeouts
 strings splitting calendar continuations accessors vectors
 math.order hashtables byte-arrays prettyprint
@@ -95,7 +95,7 @@ DEFER: (http-request)
 SYMBOL: redirects
 
 : redirect-url ( request url -- request )
-    '[ , >url derive-url ensure-port ] change-url ;
+    '[ _ >url derive-url ensure-port ] change-url ;
 
 : do-redirect ( response data -- response data )
     over code>> 300 399 between? [
@@ -169,7 +169,7 @@ M: download-failed error.
 : download-to ( url file -- )
     #! Downloads the contents of a URL to a file.
     swap http-get
-    [ content-charset>> ] [ '[ , write ] ] bi*
+    [ content-charset>> ] [ '[ _ write ] ] bi*
     with-file-writer ;
 
 : download ( url -- )
index 03cca05ff38028f278fb16ae7c551c976d6a611e..0cc228c73b841636f3eec96ecf719adca797bd15 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel combinators math namespaces
+USING: accessors kernel combinators math namespaces make
 assocs sequences splitting sorting sets debugger
 strings vectors hashtables quotations arrays byte-arrays
 math.parser calendar calendar.format present
@@ -28,7 +28,7 @@ IN: http
     [ read-crlf dup f like ] [ parse-header-line ] [ drop ] produce ;
 
 : collect-headers ( assoc -- assoc' )
-    H{ } clone [ '[ , push-at ] assoc-each ] keep ;
+    H{ } clone [ '[ _ push-at ] assoc-each ] keep ;
 
 : process-header ( alist -- assoc )
     f swap [ [ swap or dup ] dip swap ] assoc-map nip
@@ -196,7 +196,7 @@ M: response clone
         [ clone ] change-cookies ;
 
 : get-cookie ( request/response name -- cookie/f )
-    [ cookies>> ] dip '[ , _ name>> = ] find nip ;
+    [ cookies>> ] dip '[ [ _ ] dip name>> = ] find nip ;
 
 : delete-cookie ( request/response name -- )
     over cookies>> [ get-cookie ] dip delete ;
index 2a31373951c47173143ccb228c8a2ab855340654..8e8e7358d1602eb273084f08eb47b286c9ba63d6 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.short-circuit math math.order math.parser kernel
-sequences sequences.deep peg peg.parsers assocs arrays
-hashtables strings unicode.case namespaces ascii ;
+USING: combinators.short-circuit math math.order math.parser
+kernel sequences sequences.deep peg peg.parsers assocs arrays
+hashtables strings unicode.case namespaces make ascii ;
 IN: http.parsers
 
 : except ( quot -- parser )
index 354ebd8f704513accc98e4b64670bf3e3e074a90..0a3cb5cff34b67e693497f5f382d0918728a4a1f 100755 (executable)
@@ -50,7 +50,7 @@ IN: http.server.cgi
     200 >>code\r
     "CGI output follows" >>message\r
     swap '[\r
-        , output-stream get swap <cgi-process> <process-stream> [\r
+        _ output-stream get swap <cgi-process> <process-stream> [\r
             post-request? [ request get post-data>> raw>> write flush ] when\r
             input-stream get swap (stream-copy)\r
         ] with-stream\r
index 436d626578ca2acf2793f48bdc310eae2706a146..bad1eb48311f55dbaf0e6fe99460394b1574e244 100755 (executable)
@@ -158,7 +158,7 @@ main-responder global [ <404> <trivial-responder> or ] change-at
 
 : <500> ( error -- response )
     500 "Internal server error" <trivial-response>
-    swap development? get [ '[ , http-error. ] >>body ] [ drop ] if ;
+    swap development? get [ '[ _ http-error. ] >>body ] [ drop ] if ;
 
 : do-response ( response -- )
     [ request get swap write-full-response ]
@@ -198,7 +198,7 @@ LOG: httpd-header NOTICE
     [
         local-address get
         [ secure? "https" "http" ? >>protocol ]
-        [ port>> '[ , or ] change-port ]
+        [ port>> '[ _ or ] change-port ]
         bi
     ] change-url drop ;
 
@@ -207,7 +207,7 @@ LOG: httpd-header NOTICE
 
 : do-request ( request -- response )
     '[
-        ,
+        _
         {
             [ init-request ]
             [ prepare-request ]
index dfbe93d86d7af82d74e2b9022448e892c95c6b60..b484e64368ada4a22dd8f1491bf88b2368afab30 100755 (executable)
@@ -73,7 +73,7 @@ TUPLE: file-responder root hook special allow-listings ;
 \r
 : list-directory ( directory -- response )\r
     file-responder get allow-listings>> [\r
-        '[ , directory. ] "text/html" <content>\r
+        '[ _ directory. ] "text/html" <content>\r
     ] [\r
         drop <403>\r
     ] if ;\r
index a62855d78fafdaeeea80e8648b06f2e96343d932..99da00ceab5fb62a62c21b16a60475ff46f99fec 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Daniel Ehrenberg.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: kernel sequences arrays accessors grouping math.order\r
-sorting binary-search math assocs locals namespaces ;\r
+sorting binary-search math assocs locals namespaces make ;\r
 IN: interval-maps\r
 \r
 TUPLE: interval-map array ;\r
index f789f7b114b7a9e37ce5095cc5978ae16061448b..7d72659f6df82980540b4681bdbdf8e1078cf5c7 100755 (executable)
@@ -67,7 +67,7 @@ M: threaded-server handle-client* handler>> call ;
 
 : handle-client ( client remote local -- )
     '[
-        , , log-connection
+        _ _ log-connection
         threaded-server get
         [ timeout>> timeouts ] [ handle-client* ] bi
     ] with-stream ;
@@ -77,7 +77,7 @@ M: threaded-server handle-client* handler>> call ;
 
 : accept-connection ( threaded-server -- )
     [ accept ] [ addr>> ] bi
-    [ '[ , , , handle-client ] ]
+    [ '[ _ _ _ handle-client ] ]
     [ drop threaded-server get name>> swap thread-name ] 2bi
     spawn drop ;
 
index 03596ee43c7f8f7c1a0cf286d5a373ee5303bb04..c081dfb0fa368c66e7e45ec6399f3b5f4384db04 100644 (file)
@@ -18,4 +18,4 @@ LOG: received-datagram NOTICE
 PRIVATE>
 
 : with-datagrams ( seq service quot -- )
-    '[ [ , _ spawn-datagrams ] parallel-each ] with-logging ; inline
+    '[ [ [ _ ] dip spawn-datagrams ] parallel-each ] with-logging ; inline
index aa27b21d98ad62d4aec5cec7e46b37d4e46c778c..0e9139f4311c57df0d35096abd10045adb683d7c 100755 (executable)
@@ -3,7 +3,7 @@
 USING: alien alien.c-types generic assocs kernel kernel.private
 math io.ports sequences strings structs sbufs threads unix
 vectors io.buffers io.backend io.encodings math.parser
-continuations system libc qualified namespaces io.timeouts
+continuations system libc qualified namespaces make io.timeouts
 io.encodings.utf8 destructors accessors summary combinators
 locals ;
 QUALIFIED: io
index 3147d7144bec4e4b7894286c11f01d7f3eee3b81..7e1dc48e5f1147677c64eab4c1efa94864aa29b7 100755 (executable)
@@ -1,7 +1,7 @@
 USING: io.files io.sockets io kernel threads
 namespaces tools.test continuations strings byte-arrays
 sequences prettyprint system io.encodings.binary io.encodings.ascii
-io.streams.duplex destructors ;
+io.streams.duplex destructors make ;
 IN: io.unix.tests
 
 ! Unix domain stream sockets
index e21b1292e3141e7833e86fe117e2d54ecc035e1c..dd1ab8d5d8e1354b8065e62f662913a2ee05edac 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel parser-combinators namespaces sequences promises strings 
+USING: kernel parser-combinators namespaces make sequences promises strings 
        assocs math math.parser math.vectors math.functions math.order
        lists hashtables ascii accessors ;
 IN: json.reader
index 0d22494b13c7abdd62685293133f8d3e32cc634d..cbcf426545943e363da36bc0d851e38e72812040 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel io.streams.string io strings splitting sequences math 
-       math.parser assocs classes words namespaces prettyprint
-       hashtables mirrors tr ;
+USING: kernel io.streams.string io strings splitting sequences
+math math.parser assocs classes words namespaces make
+prettyprint hashtables mirrors tr ;
 IN: json.writer
 
 #! Writes the object out to a stream in JSON format
index 6f9ae3c88397f6047bedd9dd9d8b095acbf4356e..759e923a34b8eae56f203e9e68705864198dbff5 100755 (executable)
@@ -1,5 +1,6 @@
 USING: sequences kernel math locals math.order math.ranges\r
-accessors arrays namespaces combinators combinators.short-circuit ;\r
+accessors arrays namespaces make combinators\r
+combinators.short-circuit ;\r
 IN: lcs\r
 \r
 <PRIVATE\r
index af5f6834bcbc481a9df45bcd818fdf253e47e958..bfc92ee9e215b946539240eccf12986e206fd1be 100755 (executable)
@@ -1,14 +1,13 @@
 ! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces sequences sequences.private assocs math
-       vectors strings classes.tuple generalizations 
-       parser words quotations debugger macros arrays macros splitting
-       combinators prettyprint.backend definitions prettyprint
-       hashtables prettyprint.sections sets sequences.private effects
-       effects.parser generic generic.parser compiler.units accessors
-       locals.backend memoize macros.expander lexer
-       stack-checker.known-words ;
-
+USING: kernel namespaces make sequences sequences.private assocs
+math vectors strings classes.tuple generalizations parser words
+quotations debugger macros arrays macros splitting combinators
+prettyprint.backend definitions prettyprint hashtables
+prettyprint.sections sets sequences.private effects
+effects.parser generic generic.parser compiler.units accessors
+locals.backend memoize macros.expander lexer
+stack-checker.known-words ;
 IN: locals
 
 ! Inspired by
index 79d9410994909a60e72893173317ef01101c2c95..7c1db5b7c0ca85cbddc3db4b7c830e47466e5c50 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: logging.analysis logging.server logging smtp kernel\r
-io.files io.streams.string namespaces alarms assocs\r
+io.files io.streams.string namespaces make alarms assocs\r
 io.encodings.utf8 accessors calendar sequences qualified ;\r
 QUALIFIED: io.sockets\r
 IN: logging.insomniac\r
index aa4e46fad19d69e390885ba2befeb289a974928b..ae9ef877dd74e79d9da34efa16ead6ea24dfaafd 100755 (executable)
@@ -76,7 +76,7 @@ PRIVATE>
 : input# ( word -- n ) stack-effect in>> length ;\r
 \r
 : input-logging-quot ( quot word level -- quot' )\r
-    rot [ [ input# ] keep ] 2dip '[ , , , log-stack @ ] ;\r
+    rot [ [ input# ] keep ] 2dip '[ _ _ _ log-stack @ ] ;\r
 \r
 : add-input-logging ( word level -- )\r
     [ input-logging-quot ] (define-logging) ;\r
@@ -84,7 +84,7 @@ PRIVATE>
 : output# ( word -- n ) stack-effect out>> length ;\r
 \r
 : output-logging-quot ( quot word level -- quot' )\r
-    [ [ output# ] keep ] dip '[ @ , , , log-stack ] ;\r
+    [ [ output# ] keep ] dip '[ @ _ _ _ log-stack ] ;\r
 \r
 : add-output-logging ( word level -- )\r
     [ output-logging-quot ] (define-logging) ;\r
@@ -107,7 +107,7 @@ PRIVATE>
 \r
 : error-logging-quot ( quot word -- quot' )\r
     dup stack-effect stack-balancer\r
-    '[ , [ , log-error @ ] recover ] ;\r
+    '[ _ [ _ log-error @ ] recover ] ;\r
 \r
 : add-error-logging ( word level -- )\r
     [ [ input-logging-quot ] 2keep drop error-logging-quot ]\r
@@ -116,7 +116,7 @@ PRIVATE>
 : LOG:\r
     #! Syntax: name level\r
     CREATE-WORD dup scan-word\r
-    '[ 1array stack>message , , log-message ]\r
+    '[ 1array stack>message _ _ log-message ]\r
     (( message -- )) define-declared ; parsing\r
 \r
 USE: vocabs.loader\r
index 24482432011b4410d47ae02325fc25af6c8d8c4c..07a84ec5c6973f3c02730f31d83dbe404370701a 100755 (executable)
@@ -1,8 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: accessors peg peg.parsers memoize kernel sequences\r
-logging arrays words strings vectors io io.files io.encodings.utf8\r
-namespaces combinators logging.server calendar calendar.format ;\r
+logging arrays words strings vectors io io.files\r
+io.encodings.utf8 namespaces make combinators logging.server\r
+calendar calendar.format ;\r
 IN: logging.parser\r
 \r
 TUPLE: log-entry date level word-name message ;\r
index 0a1703de58aae204c9a60b6ea4b7d9f1363ad981..d766430810bfeef03317aee10a97a992fa49d388 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences namespaces quotations accessors words
-continuations vectors effects math stack-checker.transforms ;
+USING: kernel sequences namespaces make quotations accessors
+words continuations vectors effects math
+stack-checker.transforms ;
 IN: macros.expander
 
 GENERIC: expand-macros ( quot -- quot' )
index 0ae285d20d47d469ffccfbda8e9bcbfa44ec5ab4..c546555d077c26dcd5eb3d4e34b3d5e8100cdc2c 100755 (executable)
@@ -2,8 +2,8 @@
 ! See http://factorcode.org/license.txt for BSD license.
 !
 ! Based on pattern matching code from Paul Graham's book 'On Lisp'.
-USING: parser lexer kernel words namespaces sequences classes.tuple
-combinators macros assocs math effects ;
+USING: parser lexer kernel words namespaces make sequences
+classes.tuple combinators macros assocs math effects ;
 IN: match
 
 SYMBOL: _
index 60c585c779471536ebc86eb79903e9eaaa547ae3..871f40e74c9d7b9a58ccf9513c3e4717c245bb8f 100644 (file)
@@ -69,7 +69,7 @@ DEFER: byte-bit-count
 \ byte-bit-count
 256 [
     0 swap [ [ 1+ ] when ] each-bit
-] B{ } map-as '[ HEX: ff bitand , nth-unsafe ] define-inline
+] B{ } map-as '[ HEX: ff bitand _ nth-unsafe ] define-inline
 
 >>
 
index baa5558f7f02515e98e5a3d85fb28ae9fec0582b..6def4966a28c442239142d24d93b5fdd2de40f3d 100644 (file)
@@ -1,7 +1,7 @@
 ! 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 assocs quotations arrays locals
+sequences parser namespaces make assocs quotations arrays locals
 generic generic.math hashtables effects compiler.units ;
 IN: math.partial-dispatch
 
index 4b1a4a67d544e34e9928a55a791701dc5c3fdb33..1c3115631184400f8987efc6424d493fde972c55 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007 Slava Pestov, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel hashtables sequences arrays words namespaces
+USING: kernel hashtables sequences arrays words namespaces make
 parser math assocs effects definitions quotations summary
 accessors ;
 IN: memoize
index 9489da814962ff8acd4b054baf5e95016c2954ac..909f762c504b4a1a5eb4f9695d23697ecdfedc1e 100755 (executable)
@@ -16,7 +16,9 @@ MEMO: mime-db ( -- seq )
     } ;
 
 MEMO: mime-types ( -- assoc )
-    [ mime-db [ unclip '[ , _ set ] each ] each ] H{ } make-assoc
+    [
+        mime-db [ unclip '[ [ _ ] dip set ] each ] each
+    ] H{ } make-assoc
     nonstandard-mime-types assoc-union ;
 
 : mime-type ( filename -- mime-type )
index 856b9ad4562c39f687214f1167878ec205862e3c..5969fc0a95dc0a9349bdac8be37a3bdc87074bbd 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces parser lexer kernel sequences words quotations math
-accessors ;
+USING: namespaces make parser lexer kernel sequences words
+quotations math accessors ;
 IN: multiline
 
 <PRIVATE
index 7083262c496f1e91bd9626c136459a63cac13eee..776450ccd98443db593f7028236df5af3082b9b2 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2007 Chris Double.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
-USING: kernel compiler.units words arrays strings math.parser sequences \r
-       quotations vectors namespaces math assocs continuations peg\r
-       peg.parsers unicode.categories multiline \r
-       splitting accessors effects sequences.deep peg.search\r
-       combinators.short-circuit lexer io.streams.string\r
-       stack-checker io prettyprint combinators parser ;\r
+USING: kernel compiler.units words arrays strings math.parser\r
+sequences quotations vectors namespaces make math assocs\r
+continuations peg peg.parsers unicode.categories multiline\r
+splitting accessors effects sequences.deep peg.search\r
+combinators.short-circuit lexer io.streams.string stack-checker\r
+io prettyprint combinators parser ;\r
 IN: peg.ebnf\r
 \r
 : rule ( name word -- parser )\r
index 93de40d67201d60655c0643e5edf47b85dfdf39b..5739482093550d321726f0a05386588b99db6360 100755 (executable)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2007, 2008 Chris Double, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences strings namespaces math assocs shuffle 
-     vectors arrays math.parser accessors
-     unicode.categories sequences.deep peg peg.private 
-     peg.search math.ranges words ;
+USING: kernel sequences strings namespaces make math assocs
+shuffle vectors arrays math.parser accessors unicode.categories
+sequences.deep peg peg.private peg.search math.ranges words ;
 IN: peg.parsers
 
 TUPLE: just-parser p1 ;
index 11001ca41110443000b75fa169c9d714c8b50be4..2d7e2a81ac392d90b675823e541a15ffd9da0944 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 !
-USING: kernel tools.test strings namespaces arrays sequences 
+USING: kernel tools.test strings namespaces make arrays sequences 
        peg peg.private accessors words math accessors ;
 IN: peg.tests
 
index 9ef1ac658e4ccdb96a8c6b03b51bbd5021c9147d..cc13d5d42510fbfa3fcb788dea3187e0f00cef31 100755 (executable)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2007, 2008 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences strings fry namespaces math assocs shuffle debugger io
-       vectors arrays math.parser math.order vectors combinators
-       classes sets unicode.categories compiler.units parser
-       words quotations effects memoize accessors locals effects splitting 
-       combinators.short-circuit combinators.short-circuit.smart
-       generalizations ;
+USING: kernel sequences strings fry namespaces make math assocs
+shuffle debugger io vectors arrays math.parser math.order
+vectors combinators classes sets unicode.categories
+compiler.units parser words quotations effects memoize accessors
+locals effects splitting combinators.short-circuit
+combinators.short-circuit.smart generalizations ;
 IN: peg
 
 USE: prettyprint
@@ -356,7 +356,7 @@ TUPLE: token-parser symbol ;
   ] if ;
 
 M: token-parser (compile) ( peg -- quot )
-  symbol>> '[ input-slice , parse-token ] ;
+  symbol>> '[ input-slice _ parse-token ] ;
    
 TUPLE: satisfy-parser quot ;
 
@@ -373,7 +373,7 @@ TUPLE: satisfy-parser quot ;
 
 
 M: satisfy-parser (compile) ( peg -- quot )
-  quot>> '[ input-slice , parse-satisfy ] ;
+  quot>> '[ input-slice _ parse-satisfy ] ;
 
 TUPLE: range-parser min max ;
 
@@ -389,7 +389,7 @@ TUPLE: range-parser min max ;
   ] if ;
 
 M: range-parser (compile) ( peg -- quot )
-  [ min>> ] [ max>> ] bi '[ input-slice , , parse-range ] ;
+  [ min>> ] [ max>> ] bi '[ input-slice _ _ parse-range ] ;
 
 TUPLE: seq-parser parsers ;
 
@@ -447,7 +447,7 @@ TUPLE: repeat0-parser p1 ;
 
 M: repeat0-parser (compile) ( peg -- quot )
   p1>> compile-parser 1quotation '[ 
-    input-slice V{ } clone <parse-result> , swap (repeat) 
+    input-slice V{ } clone <parse-result> _ swap (repeat) 
   ] ; 
 
 TUPLE: repeat1-parser p1 ;
@@ -461,7 +461,7 @@ TUPLE: repeat1-parser p1 ;
 
 M: repeat1-parser (compile) ( peg -- quot )
   p1>> compile-parser 1quotation '[ 
-    input-slice V{ } clone <parse-result> , swap (repeat) repeat1-empty-check  
+    input-slice V{ } clone <parse-result> _ swap (repeat) repeat1-empty-check  
   ] ; 
 
 TUPLE: optional-parser p1 ;
@@ -483,7 +483,7 @@ TUPLE: semantic-parser p1 quot ;
 
 M: semantic-parser (compile) ( peg -- quot )
   [ p1>> compile-parser 1quotation ] [ quot>> ] bi  
-  '[ @ , check-semantic ] ;
+  '[ @ _ check-semantic ] ;
 
 TUPLE: ensure-parser p1 ;
 
@@ -511,7 +511,7 @@ TUPLE: action-parser p1 quot ;
   ] if ; inline
 
 M: action-parser (compile) ( peg -- quot )
-  [ p1>> compile-parser 1quotation ] [ quot>> ] bi '[ @ , check-action ] ;
+  [ p1>> compile-parser 1quotation ] [ quot>> ] bi '[ @ _ check-action ] ;
 
 TUPLE: sp-parser p1 ;
 
index ac6aa240ccd44faa85e25b19ceeac4900fa674fb..5ed72e5d599904f61a92983ef5aa6ca181510635 100644 (file)
@@ -85,7 +85,7 @@ M: hash-0-b hashcode* 2drop 0 ;
 
 : random-assocs ( -- hash phash )
     [ random-string ] replicate
-    [ H{ } clone [ '[ swap , set-at ] each-index ] keep ]
+    [ H{ } clone [ '[ swap _ set-at ] each-index ] keep ]
     [ PH{ } clone swap [ spin new-at ] each-index ]
     bi ;
 
index 2e2be264bbacc6a642abe767f1bc7d442893ad1b..a867dbb2e31859e059f01b1e92f5ebc6fa5684bb 100644 (file)
@@ -1,7 +1,7 @@
 ! Based on Clojure's PersistentHashMap by Rich Hickey.
 
 USING: kernel math accessors assocs fry combinators parser
-prettyprint.backend namespaces
+prettyprint.backend make
 persistent.assocs
 persistent.hashtables.nodes
 persistent.hashtables.nodes.empty
index 83003e5c47729e1b62feb649cd267ca0ef1555ef..2ee4008f2b437ce7e159f474a8ae7cd4bacaade4 100644 (file)
@@ -8,7 +8,7 @@ persistent.hashtables.nodes.leaf ;
 IN: persistent.hashtables.nodes.collision
 
 : find-index ( key hashcode collision-node -- n leaf-node )
-    leaves>> -rot '[ , , _ matching-key? ] find ; inline
+    leaves>> -rot '[ [ _ _ ] dip matching-key? ] find ; inline
 
 M:: collision-node (entry-at) ( key hashcode collision-node -- leaf-node )
     key hashcode collision-node find-index nip ;
index 7fa4cfe40162ff037da8ab5be835389b7c2c1e8c..3419e8387fc9bb748063b183a81f05fc4230ed21 100644 (file)
@@ -1,6 +1,6 @@
 ! Based on Clojure's PersistentHashMap by Rich Hickey.
 
-USING: kernel accessors locals math arrays namespaces
+USING: kernel accessors locals math arrays namespaces make
 persistent.hashtables.config
 persistent.hashtables.nodes ;
 IN: persistent.hashtables.nodes.leaf
index c2fd94e5cfa3ce4ed3a7b4d90710a249c2b914c6..f8445c7783a8193363d5e5d8a132dc0c684457d7 100755 (executable)
@@ -1,8 +1,8 @@
 ! 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 sequences strings
-sbufs io.styles vectors words prettyprint.config
+hashtables io assocs kernel math namespaces make sequences
+strings sbufs io.styles vectors words prettyprint.config
 prettyprint.sections quotations io io.files math.parser effects
 classes.tuple math.order classes.tuple.private classes
 combinators colors ;
index 9bffb34ed14a3d574a44890738d632435b1a2fc1..6a4ac71eb8417b5a97def16bfe7d59c2bfab5a52 100755 (executable)
@@ -3,7 +3,7 @@ kernel math namespaces parser prettyprint prettyprint.config
 prettyprint.sections sequences tools.test vectors words
 effects splitting generic.standard prettyprint.private
 continuations generic compiler.units tools.walker eval
-accessors ;
+accessors make ;
 IN: prettyprint.tests
 
 [ "4" ] [ 4 unparse ] unit-test
@@ -181,7 +181,7 @@ DEFER: parse-error-file
 
 : another-soft-break-test
     {
-        "USING: namespaces sequences ;"
+        "USING: make sequences ;"
         "IN: prettyprint.tests"
         ": another-soft-break-layout ( node -- quot )"
         "    parse-error-file"
index 3b9d034378350e0f7b5a310df64848294c1342dc..149ecde447b3175b78c0d566aa34d1ed0a41820f 100755 (executable)
@@ -1,15 +1,13 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-
-USING: arrays generic generic.standard assocs io kernel
-math namespaces sequences strings io.styles io.streams.string
+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 ;
-
 IN: prettyprint
 
 : make-pprint ( obj quot -- block in use )
index 13c86ea99430e104d3699c3e6d03723d1879bbf3..a629ca6fff2ff40efef57bd5ee56564a043e9269 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays generic hashtables io kernel math assocs
-namespaces sequences strings io.styles vectors words
+namespaces make sequences strings io.styles vectors words
 prettyprint.config splitting classes continuations
 io.streams.nested accessors sets ;
 IN: prettyprint.sections
diff --git a/basis/random/mersenne-twister/mersenne-twister-docs.factor.bak b/basis/random/mersenne-twister/mersenne-twister-docs.factor.bak
deleted file mode 100644 (file)
index 981b206..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-USING: help.markup help.syntax math ;
-IN: random.mersenne-twister
-
-ARTICLE: "random-numbers" "Generating random integers"
-"The " { $vocab-link "random" } " vocabulary implements the ``Mersenne Twister'' pseudo-random number generator algorithm."
-! { $subsection init-random }
-{ $subsection (random) }
-{ $subsection random } ;
-
-ABOUT: "random-numbers"
-
-! HELP: init-random
-! { $values { "seed" integer } }
-! { $description "Initializes the random number generator with the given seed. This word is called on startup to initialize the random number generator with the current time." } ;
-
-HELP: (random)
-{ $values { "rand" "an integer between 0 and 2^32-1" } }
-{ $description "Generates a random 32-bit unsigned integer." } ;
-
-HELP: random
-{ $values { "seq" "a sequence" } { "elt" "a random element" } }
-{ $description "Outputs a random element of the sequence. If the sequence is empty, always outputs " { $link f } "." }
-{ $notes "Since integers are sequences, passing an integer " { $snippet "n" } " yields a random integer in the interval " { $snippet "[0,n)" } "." } ;
-
-HELP: big-random
-{ $values { "n" "an integer" } { "r" "a random integer" } }
-{ $description "Outputs an integer with n bytes worth of bits." } ;
-
-HELP: random-256
-{ $values { "r" "a random integer" } }
-{ $description "Outputs an random integer 256 bits in length." } ;
index d25ceacdb1f11f630aa17ddcb04c3b530cbed296..3f0ebf692a197c3ec96c1362a5d0b88378cadd26 100755 (executable)
@@ -1,5 +1,5 @@
-USING: kernel math random namespaces random.mersenne-twister
-sequences tools.test math.order ;
+USING: kernel math random namespaces make
+random.mersenne-twister sequences tools.test math.order ;
 IN: random.mersenne-twister.tests
 
 : check-random ( max -- ? )
index 395086e2025b48c45012bddf20023be3bc3236cd..a88634aa8af20010c3705fcbdb3fdbb936c919a2 100755 (executable)
@@ -1,5 +1,5 @@
 USING: sequences.deep kernel tools.test strings math arrays
-namespaces sequences ;
+namespaces make sequences ;
 IN: sequences.deep.tests
 
 [ [ "hello" 3 4 swap ] ] [ [ { "hello" V{ 3 4 } } swap ] flatten ] unit-test
index fa98c7a9476231233dc69f6e5a5b200199f42233..f95ecddc1e6ad729bc67ee093693ee051c13d3a9 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Elie CHAFTARI, Dirk Vleugels,
 ! Slava Pestov, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays namespaces io io.timeouts kernel logging
+USING: arrays namespaces make io io.timeouts kernel logging
 io.sockets sequences combinators splitting assocs strings
 math.parser random system calendar io.encodings.ascii summary
 calendar.format accessors sets hashtables ;
index f4cd2c4a8e3892fe611c02a84d90109faf2b55db..aa280b96b6ca516463db730465ce8463db49a502 100755 (executable)
@@ -70,7 +70,7 @@ M: object apply-object push-literal ;
     2array recursive-state get swap prefix infer-quot ;
 
 : time-bomb ( error -- )
-    '[ , throw ] recursive-state get infer-quot ;
+    '[ _ throw ] recursive-state get infer-quot ;
 
 : bad-call ( -- )
     "call must be given a callable" time-bomb ;
@@ -165,7 +165,7 @@ M: object apply-object push-literal ;
     ] maybe-cannot-infer ;
 
 : apply-word/effect ( word effect -- )
-    swap '[ , #call, ] consume/produce ;
+    swap '[ _ #call, ] consume/produce ;
 
 : required-stack-effect ( word -- effect )
     dup stack-effect [ ] [ \ missing-effect inference-error ] ?if ;
index 46854831031df8b2c4e13f5c9377d03422d37265..511dcc6bbd2b3b95694911990e81cde8ed736e45 100644 (file)
@@ -17,12 +17,12 @@ SYMBOL: +bottom+
 : pad-with-bottom ( seq -- newseq )
     dup empty? [
         dup [ length ] map supremum
-        '[ , +bottom+ pad-left ] map
+        '[ _ +bottom+ pad-left ] map
     ] unless ;
 
 : phi-inputs ( max-d-in pairs -- newseq )
     dup empty? [ nip ] [
-        swap '[ , _ first2 unify-inputs ] map
+        swap '[ [ _ ] dip first2 unify-inputs ] map
         pad-with-bottom
     ] if ;
 
@@ -50,7 +50,7 @@ SYMBOL: quotations
     ] if-empty ;
 
 : branch-variable ( seq symbol -- seq )
-    '[ , _ at ] map ;
+    '[ [ _ ] dip at ] map ;
 
 : active-variable ( seq symbol -- seq )
     [ [ terminated? over at [ drop f ] when ] map ] dip
index 07ff016b2da62e5b9e71b4716aa3d787a4ef7fb9..7847fdfdcf194d4db13e226e53c205dcd814d917 100644 (file)
@@ -130,13 +130,13 @@ SYMBOL: enter-out
 : adjust-stack-effect ( effect -- effect' )
     [ in>> ] [ out>> ] bi
     meta-d get length pick length [-]
-    object <repetition> '[ , prepend ] bi@
+    object <repetition> '[ _ prepend ] bi@
     <effect> ;
 
 : call-recursive-inline-word ( word -- )
     dup "recursive" word-prop [
         [ required-stack-effect adjust-stack-effect ] [ ] [ recursive-label ] tri
-        [ 2nip check-call ] [ nip '[ , #call-recursive, ] consume/produce ] 3bi
+        [ 2nip check-call ] [ nip '[ _ #call-recursive, ] consume/produce ] 3bi
     ] [ undeclared-recursion-error inference-error ] if ;
 
 : inline-word ( word -- )
index 0d0de7f19b1faed6bc497d4c21035c2494dd3492..d3d32b50147d73eccd56d75d4c2e90571a338809 100755 (executable)
@@ -91,7 +91,7 @@ SYMBOL: dependencies
 : depends-on ( word how -- )
     over primitive? [ 2drop ] [
         dependencies get dup [
-            swap '[ , strongest-dependency ] change-at
+            swap '[ _ strongest-dependency ] change-at
         ] [ 3drop ] if
     ] if ;
 
@@ -100,7 +100,7 @@ SYMBOL: generic-dependencies
 
 : depends-on-generic ( generic class -- )
     generic-dependencies get dup
-    [ swap '[ null or , class-or ] change-at ] [ 3drop ] if ;
+    [ swap '[ null or _ class-or ] change-at ] [ 3drop ] if ;
 
 ! Words we've inferred the stack effect of, for rollback
 SYMBOL: recorded
index d60565e849d288caf8870ed0fddc1a0b176c08e9..41c7e2c9729f74655eb9ebe0c074bd371e121252 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: fry accessors arrays kernel words sequences generic math
-namespaces quotations assocs combinators classes.tuple
+namespaces make quotations assocs combinators classes.tuple
 classes.tuple.private effects summary hashtables classes generic
 sets definitions generic.standard slots.private continuations
 stack-checker.backend stack-checker.state stack-checker.visitor
@@ -19,7 +19,7 @@ IN: stack-checker.transforms
     dup [
         [
             [ drop ] [
-                [ length meta-d get '[ , pop* ] times ]
+                [ length meta-d get '[ _ pop* ] times ]
                 [ #drop, ]
                 bi
             ] bi*
@@ -97,7 +97,7 @@ IN: stack-checker.transforms
     dup tuple-class? [
         dup inlined-dependency depends-on
         [ "boa-check" word-prop ]
-        [ tuple-layout '[ , <tuple-boa> ] ]
+        [ tuple-layout '[ _ <tuple-boa> ] ]
         bi append
     ] [ drop f ] if
 ] 1 define-transform
index 15c83bf73afd2fea16abf25ddd573f56c88826be..dab5414b49ec18d0b7e80ce7b72b7d0696913a13 100644 (file)
@@ -100,7 +100,7 @@ SYMBOL: prolog-data
     #! from code until the quotation given is true and\r
     #! advance spot to after the substring.\r
     10 <sbuf> [\r
-        '[ @ [ t ] [ get-char , push f ] if ] skip-until\r
+        '[ @ [ t ] [ get-char _ push f ] if ] skip-until\r
     ] keep >string ; inline\r
 \r
 : take-rest ( -- string )\r
@@ -120,7 +120,7 @@ M: not-enough-characters summary ( obj -- str )
 \r
 : take ( n -- string )\r
     [ 1- ] [ <sbuf> ] bi [\r
-        '[ drop get-char [ next , push f ] [ t ] if* ] contains? drop\r
+        '[ drop get-char [ next _ push f ] [ t ] if* ] contains? drop\r
     ] keep get-char [ over push ] when* >string ;\r
 \r
 : pass-blank ( -- )\r
index 5da6599c63bc5670155bbaf476349cd92b5cb44d..ea2c19fd6df6198746803128a5a0e9b3c3d434c2 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
-words math math.parser io.styles prettyprint assocs ;
+make words math math.parser io.styles prettyprint assocs ;
 IN: summary
 
 GENERIC: summary ( object -- string )
index 2fa8abcd59e1599410ff15ff8ed151de6374f34f..a432d8c31c92a4cb9d1dbea726ca0cd771c73beb 100644 (file)
@@ -4,7 +4,7 @@
 USING: xml.utilities kernel assocs xml.generator math.order
     strings sequences xml.data xml.writer
     io.streams.string combinators xml xml.entities io.files io
-    http.client namespaces xml.generator hashtables
+    http.client namespaces make xml.generator hashtables
     calendar.format accessors continuations urls present ;
 IN: syndication
 
index ae4f6a8d62ad2b9e74250a7957a5dc16a56bab0e..324adcaad20ea055f385a526ce071242abce9122 100755 (executable)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces continuations.private kernel.private init
+USING: namespaces make continuations.private kernel.private init
 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 ;
+debugger io.streams.c io.files io.backend quotations io.launcher
+words.private tools.deploy.config bootstrap.image
+io.encodings.utf8 destructors accessors ;
 IN: tools.deploy.backend
 
 : copy-vm ( executable bundle-name extension -- vm )
index d38b40db4b96c5d216d623238f6e59654ef6591e..ee60ce3982a61fbbb799423aaf7f69685d670f79 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io io.files kernel namespaces sequences
+USING: io io.files kernel namespaces make sequences
 system tools.deploy.backend tools.deploy.config assocs
 hashtables prettyprint io.unix.backend cocoa io.encodings.utf8
 io.backend cocoa.application cocoa.classes cocoa.plists
index 7e37436654627489ec951634b0d129ac3f9510f8..f2726c00fa21ad104fa5e81a686ace8d1988dbb4 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors qualified io.streams.c init fry namespaces
+USING: accessors qualified 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
@@ -76,7 +76,7 @@ IN: tools.deploy.shaker
     [
         [
             props>> swap
-            '[ drop , member? not ] assoc-filter sift-assoc
+            '[ drop _ member? not ] assoc-filter sift-assoc
             dup assoc-empty? [ drop f ] [ >alist >vector ] if
         ] keep (>>props)
     ] with each ;
@@ -283,7 +283,7 @@ IN: tools.deploy.shaker
     strip-globals? [
         "Stripping globals" show
         global swap
-        '[ drop , member? not ] assoc-filter
+        '[ drop _ member? not ] assoc-filter
         [ drop string? not ] assoc-filter ! strip CLI args
         sift-assoc
         dup keys unparse show
index 887fd1b6d74739b70f75b4b4122d3816f960f3b2..dabdaaaa7caba5a5486a5732fb271ee204b9d155 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2008 Slava Pestov, Jorge Acereda Macia.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.files io words alien kernel math.parser alien.syntax
-io.launcher system assocs arrays sequences namespaces qualified
-system math compiler.generator.fixup io.encodings.ascii
-accessors generic tr ;
+io.launcher system assocs arrays sequences namespaces make
+qualified system math compiler.generator.fixup
+io.encodings.ascii accessors generic tr ;
 IN: tools.disassembler
 
 : in-file ( -- path ) "gdb-in.txt" temp-file ;
index 1c7e8d28d2c8222546c18dfbac7cc6faa7e2d927..732a6635b77e4054af2ddc67fae21277ae577350 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: kernel io io.styles io.files io.encodings.utf8\r
-vocabs.loader vocabs sequences namespaces math.parser arrays\r
-hashtables assocs memoize summary sorting splitting combinators\r
-source-files debugger continuations compiler.errors init\r
-checksums checksums.crc32 sets accessors ;\r
+vocabs.loader vocabs sequences namespaces make math.parser\r
+arrays hashtables assocs memoize summary sorting splitting\r
+combinators source-files debugger continuations compiler.errors\r
+init checksums checksums.crc32 sets accessors ;\r
 IN: tools.vocabs\r
 \r
 : vocab-tests-file ( vocab -- path )\r
index c1073eda8c2a03ad6ddc25dcc8a9fe3535d45e3b..9775bdff81a057b3ae8180dfb2e23e25af38b8d3 100755 (executable)
@@ -4,7 +4,7 @@ USING: threads kernel namespaces continuations combinators
 sequences math namespaces.private continuations.private
 concurrency.messaging quotations kernel.private words
 sequences.private assocs models models.filter arrays accessors
-generic generic.standard definitions ;
+generic generic.standard definitions make ;
 IN: tools.walker
 
 SYMBOL: show-walker-hook ! ( status continuation thread -- )
index b5ad2ba430ac5acfba2994f1c4b94599ddd5908c..30d0efb28ba0c06e8140222649f6ba839bc772be 100644 (file)
@@ -7,7 +7,7 @@ IN: tr
 <PRIVATE
 
 : compute-tr ( quot from to -- mapping )
-    zip [ 256 ] 2dip '[ [ @ , at ] keep or ] B{ } map-as ; inline
+    zip [ 256 ] 2dip '[ [ @ _ at ] keep or ] B{ } map-as ; inline
 
 : tr-hints ( word -- )
     { { byte-array } { string } } "specializer" set-word-prop ;
@@ -16,13 +16,13 @@ IN: tr
     create-in dup tr-hints ;
 
 : tr-quot ( mapping -- quot )
-    '[ [ dup 0 255 between? [ , nth-unsafe ] when ] map ] ;
+    '[ [ dup 0 255 between? [ _ nth-unsafe ] when ] map ] ;
 
 : define-tr ( word mapping -- )
     tr-quot (( seq -- translated )) define-declared ;
 
 : fast-tr-quot ( mapping -- quot )
-    '[ [ , nth-unsafe ] change-each ] ;
+    '[ [ _ nth-unsafe ] change-each ] ;
 
 : define-fast-tr ( word mapping -- )
     fast-tr-quot (( seq -- )) define-declared ;
index 804236dadcb33233abac9f17aa15bdf493f731ce..25312ad868c1bcac88b343fa410cae5664a4485f 100644 (file)
@@ -1,5 +1,5 @@
 USING: accessors ui.gestures help.markup help.syntax strings kernel
-hashtables quotations words classes sequences namespaces
+hashtables quotations words classes sequences namespaces make
 arrays assocs ;
 IN: ui.commands
 
index 2677c496ec9c95b9c55b489e881b89658b999304..b45e2e400427139c8462e1aeeca4365c883ca61e 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions kernel sequences strings
-math assocs words generic namespaces assocs quotations splitting
-ui.gestures unicode.case unicode.categories tr ;
+math assocs words generic namespaces make assocs quotations
+splitting ui.gestures unicode.case unicode.categories tr ;
 IN: ui.commands
 
 SYMBOL: +nullary+
index 81422973184373ab9dc6f2f0900b9a556ed5d9a0..888716b364b95c9efbd98daed989263dab386d14 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays documents io kernel math models
-namespaces opengl opengl.gl sequences strings io.styles
+namespaces make opengl opengl.gl sequences strings io.styles
 math.vectors sorting colors combinators assocs math.order
 ui.clipboards ui.commands ui.gadgets ui.gadgets.borders
 ui.gadgets.buttons ui.gadgets.labels ui.gadgets.scrollers
index 15850ae35786ea6eaf9bd50d81a6b98d40ed476f..05764d5b84899c48d791802f1368b7400e1e9cd4 100755 (executable)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays hashtables kernel models math namespaces
-       sequences quotations math.vectors combinators sorting
-       binary-search vectors dlists deques models threads
-       concurrency.flags math.order math.geometry.rect ;
-
+make sequences quotations math.vectors combinators sorting
+binary-search vectors dlists deques models threads
+concurrency.flags math.order math.geometry.rect ;
 IN: ui.gadgets
 
 SYMBOL: ui-notify-flag
index 42e8cfdfdf00a38a56cda3bf727fb7adbf616181..f14ccf1cca395614a8d63eddb93fd07f73d035eb 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel math namespaces sequences words io
+USING: arrays kernel math namespaces make sequences words io
 io.streams.string math.vectors ui.gadgets columns accessors
 math.geometry.rect ;
 IN: ui.gadgets.grids
index ed951824b8fee043467c3f1568da723ed9ba2690..f27b9898a125b88a67e1919ef211011e629f1922 100755 (executable)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays hashtables io kernel math namespaces
-opengl sequences strings splitting
-ui.gadgets ui.gadgets.tracks ui.gadgets.theme ui.render colors
-models ;
+make opengl sequences strings splitting ui.gadgets
+ui.gadgets.tracks ui.gadgets.theme ui.render colors models ;
 IN: ui.gadgets.labels
 
 ! A label gadget draws a string.
index cf679424e09370f09e094c0af96703a1c81da3aa..029bc5447cc0b712bdba49a0a400396b34793949 100644 (file)
@@ -9,7 +9,7 @@ IN: ui.gadgets.tracks
 TUPLE: track < pack sizes ;
 
 : normalized-sizes ( track -- seq )
-  sizes>> dup sift sum '[ dup [ , / ] when ] map ;
+  sizes>> dup sift sum '[ dup [ _ / ] when ] map ;
 
 : init-track ( track -- track )
   init-gadget
index 1170ea3fd15bcf87d83e5b400f34a615c94f98ef..a1c6adac6e452e6c3fde632483153e73c3d9f18a 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs kernel math models namespaces
-sequences words strings system hashtables math.parser
-math.vectors classes.tuple classes ui.gadgets boxes
-calendar alarms symbols combinators sets columns ;
+make sequences words strings system hashtables math.parser
+math.vectors classes.tuple classes ui.gadgets boxes calendar
+alarms symbols combinators sets columns ;
 IN: ui.gestures
 
 : set-gestures ( class hash -- ) "gestures" set-word-prop ;
index 8b4817dcacb41c15ec1e555eddbb9a087eca1df6..3e0b36486eb3cac4fd124aa3ea687255b693d675 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions kernel ui.commands
-ui.gestures sequences strings math words generic namespaces
+ui.gestures sequences strings math words generic namespaces make
 hashtables help.markup quotations assocs ;
 IN: ui.operations
 
index 51091c576dadf1129b686e5f96d508e4f50dc667..7bc42ea6761f89b6b7472eae839fe98f5a7aa1c9 100755 (executable)
@@ -4,7 +4,7 @@ USING: accessors kernel concurrency.messaging inspector
 ui.tools.listener ui.tools.traceback ui.gadgets.buttons
 ui.gadgets.status-bar ui.gadgets.tracks ui.commands ui.gadgets
 models models.filter ui.tools.workspace ui.gestures
-ui.gadgets.labels ui threads namespaces tools.walker assocs
+ui.gadgets.labels ui threads namespaces make tools.walker assocs
 combinators ;
 IN: ui.tools.walker
 
index 8486aaff217f451029b34070ff7e7d77a7f81bfb..e18637a652da2af05897f4f2f526237190266f62 100755 (executable)
@@ -1,6 +1,6 @@
-USING: accessors ui.gadgets ui.gadgets.labels namespaces sequences kernel
-math arrays tools.test io ui.gadgets.panes ui.traverse
-definitions compiler.units ;
+USING: accessors ui.gadgets ui.gadgets.labels namespaces make
+sequences kernel math arrays tools.test io ui.gadgets.panes
+ui.traverse definitions compiler.units ;
 IN: ui.traverse.tests
 
 M: array children>> ;
index 440f6487c2c62ddecb263cf95d84b3ac16b0a608..eadd110fe7e8ac3c5efab0965262bfbbc5cb231e 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors namespaces sequences kernel math arrays io ui.gadgets
-generic combinators ;
+USING: accessors namespaces make sequences kernel math arrays io
+ui.gadgets generic combinators ;
 IN: ui.traverse
 
 TUPLE: node value children ;
index e086b7ebaebe10ffe5955b56188366489c3213d9..d8c816d71750a76fb8954e783adece8ba573244e 100755 (executable)
@@ -192,7 +192,6 @@ HELP: raise-window
 ARTICLE: "ui-layouts" "Gadget hierarchy and layouts"
 "A layout gadget is a gadget whose sole purpose is to contain other gadgets. Layout gadgets position and resize children according to a certain policy, taking the preferred size of the children into account. Gadget hierarchies are constructed by building up nested layouts."
 { $subsection "ui-layout-basics" }
-{ $subsection "ui-layout-combinators" }
 "Common layout gadgets:"
 { $subsection "ui-pack-layout" }
 { $subsection "ui-track-layout" }
@@ -230,12 +229,6 @@ $nl
 { $subsection pref-dim* }
 "To get a gadget's preferred size, do not call the above word, instead use " { $link pref-dim  } ",  which caches the result." ;
 
-ARTICLE: "ui-layout-combinators" "Creating layouts using combinators"
-"The " { $link make } " combinator provides a convenient way of constructing sequences by keeping the intermediate sequence off the stack until construction is done. The " { $link , } " and " { $link % } " words operate on this implicit sequence, reducing stack noise."
-$nl
-"Similar tools exist for constructing complex gadget hierarchies. Different words are used for different types of gadgets; see " { $link "ui-pack-layout" } ", " { $link "ui-track-layout" } " and " { $link "ui-frame-layout" } " for specifics. This section documents their common factors."
-;
-
 ARTICLE: "ui-null-layout" "Manual layouts"
 "When automatic layout is not appropriate, gadgets can be added to a parent with no layout policy, and then positioned and sized manually by setting the " { $snippet "loc" } " field." ;
 
index 22abfc8f21b2c6fa45d5009c07e6910a99fdf523..da9e2f0d43eb435adde7fb5dd1e0c7fb5d9a2593 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs io kernel math models namespaces
+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
index e4018e4d20a2c48d855d4e6bccfed632d729d89c..88381ca7d704ad6fd0fb32bb13f0cd58f57e9552 100755 (executable)
@@ -1,7 +1,8 @@
-USING: combinators.short-circuit unicode.categories kernel math combinators splitting
-sequences math.parser io.files io assocs arrays namespaces
-math.ranges unicode.normalize values io.encodings.ascii
-unicode.syntax unicode.data compiler.units alien.syntax sets ;
+USING: combinators.short-circuit unicode.categories kernel math
+combinators splitting sequences math.parser io.files io assocs
+arrays namespaces make math.ranges unicode.normalize values
+io.encodings.ascii unicode.syntax unicode.data compiler.units
+alien.syntax sets ;
 IN: unicode.breaks
 
 C-ENUM: Any L V T Extend Control CR LF graphemes ;
index 0234a959daeb39543d01a6f6048bfae9b3585869..5e961e2d6795a9c15be505765680cf2f118d0aa1 100755 (executable)
@@ -1,4 +1,4 @@
-USING: unicode.data sequences sequences.next namespaces
+USING: unicode.data sequences sequences.next namespaces make
 unicode.normalize math unicode.categories combinators
 assocs strings splitting kernel accessors ;
 IN: unicode.case
index d71fffaaabea8f1675a1c1a551e35e401fad3cc0..3ebb474a8195d681bcfc2590ad2b38119f3d3066 100755 (executable)
@@ -1,6 +1,6 @@
 USING: combinators.short-circuit sequences io.files\r
 io.encodings.ascii kernel values splitting accessors math.parser\r
-ascii io assocs strings math namespaces sorting combinators\r
+ascii io assocs strings math namespaces make sorting combinators\r
 math.order arrays unicode.normalize unicode.data locals\r
 unicode.syntax macros sequences.deep words unicode.breaks\r
 quotations ;\r
index 6f36461d38b8f0f8ff494b13cd600cf80a299acf..53a38faed4eee9c9db67eda0f9d01272e545d15c 100755 (executable)
@@ -1,4 +1,4 @@
-USING: sequences namespaces unicode.data kernel math arrays
+USING: sequences namespaces make unicode.data kernel math arrays
 locals sorting.insertion accessors ;
 IN: unicode.normalize
 
index 40b0751e2c7cebe778e2aa51ae21004671267e3f..aa9ca843bd17a9853c83b780b8bb1edabe0e3c5a 100755 (executable)
@@ -1,6 +1,6 @@
 USING: accessors values kernel sequences assocs io.files
 io.encodings ascii math.ranges io splitting math.parser 
-namespaces byte-arrays locals math sets io.encodings.ascii
+namespaces make byte-arrays locals math sets io.encodings.ascii
 words compiler.units arrays interval-maps unicode.data ;
 IN: unicode.script
 
index 9df14a39289a6e3545ccb3b3eefd141d847fe194..1ba76fd380a5aa68ad4dc0b35de6d33d7ce4cf97 100755 (executable)
@@ -1,6 +1,6 @@
-USING: unicode.data kernel math sequences parser lexer bit-arrays
-namespaces sequences.private arrays quotations assocs
-classes.predicate math.order eval ;
+USING: unicode.data kernel math sequences parser lexer
+bit-arrays namespaces make sequences.private arrays quotations
+assocs classes.predicate math.order eval ;
 IN: unicode.syntax
 
 ! Character classes (categories)
index 299f3053718e9e6537fef7f636e692f5eeb433b0..e16f62d1f1e53ad30df6ba746415a8a9b854946b 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel ascii combinators combinators.short-circuit
-sequences splitting fry namespaces assocs arrays strings
+sequences splitting fry namespaces make assocs arrays strings
 io.sockets io.sockets.secure io.encodings.string
 io.encodings.utf8 math math.parser accessors parser
 strings.parser lexer prettyprint.backend hashtables present ;
@@ -105,7 +105,7 @@ TUPLE: url protocol username password host port path query anchor ;
     swap query>> at ;
 
 : set-query-param ( url value key -- url )
-    '[ , , _ ?set-at ] change-query ;
+    '[ [ _ _ ] dip ?set-at ] change-query ;
 
 : parse-host ( string -- host port )
     ":" split1 [ url-decode ] [
@@ -220,7 +220,7 @@ PRIVATE>
     } case ;
 
 : ensure-port ( url -- url' )
-    dup protocol>> '[ , protocol-port or ] change-port ;
+    dup protocol>> '[ _ protocol-port or ] change-port ;
 
 ! Literal syntax
 : URL" lexer get skip-blank parse-string >url parsed ; parsing
index b786ef55290433a3b5f60068358cf773b5085d67..f24171b2b476551f5344f5cd090119025b4b5da0 100644 (file)
@@ -1,9 +1,8 @@
 ! Copyright (C) 2006, 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel continuations sequences math
-namespaces sets math.parser math.ranges assocs regexp
-unicode.categories arrays hashtables words
-classes quotations xmode.catalog ;
+USING: kernel continuations sequences math namespaces make sets
+math.parser math.ranges assocs regexp unicode.categories arrays
+hashtables words classes quotations xmode.catalog ;
 IN: validators
 
 : v-default ( str def -- str )
index 2f766a3a517a20a5b0d2cef3e18105373d172ba6..c56293babe828b39d72efaa732858e9a9690070d 100755 (executable)
@@ -12,7 +12,7 @@ C-STRUCT: com-interface
 MACRO: com-invoke ( n return parameters -- )
     dup length -roll
     '[
-        , npick com-interface-vtbl , swap void*-nth , ,
+        _ npick com-interface-vtbl _ swap void*-nth _ _
         "stdcall" alien-indirect
     ] ;
 
index 59b616ecc7152f6cbb19ac3ab00d7dd7d7afbbd5..d376cccae2e6eede05f82ac7a710bd5b19cf535a 100755 (executable)
@@ -48,7 +48,7 @@ unless
     (query-interface-cases) 
     '[
         swap 16 memory>byte-array
-        , case
+        _ case
         [
             "void*" heap-size * rot <displaced-alien> com-add-ref
             0 rot set-void*-nth S_OK
@@ -57,14 +57,14 @@ unless
 
 : (make-add-ref) ( interfaces -- quot )
     length "void*" heap-size * '[
-        , swap <displaced-alien>
+        _ swap <displaced-alien>
         0 over ulong-nth
         1+ [ 0 rot set-ulong-nth ] keep
     ] ;
 
 : (make-release) ( interfaces -- quot )
     length "void*" heap-size * '[
-        , over <displaced-alien>
+        _ over <displaced-alien>
         0 over ulong-nth
         1- [ 0 rot set-ulong-nth ] keep
         dup zero? [ swap (free-wrapped-object) ] [ nip ] if
@@ -79,16 +79,16 @@ unless
 : (thunk) ( n -- quot )
     dup 0 =
     [ drop [ ] ]
-    [ "void*" heap-size neg * '[ , swap <displaced-alien> ] ]
+    [ "void*" heap-size neg * '[ _ swap <displaced-alien> ] ]
     if ;
 
 : (thunked-quots) ( quots iunknown-methods thunk -- {thunk,quot}s )
-    [ '[ , '[ @ com-unwrap ] [ swap 2array ] curry map ] ]
-    [ '[ ,                   [ swap 2array ] curry map ] ] bi bi*
+    [ '[ _ '[ @ com-unwrap ] [ swap 2array ] curry map ] ]
+    [ '[ _                   [ swap 2array ] curry map ] ] bi bi*
     swap append ;
 
 : compile-alien-callback ( word return parameters abi quot -- word )
-    '[ , , , , alien-callback ]
+    '[ _ _ _ _ alien-callback ]
     [ [ (( -- alien )) define-declared ] pick slip ]
     with-compilation-unit ;
 
@@ -100,7 +100,7 @@ unless
     "windows.com.wrapper.callbacks" create ;
 
 : (finish-thunk) ( param-count thunk quot -- thunked-quot )
-    [ [ drop [ ] ] [ swap 1- '[ , , ndip ] ] if-empty ]
+    [ [ drop [ ] ] [ swap 1- '[ _ _ ndip ] ] if-empty ]
     dip compose ;
 
 : (make-interface-callbacks) ( interface-name quots iunknown-methods n -- words )
@@ -108,7 +108,7 @@ unless
     swap [ find-com-interface-definition family-tree-functions ]
     keep (next-vtbl-counter) '[
         swap [
-            [ name>> , , (callback-word) ]
+            [ name>> _ _ (callback-word) ]
             [ return>> ] [
                 parameters>>
                 [ [ first ] map ]
index 6c55ff0e67cbfbb7f89e61fbcc8334d77853ca2f..182c17430ff8cbbe50873814f8ca6dd1ccfd8476 100755 (executable)
@@ -78,7 +78,7 @@ SYMBOLS:
 
 : (malloc-guid-symbol) ( symbol guid -- )
     global swap '[ [
-        , execute [ byte-length malloc ] [ over byte-array>memory ] bi
+        _ execute [ byte-length malloc ] [ over byte-array>memory ] bi
     ] unless* ] change-at ;
 
 : define-guid-constants ( -- )
index 29a8bbf10fa881c3e004d9b329006006cf48eaf6..87a870d75d771421e6abdf58bfdf1dbf2eb2809c 100644 (file)
@@ -1,4 +1,4 @@
-USING: sequences kernel namespaces splitting math math.order ;
+USING: sequences kernel namespaces make splitting math math.order ;
 IN: wrap
 
 ! Very stupid word wrapping/line breaking
index a8608235f2066bb0925f1533b12ddbf8f22bc8f0..eefb93772a07235776a7e521bfdf44418768738d 100644 (file)
@@ -3,7 +3,7 @@
 !
 ! based on glx.h from xfree86, and some of glxtokens.h
 USING: alien alien.c-types alien.syntax alien.syntax.private x11.xlib
-namespaces kernel sequences parser words ;
+namespaces make kernel sequences parser words ;
 IN: x11.glx
 
 LIBRARY: glx
index b90613ec7991d39bc95ec5b6acae1be085b0552e..d3eca306858d0420620c1d6d0939afb8930a8e37 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces kernel assocs sequences ;
+USING: namespaces make kernel assocs sequences ;
 IN: xml.entities
 
 : entities-out
index 0de1692e007bee7acf06e6ebfb1ebc759337fcbb..24da501265a309d3c97234e68688f516503cb0fc 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2006, 2007 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces kernel xml.data xml.utilities assocs sequences ;
+USING: namespaces make kernel xml.data xml.utilities assocs
+sequences ;
 IN: xml.generator
 
 : comment, ( string -- ) <comment> , ;
index f2bd5ce1e3ce1df3b9bdc8f155239bc9abff6072..623663ebe1e6eb8b5285b209c4bf603d0a3cf417 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 IN: xml.tests
-USING: kernel xml tools.test io namespaces sequences xml.errors xml.entities
-    parser strings xml.data io.files xml.writer xml.utilities state-parser 
-    continuations assocs sequences.deep accessors ;
+USING: kernel xml tools.test io namespaces make sequences
+xml.errors xml.entities parser strings xml.data io.files
+xml.writer xml.utilities state-parser continuations assocs
+sequences.deep accessors ;
 
 ! This is insufficient
 \ read-xml must-infer
index 0c3ef2c1df718ab7161e12c0b9ac9f7d67fba289..b7314c5b258f76d1037a87a1e559348f2d3ad193 100644 (file)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2006 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
 USING: xml.errors xml.data xml.utilities xml.char-classes sets
-xml.entities kernel state-parser kernel namespaces strings math
-math.parser sequences assocs arrays splitting combinators unicode.case
-accessors ;
+xml.entities kernel state-parser kernel namespaces make strings
+math math.parser sequences assocs arrays splitting combinators
+unicode.case accessors ;
 IN: xml.tokenize
 
 ! XML namespace processing: ns = namespace
index 2bc766dbc6507b12503fec26e5bcfbfd26ff0a41..9115b1389bc323a69caeaf32b07894f7c2173ad7 100755 (executable)
@@ -9,8 +9,8 @@ IN: xmode.code2html.responder
     [\r
         drop\r
         dup '[\r
-            , utf8 [\r
-                , file-name input-stream get htmlize-stream\r
+            _ utf8 [\r
+                _ file-name input-stream get htmlize-stream\r
             ] with-file-reader\r
         ] "text/html" <content>\r
     ] <file-responder> ;\r
index 5512b68b046d8cd037facfcea211f8f1d4ac30aa..69c4e4fac39bf87cbb2338aa96c8815d4ad6e3fe 100644 (file)
@@ -1,6 +1,9 @@
-USING: accessors xmode.tokens xmode.rules xmode.keyword-map xml.data
-xml.utilities xml assocs kernel combinators sequences
-math.parser namespaces parser lexer xmode.utilities regexp io.files ;
+! Copyright (C) 2007, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors xmode.tokens xmode.rules xmode.keyword-map
+xml.data xml.utilities xml assocs kernel combinators sequences
+math.parser namespaces make parser lexer xmode.utilities regexp
+io.files ;
 IN: xmode.loader.syntax
 
 SYMBOL: ignore-case?
index dfdd6c801a1f6404477dd56cac511a3d93c9a43d..d0d68febec5b964b579a43e074a3599347ce81db 100755 (executable)
@@ -1,5 +1,7 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
 IN: xmode.marker
-USING: kernel namespaces xmode.rules xmode.tokens
+USING: kernel namespaces make xmode.rules xmode.tokens
 xmode.marker.state xmode.marker.context xmode.utilities
 xmode.catalog sequences math assocs combinators
 strings regexp splitting parser-combinators ascii unicode.case
index 9075ff63294c14110ba49ee15a046dd7715a9a40..096230ff4e3577bc604c6f14e6f4950cfdfd9e0c 100755 (executable)
@@ -1,5 +1,7 @@
+! Copyright (C) 2007, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
 USING: xmode.marker.context xmode.rules symbols accessors
-xmode.tokens namespaces kernel sequences assocs math ;
+xmode.tokens namespaces make kernel sequences assocs math ;
 IN: xmode.marker.state
 
 ! Based on org.gjt.sp.jedit.syntax.TokenMarker
index 4a44dbd6417196ee93c5c36460e3fc6b0cc35444..3deb08ac628f5ca10a9a3fbf855c9606a6b83d6d 100755 (executable)
@@ -1,5 +1,5 @@
 IN: assocs.tests
-USING: kernel math namespaces tools.test vectors sequences
+USING: kernel math namespaces make tools.test vectors sequences
 sequences.private hashtables io prettyprint assocs
 continuations float-arrays ;
 
index 5ec96bbbb0f0f69ec6c31e01e51c36c4b3da036c..67a789a1dcdcb484b8538044ec73f41fcdab2ce5 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions assocs kernel kernel.private
-slots.private namespaces sequences strings words vectors math
-quotations combinators sorting effects graphs vocabs sets ;
+slots.private namespaces make sequences strings words vectors
+math quotations combinators sorting effects graphs vocabs sets ;
 IN: classes
 
 SYMBOL: class<=-cache
index e6d6b5a0d4566f2046a411e12e67e2848456ab7b..4ba93acae46674f284541e0ef34edd8d970c9f64 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: classes classes.algebra kernel namespaces words sequences
-quotations arrays kernel.private assocs combinators ;
+USING: classes classes.algebra kernel namespaces make words
+sequences quotations arrays kernel.private assocs combinators ;
 IN: classes.predicate
 
 PREDICATE: predicate-class < class
index 531658a5e0c5507799616f4d14a9ed332106493c..c190ce85e7a990ebb3f09873e2514fac2a968c45 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel sets namespaces sequences parser
+USING: accessors kernel sets namespaces make sequences parser
 lexer combinators words classes.parser classes.tuple arrays
 slots math assocs ;
 IN: classes.tuple.parser
index b5c3658542b818b2badccaa0689d79a5a854cb0d..f92c9c0fd58730e9c5e0191df761cdd319b9c24b 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays definitions hashtables kernel kernel.private math
-namespaces sequences sequences.private strings vectors words
-quotations memory combinators generic classes classes.algebra
-classes.builtin classes.private slots.private slots
-compiler.units math.private accessors assocs effects ;
+namespaces make sequences sequences.private strings vectors
+words quotations memory combinators generic classes
+classes.algebra classes.builtin classes.private slots.private
+slots compiler.units math.private accessors assocs effects ;
 IN: classes.tuple
 
 PREDICATE: tuple-class < class
index e21348fd19c1ed7f9bb3211db00444796f382377..7a28c1fb992c379366d834ee0083722debed9da6 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces assocs io sequences
+USING: kernel namespaces make assocs io sequences
 sorting continuations math math.parser ;
 IN: compiler.errors
 
index bfa3848186e2bab9a782e78a3590d223384b08d9..6dde851963442774f3b24cfaf305a43f60ddfb39 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays vectors kernel kernel.private sequences
-namespaces math splitting sorting quotations assocs
+namespaces make math splitting sorting quotations assocs
 combinators accessors ;
 IN: continuations
 
index 154e1c30ac098180e80702b5c921a4079b1a09a9..afc956fae473592ab7635f80b3ee5c3cb6cb6510 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2007, 2008 Doug Coleman, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors continuations kernel namespaces
+USING: accessors continuations kernel namespaces make
 sequences vectors ;
 IN: destructors
 
index 8a000b0615fc97eafa351963c8b6f2696c85ae18..0c082477c700df893d7292df9d821a16855f60ac 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.parser namespaces sequences strings
+USING: kernel math math.parser namespaces make sequences strings
 words assocs combinators accessors arrays ;
 IN: effects
 
index c0a21dbaba3def9070746cea7005dff9ff931c33..026e37291244b666fc255432ae4c052e3ad20713 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2006, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors words kernel sequences namespaces assocs
+USING: accessors words kernel sequences namespaces make assocs
 hashtables definitions kernel.private classes classes.private
 classes.algebra quotations arrays vocabs effects combinators
 sets ;
index 834e19d9d9b11ec20c3fe9ad87ca684ca99ff7d9..077795c4b786a8101e0a67954a807412720af8eb 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays generic hashtables kernel kernel.private
-math namespaces sequences words quotations layouts combinators
+USING: arrays generic hashtables kernel kernel.private math
+namespaces make sequences words quotations layouts combinators
 sequences.private classes classes.builtin classes.algebra
 definitions math.order ;
 IN: generic.math
index 02a7af105f8d621e96e4e813b606e42423259500..50813f191cea2f9a14e9d85484d521c0de91f31f 100644 (file)
@@ -1,4 +1,6 @@
-USING: classes.private generic.standard.engines namespaces
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: classes.private generic.standard.engines namespaces make
 arrays assocs sequences.private quotations kernel.private
 math slots.private math.private kernel accessors words
 layouts ;
index 325f2ebb394bc8754d925b78a81c9b692a662805..8c61aa4240584ff658dc2927d1e5400265614eca 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel classes.tuple.private hashtables assocs sorting
 accessors combinators sequences slots.private math.parser words
-effects namespaces generic generic.standard.engines
+effects namespaces make generic generic.standard.engines
 classes.algebra math math.private kernel.private
 quotations arrays definitions ;
 IN: generic.standard.engines.tuple
index 52d73a9a4c0ad664f14ac5cbd7a5df6f06068956..f6635276b36c26a1b06845330aa5f5c9a1c12783 100644 (file)
@@ -1,7 +1,7 @@
 IN: generic.standard.tests
 USING: tools.test math math.functions math.constants
 generic.standard strings sequences arrays kernel accessors
-words float-arrays byte-arrays bit-arrays parser namespaces
+words float-arrays byte-arrays bit-arrays parser namespaces make
 quotations stack-checker vectors growable hashtables sbufs
 prettyprint byte-vectors bit-vectors float-vectors definitions
 generic sets graphs assocs ;
index 860781e5e2636c5a00c7db4ac98cf78a86b1216a..d22d20a0fc61430189141976aa2ef65ecc6db4a1 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs kernel kernel.private slots.private math
-namespaces sequences vectors words quotations definitions
+namespaces make sequences vectors words quotations definitions
 hashtables layouts combinators sequences.private generic
 classes classes.algebra classes.private generic.standard.engines
 generic.standard.engines.tag generic.standard.engines.predicate
index abf3747244a541569eac26f81d424a231016f412..a59c6495983b9bdde080ea63452af2e1070d5bba 100755 (executable)
@@ -1,5 +1,5 @@
 IN: hashtables.tests
-USING: kernel math namespaces tools.test vectors sequences
+USING: kernel math namespaces make tools.test vectors sequences
 sequences.private hashtables io prettyprint assocs
 continuations ;
 
index af40cf8737b5d472192c3dfd30178c143df65ae7..c38a7c9ebc70286ed7b46a9e55488e08b6d41572 100755 (executable)
@@ -1,5 +1,5 @@
 USING: arrays io io.files kernel math parser strings system
-tools.test words namespaces io.encodings.8-bit
+tools.test words namespaces make io.encodings.8-bit
 io.encodings.binary sequences ;
 IN: io.tests
 
index a03aaac6d84c2277e40fdabba72fef84270b0702..0d5a8574901cc857114b7332f9710a0327fa378a 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2003, 2007 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: hashtables generic kernel math namespaces sequences
+USING: hashtables generic kernel math namespaces make sequences
 continuations destructors assocs ;
 IN: io
 
index de6d8519ca025ba1fc19a2aedef49b56d8b807bf..780d892d2e294dd0c928a71e6a6ada1136c6c365 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel kernel.private namespaces io io.encodings
+USING: kernel kernel.private namespaces make io io.encodings
 sequences math generic threads.private classes io.backend
 io.files continuations destructors byte-arrays accessors ;
 IN: io.streams.c
index 3512ac871db8010701cb59f1254707e3eeab0e48..a6502046c8e8f66736f42879cdebf25af407929d 100644 (file)
@@ -1,4 +1,5 @@
-USING: io.streams.string io kernel arrays namespaces tools.test ;
+USING: io.streams.string io kernel arrays namespaces make
+tools.test ;
 IN: io.streams.string.tests
 
 [ "line 1" CHAR: l ]
diff --git a/core/make/make-docs.factor b/core/make/make-docs.factor
new file mode 100644 (file)
index 0000000..ef037f1
--- /dev/null
@@ -0,0 +1,30 @@
+IN: make
+USING: help.markup help.syntax quotations sequences math.parser
+kernel ;
+
+ARTICLE: "namespaces-make" "Making sequences with variables"
+"The " { $vocab-link "make" } " vocabulary implements a facility for constructing sequences by holding an accumulator sequence in a variable. Storing the accumulator sequence in a variable rather than the stack may allow code to be written with less stack manipulation."
+{ $subsection make }
+{ $subsection , }
+{ $subsection % }
+{ $subsection # }
+"The accumulator sequence can be accessed directly:"
+{ $subsection building } ;
+
+ABOUT: "namespaces-make"
+
+HELP: building
+{ $var-description "Temporary mutable growable sequence holding elements accumulated so far by " { $link make } "." } ;
+
+HELP: make
+{ $values { "quot" quotation } { "exemplar" sequence } { "seq" "a new sequence" } }
+{ $description "Calls the quotation in a new " { $emphasis "dynamic scope" } ". The quotation and any words it calls can execute the " { $link , } " and " { $link % } " words to accumulate elements. When the quotation returns, all accumulated elements are collected into a sequence with the same type as " { $snippet "exemplar" } "." }
+{ $examples { $example "USING: namespaces prettyprint ;" "[ 1 , 2 , 3 , ] { } make ." "{ 1 2 3 }" } } ;
+
+HELP: ,
+{ $values { "elt" object } }
+{ $description "Adds an element to the end of the sequence being constructed by " { $link make } "." } ;
+
+HELP: %
+{ $values { "seq" sequence } }
+{ $description "Appends a sequence to the end of the sequence being constructed by " { $link make } "." } ;
diff --git a/core/make/make.factor b/core/make/make.factor
new file mode 100644 (file)
index 0000000..f8bdaa1
--- /dev/null
@@ -0,0 +1,19 @@
+! Copyright (C) 2003, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences namespaces ;
+IN: make
+
+SYMBOL: building
+
+: make ( quot exemplar -- seq )
+    [
+        [
+            1024 swap new-resizable [
+                building set call
+            ] keep
+        ] keep like
+    ] with-scope ; inline
+
+: , ( elt -- ) building get push ;
+
+: % ( seq -- ) building get push-all ;
index d72bb679709861d8ba7337c24d5a8ed5a6ad3f0c..c2077eb790cea8371271938742af97dc280fae67 100644 (file)
@@ -1,4 +1,4 @@
-USING: kernel math namespaces tools.test ;
+USING: kernel math namespaces make tools.test ;
 IN: math.tests
 
 [ ] [ 5 [ ] times ] unit-test
index 1d2a24057cd2ac4b807611b7e5759d7e8beaa3f1..bcc75a842aa9b9abd34b3217384e1bde9ab1c45d 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.markup help.syntax math math.private prettyprint
-namespaces strings ;
+namespaces make strings ;
 IN: math.parser
 
 ARTICLE: "number-strings" "Converting between numbers and strings"
index 05e267f0356aad477d1adcfeb40c3dd53b4826e0..04d8fb6a413977e4bfd094554a685a0842d8f6f9 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math.private namespaces sequences strings arrays
-combinators splitting math assocs ;
+USING: kernel math.private namespaces make sequences strings
+arrays combinators splitting math assocs ;
 IN: math.parser
 
 : digit> ( ch -- n )
index 1da3bc45db16cd3b864c518128a40c1a2d998e9b..f410148566031854b890939451c7ed7a4c01c04b 100755 (executable)
@@ -22,13 +22,6 @@ ARTICLE: "namespaces-global" "Global variables"
 { $subsection get-global }
 { $subsection set-global } ;
 
-ARTICLE: "namespaces-make" "Constructing sequences"
-"There is a lexicon of words for constructing sequences without passing the partial sequence being built on the stack. This reduces stack noise."
-{ $subsection make }
-{ $subsection , }
-{ $subsection % }
-{ $subsection # } ;
-
 ARTICLE: "namespaces.private" "Namespace implementation details"
 "The namestack holds namespaces."
 { $subsection namestack }
@@ -50,8 +43,6 @@ $nl
 { $subsection "namespaces-change" }
 { $subsection "namespaces-combinators" }
 { $subsection "namespaces-global" }
-"A useful facility for constructing sequences by holding an accumulator sequence in a variable:"
-{ $subsection "namespaces-make" }
 "Implementation details your code probably does not care about:"
 { $subsection "namespaces.private" }
 "An alternative to dynamic scope is lexical scope. Lexically-scoped values and closures are implemented in the " { $vocab-link "locals" } " vocabulary." ;
@@ -162,22 +153,6 @@ HELP: >n
 HELP: ndrop
 { $description "Pops a namespace from the name stack." } ;
 
-HELP: building
-{ $var-description "Temporary mutable growable sequence holding elements accumulated so far by " { $link make } "." } ;
-
-HELP: make
-{ $values { "quot" quotation } { "exemplar" "a sequence" } { "seq" "a new sequence" } }
-{ $description "Calls the quotation in a new " { $emphasis "dynamic scope" } ". The quotation and any words it calls can execute the " { $link , } " and " { $link % } " words to accumulate elements. When the quotation returns, all accumulated elements are collected into a sequence with the same type as " { $snippet "exemplar" } "." }
-{ $examples { $example "USING: namespaces prettyprint ;" "[ 1 , 2 , 3 , ] { } make ." "{ 1 2 3 }" } } ;
-
-HELP: ,
-{ $values { "elt" object } }
-{ $description "Adds an element to the end of the sequence being constructed by " { $link make } "." } ;
-
-HELP: %
-{ $values { "seq" "a sequence" } }
-{ $description "Appends a sequence to the end of the sequence being constructed by " { $link make } "." } ;
-
 HELP: init-namespaces
 { $description "Resets the name stack to its initial state, holding a single copy of the global namespace." }
 $low-level-note ;
index 3d3d3c554bc7aced62c3c6cfe4a71fe4ce52e926..20400f4e54d11848677f99b0d54b71a919f2bf19 100644 (file)
@@ -1,4 +1,4 @@
-! Copyright (C) 2003, 2007 Slava Pestov.
+! Copyright (C) 2003, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel vectors sequences hashtables
 arrays kernel.private math strings assocs ;
@@ -6,9 +6,7 @@ IN: namespaces
 
 <PRIVATE
 
-: namestack* ( -- namestack )
-    0 getenv { vector } declare ; inline
-
+: namestack* ( -- namestack ) 0 getenv { vector } declare ; inline
 : >n ( namespace -- ) namestack* push ;
 : ndrop ( -- ) namestack* pop* ;
 
@@ -25,18 +23,11 @@ PRIVATE>
 : off ( variable -- ) f swap set ; inline
 : get-global ( variable -- value ) global at ;
 : set-global ( value variable -- ) global set-at ;
-
-: change ( variable quot -- )
-    >r dup get r> rot slip set ; inline
-
+: change ( variable quot -- ) >r dup get r> rot slip set ; inline
 : +@ ( n variable -- ) [ 0 or + ] change ;
-
 : 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 ;
 
 : make-assoc ( quot exemplar -- hash )
@@ -47,19 +38,3 @@ PRIVATE>
 
 : with-variable ( value key quot -- )
     >r associate >n r> call ndrop ; inline
-
-! Building sequences
-SYMBOL: building
-
-: make ( quot exemplar -- seq )
-    [
-        [
-            1024 swap new-resizable [
-                building set call
-            ] keep
-        ] keep like
-    ] with-scope ; inline
-
-: , ( elt -- ) building get push ;
-
-: % ( seq -- ) building get push-all ;
index 6f831c30c5eb7faaa5570e04c1307b9368e6557f..d4ae60ca9469852b11fbfb09cd2ce79fd1744611 100755 (executable)
@@ -1,9 +1,9 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays byte-arrays kernel kernel.private math namespaces
-sequences strings words effects generic generic.standard classes
-classes.algebra slots.private combinators accessors words
-sequences.private assocs alien ;
+make sequences strings words effects generic generic.standard
+classes classes.algebra slots.private combinators accessors
+words sequences.private assocs alien ;
 IN: slots
 
 TUPLE: slot-spec name offset class initial read-only ;
index 38f5ae08912111b7e60c5ce1edad8be9d31e9f85..aac32784a1f8c49465c72f61b460b7fe31ea66cb 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math namespaces strings arrays vectors sequences
+USING: kernel math make strings arrays vectors sequences
 sets math.order accessors ;
 IN: splitting
 
index 8d95254539ffcd3d69b1f9e23c1aca0735a96da7..2695860a59b53c7c5cbba4c6350df41667297dfc 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel assocs namespaces splitting sequences
+USING: kernel assocs namespaces make splitting sequences
 strings math.parser lexer accessors ;
 IN: strings.parser
 
index d10f1603f10ed1b2737b656ed8cd1270522a00ca..078785178bc34eb493198b51cfde6979848480a7 100755 (executable)
@@ -1,6 +1,6 @@
-USING: continuations kernel math math.order namespaces strings
-strings.private sbufs tools.test sequences vectors arrays memory
-prettyprint io.streams.null ;
+USING: continuations kernel math math.order namespaces make
+strings strings.private sbufs tools.test sequences vectors
+arrays memory prettyprint io.streams.null ;
 IN: strings.tests
 
 [ CHAR: b ] [ 1 >bignum "abc" nth ] unit-test
index 4677a7b5d73bbb0ae633a0f72b0fa5e2cc4da95e..44f538d5d9a47bce08e773e910211e6f71b48791 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2007, 2008 Eduardo Cavazos, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces sequences io.files kernel assocs words vocabs
-definitions parser continuations io hashtables sorting
+USING: namespaces make sequences io.files kernel assocs words
+vocabs definitions parser continuations io hashtables sorting
 source-files arrays combinators strings system math.parser
 compiler.errors splitting init accessors ;
 IN: vocabs.loader
index df5d11be751916873d3cbcfd635275828bb92fc0..bd1ed83baa6859e1b4b3e30e46b822adf1704823 100644 (file)
@@ -3,7 +3,7 @@
 
 USING: arrays asn1.ldap assocs byte-arrays combinators
 continuations io io.binary io.streams.string kernel math
-math.parser namespaces pack strings sequences accessors ;
+math.parser namespaces make pack strings sequences accessors ;
 
 IN: asn1
 
index df397025f60f9399971fb1efcc1a60a8b5afce9e..9bef16d609c6871a73e779403835719d945a9cc2 100755 (executable)
@@ -20,9 +20,9 @@ M: amb-failure summary drop "Backtracking failure" ;
     [ fail ] unless ;\r
 \r
 MACRO: checkpoint ( quot -- quot' )\r
-    '[ failure get ,\r
-       '[ '[ failure set , continue ] callcc0\r
-          , failure set @ ] callcc0 ] ;\r
+    '[ failure get _\r
+       '[ '[ failure set _ continue ] callcc0\r
+          _ failure set @ ] callcc0 ] ;\r
 \r
 : number-from ( from -- from+n )\r
     [ 1 + number-from ] checkpoint ;\r
@@ -42,7 +42,7 @@ MACRO: unsafe-amb ( seq -- quot )
     dup length 1 =\r
     [ first 1quotation ]\r
     [ [ first ] [ rest ] bi\r
-      '[ , [ drop , unsafe-amb ] checkpoint ] ] if ;\r
+      '[ _ [ drop _ unsafe-amb ] checkpoint ] ] if ;\r
 \r
 PRIVATE> \r
 \r
@@ -55,7 +55,7 @@ PRIVATE>
 \r
 MACRO: amb-execute ( seq -- quot )\r
     [ length 1 - ] [ <enum> [ 1quotation ] assoc-map ] bi\r
-    '[ , 0 unsafe-number-from-to nip , case ] ;\r
+    '[ _ 0 unsafe-number-from-to nip _ case ] ;\r
 \r
 : if-amb ( true false -- )\r
     [\r
index 2aa31f1e85d3b0a665464ab8baafd183387c9f23..5014d530195780d9da4823f7aeb467fabe4c9cb9 100644 (file)
@@ -1,4 +1,5 @@
-USING: accessors arrays bank calendar kernel math math.functions namespaces tools.test tools.walker ;
+USING: accessors arrays bank calendar kernel math math.functions
+namespaces make tools.test tools.walker ;
 IN: bank.tests
 
 SYMBOL: my-account
index 7145cd94f7a60facef902fe6fae943a4daa37d9d..93b42c3e6c9091ba5072e0d8f4115162f124d487 100644 (file)
@@ -1,4 +1,4 @@
-USING: namespaces math sequences splitting grouping
+USING: make math sequences splitting grouping
 kernel columns float-arrays bit-arrays ;
 IN: benchmark.dispatch2
 
index d7809809413724ed3b54f7ff2f1517e1b2b7c81c..aa3d11e2fb7c3e6553fa60619deead02d68e0616 100644 (file)
@@ -1,5 +1,5 @@
 USING: sequences math mirrors splitting grouping
-kernel namespaces assocs alien.syntax columns
+kernel make assocs alien.syntax columns
 float-arrays bit-arrays ;
 IN: benchmark.dispatch3
 
index e87765499b629a662b46f27aeb6487d4be78e821..31df9e4e700baf4be3cc3b286e1a0491dd2d1433 100755 (executable)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays io kernel math math.functions math.order
-math.parser sequences byte-arrays byte-vectors io.files
-io.encodings.binary fry namespaces benchmark.mandel.params
+USING: arrays io kernel namespaces math math.functions
+math.order math.parser sequences byte-arrays byte-vectors
+io.files io.encodings.binary fry make benchmark.mandel.params
 benchmark.mandel.colors ;
 IN: benchmark.mandel
 
@@ -19,13 +19,13 @@ IN: benchmark.mandel
 
 : pixel ( c -- iterations )
     [ C{ 0.0 0.0 } max-iterations ] dip
-    '[ sq , + ] [ absq 4.0 >= ] count-iterations ; inline
+    '[ sq _ + ] [ absq 4.0 >= ] count-iterations ; inline
 
 : color ( iterations -- color )
     [ color-map [ length mod ] keep nth ] [ B{ 0 0 0 } ] if* ; inline
 
 : render ( -- )
-    height [ width swap '[ , c pixel color % ] each ] each ; inline
+    height [ width swap '[ _ c pixel color % ] each ] each ; inline
 
 : ppm-header ( -- )
     "P6\n" % width # " " % height # "\n255\n" % ; inline
index 4970b018daa7777de08ea1b7a9239fe800c72e12..ddb70972b9df1757d47e6abdd71c9475a167c801 100644 (file)
@@ -1,6 +1,6 @@
 IN: benchmark.nsieve-bits
 USING: math math.parser sequences sequences.private kernel
-bit-arrays namespaces io ;
+bit-arrays make io ;
 
 : clear-flags ( step i seq -- )
     2dup length >= [
index dd4696232255372f62771c24a65e0f3d9eadf425..76d991f7347f387d1192748b06a2e53222301cdc 100644 (file)
@@ -1,6 +1,6 @@
 IN: benchmark.nsieve
 USING: math math.parser sequences sequences.private kernel
-arrays namespaces io ;
+arrays make io ;
 
 : clear-flags ( step i seq -- )
     2dup length >= [
index d22f339ed4151c2f7f9673971d1be6607fc9e810..69454505a5ca5a282c73fce0b6863bac0071619f 100755 (executable)
@@ -3,7 +3,7 @@
 
 USING: arrays accessors float-arrays io io.files
 io.encodings.binary kernel math math.functions math.vectors
-math.parser namespaces sequences sequences.private words ;
+math.parser make sequences sequences.private words ;
 IN: benchmark.raytracer
 
 ! parameters
index 76e8d7883d4180deec732a69fb8db32b4555acb1..5eb41cd94389b62dd3356f3a8b2c6d18a3c5fa26 100755 (executable)
@@ -1,6 +1,6 @@
-USING: parser lexer kernel math sequences namespaces assocs summary
-words splitting math.parser arrays sequences.next mirrors
-generalizations compiler.units ;
+USING: parser lexer kernel math sequences namespaces make assocs
+summary words splitting math.parser arrays sequences.next
+mirrors generalizations compiler.units ;
 IN: bitfields
 
 ! Example:
index 32a27f82fdeb9705ee2e342341e2048e0fd56f11..19d3936fd9e0e5048c426ec9702373c4687df8a1 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel namespaces sequences arrays io io.files
+USING: kernel namespaces make sequences arrays io io.files
        builder.util
        builder.common
        builder.release.archive ;
index 121c835105ba959ebe9c831509515c0dc43fd3c5..99d5dbbc48201ccd26f947541c2eb4efda65c9f9 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel alien.c-types combinators namespaces arrays
+USING: kernel alien.c-types combinators namespaces make arrays
        sequences sequences.lib namespaces.lib splitting
        math math.functions math.vectors math.trig
        opengl.gl opengl.glu opengl ui ui.gadgets.slate
index f5aeeff61916f9098696863c1c9c1d1136c67090..e57116a25b7ad1a6bc5c9f6adf8796eacc57d157 100755 (executable)
@@ -21,7 +21,7 @@ MACRO: ncleave ( seq n -- quot ) [ncleave] ;
 ! Cleave into array
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-: [narr] ( seq n -- quot ) over length '[ , , ncleave , narray ] ;
+: [narr] ( seq n -- quot ) over length '[ _ _ ncleave _ narray ] ;
 
 MACRO: narr ( seq n -- array ) [narr] ;
 
@@ -34,11 +34,11 @@ MACRO: 3arr ( seq -- array ) 3 [narr] ;
 
 MACRO: <arr> ( seq -- )
   [ >quots ] [ length ] bi
- '[ , cleave , narray ] ;
+ '[ _ cleave _ narray ] ;
 
 MACRO: <2arr> ( seq -- )
   [ >quots ] [ length ] bi
- '[ , 2cleave , narray ] ;
+ '[ _ 2cleave _ narray ] ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -58,7 +58,7 @@ MACRO: <2arr> ( seq -- )
 
 MACRO: <arr*> ( seq -- )
   [ >quots ] [ length ] bi
- '[ , spread , narray ] ;
+ '[ _ spread _ narray ] ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
index cb27ef3f55b11bb0553d28f3b29de5a7038d2bfb..3c9d6d24368ca455e7538af31eb800fbd8666566 100644 (file)
@@ -5,7 +5,7 @@ IN: combinators.conditional
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-MACRO: 1if ( test then else -- ) '[ dup @ , , if ] ;
+MACRO: 1if ( test then else -- ) '[ dup @ _ _ if ] ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
index b2577e663685112ac00edb9d3341d9d94b80d722..dd8fbd89f57b220c24930a11b501e8ae05211245 100755 (executable)
@@ -2,7 +2,7 @@
 !                          Doug Coleman, Eduardo Cavazos,
 !                          Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel combinators fry namespaces quotations hashtables
+USING: kernel combinators fry namespaces make quotations hashtables
 sequences assocs arrays stack-checker effects math math.ranges
 generalizations macros continuations random locals accessors ;
 
@@ -65,10 +65,10 @@ IN: combinators.lib
 MACRO: preserving ( predicate -- quot )
     dup infer in>>
     dup 1+
-    '[ , , nkeep , nrot ] ;
+    '[ _ _ nkeep _ nrot ] ;
 
 MACRO: ifte ( quot quot quot -- )
-    '[ , preserving , , if ] ;
+    '[ _ preserving _ _ if ] ;
 
 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ! switch
index 3c1f8490c4d41b534c7d76453b0da6b007ebb9d8..dc594abd2d5330858f52f918c40dda3758eba5e3 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005 Chris Double, 2007 Clemens Hofreither.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel hashtables namespaces continuations quotations
+USING: kernel hashtables namespaces make continuations quotations
 accessors ;
 IN: coroutines
 
index e8c5608375cb9e569658ce1c5f64399a429c3513..38160de0e9cf7780711dcf145c645ba7cf34d48b 100644 (file)
@@ -6,7 +6,7 @@
 
 USING: arrays kernel sequences io io.files io.backend
 io.encodings.ascii math.parser vocabs definitions
-namespaces words sorting ;
+namespaces make words sorting ;
 IN: ctags
 
 : ctag-word ( ctag -- word )
index 8cc8c284b101eeee59c92843ad0e977bc447e34c..9fe63e914e6bf65f6c4a013b63f02a34c746eab1 100644 (file)
@@ -4,8 +4,8 @@
 ! Emacs Etags generator
 ! Alfredo Beaumont <alfredo.beaumont@gmail.com>
 USING: kernel sequences sorting assocs words prettyprint ctags
-io.encodings.ascii io.files math math.parser namespaces strings locals
-shuffle io.backend arrays ;
+io.encodings.ascii io.files math math.parser namespaces make
+strings shuffle io.backend arrays ;
 IN: ctags.etags
 
 : etag-at ( key hash -- vector )
index 40149bafa992874a24b8f923a8d2da4fb7ebe9fe..b411df1e3072baa12d74db4511327ec4516ceb15 100644 (file)
@@ -10,7 +10,7 @@ IN: demos
 : demo-vocabs ( -- seq ) "demos" tagged [ second ] map concat [ name>> ] map ;
 
 : <run-vocab-button> ( vocab-name -- button )
-  dup '[ drop [ , run ] call-listener ] <bevel-button> { 0 0 } >>align ;
+  dup '[ drop [ _ run ] call-listener ] <bevel-button> { 0 0 } >>align ;
 
 : <demo-runner> ( -- gadget )
   <pile> 1 >>fill demo-vocabs [ <run-vocab-button> add-gadget ] each ;
index 8da252f294576dca2b0cbfd1dbb8c5e51789d5ae..98af43fec867a2404f5b2cf6e281f5e667d2eb34 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel namespaces sequences math
-       listener io prettyprint sequences.lib fry ;
+       listener io prettyprint sequences.lib bake bake.fry ;
 
 IN: display-stack
 
index 16677d87613f49eee4d587f7cfb3eae3b0c47bf7..ad16db7b4157a55e40def0551110bdab5bcde1b3 100644 (file)
@@ -2,7 +2,7 @@
 USING: kernel combinators sequences sets math threads namespaces continuations
        debugger io io.sockets unicode.case accessors destructors
        combinators.cleave combinators.lib combinators.short-circuit 
-       newfx fry
+       newfx bake bake.fry
        dns dns.util dns.misc ;
 
 IN: dns.server
index 35af74b92acb2e0f4d9c449c0dfca926f6f22912..96cf6c0a1ee7aab54d8bb441de3ae5bf27ce3b2b 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel sequences sorting math math.order macros fry ;
+USING: kernel sequences sorting math math.order macros bake bake.fry ;
 
 IN: dns.util
 
index 525cef68edd3492bdf4d9f40ec22d3c4c23ca517..1ab348e434605ea0be43999a788fc2da58288d7e 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: xml kernel sequences xml.utilities combinators.lib
 math xml.data arrays assocs xml.generator xml.writer namespaces
-math.parser io accessors ;
+make math.parser io accessors ;
 IN: faq
 
 : find-after ( seq quot -- elem after )
index ac3b447f1c13d68d04aeba470f4a4e38a766abf9..c308c94054db8b7860f73a5806a1c3587b71041e 100755 (executable)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2006 Chris Double. All Rights Reserved.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel peg strings sequences math
-math.parser namespaces words quotations arrays hashtables io
+USING: accessors kernel peg strings sequences math math.parser
+namespaces make words quotations arrays hashtables io
 io.streams.string assocs ascii peg.parsers accessors ;
 IN: fjsc
 
index 642d2ce8cd7701661d5e9bd8d197aff5c2a9a97e..9b9a2214c168da7671a88d7ac2c0798326e95fc7 100644 (file)
@@ -154,7 +154,7 @@ GENERIC: ftp-download ( path obj -- )
 
 : with-ftp-client ( ftp-client quot -- )
     dupd '[
-        , [ ftp-login ] [ @ ] bi
+        _ [ ftp-login ] [ @ ] bi
         ftp-quit drop
     ] >r ftp-connect r> with-stream ; inline
 
index 21a32d1776d7d90bf69ab29ee6de3d58a8338194..3ecf8d2f3fede0c8c7d112dfa5f533051acdf39a 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.short-circuit accessors combinators io io.encodings.8-bit
-io.encodings io.encodings.binary io.encodings.utf8 io.files
-io.sockets kernel math.parser namespaces sequences
-ftp io.unix.launcher.parser unicode.case splitting assocs
-classes io.servers.connection destructors calendar io.timeouts
-io.streams.duplex threads continuations math
-concurrency.promises byte-arrays ;
+USING: combinators.short-circuit accessors combinators io
+io.encodings.8-bit io.encodings io.encodings.binary
+io.encodings.utf8 io.files io.sockets kernel math.parser
+namespaces make sequences ftp io.unix.launcher.parser
+unicode.case splitting assocs classes io.servers.connection
+destructors calendar io.timeouts io.streams.duplex threads
+continuations math concurrency.promises byte-arrays ;
 IN: ftp.server
 
 SYMBOL: client
index 322f17d2dd07ef35a986bcaa726915c556ab1f69..842f4d1f388e85cda8817aadf8eafce0d319c5cc 100644 (file)
@@ -35,10 +35,10 @@ M: graph num-vertices
     vertices length ;
 
 M: graph num-edges
-   [ vertices ] [ '[ , adjlist length ] map sum ] bi ;
+   [ vertices ] [ '[ _ adjlist length ] map sum ] bi ;
 
 M: graph adjlist
-    [ vertices ] [ swapd '[ , swap , adj? ] filter ] bi ;
+    [ vertices ] [ swapd '[ _ swap _ adj? ] filter ] bi ;
 
 M: graph adj?
     swapd adjlist index >boolean ;
@@ -50,11 +50,11 @@ M: graph delete-edge
     [ delete-edge* ] [ swapd delete-edge* ] 3bi ;
 
 : add-blank-vertices ( seq graph -- )
-    '[ , add-blank-vertex ] each ;
+    '[ _ add-blank-vertex ] each ;
 
 : delete-vertex ( index graph -- )
     [ adjlist ]
-    [ '[ , , 3dup adj? [ delete-edge* ] [ 3drop ] if ] each ]
+    [ '[ _ _ 3dup adj? [ delete-edge* ] [ 3drop ] if ] each ]
     [ delete-blank-vertex ] 2tri ;
 
 <PRIVATE
@@ -67,22 +67,22 @@ M: graph delete-edge
     { [ 2drop visited? get t -rot set-at ] 
       [ drop call ]
       [ [ graph get adjlist ] 2dip
-        '[ dup visited? get at [ drop ] [ , , (depth-first) ] if ] each ]
+        '[ dup visited? get at [ drop ] [ _ _ (depth-first) ] if ] each ]
       [ nip call ] } 3cleave ; inline
 
 PRIVATE>
 
 : depth-first ( v graph pre post -- ?list ? )
-    '[ , , (depth-first) visited? get ] swap search-wrap ; inline
+    '[ _ _ (depth-first) visited? get ] swap search-wrap ; inline
 
 : full-depth-first ( graph pre post tail -- ? )
     '[ [ visited? get [ nip not ] assoc-find ] 
-       [ drop , , (depth-first) @ ] 
+       [ drop _ _ (depth-first) @ ] 
        [ 2drop ] while ] swap search-wrap ; inline
 
 : dag? ( graph -- ? )
     V{ } clone swap [ 2dup swap push dupd
-                     '[ , swap graph get adj? not ] all? 
+                     '[ _ swap graph get adj? not ] all? 
                       [ end-search ] unless ]
                     [ drop dup pop* ] [ ] full-depth-first nip ;
 
index 33c5505f0a89c24cd1f00e1870b183c92a249f78..5c6365b563944ba8a67d030425425fdec974cc91 100644 (file)
@@ -12,7 +12,7 @@ TUPLE: sparse-graph alist ;
 
 : >sparse-graph ( graph -- sparse-graph )
     [ vertices ] keep
-    '[ dup , adjlist 2array ] map >hashtable sparse-graph boa ;
+    '[ dup _ adjlist 2array ] map >hashtable sparse-graph boa ;
 
 INSTANCE: sparse-graph graph
 
index 29ccc345d3ed763a01a4a837d2765cc30c2a1edd..b82b5662dc0a28adb3227338883d20983af48630 100755 (executable)
@@ -1,6 +1,7 @@
 USING: assocs html.parser kernel math sequences strings ascii
-arrays generalizations shuffle unicode.case namespaces splitting
-http sequences.lib accessors io combinators http.client urls ;
+arrays generalizations shuffle unicode.case namespaces make
+splitting http sequences.lib accessors io combinators
+http.client urls ;
 IN: html.parser.analyzer
 
 TUPLE: link attributes clickable ;
index ccd225e6e0b9341eaf8aeb911bb2f2eba03e2992..95bfa938a25b717fe1d595782a5007fd63f4c76a 100644 (file)
@@ -1,6 +1,6 @@
 USING: accessors arrays html.parser.utils hashtables io kernel
-namespaces prettyprint quotations
-sequences splitting state-parser strings unicode.categories unicode.case
+namespaces make prettyprint quotations sequences splitting
+state-parser strings unicode.categories unicode.case
 sequences.lib ;
 IN: html.parser
 
index b843c73983d6adafb616fef992dee8bc98ec9a7f..7f55b609e358eac1f36f9459ab7296856afa8d8e 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel words summary slots quotations
 sequences assocs math arrays stack-checker effects generalizations
-continuations debugger classes.tuple namespaces vectors
+continuations debugger classes.tuple namespaces make vectors
 bit-arrays byte-arrays strings sbufs math.functions macros
 sequences.private combinators mirrors
 combinators.short-circuit ;
index 575c26972f39c8ec9661fa2b2a371d702fd9882a..2474fd643ac68fb7cdf93465bd746c02692c9074 100644 (file)
@@ -334,7 +334,7 @@ DEFER: (connect-irc)
 
 : set+run-listener ( name irc-listener -- )
     over irc> listeners>> set-at
-    '[ , listener-loop ] "listener" spawn-irc-loop ;
+    '[ _ listener-loop ] "listener" spawn-irc-loop ;
 
 GENERIC: (add-listener) ( irc-listener -- )
 
@@ -342,7 +342,7 @@ M: irc-channel-listener (add-listener) ( irc-channel-listener -- )
     [ [ name>> ] [ password>> ] bi /JOIN ]
     [ [ [ drop irc> join-messages>> ]
         [ timeout>> ]
-        [ name>> '[ trailing>> , = ] ]
+        [ name>> '[ trailing>> _ = ] ]
         tri mailbox-get-timeout? trailing>> ] keep set+run-listener
     ] bi ;
 
@@ -382,10 +382,10 @@ PRIVATE>
       spawn-irc ] with-irc-client ;
 
 : add-listener ( irc-listener irc-client -- )
-    swap '[ , (add-listener) ] with-irc-client ;
+    swap '[ _ (add-listener) ] with-irc-client ;
 
 : remove-listener ( irc-listener irc-client -- )
-    swap '[ , (remove-listener) ] with-irc-client ;
+    swap '[ _ (remove-listener) ] with-irc-client ;
 
 : write-message ( message irc-listener -- ) out-messages>> mailbox-put ;
 : read-message ( irc-listener -- message ) in-messages>> mailbox-get ;
index d3eca92f156b5fc2b1a8f7f61c2ff92713275d23..16066199edef33ea6eb32ff75740d5f1c37d7437 100755 (executable)
@@ -77,7 +77,7 @@ M: irc-message irc-message>server-line ( irc-message -- string )
 ! ======================================
 
 : split-at-first ( seq separators -- before after )
-    dupd '[ , member? ] find
+    dupd '[ _ member? ] find
         [ cut 1 tail ]
         [ swap ]
     if ;
@@ -127,4 +127,4 @@ M: sender-in-prefix irc-message-sender ( sender-in-prefix -- sender )
     } case
     [ [ tuple-slots ] [ parameters>> ] bi append ] dip
     [ all-slots over [ length ] bi@ min head >quotation ] keep
-    '[ @ , boa ] call ;
+    '[ @ _ boa ] call ;
index 457a98482056a513f25dc0b4ae771d26507302bb..1e4bcf35f81911e238b5689518b7dd5ad964f09a 100755 (executable)
@@ -140,17 +140,17 @@ M: object time-happened drop now ;
 GENERIC: handle-inbox ( tab message -- )\r
 \r
 : value-labels ( assoc val -- seq )\r
-    '[ nip , = ] assoc-filter keys sort-strings [ <label> ] map ;\r
+    '[ nip _ = ] assoc-filter keys sort-strings [ <label> ] map ;\r
 \r
 : add-gadget-color ( pack seq color -- pack )\r
-    '[ , >>color add-gadget ] each ;\r
+    '[ _ >>color add-gadget ] each ;\r
 \r
 M: object handle-inbox\r
     nip print-irc ;\r
 \r
 : display ( stream tab -- )\r
-    '[ , [ [ t ]\r
-           [ , dup listener>> read-message handle-inbox ]\r
+    '[ _ [ [ t ]\r
+           [ _ dup listener>> read-message handle-inbox ]\r
            [  ] while ] with-output-stream ] "ircv" spawn drop ;\r
 \r
 : <irc-pane> ( tab -- tab pane )\r
@@ -168,7 +168,7 @@ TUPLE: irc-editor < editor outstream tab ;
       [ [ irc-tab? ] find-parent ]\r
       [ editor-string ]\r
       [ "" swap set-editor-string ] } cleave\r
-     '[ , irc-tab set , parse-message ] with-output-stream ;\r
+     '[ _ irc-tab set _ parse-message ] with-output-stream ;\r
 \r
 irc-editor "general" f {\r
     { T{ key-down f f "RET" } editor-send }\r
index b5289dbcbf9f8597182870f709c79636c0f03ad0..6a0b9f728f2b7d905c533c09d9bf6a3433a0d54c 100755 (executable)
@@ -125,7 +125,7 @@ TUPLE: joystick-demo-gadget < pack axis raxis controller buttons alarm ;
     [ (update-axes) ] [ kill-update-axes ] if* ;
 
 M: joystick-demo-gadget graft*
-    dup '[ , update-axes ] FREQUENCY every >>alarm
+    dup '[ _ update-axes ] FREQUENCY every >>alarm
     drop ;
 
 M: joystick-demo-gadget ungraft*
index e14a46a967cb4a51bd6058bee593ab11ebd3cf32..0865b0ada2feb696db288220b96a755a365a1e97 100755 (executable)
@@ -162,7 +162,7 @@ M: key-caps-gadget pref-dim* drop KEYBOARD-SIZE ;
     relayout-1 ;
 
 M: key-caps-gadget graft*
-    dup '[ , update-key-caps-state ] FREQUENCY every >>alarm
+    dup '[ _ update-key-caps-state ] FREQUENCY every >>alarm
     drop ;
 
 M: key-caps-gadget ungraft*
index e004af865592e298635e93ccfdeedaaed41bbc63..2866e63c69736688fe773f5c062968e115026bcb 100644 (file)
@@ -21,16 +21,16 @@ DEFER: define-lisp-macro
 
 : convert-cond ( cons -- quot )
     cdr [ 2car [ convert-form ] bi@ 2array ]
-    { } lmap-as '[ , cond ] ;
+    { } lmap-as '[ _ cond ] ;
 
 : convert-general-form ( cons -- quot )
-    uncons [ convert-body ] [ convert-form ] bi* '[ , @ funcall ] ;
+    uncons [ convert-body ] [ convert-form ] bi* '[ _ @ funcall ] ;
 
 ! words for convert-lambda
 <PRIVATE
 : localize-body ( assoc body -- newbody )
     {
-      { [ dup list? ] [ [ lisp-symbol? ] rot '[ [ name>> , at ] [ ] bi or ] traverse ] }
+      { [ dup list? ] [ [ lisp-symbol? ] rot '[ [ name>> _ at ] [ ] bi or ] traverse ] }
       { [ dup lisp-symbol? ] [ name>> swap at ] }
      [ nip ]
     } cond ;
@@ -46,7 +46,7 @@ DEFER: define-lisp-macro
 : rest-lambda ( body vars -- quot )
     "&rest" swap [ remove ] [ index ] 2bi
     [ localize-lambda <lambda> lambda-rewrite call ] dip
-    swap '[ , cut '[ @ , seq>list ] call , call call ] 1quotation ;
+    swap '[ _ cut '[ @ _ seq>list ] call _ call call ] 1quotation ;
 
 : normal-lambda ( body vars -- quot )
     localize-lambda <lambda> lambda-rewrite '[ @ compose call call ] 1quotation ;
@@ -74,7 +74,7 @@ PRIVATE>
 
 : convert-begin ( cons -- quot )
     cdr [ convert-form ] [ ] lmap-as [ 1 tail* ] [ but-last ] bi
-    [ '[ { } , with-datastack drop ] ] map prepend '[ , [ call ] each ] ;
+    [ '[ { } _ with-datastack drop ] ] map prepend '[ _ [ call ] each ] ;
 
 : form-dispatch ( cons lisp-symbol -- quot )
     name>>
@@ -97,7 +97,7 @@ PRIVATE>
     {
       { [ dup cons? ] [ convert-list-form ] }
       { [ dup lisp-var? ] [ lookup-var 1quotation ] }
-      { [ dup lisp-symbol? ] [ '[ , lookup-var ] ] }
+      { [ dup lisp-symbol? ] [ '[ _ lookup-var ] ] }
      [ 1quotation ]
     } cond ;
 
@@ -138,7 +138,7 @@ M: no-such-var summary drop "No such variable" ;
     [ 1array [ call ] with-datastack >quotation ] dip curry call ; inline
 
 : define-primitive ( name vocab word -- )
-    swap lookup 1quotation '[ , compose call ] swap lisp-define ;
+    swap lookup 1quotation '[ _ compose call ] swap lisp-define ;
 
 : lookup-macro ( lisp-symbol -- lambda )
     name>> macro-env get at ;
index 5854e37702b770d429fa6fbfea3cc16b43ec4c1a..e60fcbaadff8ff988f97f9808435a8e40f5d742c 100644 (file)
@@ -5,7 +5,7 @@
 ! Updated by Chris Double, September 2006
 ! Updated by James Cash, June 2008
 !
-USING: kernel sequences math vectors arrays namespaces
+USING: kernel sequences math vectors arrays namespaces make
 quotations promises combinators io lists accessors ;
 IN: lists.lazy
 
index 87bc6437c31713c1fca027701dc8ceef32159ec9..a135f08f28d3136961c2af375cac3d90e1e6e640 100755 (executable)
@@ -62,7 +62,7 @@ METHOD: (blas-vector-like) { object object object double-complex-blas-vector }
     1 ;
 
 MACRO: (do-copy) ( copy make-vector -- )
-    '[ over 6 npick , 2dip 1 @ ] ;
+    '[ over 6 npick _ 2dip 1 @ ] ;
 
 : (prepare-swap) ( v1 v2 -- length v1-data v1-inc v2-data v2-inc v1 v2 )
     [
@@ -105,7 +105,7 @@ MACRO: (do-copy) ( copy make-vector -- )
 MACRO: (complex-nth) ( nth-quot -- )
     '[ 
         [ 2 * dup 1+ ] dip
-        , curry bi@ rect>
+        _ curry bi@ rect>
     ] ;
 
 : (c-complex-nth) ( n alien -- complex )
@@ -120,7 +120,7 @@ MACRO: (set-complex-nth) ( set-nth-quot -- )
             [ 2 * dup 1+ ] bi*
             swapd
         ] dip
-        , curry 2bi@ 
+        _ curry 2bi@ 
     ] ;
 
 : (set-c-complex-nth) ( complex n alien -- )
index 6193edfb915d7cae6171e2a65682933c02804933..7c5d5ba4c04515a5605e23e8b4b12f267dd48244 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2007, 2008 Slava Pestov, Doug Coleman, Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs kernel math math.order math.ranges mirrors
-namespaces sequences sequences.lib sorting ;
+namespaces make sequences sequences.lib sorting ;
 IN: math.combinatorics
 
 <PRIVATE
index 163fc40c465c3d7fb51f69711daf933d3f3b1098..798d3a5e7154ee0fe81eaa4e35e11a4ba117b630 100644 (file)
@@ -1,4 +1,4 @@
-USING: arrays kernel sequences namespaces math math.ranges
+USING: arrays kernel sequences namespaces make math math.ranges
 math.vectors vectors ;
 IN: math.numerical-integration
 
index 018b041afd493be3c12987584a8ff54d477d2845..8662bbb0895725d69e7de8784daee3739103835c 100644 (file)
@@ -1,5 +1,5 @@
-USING: arrays kernel sequences vectors math math.vectors namespaces
-shuffle splitting sequences.lib math.order ;
+USING: arrays kernel sequences vectors math math.vectors
+namespaces make shuffle splitting sequences.lib math.order ;
 IN: math.polynomials
 
 ! Polynomials are vectors with the highest powers on the right:
index 83d53c42153a59040665e4bb903881eeef9369c8..059bd67c188466d43079f278226879f7375d9a17 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2007 Samuel Tardieu.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel lists math math.primes namespaces sequences ;
+USING: arrays kernel lists math math.primes namespaces make
+sequences ;
 IN: math.primes.factors
 
 <PRIVATE
index e110cb38d3397690b146bffe1cbc98412998df18..e9ae1675323d53170bb47ccdd76739088b60c76e 100644 (file)
@@ -22,7 +22,7 @@ M: monad return monad-of return ;
 M: monad fail   monad-of fail   ;
 
 : bind ( mvalue quot -- mvalue' ) swap >>= call ;
-: >>   ( mvalue k -- mvalue' ) '[ drop , ] bind ;
+: >>   ( mvalue k -- mvalue' ) '[ drop _ ] bind ;
 
 :: lift-m2 ( m1 m2 f monad -- m3 )
     m1 [| x1 | m2 [| x2 | x1 x2 f monad return ] bind ] bind ;
@@ -34,7 +34,7 @@ M: monad fail   monad-of fail   ;
         ] bind
     ] bind ;
 
-M: monad fmap over '[ @ , return ] bind ;
+M: monad fmap over '[ @ _ return ] bind ;
 
 ! 'do' notation
 : do ( quots -- result ) unclip dip [ bind ] each ;
@@ -51,7 +51,7 @@ M: identity monad-of drop identity-monad ;
 M: identity-monad return drop identity boa ;
 M: identity-monad fail   "Fail" throw ;
 
-M: identity >>= value>> '[ , _ call ] ;
+M: identity >>= value>> '[ _ swap call ] ;
 
 : run-identity ( identity -- value ) value>> ;
 
@@ -72,8 +72,8 @@ M: maybe monad-of drop maybe-monad ;
 M: maybe-monad return drop just ;
 M: maybe-monad fail   2drop nothing ;
 
-M: nothing >>= '[ drop , ] ;
-M: just    >>= value>> '[ , _ call ] ;
+M: nothing >>= '[ drop _ ] ;
+M: just    >>= value>> '[ _ swap call ] ;
 
 : if-maybe ( maybe just-quot nothing-quot -- )
     pick nothing? [ 2nip call ] [ drop [ value>> ] dip call ] if ; inline
@@ -96,8 +96,8 @@ M: either monad-of drop either-monad ;
 M: either-monad return  drop right ;
 M: either-monad fail    drop left ;
 
-M: left  >>= '[ drop , ] ;
-M: right >>= value>> '[ , _ call ] ;
+M: left  >>= '[ drop _ ] ;
+M: right >>= value>> '[ _ swap call ] ;
 
 : if-either ( value left-quot right-quot -- )
     [ [ value>> ] [ left? ] bi ] 2dip if ; inline
@@ -112,7 +112,7 @@ M: array-monad fail   2drop { } ;
 
 M: array monad-of drop array-monad ;
 
-M: array >>= '[ , _ map concat ] ;
+M: array >>= '[ _ swap map concat ] ;
 
 ! List
 SINGLETON: list-monad
@@ -124,7 +124,7 @@ M: list-monad fail   2drop nil ;
 
 M: list monad-of drop list-monad ;
 
-M: list >>= '[ , _ lazy-map lconcat ] ;
+M: list >>= '[ _ swap lazy-map lconcat ] ;
 
 ! State
 SINGLETON: state-monad
@@ -137,15 +137,15 @@ INSTANCE: state monad
 
 M: state monad-of drop state-monad ;
 
-M: state-monad return drop '[ , 2array ] state ;
+M: state-monad return drop '[ _ 2array ] state ;
 M: state-monad fail   "Fail" throw ;
 
 : mcall ( state -- ) quot>> call ;
 
-M: state >>= '[ , _ '[ , mcall first2 @ mcall ] state ] ;
+M: state >>= '[ _ swap '[ _ mcall first2 @ mcall ] state ] ;
 
 : get-st ( -- state ) [ dup 2array ] state ;
-: put-st ( value -- state ) '[ drop , f 2array ] state ;
+: put-st ( value -- state ) '[ drop _ f 2array ] state ;
 
 : run-st ( state initial -- ) swap mcall second ;
 
@@ -161,15 +161,15 @@ INSTANCE: reader monad
 
 M: reader monad-of drop reader-monad ;
 
-M: reader-monad return drop '[ drop , ] reader ;
+M: reader-monad return drop '[ drop _ ] reader ;
 M: reader-monad fail   "Fail" throw ;
 
-M: reader >>= '[ , _ '[ dup , mcall @ mcall ] reader ] ;
+M: reader >>= '[ _ swap '[ dup _ mcall @ mcall ] reader ] ;
 
 : run-reader ( reader env -- ) swap mcall ;
 
 : ask ( -- reader ) [ ] reader ;
-: local ( reader quot -- reader' ) swap '[ @ , mcall ] reader ;
+: local ( reader quot -- reader' ) swap '[ @ _ mcall ] reader ;
 
 ! Writer
 SINGLETON: writer-monad
@@ -185,7 +185,7 @@ M: writer-monad fail   "Fail" throw ;
 
 : run-writer ( writer -- value log ) [ value>> ] [ log>> ] bi ;
 
-M: writer >>= '[ , run-writer _ '[ @ run-writer ] dip append writer ] ;
+M: writer >>= '[ [ _ run-writer ] dip '[ @ run-writer ] dip append writer ] ;
 
 : pass ( writer -- writer' ) run-writer [ first2 ] dip swap call writer ;
 : listen ( writer -- writer' ) run-writer [ 2array ] keep writer ;
index fb743e15af24568ffc4fe9ee1b43175d85e57430..76bc2bae182de333ad6d1f1d3b2c4f4aa6b5b4d9 100644 (file)
@@ -1,5 +1,5 @@
 USING: io kernel math math.functions math.parser parser lexer
-namespaces sequences splitting grouping combinators
+namespaces make sequences splitting grouping combinators
 continuations sequences.lib ;
 IN: money
 
index 4cce93a5a12b88aabe671873520823eb3995a1c7..2951c96077e425f740ed534b84a95877d65099d8 100644 (file)
@@ -1,6 +1,8 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators hashtables kernel lists math namespaces openal parser-combinators promises sequences strings symbols synth synth.buffers unicode.case ;
+USING: accessors assocs combinators hashtables kernel lists math
+namespaces make openal parser-combinators promises sequences
+strings symbols synth synth.buffers unicode.case ;
 IN: morse
 
 <PRIVATE
index a8025828f1fb6d876d6809e701f09ee18ec9dbea..682abf3a5d0d9342c2415005f2dee93c6b7472f4 100755 (executable)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel math sequences vectors classes classes.algebra
-combinators arrays words assocs parser namespaces definitions
-prettyprint prettyprint.backend quotations generalizations
-debugger io compiler.units kernel.private effects accessors
-hashtables sorting shuffle math.order sets ;
+combinators arrays words assocs parser namespaces make
+definitions prettyprint prettyprint.backend quotations
+generalizations debugger io compiler.units kernel.private
+effects accessors hashtables sorting shuffle math.order sets ;
 IN: multi-methods
 
 ! PART I: Converting hook specializers
index faa6c4835470d5141d9b5009d23cb0d3939c0fed..267c7be312d6640e401a269758b3f183927f1614 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel alien alien.strings alien.syntax
-combinators alien.c-types strings sequences namespaces words
-math threads io.encodings.ascii ;
+combinators alien.c-types strings sequences namespaces make
+words math threads io.encodings.ascii ;
 IN: odbc
 
 << "odbc" "odbc32.dll" "stdcall" add-library >>
index 806935d5c9c9bc78197c7aaab124654b6caf7382..3972fea7b34487278825858afda8a55a35817a33 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Joe Groff.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces sequences splitting opengl.gl
+USING: kernel namespaces make sequences splitting opengl.gl
 continuations math.parser math arrays sets math.order ;
 IN: opengl.capabilities
 
index de720a229fa05d69b4d058c32c1e96c8c7e4171d..84d33bb77fdf960d15215143978c7f082e04dd6d 100644 (file)
@@ -1,5 +1,5 @@
 
-USING: kernel namespaces accessors
+USING: kernel namespaces make accessors
        math math.constants math.functions math.matrices math.vectors
        sequences splitting grouping self math.trig ;
 
index d58ccbd0f263a1067555bc9a5c12606b368f4164..b1a354cd4e902ece1b5463b7bc5ba1cb0e95c643 100755 (executable)
@@ -1,4 +1,5 @@
-USING: io io.streams.string kernel namespaces pack strings tools.test ;
+USING: io io.streams.string kernel namespaces make
+pack strings tools.test ;
 
 [ B{ 1 0 2 0 0 3 0 0 0 4 0 0 0 0 0 0 0 5 } ] [
     { 1 2 3 4 5 }
index a5d4b36c0b651cf17f926960a148e3c982749314..889eecb49a4deb30074b72bf272395936f6740d0 100755 (executable)
@@ -1,7 +1,7 @@
 USING: alien alien.c-types arrays assocs byte-arrays io
 io.binary io.streams.string kernel math math.parser namespaces
-parser prettyprint quotations sequences strings vectors words
-macros math.functions math.bitwise ;
+make parser prettyprint quotations sequences strings vectors
+words macros math.functions math.bitwise ;
 IN: pack
 
 SYMBOL: big-endian
index 07b92fa8fd175fba4110fc2c975803d57efbfb34..f351c989f071751d8ede61cf5e56f0c41f6517c1 100644 (file)
@@ -8,7 +8,7 @@ USING: kernel namespaces threads combinators sequences arrays
        combinators
        combinators.lib
        combinators.cleave
-       rewrite-closures fry accessors newfx
+       rewrite-closures bake bake.fry accessors newfx
        processing.gadget math.geometry.rect
        processing.shapes
        colors ;
index 690fed9012eba2be2142849ea91bbf6a6da9c4e1..c1a4a169189b0a0aa74cf893e233e433b289d0b8 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2007 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math math.functions namespaces sequences sorting ;
+USING: kernel math math.functions namespaces make sequences sorting ;
 IN: project-euler.009
 
 ! http://projecteuler.net/index.php?section=problems&id=9
index a55c3ac1242a849874dd9a801ee8e88361137a46..f4e549c7c046cb1b48b03d9f5b84d1919e5b360d 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2007 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces project-euler.common sequences
+USING: kernel namespaces make project-euler.common sequences
 splitting grouping ;
 IN: project-euler.011
 
index 4f17e855b77b5a7af888f42bcc707af2b32c69f1..fcbc956de8a305da43e270f9cd747f7748edc19c 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2007 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays combinators.lib combinators.short-circuit kernel math math.ranges
-    namespaces sequences sorting ;
+USING: arrays combinators.lib combinators.short-circuit kernel
+math math.ranges namespaces make sequences sorting ;
 IN: project-euler.014
 
 ! http://projecteuler.net/index.php?section=problems&id=14
index 4111fe80091555644b38941deaf45164624e83ed..da26e3492772b990e27993ea08f4b687ac111c4b 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: ascii io.files kernel math math.functions namespaces
+USING: ascii io.files kernel math math.functions namespaces make
     project-euler.common sequences sequences.lib splitting io.encodings.ascii ;
 IN: project-euler.042
 
index aa2cdb75b0000179ee876e71ee652a1e6cfdfd94..f209b50a467ca73ee83438e5460a5a4223ec66ab 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer, Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays ascii assocs hashtables io.encodings.ascii io.files kernel math
-    math.parser namespaces sequences sequences.lib sequences.private sorting
+    math.parser namespaces make sequences sequences.lib sequences.private sorting
     splitting grouping strings sets accessors ;
 IN: project-euler.059
 
index 1e6a2fb0b477be3526e97cb8b91db01f0dbd6295..99c70ba038e377e0522ed479691c68d4a26f74a9 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2008 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: assocs hashtables io.files kernel math math.parser namespaces
-io.encodings.ascii sequences sets ;
+USING: assocs hashtables io.files kernel math math.parser
+namespaces make io.encodings.ascii sequences sets ;
 IN: project-euler.079
 
 ! http://projecteuler.net/index.php?section=problems&id=79
index be39b26a97ea5f68857dfd710880b98442896fd5..df96d5e21105cede7807d470d2eb6bfbc097cb16 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (c) 2007 Aaron Schaefer.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: continuations io kernel math math.functions math.parser math.statistics
-    namespaces tools.time ;
+    namespaces make tools.time ;
 IN: project-euler.ave-time
 
 : collect-benchmarks ( quot n -- seq )
index 7963cde25497d0c2caed48612eb4b97d53f87d86..094893616b50386b83bc99f960a626fc95592b17 100644 (file)
@@ -1,6 +1,7 @@
-USING: arrays kernel math math.functions math.miller-rabin math.matrices
-    math.order math.parser math.primes.factors math.ranges namespaces
-    sequences sequences.lib sorting unicode.case ;
+USING: arrays kernel math math.functions math.miller-rabin
+math.matrices math.order math.parser math.primes.factors
+math.ranges namespaces make sequences sequences.lib sorting
+unicode.case ;
 IN: project-euler.common
 
 ! A collection of words used by more than one Project Euler solution
index 5d63406e78db4172cd592d08b2f81a6a9698d082..38366697eac977c1d71291968d5ab0d725164342 100755 (executable)
@@ -5,7 +5,7 @@
 ! Updated by Chris Double, September 2006
 
 USING: arrays kernel sequences math vectors arrays namespaces
-quotations parser effects stack-checker words accessors ;
+make quotations parser effects stack-checker words accessors ;
 IN: promises
 
 TUPLE: promise quot forced? value ;
index 3f7a5d09b58cc0590830c1b0d09a023d2ee63fbc..ce3bc311be3d0e06cbc449cfa77bd6f437fe42c8 100644 (file)
@@ -1,6 +1,6 @@
 
 USING: kernel namespaces arrays quotations sequences assocs combinators
-       mirrors math math.vectors random macros fry ;
+       mirrors math math.vectors random macros bake bake.fry ;
 
 IN: random-weighted
 
index cd2d0790abf3578f95d50c1618d5c64ef2c426ea..5ef3eacc6c19251e6a62f205adce9df468dbb3c6 100755 (executable)
@@ -2,8 +2,7 @@ USING: arrays combinators kernel lists math math.parser
 namespaces parser lexer parser-combinators parser-combinators.simple
 promises quotations sequences combinators.lib strings math.order
 assocs prettyprint.backend memoize unicode.case unicode.categories
-combinators.short-circuit accessors ;
-USE: io
+combinators.short-circuit accessors make io ;
 IN: regexp
 
 <PRIVATE
index 198e1744bca2cf4253d349fc3c51fec9c1f5d4d3..6d11c9d41c7ee4df3dbb18b60cf891b21df37c99 100644 (file)
@@ -1,5 +1,6 @@
 
-USING: kernel parser math quotations namespaces sequences macros fry ;
+USING: kernel parser math quotations namespaces sequences macros
+bake bake.fry ;
 
 IN: rewrite-closures
 
index aefe86328d174aadec413a0693ed84e40f672ee1..dcadb865f9687815626d0815c550062c15f8c189 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2007 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs kernel math math.order math.vectors namespaces
-quotations sequences sequences.lib sequences.private strings unicode.case ;
+USING: arrays assocs kernel math math.order math.vectors
+namespaces make quotations sequences sequences.lib
+sequences.private strings unicode.case ;
 IN: roman
 
 <PRIVATE
index 225b3b7d9ed84dc6fed4eb25245dacff2c9fc6f3..ba49b8ee9e3bb01be4225be34171e741e65e58e9 100755 (executable)
@@ -1,11 +1,10 @@
 ! Copyright (C) 2007 Slava Pestov, Chris Double, Doug Coleman,
 !                    Eduardo Cavazos, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators.lib kernel sequences math namespaces assocs 
-random sequences.private shuffle math.functions
-arrays math.parser math.private sorting strings ascii macros
-assocs.lib quotations hashtables math.order locals
-generalizations ;
+USING: combinators.lib kernel sequences math namespaces make
+assocs random sequences.private shuffle math.functions arrays
+math.parser math.private sorting strings ascii macros assocs.lib
+quotations hashtables math.order locals generalizations ;
 IN: sequences.lib
 
 : each-withn ( seq quot n -- ) nwith each ; inline
index 6a785e91b7a0fd7a61620debb1d3372092dc5dbb..37e12a6993eb67a8d96d3368c8ef2d2a6fcefb1c 100755 (executable)
@@ -1,4 +1,4 @@
-USING: kernel parser lexer strings math namespaces
+USING: kernel parser lexer strings math namespaces make
 sequences words io arrays quotations debugger accessors
 sequences.private ;
 IN: state-machine
index 9a04a5b74a05d738524433a10c96300793dab6d7..ecb258c1637376ae0d28157776f47b2218a7c941 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces sequences vectors assocs accessors ;
+USING: kernel namespaces make sequences vectors assocs accessors ;
 IN: state-tables
 
 TUPLE: table rows columns start-state final-states ;
index 3357c103ad8a84053e3c128bd31532c1419ed903..747cfb9c8647bf6fe73b071130ded44b10cdc859 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel namespaces openal sequences synth synth.buffers ;
+USING: accessors arrays kernel namespaces make openal sequences
+synth synth.buffers ;
 IN: synth.example
 
 : play-sine-wave ( freq seconds sample-freq -- )
index 50e2df2e9e3ec90696702325d026f6d672fa5af8..7e09d086c2154d1a27f17ffa89bc00484eacc8b4 100755 (executable)
@@ -14,7 +14,7 @@ DEFER: (del-page)
 \r
 :: add-toggle ( model n name toggler -- )\r
   <frame>\r
-    n name toggler parent>> '[ , , , (del-page) ] "X" swap <bevel-button>\r
+    n name toggler parent>> '[ _ _ _ (del-page) ] "X" swap <bevel-button>\r
       @right grid-add\r
     n model name <toggle-button> @center grid-add\r
   toggler swap add-gadget drop ;\r
@@ -23,7 +23,7 @@ DEFER: (del-page)
      [ names>> ] [ model>> ] [ toggler>> ] tri\r
      [ clear-gadget ] keep\r
      [ [ length ] keep ] 2dip\r
-    '[ , _ _ , add-toggle ] 2each ;\r
+     '[ [ _ ] 2dip _ add-toggle ] 2each ;\r
 \r
 : refresh-book ( tabbed -- )\r
     model>> [ ] change-model ;\r
index 2d096966af5b642ced4913bbee667c60e79f815e..cf6ea7f48e6d6612c2d47482e6ee36dc9b6f89f2 100644 (file)
@@ -1,7 +1,7 @@
 
 USING: kernel sequences math math.order
        ui.gadgets ui.gadgets.tracks ui.gestures
-       fry accessors ;
+       bake.fry accessors ;
 
 IN: ui.gadgets.tiling
 
@@ -93,7 +93,7 @@ TUPLE: tiling < track gadgets tiles first focused ;
 
 : exchanged! ( seq a b -- )
                    [ 0 max ] bi@
-  pick length 1 - '[ , min ] bi@
+  pick length 1 - '[ _ min ] bi@
   rot exchange ;
 
 : move-prev ( tiling -- tiling )
index a14d6d98235b1bfc212d872e1f76988dfd15597c..f3efb3868f2e231893e6f5a3273294b7b9944c68 100644 (file)
@@ -13,7 +13,7 @@ M: counter-app init-session* drop 0 count sset ;
 : <counter-action> ( quot -- action )
     <action>
         swap '[
-            count , schange
+            count _ schange
             URL" $counter-app" <redirect>
         ] >>submit ;
 
index 10e706598e08c2be776f9edcc4f014b38cee7587..721529de27b35224a5cf310a1ec6f35a902918b3 100755 (executable)
@@ -96,7 +96,7 @@ posting "POSTINGS"
 
 : fetch-blogroll ( blogroll -- entries )
     [ [ feed-url>> fetch-feed ] parallel-map ] [ [ name>> ] map ] bi
-    [ '[ , <posting> ] map ] 2map concat ;
+    [ '[ _ <posting> ] map ] 2map concat ;
 
 : sort-entries ( entries -- entries' )
     [ [ date>> ] compare invert-comparison ] sort ;
@@ -201,4 +201,4 @@ posting "POSTINGS"
         { planet "planet-common" } >>template ;
 
 : start-update-task ( db params -- )
-    '[ , , [ update-cached-postings ] with-db ] 10 minutes every drop ;
+    '[ _ _ [ update-cached-postings ] with-db ] 10 minutes every drop ;
index 27187c4352e30f638866921243d7a7bf1e013fcb..e4a4a6a853939457e5388783cd4be90b6174e332 100644 (file)
@@ -26,7 +26,7 @@ short-url "SHORT_URLS" {
     1 6 [a,b] random [ letter-bank random ] "" replicate-as ;
 
 : insert-short-url ( short-url -- short-url )
-    '[ , dup random-url >>short insert-tuple ] 10 retry ;
+    '[ _ dup random-url >>short insert-tuple ] 10 retry ;
 
 : shorten ( url -- short )
     short-url new swap >>url dup select-tuple
index 5f679be431047746be105fa0c0d66aea02f64938..9d1ad15aa4a0b592aee9b4d3394d4be92c8de51a 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel hashtables calendar random assocs
-namespaces splitting sequences sorting math.order present
+namespaces make splitting sequences sorting math.order present
 io.files io.encodings.ascii
 syndication farkup
 html.components html.forms
@@ -93,18 +93,12 @@ M: revision feed-entry-url id>> revision-url ;
     <article> select-tuple
     dup [ revision>> <revision> select-tuple ] when ;
 
-: init-relative-link-prefix ( -- )
-    URL" $wiki/view/" adjust-url present relative-link-prefix set ;
-
 : <view-article-action> ( -- action )
     <action>
 
         "title" >>rest
 
-        [
-            validate-title
-            init-relative-link-prefix
-        ] >>init
+        [ validate-title ] >>init
 
         [
             "title" value dup latest-revision [
@@ -126,7 +120,6 @@ M: revision feed-entry-url id>> revision-url ;
             validate-integer-id
             "id" value <revision>
             select-tuple from-object
-            init-relative-link-prefix
         ] >>init
 
         { wiki "view" } >>template
index e37f7d4c3ffe1776f675169427f647343618bb3e..a35358ae6b7166b67766578d5db40693799d6f45 100644 (file)
@@ -74,20 +74,24 @@ SYMBOL: dh-file
     "noreply@concatenative.org" lost-password-from set-global
     "website@concatenative.org" insomniac-sender set-global
     "slava@factorcode.org" insomniac-recipients set-global
-    <factor-website> main-responder set-global
     init-factor-db ;
 
 : init-testing ( -- )
     "resource:basis/openssl/test/dh1024.pem" dh-file set-global
     "resource:basis/openssl/test/server.pem" key-file set-global
     "password" key-password set-global
-    common-configuration ;
+    common-configuration
+    <factor-website> main-responder set-global ;
+
+: no-www-prefix ( -- responder )
+    "http://concatenative.org" <permanent-redirect> <trivial-responder> ;
 
 : init-production ( -- )
-    f dh-file set-global
-    f key-password set-global
-    "/home/slava/cert/host.pem" key-file set-global
-    common-configuration ;
+    common-configuration
+    <vhost-dispatcher>
+        <factor-website> "concatenative.org" add-responder
+        no-www-prefix "www.concatenative.org" add-responder
+    main-responder set-global ;
 
 : <factor-secure-config> ( -- config )
     <secure-config>
index 5dc65c661b708962ac11c631e3836055000f7045..ae3ce224149b93731209b794543368f2a9cab735 100644 (file)
@@ -1,4 +1,6 @@
-USING: kernel sequences namespaces math assocs words arrays tools.annotations vocabs sorting prettyprint io micros math.statistics accessors ;
+USING: kernel sequences namespaces make math assocs words arrays
+tools.annotations vocabs sorting prettyprint io micros
+math.statistics accessors ;
 IN: wordtimer
 
 SYMBOL: *wordtimes*
index 6b765461e579c2b33128e85823fe3e797993f292..91b31ec7e64641f5e30f39046b5d0cb069173329 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: lexer parser splitting kernel quotations namespaces
+USING: lexer parser splitting kernel quotations namespaces make
 sequences assocs sequences.lib xml.generator xml.utilities
 xml.data ;
 IN: xml.syntax
diff --git a/unfinished/compiler/alien/alien.factor b/unfinished/compiler/alien/alien.factor
new file mode 100644 (file)
index 0000000..1d63a06
--- /dev/null
@@ -0,0 +1,46 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel namespaces make math sequences layouts
+alien.c-types alien.structs compiler.backend ;
+IN: compiler.alien
+
+! Common utilities
+
+: large-struct? ( ctype -- ? )
+    dup c-struct? [
+        heap-size struct-small-enough? not
+    ] [ drop f ] if ;
+
+: alien-parameters ( params -- seq )
+    dup parameters>>
+    swap return>> large-struct? [ "void*" prefix ] when ;
+
+: alien-return ( params -- ctype )
+    return>> dup large-struct? [ drop "void" ] when ;
+
+: c-type-stack-align ( type -- align )
+    dup c-type-stack-align? [ c-type-align ] [ drop cell ] if ;
+
+: parameter-align ( n type -- n delta )
+    over >r c-type-stack-align align dup r> - ;
+
+: parameter-sizes ( types -- total offsets )
+    #! Compute stack frame locations.
+    [
+        0 [
+            [ parameter-align drop dup , ] keep stack-size +
+        ] reduce cell align
+    ] { } make ;
+
+: return-size ( ctype -- n )
+    #! Amount of space we reserve for a return value.
+    dup large-struct? [ heap-size ] [ drop 0 ] if ;
+
+: alien-stack-frame ( params -- n )
+    alien-parameters parameter-sizes drop ;
+    
+: alien-invoke-frame ( params -- n )
+    #! One cell is temporary storage, temp@
+    dup return>> return-size
+    swap alien-stack-frame +
+    cell + ;
diff --git a/unfinished/compiler/backend/alien/alien.factor b/unfinished/compiler/backend/alien/alien.factor
new file mode 100644 (file)
index 0000000..0c5a6af
--- /dev/null
@@ -0,0 +1,281 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+IN: compiler.backend.alien
+
+! #alien-invoke
+: set-stack-frame ( n -- )
+    dup [ frame-required ] when* \ stack-frame set ;
+
+: with-stack-frame ( n quot -- )
+    swap set-stack-frame
+    call
+    f set-stack-frame ; inline
+
+GENERIC: reg-size ( register-class -- n )
+
+M: int-regs reg-size drop cell ;
+
+M: single-float-regs reg-size drop 4 ;
+
+M: double-float-regs reg-size drop 8 ;
+
+GENERIC: reg-class-variable ( register-class -- symbol )
+
+M: reg-class reg-class-variable ;
+
+M: float-regs reg-class-variable drop float-regs ;
+
+GENERIC: inc-reg-class ( register-class -- )
+
+M: reg-class inc-reg-class
+    dup reg-class-variable inc
+    fp-shadows-int? [ reg-size stack-params +@ ] [ drop ] if ;
+
+M: float-regs inc-reg-class
+    dup call-next-method
+    fp-shadows-int? [ reg-size cell /i int-regs +@ ] [ drop ] if ;
+
+GENERIC: reg-class-full? ( class -- ? )
+
+M: stack-params reg-class-full? drop t ;
+
+M: object reg-class-full?
+    [ reg-class-variable get ] [ param-regs length ] bi >= ;
+
+: spill-param ( reg-class -- n reg-class )
+    stack-params get
+    >r reg-size stack-params +@ r>
+    stack-params ;
+
+: fastcall-param ( reg-class -- n reg-class )
+    [ reg-class-variable get ] [ inc-reg-class ] [ ] tri ;
+
+: alloc-parameter ( parameter -- reg reg-class )
+    c-type-reg-class dup reg-class-full?
+    [ spill-param ] [ fastcall-param ] if
+    [ param-reg ] keep ;
+
+: (flatten-int-type) ( size -- )
+    cell /i "void*" c-type <repetition> % ;
+
+GENERIC: flatten-value-type ( type -- )
+
+M: object flatten-value-type , ;
+
+M: struct-type flatten-value-type ( type -- )
+    stack-size cell align (flatten-int-type) ;
+
+M: long-long-type flatten-value-type ( type -- )
+    stack-size cell align (flatten-int-type) ;
+
+: flatten-value-types ( params -- params )
+    #! Convert value type structs to consecutive void*s.
+    [
+        0 [
+            c-type
+            [ parameter-align (flatten-int-type) ] keep
+            [ stack-size cell align + ] keep
+            flatten-value-type
+        ] reduce drop
+    ] { } make ;
+
+: each-parameter ( parameters quot -- )
+    >r [ parameter-sizes nip ] keep r> 2each ; inline
+
+: reverse-each-parameter ( parameters quot -- )
+    >r [ parameter-sizes nip ] keep r> 2reverse-each ; inline
+
+: reset-freg-counts ( -- )
+    { int-regs float-regs stack-params } [ 0 swap set ] each ;
+
+: with-param-regs ( quot -- )
+    #! In quot you can call alloc-parameter
+    [ reset-freg-counts call ] with-scope ; inline
+
+: move-parameters ( node word -- )
+    #! Moves values from C stack to registers (if word is
+    #! %load-param-reg) and registers to C stack (if word is
+    #! %save-param-reg).
+    >r
+    alien-parameters
+    flatten-value-types
+    r> [ >r alloc-parameter r> execute ] curry each-parameter ;
+    inline
+
+: unbox-parameters ( offset node -- )
+    parameters>> [
+        %prepare-unbox >r over + r> unbox-parameter
+    ] reverse-each-parameter drop ;
+
+: prepare-box-struct ( node -- offset )
+    #! Return offset on C stack where to store unboxed
+    #! parameters. If the C function is returning a structure,
+    #! the first parameter is an implicit target area pointer,
+    #! so we need to use a different offset.
+    return>> dup large-struct?
+    [ heap-size %prepare-box-struct cell ] [ drop 0 ] if ;
+
+: objects>registers ( params -- )
+    #! Generate code for unboxing a list of C types, then
+    #! generate code for moving these parameters to register on
+    #! architectures where parameters are passed in registers.
+    [
+        [ prepare-box-struct ] keep
+        [ unbox-parameters ] keep
+        \ %load-param-reg move-parameters
+    ] with-param-regs ;
+
+: box-return* ( node -- )
+    return>> [ ] [ box-return ] if-void ;
+
+TUPLE: no-such-library name ;
+
+M: no-such-library summary
+    drop "Library not found" ;
+
+M: no-such-library compiler-error-type
+    drop +linkage+ ;
+
+: no-such-library ( name -- )
+    \ no-such-library boa
+    compiling-word get compiler-error ;
+
+TUPLE: no-such-symbol name ;
+
+M: no-such-symbol summary
+    drop "Symbol not found" ;
+
+M: no-such-symbol compiler-error-type
+    drop +linkage+ ;
+
+: no-such-symbol ( name -- )
+    \ no-such-symbol boa
+    compiling-word get compiler-error ;
+
+: check-dlsym ( symbols dll -- )
+    dup dll-valid? [
+        dupd [ dlsym ] curry contains?
+        [ drop ] [ no-such-symbol ] if
+    ] [
+        dll-path no-such-library drop
+    ] if ;
+
+: stdcall-mangle ( symbol node -- symbol )
+    "@"
+    swap parameters>> parameter-sizes drop
+    number>string 3append ;
+
+: alien-invoke-dlsym ( params -- symbols dll )
+    dup function>> dup pick stdcall-mangle 2array
+    swap library>> library dup [ dll>> ] when
+    2dup check-dlsym ;
+
+M: #alien-invoke generate-node
+    params>>
+    dup alien-invoke-frame [
+        end-basic-block
+        %prepare-alien-invoke
+        dup objects>registers
+        %prepare-var-args
+        dup alien-invoke-dlsym %alien-invoke
+        dup %cleanup
+        box-return*
+        iterate-next
+    ] with-stack-frame ;
+
+! #alien-indirect
+M: #alien-indirect generate-node
+    params>>
+    dup alien-invoke-frame [
+        ! Flush registers
+        end-basic-block
+        ! Save registers for GC
+        %prepare-alien-invoke
+        ! Save alien at top of stack to temporary storage
+        %prepare-alien-indirect
+        dup objects>registers
+        %prepare-var-args
+        ! Call alien in temporary storage
+        %alien-indirect
+        dup %cleanup
+        box-return*
+        iterate-next
+    ] with-stack-frame ;
+
+! #alien-callback
+: box-parameters ( params -- )
+    alien-parameters [ box-parameter ] each-parameter ;
+
+: registers>objects ( node -- )
+    [
+        dup \ %save-param-reg move-parameters
+        "nest_stacks" f %alien-invoke
+        box-parameters
+    ] with-param-regs ;
+
+TUPLE: callback-context ;
+
+: current-callback 2 getenv ;
+
+: wait-to-return ( token -- )
+    dup current-callback eq? [
+        drop
+    ] [
+        yield wait-to-return
+    ] if ;
+
+: do-callback ( quot token -- )
+    init-catchstack
+    dup 2 setenv
+    slip
+    wait-to-return ; inline
+
+: callback-return-quot ( ctype -- quot )
+    return>> {
+        { [ dup "void" = ] [ drop [ ] ] }
+        { [ dup large-struct? ] [ heap-size [ memcpy ] curry ] }
+        [ c-type c-type-unboxer-quot ]
+    } cond ;
+
+: callback-prep-quot ( params -- quot )
+    parameters>> [ c-type c-type-boxer-quot ] map spread>quot ;
+
+: wrap-callback-quot ( params -- quot )
+    [
+        [ callback-prep-quot ]
+        [ quot>> ]
+        [ callback-return-quot ] tri 3append ,
+        [ callback-context new do-callback ] %
+    ] [ ] make ;
+
+: %unnest-stacks ( -- ) "unnest_stacks" f %alien-invoke ;
+
+: callback-unwind ( params -- n )
+    {
+        { [ dup abi>> "stdcall" = ] [ alien-stack-frame ] }
+        { [ dup return>> large-struct? ] [ drop 4 ] }
+        [ drop 0 ]
+    } cond ;
+
+: %callback-return ( params -- )
+    #! All the extra book-keeping for %unwind is only for x86.
+    #! On other platforms its an alias for %return.
+    dup alien-return
+    [ %unnest-stacks ] [ %callback-value ] if-void
+    callback-unwind %unwind ;
+
+: generate-callback ( params -- )
+    dup xt>> dup [
+        init-templates
+        %prologue
+        dup alien-stack-frame [
+            [ registers>objects ]
+            [ wrap-callback-quot %alien-callback ]
+            [ %callback-return ]
+            tri
+        ] with-stack-frame
+    ] with-cfg-builder ;
+
+M: #alien-callback generate-node
+    end-basic-block
+    params>> generate-callback iterate-next ;
diff --git a/unfinished/compiler/backend/backend.factor b/unfinished/compiler/backend/backend.factor
new file mode 100644 (file)
index 0000000..c1944eb
--- /dev/null
@@ -0,0 +1,10 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: system ;
+IN: compiler.backend
+
+! Is this structure small enough to be returned in registers?
+HOOK: struct-small-enough? cpu ( size -- ? )
+
+! Mapping from register class to machine registers
+HOOK: machine-registers cpu ( -- assoc )
diff --git a/unfinished/compiler/backend/x86/32/32.factor b/unfinished/compiler/backend/x86/32/32.factor
new file mode 100644 (file)
index 0000000..85df673
--- /dev/null
@@ -0,0 +1,10 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: system cpu.x86.assembler compiler.registers compiler.backend ;
+IN: compiler.backend.x86.32
+
+M: x86.32 machine-registers
+    {
+        { int-regs { EAX ECX EDX EBP EBX } }
+        { float-regs { XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 } }
+    } ;
diff --git a/unfinished/compiler/cfg.bluesky/alias/alias.factor b/unfinished/compiler/cfg.bluesky/alias/alias.factor
new file mode 100644 (file)
index 0000000..0ed0b49
--- /dev/null
@@ -0,0 +1,293 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math namespaces assocs hashtables sequences
+accessors vectors combinators sets compiler.vops compiler.cfg ;
+IN: compiler.cfg.alias
+
+! Alias analysis -- must be run after compiler.cfg.stack.
+!
+! We try to eliminate redundant slot and stack
+! traffic using some simple heuristics.
+! 
+! All heap-allocated objects which are loaded from the stack, or
+! other object slots are pessimistically assumed to belong to
+! the same alias class.
+!
+! Freshly-allocated objects get their own alias class.
+!
+! The data and retain stack pointer registers are treated
+! uniformly, and each one gets its own alias class.
+! 
+! Simple pseudo-C example showing load elimination:
+! 
+! int *x, *y, z: inputs
+! int a, b, c, d, e: locals
+! 
+! Before alias analysis:
+!
+! a = x[2]
+! b = x[2]
+! c = x[3]
+! y[2] = z
+! d = x[2]
+! e = y[2]
+! f = x[3]
+!
+! After alias analysis:
+!
+! a = x[2]
+! b = a /* ELIMINATED */
+! c = x[3]
+! y[2] = z
+! d = x[2] /* if x=y, d=z, if x!=y, d=b; NOT ELIMINATED */
+! e = z /* ELIMINATED */
+! f = c /* ELIMINATED */
+!
+! Simple pseudo-C example showing store elimination:
+!
+! Before alias analysis:
+!
+! x[0] = a
+! b = x[n]
+! x[0] = c
+! x[1] = d
+! e = x[0]
+! x[1] = c
+!
+! After alias analysis:
+!
+! x[0] = a /* dead if n = 0, live otherwise; NOT ELIMINATED */
+! b = x[n]
+! x[0] = c
+! /* x[1] = d */  /* ELIMINATED */
+! e = c
+! x[1] = c
+
+! Map vregs -> alias classes
+SYMBOL: vregs>acs
+
+: check [ "BUG: static type error detected" throw ] unless* ; inline
+: vreg>ac ( vreg -- ac )
+    #! Only vregs produced by %%allot, %peek and %%slot can
+    #! ever be used as valid inputs to %%slot and %%set-slot,
+    #! so we assert this fact by not giving alias classes to
+    #! other vregs.
+    vregs>acs get at check ;
+
+! Map alias classes -> sequence of vregs
+SYMBOL: acs>vregs
+
+: ac>vregs ( ac -- vregs ) acs>vregs get at ;
+
+: aliases ( vreg -- vregs )
+    #! All vregs which may contain the same value as vreg.
+    vreg>ac ac>vregs ;
+
+: each-alias ( vreg quot -- )
+    [ aliases ] dip each ; inline
+
+! Map vregs -> slot# -> vreg
+SYMBOL: live-slots
+
+! Current instruction number
+SYMBOL: insn#
+
+! Load/store history, for dead store elimination
+TUPLE: load insn# ;
+TUPLE: store insn# ;
+
+: new-action ( class -- action )
+    insn# get swap boa ; inline
+
+! Maps vreg -> slot# -> sequence of loads/stores
+SYMBOL: histories
+
+: history ( vreg -- history ) histories get at ;
+
+: set-ac ( vreg ac -- )
+    #! Set alias class of newly-seen vreg.
+    {
+        [ drop H{ } clone swap histories get set-at ]
+        [ drop H{ } clone swap live-slots get set-at ]
+        [ swap vregs>acs get set-at ]
+        [ acs>vregs get push-at ]
+    } 2cleave ;
+
+: live-slot ( slot#/f vreg -- vreg' )
+    #! If the slot number is unknown, we never reuse a previous
+    #! value.
+    over [ live-slots get at at ] [ 2drop f ] if ;
+
+: load-constant-slot ( value slot# vreg -- )
+    live-slots get at check set-at ;
+
+: load-slot ( value slot#/f vreg -- )
+    over [ load-constant-slot ] [ 3drop ] if ;
+
+: record-constant-slot ( slot# vreg -- )
+    #! A load can potentially read every store of this slot#
+    #! in that alias class.
+    [
+        history [ load new-action swap ?push ] change-at
+    ] with each-alias ;
+
+: record-computed-slot ( vreg -- )
+    #! Computed load is like a load of every slot touched so far
+    [
+        history values [ load new-action swap push ] each
+    ] each-alias ;
+
+: remember-slot ( value slot#/f vreg -- )
+    over
+    [ [ record-constant-slot ] [ load-constant-slot ] 2bi ]
+    [ 2nip record-computed-slot ] if ;
+
+SYMBOL: ac-counter
+
+: next-ac ( -- n )
+    ac-counter [ dup 1+ ] change ;
+
+! Alias class for objects which are loaded from the data stack
+! or other object slots. We pessimistically assume that they
+! can all alias each other.
+SYMBOL: heap-ac
+
+: set-heap-ac ( vreg -- ) heap-ac get set-ac ;
+
+: set-new-ac ( vreg -- ) next-ac set-ac ;
+
+: kill-constant-set-slot ( slot# vreg -- )
+    [ live-slots get at delete-at ] with each-alias ;
+
+: record-constant-set-slot ( slot# vreg -- )
+    history [
+        dup empty? [ dup peek store? [ dup pop* ] when ] unless
+        store new-action swap ?push
+    ] change-at ;
+
+: kill-computed-set-slot ( ac -- )
+    [ live-slots get at clear-assoc ] each-alias ;
+
+: remember-set-slot ( slot#/f vreg -- )
+    over [
+        [ record-constant-set-slot ]
+        [ kill-constant-set-slot ] 2bi
+    ] [ nip kill-computed-set-slot ] if ;
+
+SYMBOL: copies
+
+: resolve ( vreg -- vreg )
+    dup copies get at swap or ;
+
+SYMBOL: constants
+
+: constant ( vreg -- n/f )
+    #! Return an %iconst value, or f if the vreg was not
+    #! assigned by an %iconst.
+    resolve constants get at ;
+
+! We treat slot accessors and stack traffic alike
+GENERIC: insn-slot# ( insn -- slot#/f )
+GENERIC: insn-object ( insn -- vreg )
+
+M: %peek insn-slot# n>> ;
+M: %replace insn-slot# n>> ;
+M: %%slot insn-slot# slot>> constant ;
+M: %%set-slot insn-slot# slot>> constant ;
+
+M: %peek insn-object stack>> ;
+M: %replace insn-object stack>> ;
+M: %%slot insn-object obj>> resolve ;
+M: %%set-slot insn-object obj>> resolve ;
+
+: init-alias-analysis ( -- )
+    H{ } clone histories set
+    H{ } clone vregs>acs set
+    H{ } clone acs>vregs set
+    H{ } clone live-slots set
+    H{ } clone constants set
+    H{ } clone copies set
+
+    0 ac-counter set
+    next-ac heap-ac set
+
+    %data next-ac set-ac
+    %retain next-ac set-ac ;
+
+GENERIC: analyze-aliases ( insn -- insn' )
+
+M: %iconst analyze-aliases
+    dup [ value>> ] [ out>> ] bi constants get set-at ;
+
+M: %%allot analyze-aliases
+    #! A freshly allocated object is distinct from any other
+    #! object.
+    dup out>> set-new-ac ;
+
+M: read-op analyze-aliases
+    dup out>> set-heap-ac
+    dup [ out>> ] [ insn-slot# ] [ insn-object ] tri
+    2dup live-slot dup [
+        2nip %copy boa analyze-aliases nip
+    ] [
+        drop remember-slot
+    ] if ;
+
+: idempotent? ( value slot#/f vreg -- ? )
+    #! Are we storing a value back to the same slot it was read
+    #! from?
+    live-slot = ;
+
+M: write-op analyze-aliases
+    dup
+    [ in>> resolve ] [ insn-slot# ] [ insn-object ] tri
+    3dup idempotent? [
+        2drop 2drop nop
+    ] [
+        [ remember-set-slot drop ] [ load-slot ] 3bi
+    ] if ;
+
+M: %copy analyze-aliases
+    #! The output vreg gets the same alias class as the input
+    #! vreg, since they both contain the same value.
+    dup [ in>> resolve ] [ out>> ] bi copies get set-at ;
+
+M: vop analyze-aliases ;
+
+SYMBOL: live-stores
+
+: compute-live-stores ( -- )
+    histories get
+    values [
+        values [ [ store? ] filter [ insn#>> ] map ] map concat
+    ] map concat unique
+    live-stores set ;
+
+GENERIC: eliminate-dead-store ( insn -- insn' )
+
+: (eliminate-dead-store) ( insn -- insn' )
+    dup insn-slot# [
+        insn# get live-stores get key? [
+            drop nop
+        ] unless
+    ] when ;
+
+M: %replace eliminate-dead-store
+    #! Writes to above the top of the stack can be pruned also.
+    #! This is sound since any such writes are not observable
+    #! after the basic block, and any reads of those locations
+    #! will have been converted to copies by analyze-slot,
+    #! and the final stack height of the basic block is set at
+    #! the beginning by compiler.cfg.stack.
+    dup n>> 0 < [ drop nop ] [ (eliminate-dead-store) ] if ;
+
+M: %%set-slot eliminate-dead-store (eliminate-dead-store) ;
+
+M: vop eliminate-dead-store ;
+
+: alias-analysis ( insns -- insns' )
+    init-alias-analysis
+    [ insn# set analyze-aliases ] map-index
+    compute-live-stores
+    [ insn# set eliminate-dead-store ] map-index ;
diff --git a/unfinished/compiler/cfg.bluesky/authors.txt b/unfinished/compiler/cfg.bluesky/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/unfinished/compiler/cfg.bluesky/builder/builder-tests.factor b/unfinished/compiler/cfg.bluesky/builder/builder-tests.factor
new file mode 100644 (file)
index 0000000..098919c
--- /dev/null
@@ -0,0 +1,4 @@
+IN: compiler.cfg.builder.tests
+USING: compiler.cfg.builder tools.test ;
+
+\ build-cfg must-infer
diff --git a/unfinished/compiler/cfg.bluesky/builder/builder.factor b/unfinished/compiler/cfg.bluesky/builder/builder.factor
new file mode 100644 (file)
index 0000000..76a1b67
--- /dev/null
@@ -0,0 +1,256 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays kernel assocs sequences sequences.lib fry accessors
+namespaces math combinators math.order
+compiler.tree
+compiler.tree.combinators
+compiler.tree.propagation.info
+compiler.cfg
+compiler.vops
+compiler.vops.builder ;
+IN: compiler.cfg.builder
+
+! Convert tree SSA IR to CFG SSA IR.
+
+! We construct the graph and set successors first, then we
+! set predecessors in a separate pass. This simplifies the
+! logic.
+
+SYMBOL: procedures
+
+SYMBOL: loop-nesting
+
+SYMBOL: values>vregs
+
+GENERIC: convert ( node -- )
+
+M: #introduce convert drop ;
+
+: init-builder ( -- )
+    H{ } clone values>vregs set ;
+
+: end-basic-block ( -- )
+    basic-block get [ %b emit ] when ;
+
+: set-basic-block ( basic-block -- )
+    [ basic-block set ] [ instructions>> building set ] bi ;
+
+: begin-basic-block ( -- )
+    <basic-block> basic-block get
+    [
+        end-basic-block
+        dupd successors>> push
+    ] when*
+    set-basic-block ;
+
+: convert-nodes ( node -- )
+    [ convert ] each ;
+
+: (build-cfg) ( node word -- )
+    init-builder
+    begin-basic-block
+    basic-block get swap procedures get set-at
+    convert-nodes ;
+
+: build-cfg ( node word -- procedures )
+    H{ } clone [
+        procedures [ (build-cfg) ] with-variable
+    ] keep ;
+
+: value>vreg ( value -- vreg )
+    values>vregs get at ;
+
+: output-vreg ( value vreg -- )
+    swap values>vregs get set-at ;
+
+: produce-vreg ( value -- vreg )
+    next-vreg [ output-vreg ] keep ;
+
+: (load-inputs) ( seq stack -- )
+    over empty? [ 2drop ] [
+        [ <reversed> ] dip
+        [ '[ produce-vreg _ , %peek emit ] each-index ]
+        [ [ length neg ] dip %height emit ]
+        2bi
+    ] if ;
+
+: load-in-d ( node -- ) in-d>> %data (load-inputs) ;
+
+: load-in-r ( node -- ) in-r>> %retain (load-inputs) ;
+
+: (store-outputs) ( seq stack -- )
+    over empty? [ 2drop ] [
+        [ <reversed> ] dip
+        [ [ length ] dip %height emit ]
+        [ '[ value>vreg _ , %replace emit ] each-index ]
+        2bi
+    ] if ;
+
+: store-out-d ( node -- ) out-d>> %data (store-outputs) ;
+
+: store-out-r ( node -- ) out-r>> %retain (store-outputs) ;
+
+: (emit-call) ( word -- )
+    begin-basic-block %call emit begin-basic-block ;
+
+: intrinsic-inputs ( node -- )
+    [ load-in-d ]
+    [ in-d>> { #1 #2 #3 #4 } [ [ value>vreg ] dip set ] 2each ]
+    bi ;
+
+: intrinsic-outputs ( node -- )
+    [ out-d>> { ^1 ^2 ^3 ^4 } [ get output-vreg ] 2each ]
+    [ store-out-d ]
+    bi ;
+
+: intrinsic ( node quot -- )
+    [
+        init-intrinsic
+
+        [ intrinsic-inputs ]
+        swap
+        [ intrinsic-outputs ]
+        tri
+    ] with-scope ; inline
+
+USING: kernel.private math.private slots.private ;
+
+: maybe-emit-fixnum-shift-fast ( node -- node )
+    dup dup in-d>> second node-value-info literal>> dup fixnum? [
+        '[ , emit-fixnum-shift-fast ] intrinsic
+    ] [
+        drop dup word>> (emit-call)
+    ] if ;
+
+: emit-call ( node -- )
+    dup word>> {
+        { \ tag [ [ emit-tag ] intrinsic ] }
+
+        { \ slot [ [ dup emit-slot ] intrinsic ] }
+        { \ set-slot [ [ dup emit-set-slot ] intrinsic ] }
+
+        { \ fixnum-bitnot [ [ emit-fixnum-bitnot ] intrinsic ] }
+        { \ fixnum+fast [ [ emit-fixnum+fast ] intrinsic ] }
+        { \ fixnum-fast [ [ emit-fixnum-fast ] intrinsic ] }
+        { \ fixnum-bitand [ [ emit-fixnum-bitand ] intrinsic ] }
+        { \ fixnum-bitor [ [ emit-fixnum-bitor ] intrinsic ] }
+        { \ fixnum-bitxor [ [ emit-fixnum-bitxor ] intrinsic ] }
+        { \ fixnum*fast [ [ emit-fixnum*fast ] intrinsic ] }
+        { \ fixnum<= [ [ emit-fixnum<= ] intrinsic ] }
+        { \ fixnum>= [ [ emit-fixnum>= ] intrinsic ] }
+        { \ fixnum< [ [ emit-fixnum< ] intrinsic ] }
+        { \ fixnum> [ [ emit-fixnum> ] intrinsic ] }
+        { \ eq? [ [ emit-eq? ] intrinsic ] }
+
+        { \ fixnum-shift-fast [ maybe-emit-fixnum-shift-fast ] }
+
+        { \ float+ [ [ emit-float+ ] intrinsic ] }
+        { \ float- [ [ emit-float- ] intrinsic ] }
+        { \ float* [ [ emit-float* ] intrinsic ] }
+        { \ float/f [ [ emit-float/f ] intrinsic ] }
+        { \ float<= [ [ emit-float<= ] intrinsic ] }
+        { \ float>= [ [ emit-float>= ] intrinsic ] }
+        { \ float< [ [ emit-float< ] intrinsic ] }
+        { \ float> [ [ emit-float> ] intrinsic ] }
+        { \ float? [ [ emit-float= ] intrinsic ] }
+
+        ! { \ (tuple) [ dup first-input '[ , emit-(tuple) ] intrinsic ] }
+        ! { \ (array) [ dup first-input '[ , emit-(array) ] intrinsic ] }
+        ! { \ (byte-array) [ dup first-input '[ , emit-(byte-array) ] intrinsic ] }
+
+        [ (emit-call) ]
+    } case drop ;
+
+M: #call convert emit-call ;
+
+: emit-call-loop ( #recursive -- )
+    dup label>> loop-nesting get at basic-block get successors>> push
+    end-basic-block
+    basic-block off
+    drop ;
+
+: emit-call-recursive ( #recursive -- )
+    label>> id>> (emit-call) ;
+
+M: #call-recursive convert
+    dup label>> loop?>>
+    [ emit-call-loop ] [ emit-call-recursive ] if ;
+
+M: #push convert
+    [
+        [ out-d>> first produce-vreg ]
+        [ node-output-infos first literal>> ]
+        bi emit-literal
+    ]
+    [ store-out-d ] bi ;
+
+M: #shuffle convert [ load-in-d ] [ store-out-d ] bi ;
+
+M: #>r convert [ load-in-d ] [ store-out-r ] bi ;
+
+M: #r> convert [ load-in-r ] [ store-out-d ] bi ;
+
+M: #terminate convert drop ;
+
+: integer-conditional ( in1 in2 cc -- )
+    [ [ next-vreg dup ] 2dip %icmp emit ] dip %bi emit ; inline
+
+: float-conditional ( in1 in2 branch -- )
+    [ next-vreg [ %fcmp emit ] keep ] dip emit ; inline
+
+: emit-if ( #if -- )
+    in-d>> first value>vreg
+    next-vreg dup f emit-literal
+    cc/= integer-conditional ;
+
+: convert-nested ( node -- last-bb )
+    [
+        <basic-block>
+        [ set-basic-block ] keep
+        [ convert-nodes end-basic-block ] dip
+        basic-block get
+    ] with-scope
+    [ basic-block get successors>> push ] dip ;
+
+: convert-if-children ( #if -- )
+    children>> [ convert-nested ] map sift
+    <basic-block>
+    [ '[ , _ successors>> push ] each ]
+    [ set-basic-block ]
+    bi ;
+
+M: #if convert
+    [ load-in-d ] [ emit-if ] [ convert-if-children ] tri ;
+
+M: #dispatch convert
+    "Unimplemented" throw ;
+
+M: #phi convert drop ;
+
+M: #declare convert drop ;
+
+M: #return convert drop %return emit ;
+
+: convert-recursive ( #recursive -- )
+    [ [ label>> id>> ] [ child>> ] bi (build-cfg) ]
+    [ (emit-call) ]
+    bi ;
+
+: begin-loop ( #recursive -- )
+    label>> basic-block get 2array loop-nesting get push ;
+
+: end-loop ( -- )
+    loop-nesting get pop* ;
+
+: convert-loop ( #recursive -- )
+    begin-basic-block
+    [ begin-loop ]
+    [ child>> convert-nodes ]
+    [ drop end-loop ]
+    tri ;
+
+M: #recursive convert
+    dup label>> loop?>>
+    [ convert-loop ] [ convert-recursive ] if ;
+
+M: #copy convert drop ;
diff --git a/unfinished/compiler/cfg.bluesky/cfg.factor b/unfinished/compiler/cfg.bluesky/cfg.factor
new file mode 100644 (file)
index 0000000..ae14f3e
--- /dev/null
@@ -0,0 +1,47 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors namespaces assocs sequences sets fry ;
+IN: compiler.cfg
+
+! The id is a globally unique id used for fast hashcode* and
+! equal? on basic blocks. The number is assigned by
+! linearization.
+TUPLE: basic-block < identity-tuple
+id
+number
+instructions
+successors
+predecessors
+stack-frame ;
+
+SYMBOL: next-block-id
+
+: <basic-block> ( -- basic-block )
+    basic-block new
+        next-block-id counter >>id
+        V{ } clone >>instructions
+        V{ } clone >>successors
+        V{ } clone >>predecessors ;
+
+M: basic-block hashcode* id>> nip ;
+
+! Utilities
+SYMBOL: visited-blocks
+
+: visit-block ( basic-block quot -- )
+    over visited-blocks get 2dup key?
+    [ 2drop 2drop ] [ conjoin call ] if ; inline
+
+: (each-block) ( basic-block quot -- )
+    '[
+        ,
+        [ call ]
+        [ [ successors>> ] dip '[ , (each-block) ] each ]
+        2bi
+    ] visit-block ; inline
+
+: each-block ( basic-block quot -- )
+    H{ } clone visited-blocks [ (each-block) ] with-variable ; inline
+
+: copy-at ( from to assoc -- )
+    3dup nip at* [ -rot set-at drop ] [ 2drop 2drop ] if ; inline
diff --git a/unfinished/compiler/cfg.bluesky/elaboration/elaboration.factor b/unfinished/compiler/cfg.bluesky/elaboration/elaboration.factor
new file mode 100644 (file)
index 0000000..c3c3e47
--- /dev/null
@@ -0,0 +1,49 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors namespaces math layouts sequences locals
+combinators compiler.vops compiler.vops.builder
+compiler.cfg.builder ;
+IN: compiler.cfg.elaboration
+
+! This pass must run before conversion to machine IR to ensure
+! correctness.
+
+GENERIC: elaborate* ( insn -- )
+
+: slot-shift ( -- n )
+    tag-bits get cell log2 - ;
+
+:: compute-slot-known-tag ( insn -- addr )
+    { $1 $2 $3 $4 $5 } temps
+    init-intrinsic
+    $1 slot-shift %iconst emit  ! load shift offset
+    $2 insn slot>> $1 %shr emit ! shift slot by shift offset
+    $3 insn tag>> %iconst emit  ! load tag number
+    $4 $2 $3 %isub emit
+    $5 insn obj>> $4 %iadd emit ! compute slot offset
+    $5
+    ;
+
+:: compute-slot-any-tag ( insn -- addr )
+    { $1 $2 $3 $4 } temps
+    init-intrinsic
+    $1 insn obj>> emit-untag    ! untag object
+    $2 slot-shift %iconst emit  ! load shift offset
+    $3 insn slot>> $2 %shr emit ! shift slot by shift offset
+    $4 $1 $3 %iadd emit         ! compute slot offset
+    $4
+    ;
+
+: compute-slot ( insn -- addr )
+    dup tag>> [ compute-slot-known-tag ] [ compute-slot-any-tag ] if ;
+
+M: %%slot elaborate*
+    [ out>> ] [ compute-slot ] bi %load emit ;
+
+M: %%set-slot elaborate*
+    [ in>> ] [ compute-slot ] bi %store emit ;
+
+M: object elaborate* , ;
+
+: elaboration ( insns -- insns )
+    [ [ elaborate* ] each ] { } make ;
diff --git a/unfinished/compiler/cfg.bluesky/kill-nops/kill-nops.factor b/unfinished/compiler/cfg.bluesky/kill-nops/kill-nops.factor
new file mode 100644 (file)
index 0000000..56e88c3
--- /dev/null
@@ -0,0 +1,9 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: sequences kernel compiler.vops ;
+IN: compiler.cfg.kill-nops
+
+! Smallest compiler pass ever.
+
+: kill-nops ( instructions -- instructions' )
+    [ nop? not ] filter ;
diff --git a/unfinished/compiler/cfg.bluesky/live-ranges/live-ranges.factor b/unfinished/compiler/cfg.bluesky/live-ranges/live-ranges.factor
new file mode 100644 (file)
index 0000000..e6ff616
--- /dev/null
@@ -0,0 +1,40 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel namespaces assocs accessors math.order sequences
+compiler.vops ;
+IN: compiler.cfg.live-ranges
+
+TUPLE: live-range from to ;
+
+! Maps vregs to live ranges
+SYMBOL: live-ranges
+
+: def ( n vreg -- )
+    [ dup live-range boa ] dip live-ranges get set-at ;
+
+: use ( n vreg -- )
+    live-ranges get at [ max ] change-to drop ;
+
+GENERIC: compute-live-ranges* ( n insn -- )
+
+M: nullary-op compute-live-ranges*
+    2drop ;
+
+M: flushable-op compute-live-ranges*
+    out>> def ;
+
+M: effect-op compute-live-ranges*
+    in>> use ;
+
+M: unary-op compute-live-ranges*
+    [ out>> def ] [ in>> use ] 2bi ;
+
+M: binary-op compute-live-ranges*
+    [ call-next-method ] [ in1>> use ] [ in2>> use ] 2tri ;
+
+M: %store compute-live-ranges*
+    [ call-next-method ] [ addr>> use ] 2bi ;
+
+: compute-live-ranges ( insns -- )
+    H{ } clone live-ranges set
+    [ swap compute-live-ranges* ] each-index ;
diff --git a/unfinished/compiler/cfg.bluesky/predecessors/predecessors.factor b/unfinished/compiler/cfg.bluesky/predecessors/predecessors.factor
new file mode 100644 (file)
index 0000000..c05a425
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: compiler.cfg kernel accessors sequences ;
+IN: compiler.cfg.predecessors
+
+! Pass to compute precedecessors.
+
+: compute-predecessors ( procedure -- )
+    [
+        dup successors>>
+        [ predecessors>> push ] with each
+    ] each-block ;
diff --git a/unfinished/compiler/cfg.bluesky/simplifier/simplifier.factor b/unfinished/compiler/cfg.bluesky/simplifier/simplifier.factor
new file mode 100644 (file)
index 0000000..2e51a1a
--- /dev/null
@@ -0,0 +1,25 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors sequences kernel
+compiler.cfg
+compiler.cfg.predecessors
+compiler.cfg.stack
+compiler.cfg.alias
+compiler.cfg.write-barrier
+compiler.cfg.elaboration
+compiler.cfg.vn
+compiler.cfg.vn.conditions
+compiler.cfg.kill-nops ;
+IN: compiler.cfg.simplifier
+
+: simplify ( insns -- insns' )
+    normalize-height
+    alias-analysis
+    elaboration
+    value-numbering
+    eliminate-write-barrier
+    kill-nops ;
+
+: simplify-cfg ( procedure -- procedure )
+    dup compute-predecessors
+    dup [ [ simplify ] change-instructions drop ] each-block ;
diff --git a/unfinished/compiler/cfg.bluesky/stack/stack.factor b/unfinished/compiler/cfg.bluesky/stack/stack.factor
new file mode 100644 (file)
index 0000000..43dd7a0
--- /dev/null
@@ -0,0 +1,42 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors math namespaces sequences kernel fry
+compiler.vops ;
+IN: compiler.cfg.stack
+
+! Combine multiple stack height changes into one, done at the
+! start of the basic block.
+!
+! Alias analysis and value numbering assume this optimization
+! has been performed.
+
+! Current data and retain stack height is stored in
+! %data, %retain variables.
+GENERIC: compute-heights ( insn -- )
+
+M: %height compute-heights
+    [ n>> ] [ stack>> ] bi [ + ] change ;
+
+M: object compute-heights drop ;
+
+GENERIC: normalize-height* ( insn -- insn )
+
+M: %height normalize-height*
+    [ n>> ] [ stack>> ] bi [ swap - ] change nop ;
+
+: (normalize-height) ( insn -- insn )
+    dup stack>> get '[ , + ] change-n ; inline
+
+M: %peek normalize-height* (normalize-height) ;
+
+M: %replace normalize-height* (normalize-height) ;
+
+M: object normalize-height* ;
+
+: normalize-height ( insns -- insns' )
+    0 %data set
+    0 %retain set
+    [ [ compute-heights ] each ]
+    [ [ [ normalize-height* ] map ] with-scope ] bi
+    %data get dup zero? [ drop ] [ %data %height boa prefix ] if
+    %retain get dup zero? [ drop ] [ %retain %height boa prefix ] if ;
diff --git a/unfinished/compiler/cfg.bluesky/summary.txt b/unfinished/compiler/cfg.bluesky/summary.txt
new file mode 100644 (file)
index 0000000..eac58ba
--- /dev/null
@@ -0,0 +1 @@
+Low-level optimizer operating on control flow graph SSA IR
diff --git a/unfinished/compiler/cfg.bluesky/vn/conditions/conditions.factor b/unfinished/compiler/cfg.bluesky/vn/conditions/conditions.factor
new file mode 100644 (file)
index 0000000..259e823
--- /dev/null
@@ -0,0 +1,53 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel sequences layouts accessors compiler.vops
+compiler.cfg.vn.graph
+compiler.cfg.vn.expressions
+compiler.cfg.vn.liveness
+compiler.cfg.vn ;
+IN: compiler.cfg.vn.conditions
+
+! The CFG generator produces naive code for the following code
+! sequence:
+!
+! fixnum< [ ... ] [ ... ] if
+!
+! The fixnum< comparison generates a boolean, which is then
+! tested against f.
+!
+! Using value numbering, we optimize the comparison of a boolean
+! against f where the boolean is the result of comparison.
+
+: expr-f? ( expr -- ? )
+    dup op>> %iconst eq?
+    [ value>> \ f tag-number = ] [ drop f ] if ;
+
+: comparison-with-f? ( insn -- expr/f ? )
+    #! The expr is a binary-op %icmp or %fcmp.
+    dup code>> cc/= eq? [
+        in>> vreg>vn vn>expr dup in2>> vn>expr expr-f?
+    ] [ drop f f ] if ;
+
+: of-boolean? ( expr -- expr/f ? )
+    #! The expr is a binary-op %icmp or %fcmp.
+    in1>> vn>expr dup op>> { %%iboolean %%fboolean } memq? ;
+
+: original-comparison ( expr -- in/f code/f )
+    [ in>> vn>vreg ] [ code>> ] bi ;
+
+: eliminate-boolean ( insn -- in/f code/f )
+    comparison-with-f? [
+        of-boolean? [
+            original-comparison
+        ] [ drop f f ] if
+    ] [ drop f f ] if ;
+
+M: cond-branch make-value-node
+    #! If the conditional branch is testing the result of an
+    #! earlier comparison against f, we only mark as live the
+    #! earlier comparison, so DCE will eliminate the boolean.
+    dup eliminate-boolean drop swap in>> or live-vreg ;
+M: cond-branch eliminate
+    dup eliminate-boolean dup
+    [ [ >>in ] [ >>code ] bi* ] [ 2drop ] if ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/constant-fold/constant-fold.factor b/unfinished/compiler/cfg.bluesky/vn/constant-fold/constant-fold.factor
new file mode 100644 (file)
index 0000000..f30a55d
--- /dev/null
@@ -0,0 +1,17 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel compiler.vops compiler.cfg.vn.graph
+compiler.cfg.vn.expressions ;
+IN: compiler.cfg.vn.constant-fold
+
+GENERIC: constant-fold ( insn -- insn' )
+
+M: vop constant-fold ;
+
+: expr>insn ( out constant-expr -- constant-op )
+    [ value>> ] [ op>> ] bi new swap >>value swap >>out ;
+
+M: pure-op constant-fold
+    dup out>>
+    dup vreg>vn vn>expr
+    dup constant-expr? [ expr>insn nip ] [ 2drop ] if ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/expressions/expressions.factor b/unfinished/compiler/cfg.bluesky/vn/expressions/expressions.factor
new file mode 100644 (file)
index 0000000..7b84c01
--- /dev/null
@@ -0,0 +1,64 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors classes kernel math namespaces sorting
+compiler.vops compiler.cfg.vn.graph ;
+IN: compiler.cfg.vn.expressions
+
+! Referentially-transparent expressions
+TUPLE: expr op ;
+TUPLE: nullary-expr < expr ;
+TUPLE: unary-expr < expr in ;
+TUPLE: binary-expr < expr in1 in2 ;
+TUPLE: commutative-expr < binary-expr ;
+TUPLE: boolean-expr < unary-expr code ;
+TUPLE: constant-expr < expr value ;
+TUPLE: literal-expr < unary-expr object ;
+
+! op is always %peek
+TUPLE: peek-expr < expr loc ;
+
+SYMBOL: input-expr-counter
+
+: next-input-expr ( -- n )
+    input-expr-counter [ dup 1 + ] change ;
+
+! Expressions whose values are inputs to the basic block. We
+! can eliminate a second computation having the same 'n' as
+! the first one; we can also eliminate input-exprs whose
+! result is not used.
+TUPLE: input-expr < expr n ;
+
+GENERIC: >expr ( insn -- expr )
+
+M: %literal-table >expr
+    class nullary-expr boa ;
+
+M: constant-op >expr
+    [ class ] [ value>> ] bi constant-expr boa ;
+
+M: %literal >expr
+    [ class ] [ in>> vreg>vn ] [ object>> ] tri literal-expr boa ;
+
+M: unary-op >expr
+    [ class ] [ in>> vreg>vn ] bi unary-expr boa ;
+
+M: binary-op >expr
+    [ class ] [ in1>> vreg>vn ] [ in2>> vreg>vn ] tri
+    binary-expr boa ;
+
+M: commutative-op >expr
+    [ class ] [ in1>> vreg>vn ] [ in2>> vreg>vn ] tri
+    sort-pair commutative-expr boa ;
+
+M: boolean-op >expr
+    [ class ] [ in>> vreg>vn ] [ code>> ] tri
+    boolean-expr boa ;
+
+M: %peek >expr
+    [ class ] [ stack-loc ] bi peek-expr boa ;
+
+M: flushable-op >expr
+    class next-input-expr input-expr boa ;
+
+: init-expressions ( -- )
+    0 input-expr-counter set ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/graph/graph.factor b/unfinished/compiler/cfg.bluesky/vn/graph/graph.factor
new file mode 100644 (file)
index 0000000..ef5d7c2
--- /dev/null
@@ -0,0 +1,37 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math namespaces assocs biassocs accessors
+math.order prettyprint.backend parser ;
+IN: compiler.cfg.vn.graph
+
+TUPLE: vn n ;
+
+SYMBOL: vn-counter
+
+: next-vn ( -- vn ) vn-counter [ dup 1 + ] change vn boa ;
+
+: VN: scan-word vn boa parsed ; parsing
+
+M: vn <=> [ n>> ] compare ;
+
+M: vn pprint* \ VN: pprint-word n>> pprint* ;
+
+! biassoc mapping expressions to value numbers
+SYMBOL: exprs>vns
+
+: expr>vn ( expr -- vn ) exprs>vns get [ drop next-vn ] cache ;
+
+: vn>expr ( vn -- expr ) exprs>vns get value-at ;
+
+SYMBOL: vregs>vns
+
+: vreg>vn ( vreg -- vn ) vregs>vns get at ;
+
+: vn>vreg ( vn -- vreg ) vregs>vns get value-at ;
+
+: set-vn ( vn vreg -- ) vregs>vns get set-at ;
+
+: init-value-graph ( -- )
+    0 vn-counter set
+    <bihash> exprs>vns set
+    <bihash> vregs>vns set ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/liveness/liveness.factor b/unfinished/compiler/cfg.bluesky/vn/liveness/liveness.factor
new file mode 100644 (file)
index 0000000..4a218d4
--- /dev/null
@@ -0,0 +1,37 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces kernel assocs sets accessors compiler.vops
+compiler.cfg.vn.graph compiler.cfg.vn.expressions ;
+IN: compiler.cfg.vn.liveness
+
+! A set of VNs which are (transitively) used by effect-ops. This
+! is precisely the set of VNs whose value is needed outside of
+! the basic block.
+SYMBOL: live-vns
+
+GENERIC: live-expr ( expr -- )
+
+: live-vn ( vn -- )
+    #! Mark a VN and all VNs used in its computation as live.
+    dup live-vns get key? [ drop ] [
+        [ live-vns get conjoin ] [ vn>expr live-expr ] bi
+    ] if ;
+
+: live-vreg ( vreg -- ) vreg>vn live-vn ;
+
+M: expr live-expr drop ;
+M: literal-expr live-expr in>> live-vn ;
+M: unary-expr live-expr in>> live-vn ;
+M: binary-expr live-expr [ in1>> live-vn ] [ in2>> live-vn ] bi ;
+
+: live? ( vreg -- ? )
+    dup vreg>vn tuck vn>vreg =
+    [ live-vns get key? ] [ drop f ] if ;
+
+: init-liveness ( -- )
+    H{ } clone live-vns set ;
+
+GENERIC: eliminate ( insn -- insn' )
+
+M: flushable-op eliminate dup out>> live? ?nop ;
+M: vop eliminate ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/propagate/propagate.factor b/unfinished/compiler/cfg.bluesky/vn/propagate/propagate.factor
new file mode 100644 (file)
index 0000000..75ada5f
--- /dev/null
@@ -0,0 +1,43 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces assocs sequences kernel accessors
+compiler.vops
+compiler.cfg.vn.graph ;
+IN: compiler.cfg.vn.propagate
+
+! If two vregs compute the same value, replace references to
+! the latter with the former.
+
+: resolve ( vreg -- vreg' ) vreg>vn vn>vreg ;
+
+GENERIC: propogate ( insn -- insn )
+
+M: effect-op propogate
+    [ resolve ] change-in ;
+
+M: unary-op propogate
+    [ resolve ] change-in ;
+
+M: binary-op propogate
+    [ resolve ] change-in1
+    [ resolve ] change-in2 ;
+
+M: %phi propogate
+    [ [ resolve ] map ] change-in ;
+
+M: %%slot propogate
+    [ resolve ] change-obj
+    [ resolve ] change-slot ;
+
+M: %%set-slot propogate
+    call-next-method
+    [ resolve ] change-obj
+    [ resolve ] change-slot ;
+
+M: %store propogate
+    call-next-method
+    [ resolve ] change-addr ;
+
+M: nullary-op propogate ;
+
+M: flushable-op propogate ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/simplify/simplify.factor b/unfinished/compiler/cfg.bluesky/vn/simplify/simplify.factor
new file mode 100644 (file)
index 0000000..f16f3e3
--- /dev/null
@@ -0,0 +1,220 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors combinators classes math math.order
+layouts locals
+compiler.vops
+compiler.cfg.vn.graph
+compiler.cfg.vn.expressions ;
+IN: compiler.cfg.vn.simplify
+
+! Return value of f means we didn't simplify.
+GENERIC: simplify* ( expr -- vn/expr/f )
+
+: constant ( val type -- expr ) swap constant-expr boa ;
+
+: simplify-not ( in -- vn/expr/f )
+    {
+        { [ dup constant-expr? ] [ value>> bitnot %iconst constant ] }
+        { [ dup op>> %not = ] [ in>> ] }
+        [ drop f ]
+    } cond ;
+
+: simplify-box-float ( in -- vn/expr/f )
+    {
+        { [ dup op>> %%unbox-float = ] [ in>> ] }
+        [ drop f ]
+    } cond ;
+
+: simplify-unbox-float ( in -- vn/expr/f )
+    {
+        { [ dup literal-expr? ] [ object>> %fconst constant ] }
+        { [ dup op>> %%box-float = ] [ in>> ] }
+        [ drop f ]
+    } cond ;
+
+M: unary-expr simplify*
+    #! Note the copy propagation: a %copy always simplifies to
+    #! its source vn.
+    [ in>> vn>expr ] [ op>> ] bi {
+        { %copy [ ] }
+        { %not [ simplify-not ] }
+        { %%box-float [ simplify-box-float ] }
+        { %%unbox-float [ simplify-unbox-float ] }
+        [ 2drop f ]
+    } case ;
+
+: izero? ( expr -- ? ) T{ constant-expr f %iconst 0 } = ;
+
+: ione? ( expr -- ? ) T{ constant-expr f %iconst 1 } = ;
+
+: ineg-one? ( expr -- ? ) T{ constant-expr f %iconst -1 } = ;
+
+: fzero? ( expr -- ? ) T{ constant-expr f %fconst 0 } = ;
+
+: fone? ( expr -- ? ) T{ constant-expr f %fconst 1 } = ;
+
+: fneg-one? ( expr -- ? ) T{ constant-expr f %fconst -1 } = ;
+
+: identity ( in1 in2 val type -- expr ) constant 2nip ;
+
+: constant-fold? ( in1 in2 -- ? )
+    [ constant-expr? ] both? ;
+
+:: constant-fold ( in1 in2 quot type -- expr )
+    in1 in2 constant-fold?
+    [ in1 value>> in2 value>> quot call type constant ]
+    [ f ]
+    if ; inline
+
+: simplify-iadd ( in1 in2 -- vn/expr/f )
+    {
+        { [ over izero? ] [ nip ] }
+        { [ dup izero? ] [ drop ] }
+        [ [ + ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-imul ( in1 in2 -- vn/expr/f )
+    {
+        { [ over ione? ] [ nip ] }
+        { [ dup ione? ] [ drop ] }
+        [ [ * ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-and ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ 0 %iconst identity ] }
+        { [ dup ineg-one? ] [ drop ] }
+        { [ 2dup = ] [ drop ] }
+        [ [ bitand ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-or ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        { [ dup ineg-one? ] [ -1 %iconst identity ] }
+        { [ 2dup = ] [ drop ] }
+        [ [ bitor ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-xor ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        [ [ bitxor ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-fadd ( in1 in2 -- vn/expr/f )
+    {
+        { [ over fzero? ] [ nip ] }
+        { [ dup fzero? ] [ drop ] }
+        [ [ + ] %fconst constant-fold ]
+    } cond ;
+
+: simplify-fmul ( in1 in2 -- vn/expr/f )
+    {
+        { [ over fone? ] [ nip ] }
+        { [ dup fone? ] [ drop ] }
+        [ [ * ] %fconst constant-fold ]
+    } cond ;
+
+: commutative-operands ( expr -- in1 in2 )
+    [ in1>> vn>expr ] [ in2>> vn>expr ] bi
+    over constant-expr? [ swap ] when ;
+
+M: commutative-expr simplify*
+    [ commutative-operands ] [ op>> ] bi {
+        { %iadd [ simplify-iadd ] }
+        { %imul [ simplify-imul ] }
+        { %and [ simplify-and ] }
+        { %or [ simplify-or ] }
+        { %xor [ simplify-xor ] }
+        { %fadd [ simplify-fadd ] }
+        { %fmul [ simplify-fmul ] }
+        [ 3drop f ]
+    } case ;
+
+: simplify-isub ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        { [ 2dup = ] [ 0 %iconst identity ] }
+        [ [ - ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-idiv ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup ione? ] [ drop ] }
+        [ [ /i ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-imod ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup ione? ] [ 0 %iconst identity ] }
+        { [ 2dup = ] [ 0 %iconst identity ] }
+        [ [ mod ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-shl ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        { [ over izero? ] [ drop ] }
+        [ [ shift ] %iconst constant-fold ]
+    } cond ;
+
+: unsigned ( n -- n' )
+    cell-bits 2^ 1- bitand ;
+
+: useless-shift? ( in1 in2 -- ? )
+    over op>> %shl = [ [ in2>> ] [ expr>vn ] bi* = ] [ 2drop f ] if ;
+
+: simplify-shr ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        { [ over izero? ] [ drop ] }
+        { [ 2dup useless-shift? ] [ drop in1>> ] }
+        [ [ neg shift unsigned ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-sar ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        { [ over izero? ] [ drop ] }
+        { [ 2dup useless-shift? ] [ drop in1>> ] }
+        [ [ neg shift ] %iconst constant-fold ]
+    } cond ;
+
+: simplify-icmp ( in1 in2 -- vn/expr/f )
+    = [ +eq+ %cconst constant ] [ f ] if ;
+
+: simplify-fsub ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup izero? ] [ drop ] }
+        [ [ - ] %fconst constant-fold ]
+    } cond ;
+
+: simplify-fdiv ( in1 in2 -- vn/expr/f )
+    {
+        { [ dup fone? ] [ drop ] }
+        [ [ /i ] %fconst constant-fold ]
+    } cond ;
+
+M: binary-expr simplify*
+    [ in1>> vn>expr ] [ in2>> vn>expr ] [ op>> ] tri {
+        { %isub [ simplify-isub ] }
+        { %idiv [ simplify-idiv ] }
+        { %imod [ simplify-imod ] }
+        { %shl [ simplify-shl ] }
+        { %shr [ simplify-shr ] }
+        { %sar [ simplify-sar ] }
+        { %icmp [ simplify-icmp ] }
+        { %fsub [ simplify-fsub ] }
+        { %fdiv [ simplify-fdiv ] }
+        [ 3drop f ]
+    } case ;
+
+M: expr simplify* drop f ;
+
+: simplify ( expr -- vn )
+    dup simplify* {
+        { [ dup not ] [ drop expr>vn ] }
+        { [ dup expr? ] [ expr>vn nip ] }
+        { [ dup vn? ] [ nip ] }
+    } cond ;
diff --git a/unfinished/compiler/cfg.bluesky/vn/vn.factor b/unfinished/compiler/cfg.bluesky/vn/vn.factor
new file mode 100644 (file)
index 0000000..e16fff0
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces assocs biassocs classes kernel math accessors
+sorting sets sequences compiler.vops
+compiler.cfg.vn.graph
+compiler.cfg.vn.expressions
+compiler.cfg.vn.simplify
+compiler.cfg.vn.liveness
+compiler.cfg.vn.constant-fold
+compiler.cfg.vn.propagate ;
+IN: compiler.cfg.vn
+
+: insn>vn ( insn -- vn ) >expr simplify ; inline
+
+GENERIC: make-value-node ( insn -- )
+M: flushable-op make-value-node [ insn>vn ] [ out>> ] bi set-vn ;
+M: effect-op make-value-node in>> live-vreg ;
+M: %store make-value-node [ in>> live-vreg ] [ addr>> live-vreg ] bi ;
+M: %%set-slot make-value-node [ in>> live-vreg ] [ obj>> live-vreg ] bi ;
+M: nullary-op make-value-node drop ;
+
+: init-value-numbering ( -- )
+    init-value-graph
+    init-expressions
+    init-liveness ;
+
+: value-numbering ( instructions -- instructions )
+    init-value-numbering
+    [ [ make-value-node ] each ]
+    [ [ eliminate constant-fold propogate ] map ]
+    bi ;
diff --git a/unfinished/compiler/cfg.bluesky/write-barrier/write-barrier.factor b/unfinished/compiler/cfg.bluesky/write-barrier/write-barrier.factor
new file mode 100644 (file)
index 0000000..f42f377
--- /dev/null
@@ -0,0 +1,26 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors namespaces assocs sets sequences
+compiler.vops compiler.cfg ;
+IN: compiler.cfg.write-barrier
+
+! Eliminate redundant write barrier hits.
+SYMBOL: hits
+
+GENERIC: eliminate-write-barrier* ( insn -- insn' )
+
+M: %%allot eliminate-write-barrier*
+    dup out>> hits get conjoin ;
+
+M: %write-barrier eliminate-write-barrier*
+    dup in>> hits get key?
+    [ drop nop ] [ dup in>> hits get conjoin ] if ;
+
+M: %copy eliminate-write-barrier*
+    dup in/out hits get copy-at ;
+
+M: vop eliminate-write-barrier* ;
+
+: eliminate-write-barrier ( insns -- insns )
+    H{ } clone hits set
+    [ eliminate-write-barrier* ] map ;
diff --git a/unfinished/compiler/cfg/alias/alias.factor b/unfinished/compiler/cfg/alias/alias.factor
deleted file mode 100644 (file)
index 0ed0b49..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math namespaces assocs hashtables sequences
-accessors vectors combinators sets compiler.vops compiler.cfg ;
-IN: compiler.cfg.alias
-
-! Alias analysis -- must be run after compiler.cfg.stack.
-!
-! We try to eliminate redundant slot and stack
-! traffic using some simple heuristics.
-! 
-! All heap-allocated objects which are loaded from the stack, or
-! other object slots are pessimistically assumed to belong to
-! the same alias class.
-!
-! Freshly-allocated objects get their own alias class.
-!
-! The data and retain stack pointer registers are treated
-! uniformly, and each one gets its own alias class.
-! 
-! Simple pseudo-C example showing load elimination:
-! 
-! int *x, *y, z: inputs
-! int a, b, c, d, e: locals
-! 
-! Before alias analysis:
-!
-! a = x[2]
-! b = x[2]
-! c = x[3]
-! y[2] = z
-! d = x[2]
-! e = y[2]
-! f = x[3]
-!
-! After alias analysis:
-!
-! a = x[2]
-! b = a /* ELIMINATED */
-! c = x[3]
-! y[2] = z
-! d = x[2] /* if x=y, d=z, if x!=y, d=b; NOT ELIMINATED */
-! e = z /* ELIMINATED */
-! f = c /* ELIMINATED */
-!
-! Simple pseudo-C example showing store elimination:
-!
-! Before alias analysis:
-!
-! x[0] = a
-! b = x[n]
-! x[0] = c
-! x[1] = d
-! e = x[0]
-! x[1] = c
-!
-! After alias analysis:
-!
-! x[0] = a /* dead if n = 0, live otherwise; NOT ELIMINATED */
-! b = x[n]
-! x[0] = c
-! /* x[1] = d */  /* ELIMINATED */
-! e = c
-! x[1] = c
-
-! Map vregs -> alias classes
-SYMBOL: vregs>acs
-
-: check [ "BUG: static type error detected" throw ] unless* ; inline
-: vreg>ac ( vreg -- ac )
-    #! Only vregs produced by %%allot, %peek and %%slot can
-    #! ever be used as valid inputs to %%slot and %%set-slot,
-    #! so we assert this fact by not giving alias classes to
-    #! other vregs.
-    vregs>acs get at check ;
-
-! Map alias classes -> sequence of vregs
-SYMBOL: acs>vregs
-
-: ac>vregs ( ac -- vregs ) acs>vregs get at ;
-
-: aliases ( vreg -- vregs )
-    #! All vregs which may contain the same value as vreg.
-    vreg>ac ac>vregs ;
-
-: each-alias ( vreg quot -- )
-    [ aliases ] dip each ; inline
-
-! Map vregs -> slot# -> vreg
-SYMBOL: live-slots
-
-! Current instruction number
-SYMBOL: insn#
-
-! Load/store history, for dead store elimination
-TUPLE: load insn# ;
-TUPLE: store insn# ;
-
-: new-action ( class -- action )
-    insn# get swap boa ; inline
-
-! Maps vreg -> slot# -> sequence of loads/stores
-SYMBOL: histories
-
-: history ( vreg -- history ) histories get at ;
-
-: set-ac ( vreg ac -- )
-    #! Set alias class of newly-seen vreg.
-    {
-        [ drop H{ } clone swap histories get set-at ]
-        [ drop H{ } clone swap live-slots get set-at ]
-        [ swap vregs>acs get set-at ]
-        [ acs>vregs get push-at ]
-    } 2cleave ;
-
-: live-slot ( slot#/f vreg -- vreg' )
-    #! If the slot number is unknown, we never reuse a previous
-    #! value.
-    over [ live-slots get at at ] [ 2drop f ] if ;
-
-: load-constant-slot ( value slot# vreg -- )
-    live-slots get at check set-at ;
-
-: load-slot ( value slot#/f vreg -- )
-    over [ load-constant-slot ] [ 3drop ] if ;
-
-: record-constant-slot ( slot# vreg -- )
-    #! A load can potentially read every store of this slot#
-    #! in that alias class.
-    [
-        history [ load new-action swap ?push ] change-at
-    ] with each-alias ;
-
-: record-computed-slot ( vreg -- )
-    #! Computed load is like a load of every slot touched so far
-    [
-        history values [ load new-action swap push ] each
-    ] each-alias ;
-
-: remember-slot ( value slot#/f vreg -- )
-    over
-    [ [ record-constant-slot ] [ load-constant-slot ] 2bi ]
-    [ 2nip record-computed-slot ] if ;
-
-SYMBOL: ac-counter
-
-: next-ac ( -- n )
-    ac-counter [ dup 1+ ] change ;
-
-! Alias class for objects which are loaded from the data stack
-! or other object slots. We pessimistically assume that they
-! can all alias each other.
-SYMBOL: heap-ac
-
-: set-heap-ac ( vreg -- ) heap-ac get set-ac ;
-
-: set-new-ac ( vreg -- ) next-ac set-ac ;
-
-: kill-constant-set-slot ( slot# vreg -- )
-    [ live-slots get at delete-at ] with each-alias ;
-
-: record-constant-set-slot ( slot# vreg -- )
-    history [
-        dup empty? [ dup peek store? [ dup pop* ] when ] unless
-        store new-action swap ?push
-    ] change-at ;
-
-: kill-computed-set-slot ( ac -- )
-    [ live-slots get at clear-assoc ] each-alias ;
-
-: remember-set-slot ( slot#/f vreg -- )
-    over [
-        [ record-constant-set-slot ]
-        [ kill-constant-set-slot ] 2bi
-    ] [ nip kill-computed-set-slot ] if ;
-
-SYMBOL: copies
-
-: resolve ( vreg -- vreg )
-    dup copies get at swap or ;
-
-SYMBOL: constants
-
-: constant ( vreg -- n/f )
-    #! Return an %iconst value, or f if the vreg was not
-    #! assigned by an %iconst.
-    resolve constants get at ;
-
-! We treat slot accessors and stack traffic alike
-GENERIC: insn-slot# ( insn -- slot#/f )
-GENERIC: insn-object ( insn -- vreg )
-
-M: %peek insn-slot# n>> ;
-M: %replace insn-slot# n>> ;
-M: %%slot insn-slot# slot>> constant ;
-M: %%set-slot insn-slot# slot>> constant ;
-
-M: %peek insn-object stack>> ;
-M: %replace insn-object stack>> ;
-M: %%slot insn-object obj>> resolve ;
-M: %%set-slot insn-object obj>> resolve ;
-
-: init-alias-analysis ( -- )
-    H{ } clone histories set
-    H{ } clone vregs>acs set
-    H{ } clone acs>vregs set
-    H{ } clone live-slots set
-    H{ } clone constants set
-    H{ } clone copies set
-
-    0 ac-counter set
-    next-ac heap-ac set
-
-    %data next-ac set-ac
-    %retain next-ac set-ac ;
-
-GENERIC: analyze-aliases ( insn -- insn' )
-
-M: %iconst analyze-aliases
-    dup [ value>> ] [ out>> ] bi constants get set-at ;
-
-M: %%allot analyze-aliases
-    #! A freshly allocated object is distinct from any other
-    #! object.
-    dup out>> set-new-ac ;
-
-M: read-op analyze-aliases
-    dup out>> set-heap-ac
-    dup [ out>> ] [ insn-slot# ] [ insn-object ] tri
-    2dup live-slot dup [
-        2nip %copy boa analyze-aliases nip
-    ] [
-        drop remember-slot
-    ] if ;
-
-: idempotent? ( value slot#/f vreg -- ? )
-    #! Are we storing a value back to the same slot it was read
-    #! from?
-    live-slot = ;
-
-M: write-op analyze-aliases
-    dup
-    [ in>> resolve ] [ insn-slot# ] [ insn-object ] tri
-    3dup idempotent? [
-        2drop 2drop nop
-    ] [
-        [ remember-set-slot drop ] [ load-slot ] 3bi
-    ] if ;
-
-M: %copy analyze-aliases
-    #! The output vreg gets the same alias class as the input
-    #! vreg, since they both contain the same value.
-    dup [ in>> resolve ] [ out>> ] bi copies get set-at ;
-
-M: vop analyze-aliases ;
-
-SYMBOL: live-stores
-
-: compute-live-stores ( -- )
-    histories get
-    values [
-        values [ [ store? ] filter [ insn#>> ] map ] map concat
-    ] map concat unique
-    live-stores set ;
-
-GENERIC: eliminate-dead-store ( insn -- insn' )
-
-: (eliminate-dead-store) ( insn -- insn' )
-    dup insn-slot# [
-        insn# get live-stores get key? [
-            drop nop
-        ] unless
-    ] when ;
-
-M: %replace eliminate-dead-store
-    #! Writes to above the top of the stack can be pruned also.
-    #! This is sound since any such writes are not observable
-    #! after the basic block, and any reads of those locations
-    #! will have been converted to copies by analyze-slot,
-    #! and the final stack height of the basic block is set at
-    #! the beginning by compiler.cfg.stack.
-    dup n>> 0 < [ drop nop ] [ (eliminate-dead-store) ] if ;
-
-M: %%set-slot eliminate-dead-store (eliminate-dead-store) ;
-
-M: vop eliminate-dead-store ;
-
-: alias-analysis ( insns -- insns' )
-    init-alias-analysis
-    [ insn# set analyze-aliases ] map-index
-    compute-live-stores
-    [ insn# set eliminate-dead-store ] map-index ;
diff --git a/unfinished/compiler/cfg/authors.txt b/unfinished/compiler/cfg/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/unfinished/compiler/cfg/builder/authors.txt b/unfinished/compiler/cfg/builder/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
index 098919c868bc503bf7d50478fb09e754e42229ef..ddc7d13f2546313dd953fd06808334f55ce4d2a7 100644 (file)
@@ -1,4 +1,45 @@
 IN: compiler.cfg.builder.tests
-USING: compiler.cfg.builder tools.test ;
+USING: compiler.cfg.builder tools.test kernel sequences
+math.private compiler.tree.builder compiler.tree.optimizer
+words sequences.private fry prettyprint alien ;
 
-\ build-cfg must-infer
+! Just ensure that various CFGs build correctly.
+: test-cfg ( quot -- result )
+    build-tree optimize-tree gensym gensym build-cfg ;
+
+{
+    [ ]
+    [ dup ]
+    [ swap ]
+    [ >r r> ]
+    [ fixnum+ ]
+    [ fixnum< ]
+    [ [ 1 ] [ 2 ] if ]
+    [ fixnum< [ 1 ] [ 2 ] if ]
+    [ float+ [ 2.0 float* ] [ 3.0 float* ] bi float/f ]
+    [ { [ 1 ] [ 2 ] [ 3 ] } dispatch ]
+    [ [ t ] loop ]
+    [ [ dup ] loop ]
+    [ [ 2 ] [ 3 throw ] if 4 ]
+    [ "int" f "malloc" { "int" } alien-invoke ]
+    [ "int" { "int" } "cdecl" alien-indirect ]
+    [ "int" { "int" } "cdecl" [ ] alien-callback ]
+} [
+    '[ _ test-cfg drop ] [ ] swap unit-test
+] each
+
+: test-word-cfg ( word -- result )
+    [ build-tree-from-word nip optimize-tree ] keep dup
+    build-cfg ;
+
+: test-1 ( -- ) test-1 ;
+: test-2 ( -- ) 3 . test-2 ;
+: test-3 ( a -- b ) dup [ test-3 ] when ;
+
+{
+    test-1
+    test-2
+    test-3
+} [
+    '[ _ test-word-cfg drop ] [ ] swap unit-test
+] each
old mode 100644 (file)
new mode 100755 (executable)
index 76a1b67..0e13491
-! Copyright (C) 2008 Slava Pestov.
+ ! Copyright (C) 2004, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays kernel assocs sequences sequences.lib fry accessors
-namespaces math combinators math.order
+USING: accessors arrays assocs combinators hashtables kernel
+math fry namespaces make sequences words stack-checker.inlining
 compiler.tree
+compiler.tree.builder
 compiler.tree.combinators
 compiler.tree.propagation.info
 compiler.cfg
-compiler.vops
-compiler.vops.builder ;
+compiler.cfg.stacks
+compiler.cfg.templates
+compiler.cfg.iterator
+compiler.alien
+compiler.instructions
+compiler.registers ;
 IN: compiler.cfg.builder
 
-! Convert tree SSA IR to CFG SSA IR.
-
-! We construct the graph and set successors first, then we
-! set predecessors in a separate pass. This simplifies the
-! logic.
-
-SYMBOL: procedures
-
-SYMBOL: loop-nesting
-
-SYMBOL: values>vregs
-
-GENERIC: convert ( node -- )
-
-M: #introduce convert drop ;
-
-: init-builder ( -- )
-    H{ } clone values>vregs set ;
-
-: end-basic-block ( -- )
-    basic-block get [ %b emit ] when ;
+! Convert tree SSA IR to CFG (not quite SSA yet) IR.
 
 : set-basic-block ( basic-block -- )
     [ basic-block set ] [ instructions>> building set ] bi ;
 
 : begin-basic-block ( -- )
-    <basic-block> basic-block get
-    [
-        end-basic-block
+    <basic-block> basic-block get [
         dupd successors>> push
     ] when*
     set-basic-block ;
 
-: convert-nodes ( node -- )
-    [ convert ] each ;
+: end-basic-block ( -- )
+    building off
+    basic-block off ;
 
-: (build-cfg) ( node word -- )
-    init-builder
-    begin-basic-block
-    basic-block get swap procedures get set-at
-    convert-nodes ;
+USE: qualified
+FROM: compiler.generator.registers => +input+   ;
+FROM: compiler.generator.registers => +output+  ;
+FROM: compiler.generator.registers => +scratch+ ;
+FROM: compiler.generator.registers => +clobber+ ;
 
-: build-cfg ( node word -- procedures )
-    H{ } clone [
-        procedures [ (build-cfg) ] with-variable
-    ] keep ;
+SYMBOL: procedures
 
-: value>vreg ( value -- vreg )
-    values>vregs get at ;
+SYMBOL: current-word
 
-: output-vreg ( value vreg -- )
-    swap values>vregs get set-at ;
+SYMBOL: current-label
 
-: produce-vreg ( value -- vreg )
-    next-vreg [ output-vreg ] keep ;
+SYMBOL: loops
 
-: (load-inputs) ( seq stack -- )
-    over empty? [ 2drop ] [
-        [ <reversed> ] dip
-        [ '[ produce-vreg _ , %peek emit ] each-index ]
-        [ [ length neg ] dip %height emit ]
-        2bi
-    ] if ;
+! Basic block after prologue, makes recursion faster
+SYMBOL: current-label-start
 
-: load-in-d ( node -- ) in-d>> %data (load-inputs) ;
+: add-procedure ( -- )
+    basic-block get current-word get current-label get
+    <procedure> procedures get push ;
 
-: load-in-r ( node -- ) in-r>> %retain (load-inputs) ;
+: begin-procedure ( word label -- )
+    end-basic-block
+    begin-basic-block
+    H{ } clone loops set
+    current-label set
+    current-word set
+    add-procedure ;
 
-: (store-outputs) ( seq stack -- )
-    over empty? [ 2drop ] [
-        [ <reversed> ] dip
-        [ [ length ] dip %height emit ]
-        [ '[ value>vreg _ , %replace emit ] each-index ]
-        2bi
-    ] if ;
+: with-cfg-builder ( nodes word label quot -- )
+    '[ begin-procedure @ ] with-scope ; inline
 
-: store-out-d ( node -- ) out-d>> %data (store-outputs) ;
+GENERIC: emit-node ( node -- next )
 
-: store-out-r ( node -- ) out-r>> %retain (store-outputs) ;
+: check-basic-block ( node -- node' )
+    basic-block get [ drop f ] unless ; inline
 
-: (emit-call) ( word -- )
-    begin-basic-block %call emit begin-basic-block ;
+: emit-nodes ( nodes -- )
+    [ current-node emit-node check-basic-block ] iterate-nodes
+    finalize-phantoms ;
 
-: intrinsic-inputs ( node -- )
-    [ load-in-d ]
-    [ in-d>> { #1 #2 #3 #4 } [ [ value>vreg ] dip set ] 2each ]
-    bi ;
+: remember-loop ( label -- )
+    basic-block get swap loops get set-at ;
 
-: intrinsic-outputs ( node -- )
-    [ out-d>> { ^1 ^2 ^3 ^4 } [ get output-vreg ] 2each ]
-    [ store-out-d ]
-    bi ;
+: begin-word ( -- )
+    #! We store the basic block after the prologue as a loop
+    #! labelled by the current word, so that self-recursive
+    #! calls can skip an epilogue/prologue.
+    init-phantoms
+    %prologue
+    %branch
+    begin-basic-block
+    current-label get remember-loop ;
 
-: intrinsic ( node quot -- )
+: (build-cfg) ( nodes word label -- )
     [
-        init-intrinsic
+        begin-word
+        [ emit-nodes ] with-node-iterator
+    ] with-cfg-builder ;
+
+: build-cfg ( nodes word label -- procedures )
+    V{ } clone [
+        procedures [
+            (build-cfg)
+        ] with-variable
+    ] keep ;
 
-        [ intrinsic-inputs ]
-        swap
-        [ intrinsic-outputs ]
-        tri
-    ] with-scope ; inline
+: if-intrinsics ( #call -- quot )
+    word>> "if-intrinsics" word-prop ;
+
+: local-recursive-call ( basic-block -- )
+    %branch
+    basic-block get successors>> push
+    end-basic-block ;
+
+: emit-call ( word -- next )
+    finalize-phantoms
+    {
+        { [ tail-call? not ] [ 0 %frame-required %call iterate-next ] }
+        { [ dup loops get key? ] [ loops get at local-recursive-call f ] }
+        [ %epilogue %jump f ]
+    } cond ;
+
+! #recursive
+: compile-recursive ( node -- next )
+    [ label>> id>> emit-call ]
+    [ [ child>> ] [ label>> word>> ] [ label>> id>> ] tri (build-cfg) ] bi ;
+
+: compile-loop ( node -- next )
+    finalize-phantoms
+    begin-basic-block
+    [ label>> id>> remember-loop ] [ child>> emit-nodes ] bi
+    iterate-next ;
 
-USING: kernel.private math.private slots.private ;
+M: #recursive emit-node
+    dup label>> loop?>> [ compile-loop ] [ compile-recursive ] if ;
 
-: maybe-emit-fixnum-shift-fast ( node -- node )
-    dup dup in-d>> second node-value-info literal>> dup fixnum? [
-        '[ , emit-fixnum-shift-fast ] intrinsic
-    ] [
-        drop dup word>> (emit-call)
-    ] if ;
+! #if
+: emit-branch ( nodes -- final-bb )
+    [
+        begin-basic-block copy-phantoms
+        emit-nodes
+        basic-block get dup [ %branch ] when
+    ] with-scope ;
 
-: emit-call ( node -- )
-    dup word>> {
-        { \ tag [ [ emit-tag ] intrinsic ] }
-
-        { \ slot [ [ dup emit-slot ] intrinsic ] }
-        { \ set-slot [ [ dup emit-set-slot ] intrinsic ] }
-
-        { \ fixnum-bitnot [ [ emit-fixnum-bitnot ] intrinsic ] }
-        { \ fixnum+fast [ [ emit-fixnum+fast ] intrinsic ] }
-        { \ fixnum-fast [ [ emit-fixnum-fast ] intrinsic ] }
-        { \ fixnum-bitand [ [ emit-fixnum-bitand ] intrinsic ] }
-        { \ fixnum-bitor [ [ emit-fixnum-bitor ] intrinsic ] }
-        { \ fixnum-bitxor [ [ emit-fixnum-bitxor ] intrinsic ] }
-        { \ fixnum*fast [ [ emit-fixnum*fast ] intrinsic ] }
-        { \ fixnum<= [ [ emit-fixnum<= ] intrinsic ] }
-        { \ fixnum>= [ [ emit-fixnum>= ] intrinsic ] }
-        { \ fixnum< [ [ emit-fixnum< ] intrinsic ] }
-        { \ fixnum> [ [ emit-fixnum> ] intrinsic ] }
-        { \ eq? [ [ emit-eq? ] intrinsic ] }
-
-        { \ fixnum-shift-fast [ maybe-emit-fixnum-shift-fast ] }
-
-        { \ float+ [ [ emit-float+ ] intrinsic ] }
-        { \ float- [ [ emit-float- ] intrinsic ] }
-        { \ float* [ [ emit-float* ] intrinsic ] }
-        { \ float/f [ [ emit-float/f ] intrinsic ] }
-        { \ float<= [ [ emit-float<= ] intrinsic ] }
-        { \ float>= [ [ emit-float>= ] intrinsic ] }
-        { \ float< [ [ emit-float< ] intrinsic ] }
-        { \ float> [ [ emit-float> ] intrinsic ] }
-        { \ float? [ [ emit-float= ] intrinsic ] }
-
-        ! { \ (tuple) [ dup first-input '[ , emit-(tuple) ] intrinsic ] }
-        ! { \ (array) [ dup first-input '[ , emit-(array) ] intrinsic ] }
-        ! { \ (byte-array) [ dup first-input '[ , emit-(byte-array) ] intrinsic ] }
-
-        [ (emit-call) ]
-    } case drop ;
-
-M: #call convert emit-call ;
-
-: emit-call-loop ( #recursive -- )
-    dup label>> loop-nesting get at basic-block get successors>> push
+: emit-if ( node -- next )
+    children>> [ emit-branch ] map
     end-basic-block
-    basic-block off
-    drop ;
-
-: emit-call-recursive ( #recursive -- )
-    label>> id>> (emit-call) ;
+    begin-basic-block
+    basic-block get '[ [ _ swap successors>> push ] when* ] each
+    init-phantoms
+    iterate-next ;
+
+M: #if emit-node
+    { { f "flag" } } lazy-load first %branch-t
+    emit-if ;
+
+! #dispatch
+: dispatch-branch ( nodes word -- label )
+    gensym [
+        [
+            copy-phantoms
+            %prologue
+            [ emit-nodes ] with-node-iterator
+            %epilogue
+            %return
+        ] with-cfg-builder
+    ] keep ;
 
-M: #call-recursive convert
-    dup label>> loop?>>
-    [ emit-call-loop ] [ emit-call-recursive ] if ;
+: dispatch-branches ( node -- )
+    children>> [
+        current-word get dispatch-branch
+        %dispatch-label
+    ] each ;
+
+: emit-dispatch ( node -- )
+    %dispatch dispatch-branches init-phantoms ;
+
+M: #dispatch emit-node
+    #! The order here is important, dispatch-branches must
+    #! run after %dispatch, so that each branch gets the
+    #! correct register state
+    tail-call? [
+        emit-dispatch iterate-next
+    ] [
+        current-word get gensym [
+            [
+                begin-word
+                emit-dispatch
+            ] with-cfg-builder
+        ] keep emit-call
+    ] if ;
 
-M: #push convert
-    [
-        [ out-d>> first produce-vreg ]
-        [ node-output-infos first literal>> ]
-        bi emit-literal
-    ]
-    [ store-out-d ] bi ;
+! #call
+: define-intrinsics ( word intrinsics -- )
+    "intrinsics" set-word-prop ;
 
-M: #shuffle convert [ load-in-d ] [ store-out-d ] bi ;
+: define-intrinsic ( word quot assoc -- )
+    2array 1array define-intrinsics ;
 
-M: #>r convert [ load-in-d ] [ store-out-r ] bi ;
+: define-if-intrinsics ( word intrinsics -- )
+    [ +input+ associate ] assoc-map
+    "if-intrinsics" set-word-prop ;
 
-M: #r> convert [ load-in-r ] [ store-out-d ] bi ;
+: define-if-intrinsic ( word quot inputs -- )
+    2array 1array define-if-intrinsics ;
 
-M: #terminate convert drop ;
+: find-intrinsic ( #call -- pair/f )
+    word>> "intrinsics" word-prop find-template ;
 
-: integer-conditional ( in1 in2 cc -- )
-    [ [ next-vreg dup ] 2dip %icmp emit ] dip %bi emit ; inline
+: find-boolean-intrinsic ( #call -- pair/f )
+    word>> "if-intrinsics" word-prop find-template ;
 
-: float-conditional ( in1 in2 branch -- )
-    [ next-vreg [ %fcmp emit ] keep ] dip emit ; inline
+: find-if-intrinsic ( #call -- pair/f )
+    node@ {
+        { [ dup length 2 < ] [ 2drop f ] }
+        { [ dup second #if? ] [ drop find-boolean-intrinsic ] }
+        [ 2drop f ]
+    } cond ;
 
-: emit-if ( #if -- )
-    in-d>> first value>vreg
-    next-vreg dup f emit-literal
-    cc/= integer-conditional ;
+: do-if-intrinsic ( pair -- next )
+    [ %if-intrinsic ] apply-template skip-next emit-if ;
 
-: convert-nested ( node -- last-bb )
+: do-boolean-intrinsic ( pair -- next )
     [
-        <basic-block>
-        [ set-basic-block ] keep
-        [ convert-nodes end-basic-block ] dip
-        basic-block get
-    ] with-scope
-    [ basic-block get successors>> push ] dip ;
-
-: convert-if-children ( #if -- )
-    children>> [ convert-nested ] map sift
-    <basic-block>
-    [ '[ , _ successors>> push ] each ]
-    [ set-basic-block ]
+        f alloc-vreg [ %boolean-intrinsic ] keep phantom-push
+    ] apply-template iterate-next ;
+
+: do-intrinsic ( pair -- next )
+    [ %intrinsic ] apply-template iterate-next ;
+
+: setup-operand-classes ( #call -- )
+    node-input-infos [ class>> ] map set-operand-classes ;
+
+M: #call emit-node
+    dup setup-operand-classes
+    dup find-if-intrinsic [ do-if-intrinsic ] [
+        dup find-boolean-intrinsic [ do-boolean-intrinsic ] [
+            dup find-intrinsic [ do-intrinsic ] [
+                word>> emit-call
+            ] ?if
+        ] ?if
+    ] ?if ;
+
+! #call-recursive
+M: #call-recursive emit-node label>> id>> emit-call ;
+
+! #push
+M: #push emit-node
+    literal>> <constant> phantom-push iterate-next ;
+
+! #shuffle
+M: #shuffle emit-node
+    shuffle-effect phantom-shuffle iterate-next ;
+
+M: #>r emit-node
+    [ in-d>> length ] [ out-r>> empty? ] bi
+    [ phantom-drop ] [ phantom->r ] if
+    iterate-next ;
+
+M: #r> emit-node
+    [ in-r>> length ] [ out-d>> empty? ] bi
+    [ phantom-rdrop ] [ phantom-r> ] if
+    iterate-next ;
+
+! #return
+M: #return emit-node
+    drop finalize-phantoms %epilogue %return f ;
+
+M: #return-recursive emit-node
+    finalize-phantoms
+    label>> id>> loops get key?
+    [ %epilogue %return ] unless f ;
+
+! #terminate
+M: #terminate emit-node drop end-basic-block f ;
+
+! FFI
+M: #alien-invoke emit-node
+    params>>
+    [ alien-invoke-frame %frame-required ]
+    [ %alien-invoke iterate-next ]
     bi ;
 
-M: #if convert
-    [ load-in-d ] [ emit-if ] [ convert-if-children ] tri ;
-
-M: #dispatch convert
-    "Unimplemented" throw ;
-
-M: #phi convert drop ;
-
-M: #declare convert drop ;
-
-M: #return convert drop %return emit ;
-
-: convert-recursive ( #recursive -- )
-    [ [ label>> id>> ] [ child>> ] bi (build-cfg) ]
-    [ (emit-call) ]
+M: #alien-indirect emit-node
+    params>>
+    [ alien-invoke-frame %frame-required ]
+    [ %alien-indirect iterate-next ]
     bi ;
 
-: begin-loop ( #recursive -- )
-    label>> basic-block get 2array loop-nesting get push ;
+M: #alien-callback emit-node
+    params>> dup xt>> dup
+    [ init-phantoms %alien-callback ] with-cfg-builder
+    iterate-next ;
 
-: end-loop ( -- )
-    loop-nesting get pop* ;
+! No-op nodes
+M: #introduce emit-node drop iterate-next ;
 
-: convert-loop ( #recursive -- )
-    begin-basic-block
-    [ begin-loop ]
-    [ child>> convert-nodes ]
-    [ drop end-loop ]
-    tri ;
+M: #copy emit-node drop iterate-next ;
 
-M: #recursive convert
-    dup label>> loop?>>
-    [ convert-loop ] [ convert-recursive ] if ;
+M: #enter-recursive emit-node drop iterate-next ;
 
-M: #copy convert drop ;
+M: #phi emit-node drop iterate-next ;
diff --git a/unfinished/compiler/cfg/builder/summary.txt b/unfinished/compiler/cfg/builder/summary.txt
new file mode 100644 (file)
index 0000000..cf857ad
--- /dev/null
@@ -0,0 +1 @@
+Final stage of compilation generates machine code from dataflow IR
diff --git a/unfinished/compiler/cfg/builder/tags.txt b/unfinished/compiler/cfg/builder/tags.txt
new file mode 100644 (file)
index 0000000..86a7c8e
--- /dev/null
@@ -0,0 +1 @@
+compiler
index ae14f3e0092b23608249d6c7e9c6833e4b7db5ca..92a5700af415cb8f214048f174506f45d5f55456 100644 (file)
@@ -3,16 +3,19 @@
 USING: kernel accessors namespaces assocs sequences sets fry ;
 IN: compiler.cfg
 
-! The id is a globally unique id used for fast hashcode* and
-! equal? on basic blocks. The number is assigned by
-! linearization.
+TUPLE: procedure entry word label ;
+
+C: <procedure> procedure
+
+! - "id" is a globally unique id used for hashcode*.
+! - "number" is assigned by linearization.
 TUPLE: basic-block < identity-tuple
 id
 number
+label
 instructions
 successors
-predecessors
-stack-frame ;
+predecessors ;
 
 SYMBOL: next-block-id
 
@@ -34,14 +37,11 @@ SYMBOL: visited-blocks
 
 : (each-block) ( basic-block quot -- )
     '[
-        ,
+        _
         [ call ]
-        [ [ successors>> ] dip '[ , (each-block) ] each ]
+        [ [ successors>> ] dip '[ _ (each-block) ] each ]
         2bi
     ] visit-block ; inline
 
 : each-block ( basic-block quot -- )
     H{ } clone visited-blocks [ (each-block) ] with-variable ; inline
-
-: copy-at ( from to assoc -- )
-    3dup nip at* [ -rot set-at drop ] [ 2drop 2drop ] if ; inline
diff --git a/unfinished/compiler/cfg/elaboration/elaboration.factor b/unfinished/compiler/cfg/elaboration/elaboration.factor
deleted file mode 100644 (file)
index c3c3e47..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors namespaces math layouts sequences locals
-combinators compiler.vops compiler.vops.builder
-compiler.cfg.builder ;
-IN: compiler.cfg.elaboration
-
-! This pass must run before conversion to machine IR to ensure
-! correctness.
-
-GENERIC: elaborate* ( insn -- )
-
-: slot-shift ( -- n )
-    tag-bits get cell log2 - ;
-
-:: compute-slot-known-tag ( insn -- addr )
-    { $1 $2 $3 $4 $5 } temps
-    init-intrinsic
-    $1 slot-shift %iconst emit  ! load shift offset
-    $2 insn slot>> $1 %shr emit ! shift slot by shift offset
-    $3 insn tag>> %iconst emit  ! load tag number
-    $4 $2 $3 %isub emit
-    $5 insn obj>> $4 %iadd emit ! compute slot offset
-    $5
-    ;
-
-:: compute-slot-any-tag ( insn -- addr )
-    { $1 $2 $3 $4 } temps
-    init-intrinsic
-    $1 insn obj>> emit-untag    ! untag object
-    $2 slot-shift %iconst emit  ! load shift offset
-    $3 insn slot>> $2 %shr emit ! shift slot by shift offset
-    $4 $1 $3 %iadd emit         ! compute slot offset
-    $4
-    ;
-
-: compute-slot ( insn -- addr )
-    dup tag>> [ compute-slot-known-tag ] [ compute-slot-any-tag ] if ;
-
-M: %%slot elaborate*
-    [ out>> ] [ compute-slot ] bi %load emit ;
-
-M: %%set-slot elaborate*
-    [ in>> ] [ compute-slot ] bi %store emit ;
-
-M: object elaborate* , ;
-
-: elaboration ( insns -- insns )
-    [ [ elaborate* ] each ] { } make ;
diff --git a/unfinished/compiler/cfg/iterator/iterator.factor b/unfinished/compiler/cfg/iterator/iterator.factor
new file mode 100644 (file)
index 0000000..904da3f
--- /dev/null
@@ -0,0 +1,48 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces sequences kernel compiler.tree ;
+IN: compiler.cfg.iterator
+
+SYMBOL: node-stack
+
+: >node ( cursor -- ) node-stack get push ;
+: node> ( -- cursor ) node-stack get pop ;
+: node@ ( -- cursor ) node-stack get peek ;
+: current-node ( -- node ) node@ first ;
+: iterate-next ( -- cursor ) node@ rest-slice ;
+: skip-next ( -- next ) node> rest-slice [ first ] [ >node ] bi ;
+
+: iterate-nodes ( cursor quot: ( -- ) -- )
+    over empty? [
+        2drop
+    ] [
+        [ swap >node call node> drop ] keep iterate-nodes
+    ] if ; inline recursive
+
+: with-node-iterator ( quot -- )
+    >r V{ } clone node-stack r> with-variable ; inline
+
+DEFER: (tail-call?)
+
+: tail-phi? ( cursor -- ? )
+    [ first #phi? ] [ rest-slice (tail-call?) ] bi and ;
+
+: (tail-call?) ( cursor -- ? )
+    [ t ] [
+        [
+            first
+            [ #return? ]
+            [ #return-recursive? ]
+            [ #terminate? ] tri or or
+        ] [ tail-phi? ] bi or
+    ] if-empty ;
+
+: tail-call? ( -- ? )
+    node-stack get [
+        rest-slice
+        [ t ] [
+            [ (tail-call?) ]
+            [ first #terminate? not ]
+            bi and
+        ] if-empty
+    ] all? ;
diff --git a/unfinished/compiler/cfg/kill-nops/kill-nops.factor b/unfinished/compiler/cfg/kill-nops/kill-nops.factor
deleted file mode 100644 (file)
index 56e88c3..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel compiler.vops ;
-IN: compiler.cfg.kill-nops
-
-! Smallest compiler pass ever.
-
-: kill-nops ( instructions -- instructions' )
-    [ nop? not ] filter ;
diff --git a/unfinished/compiler/cfg/live-ranges/live-ranges.factor b/unfinished/compiler/cfg/live-ranges/live-ranges.factor
deleted file mode 100644 (file)
index e6ff616..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel namespaces assocs accessors math.order sequences
-compiler.vops ;
-IN: compiler.cfg.live-ranges
-
-TUPLE: live-range from to ;
-
-! Maps vregs to live ranges
-SYMBOL: live-ranges
-
-: def ( n vreg -- )
-    [ dup live-range boa ] dip live-ranges get set-at ;
-
-: use ( n vreg -- )
-    live-ranges get at [ max ] change-to drop ;
-
-GENERIC: compute-live-ranges* ( n insn -- )
-
-M: nullary-op compute-live-ranges*
-    2drop ;
-
-M: flushable-op compute-live-ranges*
-    out>> def ;
-
-M: effect-op compute-live-ranges*
-    in>> use ;
-
-M: unary-op compute-live-ranges*
-    [ out>> def ] [ in>> use ] 2bi ;
-
-M: binary-op compute-live-ranges*
-    [ call-next-method ] [ in1>> use ] [ in2>> use ] 2tri ;
-
-M: %store compute-live-ranges*
-    [ call-next-method ] [ addr>> use ] 2bi ;
-
-: compute-live-ranges ( insns -- )
-    H{ } clone live-ranges set
-    [ swap compute-live-ranges* ] each-index ;
diff --git a/unfinished/compiler/cfg/predecessors/predecessors.factor b/unfinished/compiler/cfg/predecessors/predecessors.factor
deleted file mode 100644 (file)
index c05a425..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: compiler.cfg kernel accessors sequences ;
-IN: compiler.cfg.predecessors
-
-! Pass to compute precedecessors.
-
-: compute-predecessors ( procedure -- )
-    [
-        dup successors>>
-        [ predecessors>> push ] with each
-    ] each-block ;
diff --git a/unfinished/compiler/cfg/simplifier/simplifier.factor b/unfinished/compiler/cfg/simplifier/simplifier.factor
deleted file mode 100644 (file)
index 2e51a1a..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors sequences kernel
-compiler.cfg
-compiler.cfg.predecessors
-compiler.cfg.stack
-compiler.cfg.alias
-compiler.cfg.write-barrier
-compiler.cfg.elaboration
-compiler.cfg.vn
-compiler.cfg.vn.conditions
-compiler.cfg.kill-nops ;
-IN: compiler.cfg.simplifier
-
-: simplify ( insns -- insns' )
-    normalize-height
-    alias-analysis
-    elaboration
-    value-numbering
-    eliminate-write-barrier
-    kill-nops ;
-
-: simplify-cfg ( procedure -- procedure )
-    dup compute-predecessors
-    dup [ [ simplify ] change-instructions drop ] each-block ;
diff --git a/unfinished/compiler/cfg/stack/stack.factor b/unfinished/compiler/cfg/stack/stack.factor
deleted file mode 100644 (file)
index 43dd7a0..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors math namespaces sequences kernel fry
-compiler.vops ;
-IN: compiler.cfg.stack
-
-! Combine multiple stack height changes into one, done at the
-! start of the basic block.
-!
-! Alias analysis and value numbering assume this optimization
-! has been performed.
-
-! Current data and retain stack height is stored in
-! %data, %retain variables.
-GENERIC: compute-heights ( insn -- )
-
-M: %height compute-heights
-    [ n>> ] [ stack>> ] bi [ + ] change ;
-
-M: object compute-heights drop ;
-
-GENERIC: normalize-height* ( insn -- insn )
-
-M: %height normalize-height*
-    [ n>> ] [ stack>> ] bi [ swap - ] change nop ;
-
-: (normalize-height) ( insn -- insn )
-    dup stack>> get '[ , + ] change-n ; inline
-
-M: %peek normalize-height* (normalize-height) ;
-
-M: %replace normalize-height* (normalize-height) ;
-
-M: object normalize-height* ;
-
-: normalize-height ( insns -- insns' )
-    0 %data set
-    0 %retain set
-    [ [ compute-heights ] each ]
-    [ [ [ normalize-height* ] map ] with-scope ] bi
-    %data get dup zero? [ drop ] [ %data %height boa prefix ] if
-    %retain get dup zero? [ drop ] [ %retain %height boa prefix ] if ;
diff --git a/unfinished/compiler/cfg/stacks/authors.txt b/unfinished/compiler/cfg/stacks/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/unfinished/compiler/cfg/stacks/stacks.factor b/unfinished/compiler/cfg/stacks/stacks.factor
new file mode 100755 (executable)
index 0000000..f2cfbb7
--- /dev/null
@@ -0,0 +1,389 @@
+! Copyright (C) 2006, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: arrays assocs classes classes.private classes.algebra
+combinators hashtables kernel layouts math fry namespaces
+quotations sequences system vectors words effects alien
+byte-arrays accessors sets math.order compiler.instructions
+compiler.registers ;
+IN: compiler.cfg.stacks
+
+! Converting stack operations into register operations, while
+! doing a bit of optimization along the way.
+
+USE: qualified
+FROM: compiler.generator.registers => +input+   ;
+FROM: compiler.generator.registers => +output+  ;
+FROM: compiler.generator.registers => +scratch+ ;
+FROM: compiler.generator.registers => +clobber+ ;
+SYMBOL: known-tag
+
+! Value protocol
+GENERIC: set-operand-class ( class obj -- )
+GENERIC: operand-class* ( operand -- class )
+GENERIC: move-spec ( obj -- spec )
+GENERIC: live-loc? ( actual current -- ? )
+GENERIC# (lazy-load) 1 ( value spec -- value )
+GENERIC# (eager-load) 1 ( value spec -- value )
+GENERIC: lazy-store ( dst src -- )
+GENERIC: minimal-ds-loc* ( min obj -- min )
+
+! This will be a multimethod soon
+DEFER: %move
+
+PRIVATE>
+
+: operand-class ( operand -- class )
+    operand-class* object or ;
+
+! Default implementation
+M: value set-operand-class 2drop ;
+M: value operand-class* drop f ;
+M: value live-loc? 2drop f ;
+M: value minimal-ds-loc* drop ;
+M: value lazy-store 2drop ;
+
+M: vreg move-spec reg-class>> move-spec ;
+
+M: int-regs move-spec drop f ;
+M: int-regs operand-class* drop object ;
+
+M: float-regs move-spec drop float ;
+M: float-regs operand-class* drop float ;
+
+M: ds-loc minimal-ds-loc* n>> min ;
+M: ds-loc live-loc?
+    over ds-loc? [ [ n>> ] bi@ = not ] [ 2drop t ] if ;
+
+M: rs-loc live-loc?
+    over rs-loc? [ [ n>> ] bi@ = not ] [ 2drop t ] if ;
+
+M: loc operand-class* class>> ;
+M: loc set-operand-class (>>class) ;
+M: loc move-spec drop loc ;
+
+M: f move-spec drop loc ;
+M: f operand-class* ;
+
+M: cached set-operand-class vreg>> set-operand-class ;
+M: cached operand-class* vreg>> operand-class* ;
+M: cached move-spec drop cached ;
+M: cached live-loc? loc>> live-loc? ;
+M: cached (lazy-load) >r vreg>> r> (lazy-load) ;
+M: cached (eager-load) >r vreg>> r> (eager-load) ;
+M: cached lazy-store
+    2dup loc>> live-loc?
+    [ "live-locs" get at %move ] [ 2drop ] if ;
+M: cached minimal-ds-loc* loc>> minimal-ds-loc* ;
+
+M: tagged set-operand-class (>>class) ;
+M: tagged operand-class* class>> ;
+M: tagged move-spec drop f ;
+
+M: unboxed-alien operand-class* drop simple-alien ;
+M: unboxed-alien move-spec class ;
+
+M: unboxed-byte-array operand-class* drop c-ptr ;
+M: unboxed-byte-array move-spec class ;
+
+M: unboxed-f operand-class* drop \ f ;
+M: unboxed-f move-spec class ;
+
+M: unboxed-c-ptr operand-class* drop c-ptr ;
+M: unboxed-c-ptr move-spec class ;
+
+M: constant operand-class* value>> class ;
+M: constant move-spec class ;
+
+! Moving values between locations and registers
+: %move-bug ( -- * ) "Bug in generator.registers" throw ;
+
+: %unbox-c-ptr ( dst src -- )
+    dup operand-class {
+        { [ dup \ f class<= ] [ drop %unbox-f ] }
+        { [ dup simple-alien class<= ] [ drop %unbox-alien ] }
+        { [ dup byte-array class<= ] [ drop %unbox-byte-array ] }
+        [ drop %unbox-any-c-ptr ]
+    } cond ; inline
+
+: %move-via-temp ( dst src -- )
+    #! For many transfers, such as loc to unboxed-alien, we
+    #! don't have an intrinsic, so we transfer the source to
+    #! temp then temp to the destination.
+    int-regs next-vreg [ over %move operand-class ] keep
+    tagged new
+        swap >>vreg
+        swap >>class
+    %move ;
+
+: %move ( dst src -- )
+    2dup [ move-spec ] bi@ 2array {
+        { { f f } [ %copy ] }
+        { { unboxed-alien unboxed-alien } [ %copy ] }
+        { { unboxed-byte-array unboxed-byte-array } [ %copy ] }
+        { { unboxed-f unboxed-f } [ %copy ] }
+        { { unboxed-c-ptr unboxed-c-ptr } [ %copy ] }
+        { { float float } [ %copy-float ] }
+
+        { { f unboxed-c-ptr } [ %move-bug ] }
+        { { f unboxed-byte-array } [ %move-bug ] }
+
+        { { f constant } [ value>> swap %load-literal ] }
+
+        { { f float } [ %box-float ] }
+        { { f unboxed-alien } [ %box-alien ] }
+        { { f loc } [ %peek ] }
+
+        { { float f } [ %unbox-float ] }
+        { { unboxed-alien f } [ %unbox-alien ] }
+        { { unboxed-byte-array f } [ %unbox-byte-array ] }
+        { { unboxed-f f } [ %unbox-f ] }
+        { { unboxed-c-ptr f } [ %unbox-c-ptr ] }
+        { { loc f } [ swap %replace ] }
+
+        [ drop %move-via-temp ]
+    } case ;
+
+! A compile-time stack
+TUPLE: phantom-stack height stack ;
+
+M: phantom-stack clone
+    call-next-method [ clone ] change-stack ;
+
+GENERIC: finalize-height ( stack -- )
+
+: new-phantom-stack ( class -- stack )
+    >r 0 V{ } clone r> boa ; inline
+
+: (loc) ( m stack -- n )
+    #! Utility for methods on <loc>
+    height>> - ;
+
+: (finalize-height) ( stack word -- )
+    #! We consolidate multiple stack height changes until the
+    #! last moment, and we emit the final height changing
+    #! instruction here.
+    '[ dup zero? [ drop ] [ _ execute ] if 0 ] change-height drop ; inline
+
+GENERIC: <loc> ( n stack -- loc )
+
+TUPLE: phantom-datastack < phantom-stack ;
+
+: <phantom-datastack> ( -- stack )
+    phantom-datastack new-phantom-stack ;
+
+M: phantom-datastack <loc> (loc) <ds-loc> ;
+
+M: phantom-datastack finalize-height
+    \ %inc-d (finalize-height) ;
+
+TUPLE: phantom-retainstack < phantom-stack ;
+
+: <phantom-retainstack> ( -- stack )
+    phantom-retainstack new-phantom-stack ;
+
+M: phantom-retainstack <loc> (loc) <rs-loc> ;
+
+M: phantom-retainstack finalize-height
+    \ %inc-r (finalize-height) ;
+
+: phantom-locs ( n phantom -- locs )
+    #! A sequence of n ds-locs or rs-locs indexing the stack.
+    >r <reversed> r> '[ _ <loc> ] map ;
+
+: phantom-locs* ( phantom -- locs )
+    [ stack>> length ] keep phantom-locs ;
+
+: phantoms ( -- phantom phantom )
+    phantom-datastack get phantom-retainstack get ;
+
+: (each-loc) ( phantom quot -- )
+    >r [ phantom-locs* ] [ stack>> ] bi r> 2each ; inline
+
+: each-loc ( quot -- )
+    phantoms 2array swap '[ _ (each-loc) ] each ; inline
+
+: adjust-phantom ( n phantom -- )
+    swap '[ _ + ] change-height drop ;
+
+: cut-phantom ( n phantom -- seq )
+    swap '[ _ cut* swap ] change-stack drop ;
+
+: phantom-append ( seq stack -- )
+    over length over adjust-phantom stack>> push-all ;
+
+: add-locs ( n phantom -- )
+    2dup stack>> length <= [
+        2drop
+    ] [
+        [ phantom-locs ] keep
+        [ stack>> length head-slice* ] keep
+        [ append >vector ] change-stack drop
+    ] if ;
+
+: phantom-input ( n phantom -- seq )
+    2dup add-locs
+    2dup cut-phantom
+    >r >r neg r> adjust-phantom r> ;
+
+: each-phantom ( quot -- ) phantoms rot bi@ ; inline
+
+: finalize-heights ( -- ) [ finalize-height ] each-phantom ;
+
+: (live-locs) ( phantom -- seq )
+    #! Discard locs which haven't moved
+    [ phantom-locs* ] [ stack>> ] bi zip
+    [ live-loc? ] assoc-filter
+    values ;
+
+: live-locs ( -- seq )
+    [ (live-locs) ] each-phantom append prune ;
+
+! Operands holding pointers to freshly-allocated objects which
+! are guaranteed to be in the nursery
+SYMBOL: fresh-objects
+
+: reg-spec>class ( spec -- class )
+    float eq? double-float-regs int-regs ? ;
+
+: alloc-vreg ( spec -- reg )
+    [ reg-spec>class next-vreg ] keep {
+        { f [ <tagged> ] }
+        { unboxed-alien [ <unboxed-alien> ] }
+        { unboxed-byte-array [ <unboxed-byte-array> ] }
+        { unboxed-f [ <unboxed-f> ] }
+        { unboxed-c-ptr [ <unboxed-c-ptr> ] }
+        [ drop ]
+    } case ;
+
+: compatible? ( value spec -- ? )
+    >r move-spec r> {
+        { [ 2dup = ] [ t ] }
+        { [ dup unboxed-c-ptr eq? ] [
+            over { unboxed-byte-array unboxed-alien } member?
+        ] }
+        [ f ]
+    } cond 2nip ;
+
+: alloc-vreg-for ( value spec -- vreg )
+    alloc-vreg swap operand-class
+    over tagged? [ >>class ] [ drop ] if ;
+
+M: value (lazy-load)
+    {
+        { [ dup quotation? ] [ drop ] }
+        { [ 2dup compatible? ] [ drop ] }
+        [ (eager-load) ]
+    } cond ;
+
+M: value (eager-load) ( value spec -- vreg )
+    [ alloc-vreg-for ] [ drop ] 2bi
+    [ %move ] [ drop ] 2bi ;
+
+M: loc lazy-store
+    2dup live-loc? [ "live-locs" get at %move ] [ 2drop ] if ;
+
+: finalize-locs ( -- )
+    #! Perform any deferred stack shuffling.
+    live-locs [ dup f (lazy-load) ] H{ } map>assoc
+    dup assoc-empty? [ drop ] [
+        "live-locs" set [ lazy-store ] each-loc
+    ] if ;
+
+: finalize-vregs ( -- )
+    #! Store any vregs to their final stack locations.
+    [
+        dup loc? over cached? or [ 2drop ] [ %move ] if
+    ] each-loc ;
+
+: reset-phantom ( phantom -- )
+    #! Kill register assignments but preserve constants and
+    #! class information.
+    dup phantom-locs*
+    over stack>> [
+        dup constant? [ nip ] [
+            operand-class over set-operand-class
+        ] if
+    ] 2map
+    over stack>> delete-all
+    swap stack>> push-all ;
+
+: reset-phantoms ( -- )
+    [ reset-phantom ] each-phantom ;
+
+: finalize-contents ( -- )
+    finalize-locs finalize-vregs reset-phantoms ;
+
+! Loading stacks to vregs
+: vreg-substitution ( value vreg -- pair )
+    dupd <cached> 2array ;
+
+: substitute-vreg? ( old new -- ? )
+    #! We don't substitute locs for float or alien vregs,
+    #! since in those cases the boxing overhead might kill us.
+    vreg>> tagged? >r loc? r> and ;
+
+: substitute-vregs ( values vregs -- )
+    [ vreg-substitution ] 2map
+    [ substitute-vreg? ] assoc-filter >hashtable
+    '[ stack>> _ substitute-here ] each-phantom ;
+
+: clear-phantoms ( -- )
+    [ stack>> delete-all ] each-phantom ;
+
+: set-operand-classes ( classes -- )
+    phantom-datastack get
+    over length over add-locs
+    stack>> [ set-operand-class ] 2reverse-each ;
+
+: finalize-phantoms ( -- )
+    #! Commit all deferred stacking shuffling, and ensure the
+    #! in-memory data and retain stacks are up to date with
+    #! respect to the compiler's current picture.
+    finalize-contents
+    clear-phantoms
+    finalize-heights
+    fresh-objects get [ empty? [ %gc ] unless ] [ delete-all ] bi ;
+
+: fresh-object ( obj -- ) fresh-objects get push ;
+
+: fresh-object? ( obj -- ? ) fresh-objects get memq? ;
+
+: init-phantoms ( -- )
+    V{ } clone fresh-objects set
+    <phantom-datastack> phantom-datastack set
+    <phantom-retainstack> phantom-retainstack set ;
+
+: copy-phantoms ( -- )
+    fresh-objects [ clone ] change
+    phantom-datastack [ clone ] change
+    phantom-retainstack [ clone ] change ;
+
+: operand-tag ( operand -- tag/f )
+    operand-class dup [ class-tag ] when ;
+
+UNION: immediate fixnum POSTPONE: f ;
+
+: operand-immediate? ( operand -- ? )
+    operand-class immediate class<= ;
+
+: phantom-push ( obj -- )
+    1 phantom-datastack get adjust-phantom
+    phantom-datastack get stack>> push ;
+
+: phantom-shuffle ( shuffle -- )
+    [ in>> length phantom-datastack get phantom-input ] keep
+    shuffle phantom-datastack get phantom-append ;
+
+: phantom->r ( n -- )
+    phantom-datastack get phantom-input
+    phantom-retainstack get phantom-append ;
+
+: phantom-r> ( n -- )
+    phantom-retainstack get phantom-input
+    phantom-datastack get phantom-append ;
+
+: phantom-drop ( n -- )
+    phantom-datastack get phantom-input drop ;
+
+: phantom-rdrop ( n -- )
+    phantom-retainstack get phantom-input drop ;
diff --git a/unfinished/compiler/cfg/summary.txt b/unfinished/compiler/cfg/summary.txt
deleted file mode 100644 (file)
index eac58ba..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Low-level optimizer operating on control flow graph SSA IR
diff --git a/unfinished/compiler/cfg/templates/templates.factor b/unfinished/compiler/cfg/templates/templates.factor
new file mode 100644 (file)
index 0000000..798e1fd
--- /dev/null
@@ -0,0 +1,103 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs accessors sequences kernel fry namespaces
+quotations combinators classes.algebra compiler.instructions
+compiler.registers compiler.cfg.stacks ;
+IN: compiler.cfg.templates
+
+USE: qualified
+FROM: compiler.generator.registers => +input+   ;
+FROM: compiler.generator.registers => +output+  ;
+FROM: compiler.generator.registers => +scratch+ ;
+FROM: compiler.generator.registers => +clobber+ ;
+
+: template-input +input+ swap at ; inline
+: template-output +output+ swap at ; inline
+: template-scratch +scratch+ swap at ; inline
+: template-clobber +clobber+ swap at ; inline
+
+: phantom&spec ( phantom specs -- phantom' specs' )
+    >r stack>> r>
+    [ length f pad-left ] keep
+    [ <reversed> ] bi@ ; inline
+
+: phantom&spec-agree? ( phantom spec quot -- ? )
+    >r phantom&spec r> 2all? ; inline
+
+: live-vregs ( -- seq )
+    [ stack>> [ >vreg ] map sift ] each-phantom append ;
+
+: clobbered ( template -- seq )
+    [ template-output ] [ template-clobber ] bi append ;
+
+: clobbered? ( value name -- ? )
+    \ clobbered get member? [
+        >vreg \ live-vregs get member?
+    ] [ drop f ] if ;
+
+: lazy-load ( specs -- seq )
+    [ length phantom-datastack get phantom-input ] keep
+    [ drop ] [
+        [
+            2dup second clobbered?
+            [ first (eager-load) ] [ first (lazy-load) ] if
+        ] 2map
+    ] 2bi
+    [ substitute-vregs ] keep ;
+
+: load-inputs ( template -- assoc )
+    [
+        live-vregs \ live-vregs set
+        dup clobbered \ clobbered set
+        template-input [ values ] [ lazy-load ] bi zip
+    ] with-scope ;
+
+: alloc-scratch ( template -- assoc )
+    template-scratch [ swap alloc-vreg ] assoc-map ;
+
+: do-template-inputs ( template -- inputs )
+    #! Load input values into registers and allocates scratch
+    #! registers.
+    [ load-inputs ] [ alloc-scratch ] bi assoc-union ;
+
+: do-template-outputs ( template inputs -- )
+    [ template-output ] dip '[ _ at ] map
+    phantom-datastack get phantom-append ;
+
+: apply-template ( pair quot -- vregs )
+    [
+        first2 dup do-template-inputs
+        [ do-template-outputs ] keep
+    ] dip call ; inline
+
+: value-matches? ( value spec -- ? )
+    #! If the spec is a quotation and the value is a literal
+    #! fixnum, see if the quotation yields true when applied
+    #! to the fixnum. Otherwise, the values don't match. If the
+    #! spec is not a quotation, its a reg-class, in which case
+    #! the value is always good.
+    dup quotation? [
+        over constant?
+        [ >r value>> r> 2drop f ] [ 2drop f ] if
+    ] [
+        2drop t
+    ] if ;
+
+: class-matches? ( actual expected -- ? )
+    {
+        { f [ drop t ] }
+        { known-tag [ dup [ class-tag >boolean ] when ] }
+        [ class<= ]
+    } case ;
+
+: spec-matches? ( value spec -- ? )
+    2dup first value-matches?
+    >r >r operand-class 2 r> ?nth class-matches? r> and ;
+
+: template-matches? ( template -- ? )
+    template-input phantom-datastack get swap
+    [ spec-matches? ] phantom&spec-agree? ;
+
+: find-template ( templates -- pair/f )
+    #! Pair has shape { quot assoc }
+    [ second template-matches? ] find nip ;
diff --git a/unfinished/compiler/cfg/vn/conditions/conditions.factor b/unfinished/compiler/cfg/vn/conditions/conditions.factor
deleted file mode 100644 (file)
index 259e823..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel sequences layouts accessors compiler.vops
-compiler.cfg.vn.graph
-compiler.cfg.vn.expressions
-compiler.cfg.vn.liveness
-compiler.cfg.vn ;
-IN: compiler.cfg.vn.conditions
-
-! The CFG generator produces naive code for the following code
-! sequence:
-!
-! fixnum< [ ... ] [ ... ] if
-!
-! The fixnum< comparison generates a boolean, which is then
-! tested against f.
-!
-! Using value numbering, we optimize the comparison of a boolean
-! against f where the boolean is the result of comparison.
-
-: expr-f? ( expr -- ? )
-    dup op>> %iconst eq?
-    [ value>> \ f tag-number = ] [ drop f ] if ;
-
-: comparison-with-f? ( insn -- expr/f ? )
-    #! The expr is a binary-op %icmp or %fcmp.
-    dup code>> cc/= eq? [
-        in>> vreg>vn vn>expr dup in2>> vn>expr expr-f?
-    ] [ drop f f ] if ;
-
-: of-boolean? ( expr -- expr/f ? )
-    #! The expr is a binary-op %icmp or %fcmp.
-    in1>> vn>expr dup op>> { %%iboolean %%fboolean } memq? ;
-
-: original-comparison ( expr -- in/f code/f )
-    [ in>> vn>vreg ] [ code>> ] bi ;
-
-: eliminate-boolean ( insn -- in/f code/f )
-    comparison-with-f? [
-        of-boolean? [
-            original-comparison
-        ] [ drop f f ] if
-    ] [ drop f f ] if ;
-
-M: cond-branch make-value-node
-    #! If the conditional branch is testing the result of an
-    #! earlier comparison against f, we only mark as live the
-    #! earlier comparison, so DCE will eliminate the boolean.
-    dup eliminate-boolean drop swap in>> or live-vreg ;
-M: cond-branch eliminate
-    dup eliminate-boolean dup
-    [ [ >>in ] [ >>code ] bi* ] [ 2drop ] if ;
diff --git a/unfinished/compiler/cfg/vn/constant-fold/constant-fold.factor b/unfinished/compiler/cfg/vn/constant-fold/constant-fold.factor
deleted file mode 100644 (file)
index f30a55d..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel compiler.vops compiler.cfg.vn.graph
-compiler.cfg.vn.expressions ;
-IN: compiler.cfg.vn.constant-fold
-
-GENERIC: constant-fold ( insn -- insn' )
-
-M: vop constant-fold ;
-
-: expr>insn ( out constant-expr -- constant-op )
-    [ value>> ] [ op>> ] bi new swap >>value swap >>out ;
-
-M: pure-op constant-fold
-    dup out>>
-    dup vreg>vn vn>expr
-    dup constant-expr? [ expr>insn nip ] [ 2drop ] if ;
diff --git a/unfinished/compiler/cfg/vn/expressions/expressions.factor b/unfinished/compiler/cfg/vn/expressions/expressions.factor
deleted file mode 100644 (file)
index 7b84c01..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors classes kernel math namespaces sorting
-compiler.vops compiler.cfg.vn.graph ;
-IN: compiler.cfg.vn.expressions
-
-! Referentially-transparent expressions
-TUPLE: expr op ;
-TUPLE: nullary-expr < expr ;
-TUPLE: unary-expr < expr in ;
-TUPLE: binary-expr < expr in1 in2 ;
-TUPLE: commutative-expr < binary-expr ;
-TUPLE: boolean-expr < unary-expr code ;
-TUPLE: constant-expr < expr value ;
-TUPLE: literal-expr < unary-expr object ;
-
-! op is always %peek
-TUPLE: peek-expr < expr loc ;
-
-SYMBOL: input-expr-counter
-
-: next-input-expr ( -- n )
-    input-expr-counter [ dup 1 + ] change ;
-
-! Expressions whose values are inputs to the basic block. We
-! can eliminate a second computation having the same 'n' as
-! the first one; we can also eliminate input-exprs whose
-! result is not used.
-TUPLE: input-expr < expr n ;
-
-GENERIC: >expr ( insn -- expr )
-
-M: %literal-table >expr
-    class nullary-expr boa ;
-
-M: constant-op >expr
-    [ class ] [ value>> ] bi constant-expr boa ;
-
-M: %literal >expr
-    [ class ] [ in>> vreg>vn ] [ object>> ] tri literal-expr boa ;
-
-M: unary-op >expr
-    [ class ] [ in>> vreg>vn ] bi unary-expr boa ;
-
-M: binary-op >expr
-    [ class ] [ in1>> vreg>vn ] [ in2>> vreg>vn ] tri
-    binary-expr boa ;
-
-M: commutative-op >expr
-    [ class ] [ in1>> vreg>vn ] [ in2>> vreg>vn ] tri
-    sort-pair commutative-expr boa ;
-
-M: boolean-op >expr
-    [ class ] [ in>> vreg>vn ] [ code>> ] tri
-    boolean-expr boa ;
-
-M: %peek >expr
-    [ class ] [ stack-loc ] bi peek-expr boa ;
-
-M: flushable-op >expr
-    class next-input-expr input-expr boa ;
-
-: init-expressions ( -- )
-    0 input-expr-counter set ;
diff --git a/unfinished/compiler/cfg/vn/graph/graph.factor b/unfinished/compiler/cfg/vn/graph/graph.factor
deleted file mode 100644 (file)
index ef5d7c2..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math namespaces assocs biassocs accessors
-math.order prettyprint.backend parser ;
-IN: compiler.cfg.vn.graph
-
-TUPLE: vn n ;
-
-SYMBOL: vn-counter
-
-: next-vn ( -- vn ) vn-counter [ dup 1 + ] change vn boa ;
-
-: VN: scan-word vn boa parsed ; parsing
-
-M: vn <=> [ n>> ] compare ;
-
-M: vn pprint* \ VN: pprint-word n>> pprint* ;
-
-! biassoc mapping expressions to value numbers
-SYMBOL: exprs>vns
-
-: expr>vn ( expr -- vn ) exprs>vns get [ drop next-vn ] cache ;
-
-: vn>expr ( vn -- expr ) exprs>vns get value-at ;
-
-SYMBOL: vregs>vns
-
-: vreg>vn ( vreg -- vn ) vregs>vns get at ;
-
-: vn>vreg ( vn -- vreg ) vregs>vns get value-at ;
-
-: set-vn ( vn vreg -- ) vregs>vns get set-at ;
-
-: init-value-graph ( -- )
-    0 vn-counter set
-    <bihash> exprs>vns set
-    <bihash> vregs>vns set ;
diff --git a/unfinished/compiler/cfg/vn/liveness/liveness.factor b/unfinished/compiler/cfg/vn/liveness/liveness.factor
deleted file mode 100644 (file)
index 4a218d4..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces kernel assocs sets accessors compiler.vops
-compiler.cfg.vn.graph compiler.cfg.vn.expressions ;
-IN: compiler.cfg.vn.liveness
-
-! A set of VNs which are (transitively) used by effect-ops. This
-! is precisely the set of VNs whose value is needed outside of
-! the basic block.
-SYMBOL: live-vns
-
-GENERIC: live-expr ( expr -- )
-
-: live-vn ( vn -- )
-    #! Mark a VN and all VNs used in its computation as live.
-    dup live-vns get key? [ drop ] [
-        [ live-vns get conjoin ] [ vn>expr live-expr ] bi
-    ] if ;
-
-: live-vreg ( vreg -- ) vreg>vn live-vn ;
-
-M: expr live-expr drop ;
-M: literal-expr live-expr in>> live-vn ;
-M: unary-expr live-expr in>> live-vn ;
-M: binary-expr live-expr [ in1>> live-vn ] [ in2>> live-vn ] bi ;
-
-: live? ( vreg -- ? )
-    dup vreg>vn tuck vn>vreg =
-    [ live-vns get key? ] [ drop f ] if ;
-
-: init-liveness ( -- )
-    H{ } clone live-vns set ;
-
-GENERIC: eliminate ( insn -- insn' )
-
-M: flushable-op eliminate dup out>> live? ?nop ;
-M: vop eliminate ;
diff --git a/unfinished/compiler/cfg/vn/propagate/propagate.factor b/unfinished/compiler/cfg/vn/propagate/propagate.factor
deleted file mode 100644 (file)
index 75ada5f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces assocs sequences kernel accessors
-compiler.vops
-compiler.cfg.vn.graph ;
-IN: compiler.cfg.vn.propagate
-
-! If two vregs compute the same value, replace references to
-! the latter with the former.
-
-: resolve ( vreg -- vreg' ) vreg>vn vn>vreg ;
-
-GENERIC: propogate ( insn -- insn )
-
-M: effect-op propogate
-    [ resolve ] change-in ;
-
-M: unary-op propogate
-    [ resolve ] change-in ;
-
-M: binary-op propogate
-    [ resolve ] change-in1
-    [ resolve ] change-in2 ;
-
-M: %phi propogate
-    [ [ resolve ] map ] change-in ;
-
-M: %%slot propogate
-    [ resolve ] change-obj
-    [ resolve ] change-slot ;
-
-M: %%set-slot propogate
-    call-next-method
-    [ resolve ] change-obj
-    [ resolve ] change-slot ;
-
-M: %store propogate
-    call-next-method
-    [ resolve ] change-addr ;
-
-M: nullary-op propogate ;
-
-M: flushable-op propogate ;
diff --git a/unfinished/compiler/cfg/vn/simplify/simplify.factor b/unfinished/compiler/cfg/vn/simplify/simplify.factor
deleted file mode 100644 (file)
index f16f3e3..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors combinators classes math math.order
-layouts locals
-compiler.vops
-compiler.cfg.vn.graph
-compiler.cfg.vn.expressions ;
-IN: compiler.cfg.vn.simplify
-
-! Return value of f means we didn't simplify.
-GENERIC: simplify* ( expr -- vn/expr/f )
-
-: constant ( val type -- expr ) swap constant-expr boa ;
-
-: simplify-not ( in -- vn/expr/f )
-    {
-        { [ dup constant-expr? ] [ value>> bitnot %iconst constant ] }
-        { [ dup op>> %not = ] [ in>> ] }
-        [ drop f ]
-    } cond ;
-
-: simplify-box-float ( in -- vn/expr/f )
-    {
-        { [ dup op>> %%unbox-float = ] [ in>> ] }
-        [ drop f ]
-    } cond ;
-
-: simplify-unbox-float ( in -- vn/expr/f )
-    {
-        { [ dup literal-expr? ] [ object>> %fconst constant ] }
-        { [ dup op>> %%box-float = ] [ in>> ] }
-        [ drop f ]
-    } cond ;
-
-M: unary-expr simplify*
-    #! Note the copy propagation: a %copy always simplifies to
-    #! its source vn.
-    [ in>> vn>expr ] [ op>> ] bi {
-        { %copy [ ] }
-        { %not [ simplify-not ] }
-        { %%box-float [ simplify-box-float ] }
-        { %%unbox-float [ simplify-unbox-float ] }
-        [ 2drop f ]
-    } case ;
-
-: izero? ( expr -- ? ) T{ constant-expr f %iconst 0 } = ;
-
-: ione? ( expr -- ? ) T{ constant-expr f %iconst 1 } = ;
-
-: ineg-one? ( expr -- ? ) T{ constant-expr f %iconst -1 } = ;
-
-: fzero? ( expr -- ? ) T{ constant-expr f %fconst 0 } = ;
-
-: fone? ( expr -- ? ) T{ constant-expr f %fconst 1 } = ;
-
-: fneg-one? ( expr -- ? ) T{ constant-expr f %fconst -1 } = ;
-
-: identity ( in1 in2 val type -- expr ) constant 2nip ;
-
-: constant-fold? ( in1 in2 -- ? )
-    [ constant-expr? ] both? ;
-
-:: constant-fold ( in1 in2 quot type -- expr )
-    in1 in2 constant-fold?
-    [ in1 value>> in2 value>> quot call type constant ]
-    [ f ]
-    if ; inline
-
-: simplify-iadd ( in1 in2 -- vn/expr/f )
-    {
-        { [ over izero? ] [ nip ] }
-        { [ dup izero? ] [ drop ] }
-        [ [ + ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-imul ( in1 in2 -- vn/expr/f )
-    {
-        { [ over ione? ] [ nip ] }
-        { [ dup ione? ] [ drop ] }
-        [ [ * ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-and ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ 0 %iconst identity ] }
-        { [ dup ineg-one? ] [ drop ] }
-        { [ 2dup = ] [ drop ] }
-        [ [ bitand ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-or ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        { [ dup ineg-one? ] [ -1 %iconst identity ] }
-        { [ 2dup = ] [ drop ] }
-        [ [ bitor ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-xor ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        [ [ bitxor ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-fadd ( in1 in2 -- vn/expr/f )
-    {
-        { [ over fzero? ] [ nip ] }
-        { [ dup fzero? ] [ drop ] }
-        [ [ + ] %fconst constant-fold ]
-    } cond ;
-
-: simplify-fmul ( in1 in2 -- vn/expr/f )
-    {
-        { [ over fone? ] [ nip ] }
-        { [ dup fone? ] [ drop ] }
-        [ [ * ] %fconst constant-fold ]
-    } cond ;
-
-: commutative-operands ( expr -- in1 in2 )
-    [ in1>> vn>expr ] [ in2>> vn>expr ] bi
-    over constant-expr? [ swap ] when ;
-
-M: commutative-expr simplify*
-    [ commutative-operands ] [ op>> ] bi {
-        { %iadd [ simplify-iadd ] }
-        { %imul [ simplify-imul ] }
-        { %and [ simplify-and ] }
-        { %or [ simplify-or ] }
-        { %xor [ simplify-xor ] }
-        { %fadd [ simplify-fadd ] }
-        { %fmul [ simplify-fmul ] }
-        [ 3drop f ]
-    } case ;
-
-: simplify-isub ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        { [ 2dup = ] [ 0 %iconst identity ] }
-        [ [ - ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-idiv ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup ione? ] [ drop ] }
-        [ [ /i ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-imod ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup ione? ] [ 0 %iconst identity ] }
-        { [ 2dup = ] [ 0 %iconst identity ] }
-        [ [ mod ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-shl ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        { [ over izero? ] [ drop ] }
-        [ [ shift ] %iconst constant-fold ]
-    } cond ;
-
-: unsigned ( n -- n' )
-    cell-bits 2^ 1- bitand ;
-
-: useless-shift? ( in1 in2 -- ? )
-    over op>> %shl = [ [ in2>> ] [ expr>vn ] bi* = ] [ 2drop f ] if ;
-
-: simplify-shr ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        { [ over izero? ] [ drop ] }
-        { [ 2dup useless-shift? ] [ drop in1>> ] }
-        [ [ neg shift unsigned ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-sar ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        { [ over izero? ] [ drop ] }
-        { [ 2dup useless-shift? ] [ drop in1>> ] }
-        [ [ neg shift ] %iconst constant-fold ]
-    } cond ;
-
-: simplify-icmp ( in1 in2 -- vn/expr/f )
-    = [ +eq+ %cconst constant ] [ f ] if ;
-
-: simplify-fsub ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup izero? ] [ drop ] }
-        [ [ - ] %fconst constant-fold ]
-    } cond ;
-
-: simplify-fdiv ( in1 in2 -- vn/expr/f )
-    {
-        { [ dup fone? ] [ drop ] }
-        [ [ /i ] %fconst constant-fold ]
-    } cond ;
-
-M: binary-expr simplify*
-    [ in1>> vn>expr ] [ in2>> vn>expr ] [ op>> ] tri {
-        { %isub [ simplify-isub ] }
-        { %idiv [ simplify-idiv ] }
-        { %imod [ simplify-imod ] }
-        { %shl [ simplify-shl ] }
-        { %shr [ simplify-shr ] }
-        { %sar [ simplify-sar ] }
-        { %icmp [ simplify-icmp ] }
-        { %fsub [ simplify-fsub ] }
-        { %fdiv [ simplify-fdiv ] }
-        [ 3drop f ]
-    } case ;
-
-M: expr simplify* drop f ;
-
-: simplify ( expr -- vn )
-    dup simplify* {
-        { [ dup not ] [ drop expr>vn ] }
-        { [ dup expr? ] [ expr>vn nip ] }
-        { [ dup vn? ] [ nip ] }
-    } cond ;
diff --git a/unfinished/compiler/cfg/vn/vn.factor b/unfinished/compiler/cfg/vn/vn.factor
deleted file mode 100644 (file)
index e16fff0..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: namespaces assocs biassocs classes kernel math accessors
-sorting sets sequences compiler.vops
-compiler.cfg.vn.graph
-compiler.cfg.vn.expressions
-compiler.cfg.vn.simplify
-compiler.cfg.vn.liveness
-compiler.cfg.vn.constant-fold
-compiler.cfg.vn.propagate ;
-IN: compiler.cfg.vn
-
-: insn>vn ( insn -- vn ) >expr simplify ; inline
-
-GENERIC: make-value-node ( insn -- )
-M: flushable-op make-value-node [ insn>vn ] [ out>> ] bi set-vn ;
-M: effect-op make-value-node in>> live-vreg ;
-M: %store make-value-node [ in>> live-vreg ] [ addr>> live-vreg ] bi ;
-M: %%set-slot make-value-node [ in>> live-vreg ] [ obj>> live-vreg ] bi ;
-M: nullary-op make-value-node drop ;
-
-: init-value-numbering ( -- )
-    init-value-graph
-    init-expressions
-    init-liveness ;
-
-: value-numbering ( instructions -- instructions )
-    init-value-numbering
-    [ [ make-value-node ] each ]
-    [ [ eliminate constant-fold propogate ] map ]
-    bi ;
diff --git a/unfinished/compiler/cfg/write-barrier/write-barrier.factor b/unfinished/compiler/cfg/write-barrier/write-barrier.factor
deleted file mode 100644 (file)
index f42f377..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors namespaces assocs sets sequences
-compiler.vops compiler.cfg ;
-IN: compiler.cfg.write-barrier
-
-! Eliminate redundant write barrier hits.
-SYMBOL: hits
-
-GENERIC: eliminate-write-barrier* ( insn -- insn' )
-
-M: %%allot eliminate-write-barrier*
-    dup out>> hits get conjoin ;
-
-M: %write-barrier eliminate-write-barrier*
-    dup in>> hits get key?
-    [ drop nop ] [ dup in>> hits get conjoin ] if ;
-
-M: %copy eliminate-write-barrier*
-    dup in/out hits get copy-at ;
-
-M: vop eliminate-write-barrier* ;
-
-: eliminate-write-barrier ( insns -- insns )
-    H{ } clone hits set
-    [ eliminate-write-barrier* ] map ;
diff --git a/unfinished/compiler/codegen/fixup/authors.txt b/unfinished/compiler/codegen/fixup/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/unfinished/compiler/codegen/fixup/fixup.factor b/unfinished/compiler/codegen/fixup/fixup.factor
new file mode 100755 (executable)
index 0000000..1f1cf81
--- /dev/null
@@ -0,0 +1,154 @@
+! 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 cpu.architecture
+math.order accessors growable ;
+IN: compiler.cfg.fixup
+
+: no-stack-frame -1 ; inline
+
+TUPLE: frame-required n ;
+
+: frame-required ( n -- ) \ frame-required boa , ;
+
+: stack-frame-size ( code -- n )
+    no-stack-frame [
+        dup frame-required? [ n>> max ] [ drop ] if
+    ] reduce ;
+
+GENERIC: fixup* ( frame-size obj -- frame-size )
+
+: code-format 22 getenv ;
+
+: compiled-offset ( -- n ) building get length code-format * ;
+
+TUPLE: label offset ;
+
+: <label> ( -- label ) label new ;
+
+M: label fixup*
+    compiled-offset >>offset drop ;
+
+: define-label ( name -- ) <label> swap set ;
+
+: resolve-label ( label/name -- ) dup label? [ get ] unless , ;
+
+: if-stack-frame ( frame-size quot -- )
+    swap dup no-stack-frame =
+    [ 2drop ] [ stack-frame swap call ] if ; inline
+
+M: word fixup*
+    {
+        { \ %prologue-later [ dup [ %prologue ] if-stack-frame ] }
+        { \ %epilogue-later [ dup [ %epilogue ] if-stack-frame ] }
+    } case ;
+
+SYMBOL: relocation-table
+SYMBOL: label-table
+
+! Relocation classes
+: rc-absolute-cell     0 ;
+: rc-absolute          1 ;
+: rc-relative          2 ;
+: rc-absolute-ppc-2/2  3 ;
+: rc-relative-ppc-2    4 ;
+: rc-relative-ppc-3    5 ;
+: rc-relative-arm-3    6 ;
+: rc-indirect-arm      7 ;
+: rc-indirect-arm-pc   8 ;
+
+: rc-absolute? ( n -- ? )
+    dup rc-absolute-cell =
+    over rc-absolute =
+    rot rc-absolute-ppc-2/2 = or or ;
+
+! Relocation types
+: rt-primitive 0 ;
+: rt-dlsym     1 ;
+: rt-literal   2 ;
+: rt-dispatch  3 ;
+: rt-xt        4 ;
+: rt-here      5 ;
+: rt-label     6 ;
+: rt-immediate 7 ;
+
+TUPLE: label-fixup label class ;
+
+: label-fixup ( label class -- ) \ label-fixup boa , ;
+
+M: label-fixup fixup*
+    dup class>> rc-absolute?
+    [ "Absolute labels not supported" throw ] when
+    dup label>> swap class>> compiled-offset 4 - rot
+    3array label-table get push ;
+
+TUPLE: rel-fixup arg class type ;
+
+: rel-fixup ( arg class type -- ) \ rel-fixup boa , ;
+
+: push-4 ( value vector -- )
+    [ length ] [ B{ 0 0 0 0 } swap push-all ] [ underlying>> ] tri
+    swap set-alien-unsigned-4 ;
+
+M: rel-fixup fixup*
+    [ [ arg>> ] [ class>> ] [ type>> ] tri { 0 8 16 } bitfield ]
+    [ class>> rc-absolute-cell = cell 4 ? compiled-offset swap - ] bi
+    [ relocation-table get push-4 ] bi@ ;
+
+M: frame-required fixup* drop ;
+
+M: integer fixup* , ;
+
+: adjoin* ( obj table -- n )
+    2dup swap [ eq? ] curry find drop
+    [ 2nip ] [ dup length >r push r> ] if* ;
+
+SYMBOL: literal-table
+
+: add-literal ( obj -- n ) literal-table get adjoin* ;
+
+: add-dlsym-literals ( symbol dll -- )
+    >r string>symbol r> 2array literal-table get push-all ;
+
+: rel-dlsym ( name dll class -- )
+    >r literal-table get length >r
+    add-dlsym-literals
+    r> r> rt-dlsym rel-fixup ;
+
+: rel-word ( word class -- )
+    >r add-literal r> rt-xt rel-fixup ;
+
+: rel-primitive ( word class -- )
+    >r def>> first r> rt-primitive rel-fixup ;
+
+: rel-literal ( literal class -- )
+    >r add-literal r> rt-literal rel-fixup ;
+
+: rel-this ( class -- )
+    0 swap rt-label rel-fixup ;
+
+: rel-here ( class -- )
+    0 swap rt-here rel-fixup ;
+
+: init-fixup ( -- )
+    BV{ } clone relocation-table set
+    V{ } clone label-table set ;
+
+: resolve-labels ( labels -- labels' )
+    [
+        first3 offset>>
+        [ "Unresolved label" throw ] unless*
+        3array
+    ] map concat ;
+
+: fixup ( code -- literals relocation labels code )
+    [
+        init-fixup
+        dup stack-frame-size swap [ fixup* ] each drop
+
+        literal-table get >array
+        relocation-table get >byte-array
+        label-table get resolve-labels
+    ] { } make ;
diff --git a/unfinished/compiler/codegen/fixup/summary.txt b/unfinished/compiler/codegen/fixup/summary.txt
new file mode 100644 (file)
index 0000000..ce83e6d
--- /dev/null
@@ -0,0 +1 @@
+Support for generation of relocatable code
diff --git a/unfinished/compiler/instructions/instructions.factor b/unfinished/compiler/instructions/instructions.factor
new file mode 100644 (file)
index 0000000..199cd54
--- /dev/null
@@ -0,0 +1,72 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs accessors arrays kernel sequences
+compiler.instructions.syntax ;
+IN: compiler.instructions
+
+! Virtual CPU instructions, used by CFG and machine IRs
+
+INSN: %cond-branch vreg ;
+INSN: %unary dst src ;
+
+! Stack operations
+INSN: %peek vreg loc ;
+INSN: %replace vreg loc ;
+INSN: %inc-d n ;
+INSN: %inc-r n ;
+INSN: %load-literal obj vreg ;
+
+! Calling convention
+INSN: %prologue ;
+INSN: %epilogue ;
+INSN: %frame-required n ;
+INSN: %return ;
+
+! Subroutine calls
+INSN: %call word ;
+INSN: %jump word ;
+INSN: %intrinsic quot vregs ;
+
+! Jump tables
+INSN: %dispatch-label label ;
+INSN: %dispatch ;
+
+! Unconditional branch to successor (CFG only)
+INSN: %branch ;
+
+! Conditional branches (CFG only)
+INSN: %branch-f < %cond-branch ;
+INSN: %branch-t < %cond-branch ;
+INSN: %if-intrinsic quot vregs ;
+INSN: %boolean-intrinsic quot vregs out ;
+
+! Boxing and unboxing
+INSN: %copy < %unary ;
+INSN: %copy-float < %unary ;
+INSN: %unbox-float < %unary ;
+INSN: %unbox-f < %unary ;
+INSN: %unbox-alien < %unary ;
+INSN: %unbox-byte-array < %unary ;
+INSN: %unbox-any-c-ptr < %unary ;
+INSN: %box-float < %unary ;
+INSN: %box-alien < %unary ;
+
+INSN: %gc ;
+
+! FFI
+INSN: %alien-invoke params ;
+INSN: %alien-indirect params ;
+INSN: %alien-callback params ;
+
+GENERIC: uses-vregs ( insn -- seq )
+
+M: insn uses-vregs drop f ;
+M: %peek uses-vregs vreg>> 1array ;
+M: %replace uses-vregs vreg>> 1array ;
+M: %load-literal uses-vregs vreg>> 1array ;
+M: %cond-branch uses-vregs vreg>> 1array ;
+M: %unary uses-vregs [ dst>> ] [ src>> ] bi 2array ;
+M: %intrinsic uses-vregs vregs>> values ;
+M: %if-intrinsic uses-vregs vregs>> values ;
+M: %boolean-intrinsic uses-vregs
+    [ vregs>> values ] [ out>> ] bi suffix ;
diff --git a/unfinished/compiler/instructions/syntax/syntax.factor b/unfinished/compiler/instructions/syntax/syntax.factor
new file mode 100644 (file)
index 0000000..0a4ffae
--- /dev/null
@@ -0,0 +1,15 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: classes.tuple classes.tuple.parser kernel words
+make parser ;
+IN: compiler.instructions.syntax
+
+TUPLE: insn ;
+
+: INSN:
+    parse-tuple-definition
+    [ dup tuple eq? [ drop insn ] when ] dip
+    [ define-tuple-class ]
+    [ 2drop save-location ]
+    [ 2drop dup [ boa , ] curry define-inline ]
+    3tri ; parsing
diff --git a/unfinished/compiler/lvops.bluesky/lvops.factor b/unfinished/compiler/lvops.bluesky/lvops.factor
new file mode 100644 (file)
index 0000000..e1f5ebb
--- /dev/null
@@ -0,0 +1,21 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+IN: compiler.lvops
+
+! Machine representation ("linear virtual operations"). Uses
+! same operations as CFG basic blocks, except edges and branches
+! are replaced by linear jumps (_b* instances).
+
+TUPLE: _label label ;
+
+! Unconditional jump to label
+TUPLE: _b label ;
+
+! Integer
+TUPLE: _bi label in code ;
+TUPLE: _bf label in code ;
+
+! Dispatch table, jumps to one of following _address
+! depending value of 'in'
+TUPLE: _dispatch in ;
+TUPLE: _address word ;
diff --git a/unfinished/compiler/lvops/lvops.factor b/unfinished/compiler/lvops/lvops.factor
deleted file mode 100644 (file)
index e1f5ebb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-IN: compiler.lvops
-
-! Machine representation ("linear virtual operations"). Uses
-! same operations as CFG basic blocks, except edges and branches
-! are replaced by linear jumps (_b* instances).
-
-TUPLE: _label label ;
-
-! Unconditional jump to label
-TUPLE: _b label ;
-
-! Integer
-TUPLE: _bi label in code ;
-TUPLE: _bf label in code ;
-
-! Dispatch table, jumps to one of following _address
-! depending value of 'in'
-TUPLE: _dispatch in ;
-TUPLE: _address word ;
diff --git a/unfinished/compiler/machine.bluesky/builder/builder.factor b/unfinished/compiler/machine.bluesky/builder/builder.factor
new file mode 100644 (file)
index 0000000..42379d4
--- /dev/null
@@ -0,0 +1,50 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel math accessors sequences namespaces
+compiler.cfg compiler.vops compiler.lvops ;
+IN: compiler.machine.builder
+
+SYMBOL: block-counter
+
+: number-basic-block ( basic-block -- )
+    #! Make this fancy later.
+    dup number>> [ drop ] [
+        block-counter [ dup 1+ ] change >>number
+        [ , ] [
+            successors>> <reversed>
+            [ number-basic-block ] each
+        ] bi
+    ] if ;
+
+: flatten-basic-blocks ( procedure -- blocks )
+    [
+        0 block-counter
+        [ number-basic-block ]
+        with-variable
+    ] { } make ;
+
+GENERIC: linearize-instruction ( basic-block insn -- )
+
+M: object linearize-instruction
+    , drop ;
+
+M: %b linearize-instruction
+    drop successors>> first number>> _b emit ;
+
+: conditional-branch ( basic-block insn class -- )
+    [ successors>> ] 2dip
+    [ [ first number>> ] [ [ in>> ] [ code>> ] bi ] [ ] tri* emit ]
+    [ 2drop second number>> _b emit ]
+    3bi ; inline
+
+M: %bi linearize-instruction _bi conditional-branch ;
+M: %bf linearize-instruction _bf conditional-branch ;
+
+: build-mr ( procedure -- insns )
+    [
+        flatten-basic-blocks [
+            [ number>> _label emit ]
+            [ dup instructions>> [ linearize-instruction ] with each ]
+            bi
+        ] each
+    ] { } make ;
diff --git a/unfinished/compiler/machine.bluesky/debugger/debugger.factor b/unfinished/compiler/machine.bluesky/debugger/debugger.factor
new file mode 100644 (file)
index 0000000..adc84d7
--- /dev/null
@@ -0,0 +1,45 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors kernel namespaces sequences assocs io
+prettyprint inference generator optimizer
+compiler.vops
+compiler.tree.builder
+compiler.tree.optimizer
+compiler.cfg.builder
+compiler.cfg.simplifier
+compiler.machine.builder
+compiler.machine.simplifier ;
+IN: compiler.machine.debugger
+
+: tree>linear ( tree word -- linear )
+    [
+        init-counter
+        build-cfg
+        [ simplify-cfg build-mr simplify-mr ] assoc-map
+    ] with-scope ;
+
+: linear. ( linear -- )
+    [
+        "==== " write swap .
+        [ . ] each
+    ] assoc-each ;
+
+: linearized-quot. ( quot -- )
+    build-tree optimize-tree
+    "Anonymous quotation" tree>linear
+    linear. ;
+
+: linearized-word. ( word -- )
+    dup build-tree-from-word nip optimize-tree
+    dup word-dataflow nip optimize swap tree>linear linear. ;
+
+: >basic-block ( quot -- basic-block )
+    build-tree optimize-tree
+    [
+        init-counter
+        "Anonymous quotation" build-cfg
+        >alist first second simplify-cfg
+    ] with-scope ;
+
+: basic-block. ( basic-block -- )
+    instructions>> [ . ] each ;
diff --git a/unfinished/compiler/machine.bluesky/simplifier/simplifier.factor b/unfinished/compiler/machine.bluesky/simplifier/simplifier.factor
new file mode 100644 (file)
index 0000000..a477c71
--- /dev/null
@@ -0,0 +1,18 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors namespaces sequences.next compiler.lvops ;
+IN: compiler.machine.simplifier
+
+: useless-branch? ( next insn -- ? )
+    2dup [ _label? ] [ _b? ] bi* and
+    [ [ label>> ] bi@ = ] [ 2drop f ] if ;
+
+: simplify-mr ( insns -- insns )
+    #! Remove unconditional branches to labels immediately
+    #! following.
+    [
+        [
+            tuck useless-branch?
+            [ drop ] [ , ] if
+        ] each-next
+    ] { } make ;
index 42379d4fa3d2bdc4b8e66df2a6e8537bf7bb6b0b..bf7f917c5a8c6baaf6a8909caae906fe6cdbc146 100644 (file)
@@ -1,14 +1,17 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel math accessors sequences namespaces
-compiler.cfg compiler.vops compiler.lvops ;
+USING: kernel math accessors sequences namespaces make
+compiler.cfg compiler.instructions compiler.machine ;
 IN: compiler.machine.builder
 
+! Convert CFG IR to machine IR.
+
 SYMBOL: block-counter
 
 : number-basic-block ( basic-block -- )
     #! Make this fancy later.
     dup number>> [ drop ] [
+        <label> >>label
         block-counter [ dup 1+ ] change >>number
         [ , ] [
             successors>> <reversed>
@@ -23,28 +26,47 @@ SYMBOL: block-counter
         with-variable
     ] { } make ;
 
-GENERIC: linearize-instruction ( basic-block insn -- )
+GENERIC: linearize* ( basic-block insn -- )
+
+M: object linearize* , drop ;
+
+M: %branch linearize*
+    drop successors>> first label>> _branch ;
 
-M: object linearize-instruction
-    , drop ;
+: conditional ( basic-block -- label1 label2 )
+    successors>> first2 [ label>> ] bi@ swap ; inline
 
-M: %b linearize-instruction
-    drop successors>> first number>> _b emit ;
+: boolean-conditional ( basic-block insn -- label1 vreg label2 )
+    [ conditional ] [ vreg>> ] bi* swap ; inline
 
-: conditional-branch ( basic-block insn class -- )
-    [ successors>> ] 2dip
-    [ [ first number>> ] [ [ in>> ] [ code>> ] bi ] [ ] tri* emit ]
-    [ 2drop second number>> _b emit ]
-    3bi ; inline
+M: %branch-f linearize*
+    boolean-conditional _branch-f _branch ;
 
-M: %bi linearize-instruction _bi conditional-branch ;
-M: %bf linearize-instruction _bf conditional-branch ;
+M: %branch-t linearize*
+    boolean-conditional _branch-t _branch ;
+
+M: %if-intrinsic linearize*
+    [ conditional ] [ [ quot>> ] [ vregs>> ] bi ] bi*
+    _if-intrinsic _branch ;
+
+M: %boolean-intrinsic linearize*
+    [
+        "false" define-label
+        "end" define-label
+        "false" get over [ quot>> ] [ vregs>> ] bi _if-intrinsic
+        t over out>> %load-literal
+        "end" get _branch
+        "false" resolve-label
+        f over out>> %load-literal
+        "end" resolve-label
+    ] with-scope
+    2drop ;
 
-: build-mr ( procedure -- insns )
+: build-machine ( procedure -- insns )
     [
-        flatten-basic-blocks [
-            [ number>> _label emit ]
-            [ dup instructions>> [ linearize-instruction ] with each ]
+        entry>> flatten-basic-blocks [
+            [ label>> _label ]
+            [ dup instructions>> [ linearize* ] with each ]
             bi
         ] each
     ] { } make ;
diff --git a/unfinished/compiler/machine/debugger/debugger.factor b/unfinished/compiler/machine/debugger/debugger.factor
deleted file mode 100644 (file)
index adc84d7..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors kernel namespaces sequences assocs io
-prettyprint inference generator optimizer
-compiler.vops
-compiler.tree.builder
-compiler.tree.optimizer
-compiler.cfg.builder
-compiler.cfg.simplifier
-compiler.machine.builder
-compiler.machine.simplifier ;
-IN: compiler.machine.debugger
-
-: tree>linear ( tree word -- linear )
-    [
-        init-counter
-        build-cfg
-        [ simplify-cfg build-mr simplify-mr ] assoc-map
-    ] with-scope ;
-
-: linear. ( linear -- )
-    [
-        "==== " write swap .
-        [ . ] each
-    ] assoc-each ;
-
-: linearized-quot. ( quot -- )
-    build-tree optimize-tree
-    "Anonymous quotation" tree>linear
-    linear. ;
-
-: linearized-word. ( word -- )
-    dup build-tree-from-word nip optimize-tree
-    dup word-dataflow nip optimize swap tree>linear linear. ;
-
-: >basic-block ( quot -- basic-block )
-    build-tree optimize-tree
-    [
-        init-counter
-        "Anonymous quotation" build-cfg
-        >alist first second simplify-cfg
-    ] with-scope ;
-
-: basic-block. ( basic-block -- )
-    instructions>> [ . ] each ;
diff --git a/unfinished/compiler/machine/linear-scan/allocation/allocation.factor b/unfinished/compiler/machine/linear-scan/allocation/allocation.factor
new file mode 100644 (file)
index 0000000..9d964c9
--- /dev/null
@@ -0,0 +1,90 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces sequences math math.order kernel assocs
+accessors vectors fry
+compiler.machine.linear-scan.live-intervals
+compiler.backend ;
+IN: compiler.machine.linear-scan.allocation
+
+! Mapping from vregs to machine registers
+SYMBOL: register-allocation
+
+! Mapping from vregs to spill locations
+SYMBOL: spill-locations
+
+! Vector of active live intervals, in order of increasing end point
+SYMBOL: active-intervals
+
+: add-active ( live-interval -- )
+    active-intervals get push ;
+
+: delete-active ( live-interval -- )
+    active-intervals get delete ;
+
+! Mapping from register classes to sequences of machine registers
+SYMBOL: free-registers
+
+! Counter of spill locations
+SYMBOL: spill-counter
+
+: next-spill-location ( -- n )
+    spill-counter [ dup 1+ ] change ;
+
+: assign-spill ( live-interval -- )
+    next-spill-location swap vreg>> spill-locations get set-at ;
+
+: free-registers-for ( vreg -- seq )
+    reg-class>> free-registers get at ;
+
+: free-register ( vreg -- )
+    #! Free machine register currently assigned to vreg.
+    [ register-allocation get at ] [ free-registers-for ] bi push ;
+
+: expire-old-intervals ( live-interval -- )
+    active-intervals get
+    swap '[ end>> _ start>> < ] partition
+    active-intervals set
+    [ vreg>> free-register ] each ;
+
+: interval-to-spill ( -- live-interval )
+    #! We spill the interval with the longest remaining range.
+    active-intervals get unclip-slice [
+        [ [ end>> ] bi@ > ] most
+    ] reduce ;
+
+: reuse-register ( live-interval to-spill -- )
+    vreg>> swap vreg>>
+    register-allocation get
+    tuck [ at ] [ set-at ] 2bi* ;
+
+: spill-at-interval ( live-interval -- )
+    interval-to-spill
+    2dup [ end>> ] bi@ > [
+        [ reuse-register ]
+        [ nip assign-spill ]
+        [ [ add-active ] [ delete-active ] bi* ]
+        2tri
+    ] [ drop assign-spill ] if ;
+
+: init-allocator ( -- )
+    H{ } clone register-allocation set
+    H{ } clone spill-locations set
+    V{ } clone active-intervals set
+    machine-registers [ >vector ] assoc-map free-registers set
+    0 spill-counter set ;
+
+: assign-register ( live-interval register -- )
+    swap vreg>> register-allocation get set-at ;
+
+: allocate-register ( live-interval -- )
+    dup vreg>> free-registers-for [
+        spill-at-interval
+    ] [
+        [ pop assign-register ]
+        [ drop add-active ]
+        2bi
+    ] if-empty ;
+
+: allocate-registers ( live-intervals -- )
+    init-allocator
+    [ [ expire-old-intervals ] [ allocate-register ] bi ] each ;
diff --git a/unfinished/compiler/machine/linear-scan/linear-scan.factor b/unfinished/compiler/machine/linear-scan/linear-scan.factor
new file mode 100644 (file)
index 0000000..260e0af
--- /dev/null
@@ -0,0 +1,12 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+IN: compiler.machine.linear-scan
+
+! See http://www.cs.ucla.edu/~palsberg/course/cs132/linearscan.pdf
+
+! ! ! Step 1: compute live intervals
+
+
+! ! ! Step 2: allocate registers
+
+
diff --git a/unfinished/compiler/machine/linear-scan/live-intervals/live-intervals.factor b/unfinished/compiler/machine/linear-scan/live-intervals/live-intervals.factor
new file mode 100644 (file)
index 0000000..d5e1543
--- /dev/null
@@ -0,0 +1,32 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: namespaces kernel assocs accessors sequences math
+math.order sorting compiler.instructions compiler.registers ;
+IN: compiler.machine.linear-scan.live-intervals
+
+TUPLE: live-interval < identity-tuple vreg start end ;
+
+M: live-interval hashcode* nip [ start>> ] [ end>> 1000 * ] bi + ;
+
+! Mapping from vreg to live-interval
+SYMBOL: live-intervals
+
+: update-live-interval ( n vreg -- )
+    >vreg
+    live-intervals get
+    [ over f live-interval boa ] cache
+    (>>end) ;
+
+: compute-live-intervals* ( n insn -- )
+    uses-vregs [ update-live-interval ] with each ;
+
+: sort-live-intervals ( assoc -- seq' )
+    #! Sort by increasing start location.
+    values [ [ start>> ] compare ] sort ;
+
+: compute-live-intervals ( instructions -- live-intervals )
+    H{ } clone [
+        live-intervals [
+            [ swap compute-live-intervals* ] each-index
+        ] with-variable
+    ] keep sort-live-intervals ;
diff --git a/unfinished/compiler/machine/machine.factor b/unfinished/compiler/machine/machine.factor
new file mode 100644 (file)
index 0000000..2071dab
--- /dev/null
@@ -0,0 +1,27 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: assocs accessors arrays namespaces kernel math
+sequences compiler.instructions compiler.instructions.syntax ;
+IN: compiler.machine
+
+! Machine representation. Flat list of instructions, all
+! registers allocated, with labels and jumps.
+
+INSN: _prologue n ;
+INSN: _epilogue n ;
+
+INSN: _label label ;
+
+: <label> ( -- label ) \ <label> counter ;
+: define-label ( name -- ) <label> swap set ;
+: resolve-label ( label/name -- ) dup integer? [ get ] unless _label ;
+
+TUPLE: _cond-branch vreg label ;
+
+INSN: _branch label ;
+INSN: _branch-f < _cond-branch ;
+INSN: _branch-t < _cond-branch ;
+INSN: _if-intrinsic label quot vregs ;
+
+M: _cond-branch uses-vregs vreg>> 1array ;
+M: _if-intrinsic uses-vregs vregs>> values ;
diff --git a/unfinished/compiler/machine/optimizer/optimizer-tests.factor b/unfinished/compiler/machine/optimizer/optimizer-tests.factor
new file mode 100644 (file)
index 0000000..62ada75
--- /dev/null
@@ -0,0 +1,4 @@
+IN: compiler.machine.optimizer.tests
+USING: compiler.machine.optimizer tools.test ;
+
+\ optimize-machine must-infer
diff --git a/unfinished/compiler/machine/optimizer/optimizer.factor b/unfinished/compiler/machine/optimizer/optimizer.factor
new file mode 100644 (file)
index 0000000..74f6b9b
--- /dev/null
@@ -0,0 +1,39 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel accessors math namespaces make sequences
+sequences.next
+compiler.instructions
+compiler.instructions.syntax
+compiler.machine ;
+IN: compiler.machine.optimizer
+
+: frame-required ( insns -- n/f )
+    [ %frame-required? ] filter
+    [ f ] [ [ n>> ] map supremum ] if-empty ;
+
+GENERIC: optimize* ( next insn -- )
+
+: useless-branch? ( next insn -- ? )
+    over _label? [ [ label>> ] bi@ = ] [ 2drop f ] if ;
+
+M: _branch optimize*
+    #! Remove unconditional branches to labels immediately
+    #! following.
+    tuck useless-branch? [ drop ] [ , ] if ;
+
+M: %prologue optimize*
+    2drop \ frame-required get [ _prologue ] when* ;
+
+M: %epilogue optimize*
+    2drop \ frame-required get [ _epilogue ] when* ;
+
+M: %frame-required optimize* 2drop ;
+
+M: insn optimize* nip , ;
+
+: optimize-machine ( insns -- insns )
+    [
+        [ frame-required \ frame-required set ]
+        [ [ optimize* ] each-next ]
+        bi
+    ] { } make ;
diff --git a/unfinished/compiler/machine/simplifier/simplifier.factor b/unfinished/compiler/machine/simplifier/simplifier.factor
deleted file mode 100644 (file)
index a477c71..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel accessors namespaces sequences.next compiler.lvops ;
-IN: compiler.machine.simplifier
-
-: useless-branch? ( next insn -- ? )
-    2dup [ _label? ] [ _b? ] bi* and
-    [ [ label>> ] bi@ = ] [ 2drop f ] if ;
-
-: simplify-mr ( insns -- insns )
-    #! Remove unconditional branches to labels immediately
-    #! following.
-    [
-        [
-            tuck useless-branch?
-            [ drop ] [ , ] if
-        ] each-next
-    ] { } make ;
diff --git a/unfinished/compiler/registers/registers.factor b/unfinished/compiler/registers/registers.factor
new file mode 100644 (file)
index 0000000..6087064
--- /dev/null
@@ -0,0 +1,90 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors namespaces math kernel ;
+IN: compiler.registers
+
+! Virtual CPU registers, used by CFG and machine IRs
+
+MIXIN: value
+
+GENERIC: >vreg ( obj -- vreg )
+
+M: value >vreg drop f ;
+
+! Register classes
+SINGLETON: int-regs
+SINGLETON: single-float-regs
+SINGLETON: double-float-regs
+UNION: float-regs single-float-regs double-float-regs ;
+UNION: reg-class int-regs float-regs ;
+
+! Virtual registers
+TUPLE: vreg reg-class n ;
+SYMBOL: vreg-counter
+: next-vreg ( reg-class -- vreg ) \ vreg-counter counter vreg boa ;
+
+M: vreg >vreg ;
+
+INSTANCE: vreg value
+
+! Stack locations
+TUPLE: loc n class ;
+
+! A data stack location.
+TUPLE: ds-loc < loc ;
+: <ds-loc> ( n -- loc ) f ds-loc boa ;
+
+TUPLE: rs-loc < loc ;
+: <rs-loc> ( n -- loc ) f rs-loc boa ;
+
+INSTANCE: loc value
+
+! A stack location which has been loaded into a register. To
+! read the location, we just read the register, but when time
+! comes to save it back to the stack, we know the register just
+! contains a stack value so we don't have to redundantly write
+! it back.
+TUPLE: cached loc vreg ;
+C: <cached> cached
+
+M: cached >vreg vreg>> >vreg ;
+
+INSTANCE: cached value
+
+! A tagged pointer
+TUPLE: tagged vreg class ;
+: <tagged> ( vreg -- tagged ) f tagged boa ;
+
+M: tagged >vreg vreg>> ;
+
+INSTANCE: tagged value
+
+! Unboxed value
+TUPLE: unboxed vreg ;
+C: <unboxed> unboxed
+
+M: unboxed >vreg vreg>> ;
+
+INSTANCE: unboxed value
+
+! Unboxed alien pointer
+TUPLE: unboxed-alien < unboxed ;
+C: <unboxed-alien> unboxed-alien
+
+! Untagged byte array pointer
+TUPLE: unboxed-byte-array < unboxed ;
+C: <unboxed-byte-array> unboxed-byte-array
+
+! A register set to f
+TUPLE: unboxed-f < unboxed ;
+C: <unboxed-f> unboxed-f
+
+! An alien, byte array or f
+TUPLE: unboxed-c-ptr < unboxed ;
+C: <unboxed-c-ptr> unboxed-c-ptr
+
+! A constant value
+TUPLE: constant value ;
+C: <constant> constant
+
+INSTANCE: constant value
diff --git a/unfinished/compiler/vops.bluesky/builder/builder.factor b/unfinished/compiler/vops.bluesky/builder/builder.factor
new file mode 100644 (file)
index 0000000..9ce3be8
--- /dev/null
@@ -0,0 +1,202 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: parser kernel namespaces words layouts sequences classes
+classes.algebra accessors math arrays byte-arrays
+inference.dataflow optimizer.allot compiler.cfg compiler.vops ;
+IN: compiler.vops.builder
+
+<< : TEMP: CREATE dup [ get ] curry define-inline ; parsing >>
+
+! Temps   Inputs    Outputs
+TEMP: $1  TEMP: #1  TEMP: ^1
+TEMP: $2  TEMP: #2  TEMP: ^2
+TEMP: $3  TEMP: #3  TEMP: ^3
+TEMP: $4  TEMP: #4  TEMP: ^4
+TEMP: $5  TEMP: #5  TEMP: ^5
+
+GENERIC: emit-literal ( vreg object -- )
+
+M: fixnum emit-literal ( vreg object -- )
+    tag-bits get shift %iconst emit ;
+
+M: f emit-literal
+    class tag-number %iconst emit ;
+
+M: object emit-literal ( vreg object -- )
+    next-vreg [ %literal-table emit ] keep
+    swap %literal emit ;
+
+: temps ( seq -- ) [ next-vreg swap set ] each ;
+
+: init-intrinsic ( -- )
+    { $1 $2 $3 $4 ^1 ^2 ^3 ^4 } temps ;
+
+: load-iconst ( value -- vreg )
+    [ next-vreg dup ] dip %iconst emit ;
+
+: load-tag-mask ( -- vreg )
+    tag-mask get load-iconst ;
+
+: load-tag-bits ( -- vreg )
+    tag-bits get load-iconst ;
+
+: emit-tag-fixnum ( out in -- )
+    load-tag-bits %shl emit ;
+
+: emit-untag-fixnum ( out in -- )
+    load-tag-bits %sar emit ;
+
+: emit-untag ( out in -- )
+    next-vreg dup tag-mask get bitnot %iconst emit
+    %and emit ;
+
+: emit-tag ( -- )
+    $1 #1 load-tag-mask %and emit
+    ^1 $1 emit-tag-fixnum ;
+
+: emit-slot ( node -- )
+    [ ^1 #1 #2 ] dip dup in-d>> first node-class class-tag %%slot emit ;
+
+UNION: immediate fixnum POSTPONE: f ;
+
+: emit-write-barrier ( node -- )
+    dup in-d>> first node-class immediate class< [ #2 %write-barrier emit ] unless ;
+
+: emit-set-slot ( node -- )
+    [ emit-write-barrier ]
+    [ [ #1 #2 #3 ] dip dup in-d>> second node-class class-tag %%set-slot emit ]
+    bi ;
+
+: emit-fixnum-bitnot ( -- )
+    $1 #1 %not emit
+    ^1 $1 load-tag-mask %xor emit ;
+
+: emit-fixnum+fast ( -- )
+    ^1 #1 #2 %iadd emit ;
+
+: emit-fixnum-fast ( -- )
+    ^1 #1 #2 %isub emit ;
+
+: emit-fixnum-bitand ( -- )
+    ^1 #1 #2 %and emit ;
+
+: emit-fixnum-bitor ( -- )
+    ^1 #1 #2 %or emit ;
+
+: emit-fixnum-bitxor ( -- )
+    ^1 #1 #2 %xor emit ;
+
+: emit-fixnum*fast ( -- )
+    $1 #1 emit-untag-fixnum
+    ^1 $1 #2 %imul emit ;
+
+: emit-fixnum-shift-left-fast ( n -- )
+    [ $1 ] dip %iconst emit
+    ^1 #1 $1 %shl emit ;
+
+: emit-fixnum-shift-right-fast ( n -- )
+    [ $1 ] dip %iconst emit
+    $2 #1 $1 %sar emit
+    ^1 $2 emit-untag ;
+
+: emit-fixnum-shift-fast ( n -- )
+    dup 0 >=
+    [ emit-fixnum-shift-left-fast ]
+    [ neg emit-fixnum-shift-right-fast ] if ;
+
+: emit-fixnum-compare ( cc -- )
+    $1 #1 #2 %icmp emit
+    [ ^1 $1 ] dip %%iboolean emit ;
+
+: emit-fixnum<= ( -- )
+    cc<= emit-fixnum-compare ;
+
+: emit-fixnum>= ( -- )
+    cc>= emit-fixnum-compare ;
+
+: emit-fixnum< ( -- )
+    cc< emit-fixnum-compare ;
+
+: emit-fixnum> ( -- )
+    cc> emit-fixnum-compare ;
+
+: emit-eq? ( -- )
+    cc= emit-fixnum-compare ;
+
+: emit-unbox-float ( out in -- )
+    %%unbox-float emit ;
+
+: emit-box-float ( out in -- )
+    %%box-float emit ;
+
+: emit-unbox-floats ( -- )
+    $1 #1 emit-unbox-float
+    $2 #2 emit-unbox-float ;
+
+: emit-float+ ( -- )
+    emit-unbox-floats
+    $3 $1 $2 %fadd emit
+    ^1 $3 emit-box-float ;
+
+: emit-float- ( -- )
+    emit-unbox-floats
+    $3 $1 $2 %fsub emit
+    ^1 $3 emit-box-float ;
+
+: emit-float* ( -- )
+    emit-unbox-floats
+    $3 $1 $2 %fmul emit
+    ^1 $3 emit-box-float ;
+
+: emit-float/f ( -- )
+    emit-unbox-floats
+    $3 $1 $2 %fdiv emit
+    ^1 $3 emit-box-float ;
+
+: emit-float-compare ( cc -- )
+    emit-unbox-floats
+    $3 $1 $2 %fcmp emit
+    [ ^1 $3 ] dip %%fboolean emit ;
+
+: emit-float<= ( -- )
+    cc<= emit-float-compare ;
+
+: emit-float>= ( -- )
+    cc>= emit-float-compare ;
+
+: emit-float< ( -- )
+    cc< emit-float-compare ;
+
+: emit-float> ( -- )
+    cc> emit-float-compare ;
+
+: emit-float= ( -- )
+    cc= emit-float-compare ;
+
+: emit-allot ( vreg size class -- )
+    [ tag-number ] [ type-number ] bi %%allot emit ;
+
+: emit-(tuple) ( layout -- )
+    [ [ ^1 ] dip size>> 2 + tuple emit-allot ]
+    [ [ $1 ] dip emit-literal ] bi
+    $2 1 emit-literal
+    $1 ^1 $2 tuple tag-number %%set-slot emit ;
+
+: emit-(array) ( n -- )
+    [ [ ^1 ] dip 2 + array emit-allot ]
+    [ [ $1 ] dip emit-literal ] bi
+    $2 1 emit-literal
+    $1 ^1 $2 array tag-number %%set-slot emit ;
+
+: emit-(byte-array) ( n -- )
+    [ [ ^1 ] dip bytes>cells 2 + byte-array emit-allot ]
+    [ [ $1 ] dip emit-literal ] bi
+    $2 1 emit-literal
+    $1 ^1 $2 byte-array tag-number %%set-slot emit ;
+
+! fixnum>bignum
+! bignum>fixnum
+! fixnum+
+! fixnum-
+! getenv, setenv
+! alien accessors
diff --git a/unfinished/compiler/vops.bluesky/vops.factor b/unfinished/compiler/vops.bluesky/vops.factor
new file mode 100644 (file)
index 0000000..839d4e0
--- /dev/null
@@ -0,0 +1,181 @@
+! Copyright (C) 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: parser prettyprint.backend kernel accessors math
+math.order sequences namespaces arrays assocs ;
+IN: compiler.vops
+
+TUPLE: vreg n ;
+
+: VREG: scan-word vreg boa parsed ; parsing
+
+M: vreg pprint* \ VREG: pprint-word n>> pprint* ;
+
+SYMBOL: vreg-counter
+
+: init-counter ( -- )
+    { 0 } clone vreg-counter set ;
+
+: next-vreg ( -- n )
+    0 vreg-counter get [ dup 1+ ] change-nth vreg boa ;
+
+: emit ( ... class -- ) boa , ; inline
+
+! ! ! Instructions. Those prefixed with %% are high level
+! ! ! instructions eliminated during the elaboration phase.
+TUPLE: vop ;
+
+! Instruction which does not touch vregs.
+TUPLE: nullary-op < vop ;
+
+! Does nothing
+TUPLE: nop < nullary-op ;
+
+: nop ( -- vop ) T{ nop } ;
+
+: ?nop ( vop ? -- vop/nop ) [ drop nop ] unless ;
+
+! Instruction with no side effects; if 'out' is never read, we
+! can eliminate it.
+TUPLE: flushable-op < vop out ;
+
+! Instruction which is referentially transparent; we can replace
+! repeated computation with a reference to a previous value
+TUPLE: pure-op < flushable-op ;
+
+! Instruction only used for its side effect, produces no values
+TUPLE: effect-op < vop in ;
+
+TUPLE: binary-op < pure-op in1 in2 ;
+
+: inputs ( insn -- in1 in2 ) [ in1>> ] [ in2>> ] bi ; inline
+
+: in/out ( insn -- in out ) [ in>> ] [ out>> ] bi ; inline
+
+TUPLE: unary-op < pure-op in ;
+
+! Merge point; out is a sequence of vregs in a sequence of
+! sequences of vregs
+TUPLE: %phi < pure-op in ;
+
+! Integer, floating point, condition register copy
+TUPLE: %copy < unary-op ;
+
+! Constants
+TUPLE: constant-op < pure-op value ;
+
+TUPLE: %iconst < constant-op ; ! Integer
+TUPLE: %fconst < constant-op ; ! Float
+TUPLE: %cconst < constant-op ; ! Comparison result, +lt+ +eq+ +gt+
+
+! Load address of literal table into out
+TUPLE: %literal-table < pure-op ;
+
+! Load object literal from table.
+TUPLE: %literal < unary-op object ;
+
+! Read/write ops: candidates for alias analysis
+TUPLE: read-op < flushable-op ;
+TUPLE: write-op < effect-op ;
+
+! Stack shuffling
+SINGLETON: %data
+SINGLETON: %retain
+
+TUPLE: %peek < read-op n stack ;
+TUPLE: %replace < write-op n stack ;
+TUPLE: %height < nullary-op n stack ;
+
+: stack-loc ( insn -- pair ) [ n>> ] [ stack>> ] bi 2array ;
+
+TUPLE: commutative-op < binary-op ;
+
+! Integer arithmetic
+TUPLE: %iadd < commutative-op ;
+TUPLE: %isub < binary-op ;
+TUPLE: %imul < commutative-op ;
+TUPLE: %idiv < binary-op ;
+TUPLE: %imod < binary-op ;
+TUPLE: %icmp < binary-op ;
+
+! Bitwise ops
+TUPLE: %not < unary-op ;
+TUPLE: %and < commutative-op ;
+TUPLE: %or  < commutative-op ;
+TUPLE: %xor < commutative-op ;
+TUPLE: %shl < binary-op ;
+TUPLE: %shr < binary-op ;
+TUPLE: %sar < binary-op ;
+
+! Float arithmetic
+TUPLE: %fadd < commutative-op ;
+TUPLE: %fsub < binary-op ;
+TUPLE: %fmul < commutative-op ;
+TUPLE: %fdiv < binary-op ;
+TUPLE: %fcmp < binary-op ;
+
+! Float/integer conversion
+TUPLE: %f>i < unary-op ;
+TUPLE: %i>f < unary-op ;
+
+! Float boxing/unboxing
+TUPLE: %%box-float < unary-op ;
+TUPLE: %%unbox-float < unary-op ;
+
+! High level slot accessors for alias analysis
+! tag is f; if its not f, we can generate a faster sequence
+TUPLE: %%slot < read-op obj slot tag ;
+TUPLE: %%set-slot < write-op obj slot tag ;
+
+TUPLE: %write-barrier < effect-op ;
+
+! Memory
+TUPLE: %load < unary-op ;
+TUPLE: %store < effect-op addr ;
+
+! Control flow; they jump to either the first or second successor
+! of the BB
+
+! Unconditional transfer to first successor
+TUPLE: %b < nullary-op ;
+
+SYMBOL: cc<
+SYMBOL: cc<=
+SYMBOL: cc=
+SYMBOL: cc>
+SYMBOL: cc>=
+SYMBOL: cc/=
+
+: evaluate-cc ( result cc -- ? )
+    H{
+        { cc<  { +lt+           } }
+        { cc<= { +lt+ +eq+      } }
+        { cc=  {      +eq+      } }
+        { cc>= {      +eq+ +gt+ } }
+        { cc>  {           +gt+ } }
+        { cc/= { +lt+      +gt+ } }
+    } at memq? ;
+
+TUPLE: cond-branch < effect-op code ;
+
+TUPLE: %bi < cond-branch ;
+TUPLE: %bf < cond-branch ;
+
+! Convert condition register to a boolean
+TUPLE: boolean-op < unary-op code ;
+
+TUPLE: %%iboolean < boolean-op ;
+TUPLE: %%fboolean < boolean-op ;
+
+! Dispatch table, jumps to successor 0..n-1 depending value of
+! in, which must be in the range [0,n)
+TUPLE: %dispatch < effect-op ;
+
+! Procedures
+TUPLE: %return < nullary-op ;
+TUPLE: %prolog < nullary-op ;
+TUPLE: %epilog < nullary-op ;
+TUPLE: %jump < nullary-op word ;
+TUPLE: %call < nullary-op word ;
+
+! Heap allocation
+TUPLE: %%allot < flushable-op size tag type ;
diff --git a/unfinished/compiler/vops/builder/builder.factor b/unfinished/compiler/vops/builder/builder.factor
deleted file mode 100644 (file)
index 9ce3be8..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: parser kernel namespaces words layouts sequences classes
-classes.algebra accessors math arrays byte-arrays
-inference.dataflow optimizer.allot compiler.cfg compiler.vops ;
-IN: compiler.vops.builder
-
-<< : TEMP: CREATE dup [ get ] curry define-inline ; parsing >>
-
-! Temps   Inputs    Outputs
-TEMP: $1  TEMP: #1  TEMP: ^1
-TEMP: $2  TEMP: #2  TEMP: ^2
-TEMP: $3  TEMP: #3  TEMP: ^3
-TEMP: $4  TEMP: #4  TEMP: ^4
-TEMP: $5  TEMP: #5  TEMP: ^5
-
-GENERIC: emit-literal ( vreg object -- )
-
-M: fixnum emit-literal ( vreg object -- )
-    tag-bits get shift %iconst emit ;
-
-M: f emit-literal
-    class tag-number %iconst emit ;
-
-M: object emit-literal ( vreg object -- )
-    next-vreg [ %literal-table emit ] keep
-    swap %literal emit ;
-
-: temps ( seq -- ) [ next-vreg swap set ] each ;
-
-: init-intrinsic ( -- )
-    { $1 $2 $3 $4 ^1 ^2 ^3 ^4 } temps ;
-
-: load-iconst ( value -- vreg )
-    [ next-vreg dup ] dip %iconst emit ;
-
-: load-tag-mask ( -- vreg )
-    tag-mask get load-iconst ;
-
-: load-tag-bits ( -- vreg )
-    tag-bits get load-iconst ;
-
-: emit-tag-fixnum ( out in -- )
-    load-tag-bits %shl emit ;
-
-: emit-untag-fixnum ( out in -- )
-    load-tag-bits %sar emit ;
-
-: emit-untag ( out in -- )
-    next-vreg dup tag-mask get bitnot %iconst emit
-    %and emit ;
-
-: emit-tag ( -- )
-    $1 #1 load-tag-mask %and emit
-    ^1 $1 emit-tag-fixnum ;
-
-: emit-slot ( node -- )
-    [ ^1 #1 #2 ] dip dup in-d>> first node-class class-tag %%slot emit ;
-
-UNION: immediate fixnum POSTPONE: f ;
-
-: emit-write-barrier ( node -- )
-    dup in-d>> first node-class immediate class< [ #2 %write-barrier emit ] unless ;
-
-: emit-set-slot ( node -- )
-    [ emit-write-barrier ]
-    [ [ #1 #2 #3 ] dip dup in-d>> second node-class class-tag %%set-slot emit ]
-    bi ;
-
-: emit-fixnum-bitnot ( -- )
-    $1 #1 %not emit
-    ^1 $1 load-tag-mask %xor emit ;
-
-: emit-fixnum+fast ( -- )
-    ^1 #1 #2 %iadd emit ;
-
-: emit-fixnum-fast ( -- )
-    ^1 #1 #2 %isub emit ;
-
-: emit-fixnum-bitand ( -- )
-    ^1 #1 #2 %and emit ;
-
-: emit-fixnum-bitor ( -- )
-    ^1 #1 #2 %or emit ;
-
-: emit-fixnum-bitxor ( -- )
-    ^1 #1 #2 %xor emit ;
-
-: emit-fixnum*fast ( -- )
-    $1 #1 emit-untag-fixnum
-    ^1 $1 #2 %imul emit ;
-
-: emit-fixnum-shift-left-fast ( n -- )
-    [ $1 ] dip %iconst emit
-    ^1 #1 $1 %shl emit ;
-
-: emit-fixnum-shift-right-fast ( n -- )
-    [ $1 ] dip %iconst emit
-    $2 #1 $1 %sar emit
-    ^1 $2 emit-untag ;
-
-: emit-fixnum-shift-fast ( n -- )
-    dup 0 >=
-    [ emit-fixnum-shift-left-fast ]
-    [ neg emit-fixnum-shift-right-fast ] if ;
-
-: emit-fixnum-compare ( cc -- )
-    $1 #1 #2 %icmp emit
-    [ ^1 $1 ] dip %%iboolean emit ;
-
-: emit-fixnum<= ( -- )
-    cc<= emit-fixnum-compare ;
-
-: emit-fixnum>= ( -- )
-    cc>= emit-fixnum-compare ;
-
-: emit-fixnum< ( -- )
-    cc< emit-fixnum-compare ;
-
-: emit-fixnum> ( -- )
-    cc> emit-fixnum-compare ;
-
-: emit-eq? ( -- )
-    cc= emit-fixnum-compare ;
-
-: emit-unbox-float ( out in -- )
-    %%unbox-float emit ;
-
-: emit-box-float ( out in -- )
-    %%box-float emit ;
-
-: emit-unbox-floats ( -- )
-    $1 #1 emit-unbox-float
-    $2 #2 emit-unbox-float ;
-
-: emit-float+ ( -- )
-    emit-unbox-floats
-    $3 $1 $2 %fadd emit
-    ^1 $3 emit-box-float ;
-
-: emit-float- ( -- )
-    emit-unbox-floats
-    $3 $1 $2 %fsub emit
-    ^1 $3 emit-box-float ;
-
-: emit-float* ( -- )
-    emit-unbox-floats
-    $3 $1 $2 %fmul emit
-    ^1 $3 emit-box-float ;
-
-: emit-float/f ( -- )
-    emit-unbox-floats
-    $3 $1 $2 %fdiv emit
-    ^1 $3 emit-box-float ;
-
-: emit-float-compare ( cc -- )
-    emit-unbox-floats
-    $3 $1 $2 %fcmp emit
-    [ ^1 $3 ] dip %%fboolean emit ;
-
-: emit-float<= ( -- )
-    cc<= emit-float-compare ;
-
-: emit-float>= ( -- )
-    cc>= emit-float-compare ;
-
-: emit-float< ( -- )
-    cc< emit-float-compare ;
-
-: emit-float> ( -- )
-    cc> emit-float-compare ;
-
-: emit-float= ( -- )
-    cc= emit-float-compare ;
-
-: emit-allot ( vreg size class -- )
-    [ tag-number ] [ type-number ] bi %%allot emit ;
-
-: emit-(tuple) ( layout -- )
-    [ [ ^1 ] dip size>> 2 + tuple emit-allot ]
-    [ [ $1 ] dip emit-literal ] bi
-    $2 1 emit-literal
-    $1 ^1 $2 tuple tag-number %%set-slot emit ;
-
-: emit-(array) ( n -- )
-    [ [ ^1 ] dip 2 + array emit-allot ]
-    [ [ $1 ] dip emit-literal ] bi
-    $2 1 emit-literal
-    $1 ^1 $2 array tag-number %%set-slot emit ;
-
-: emit-(byte-array) ( n -- )
-    [ [ ^1 ] dip bytes>cells 2 + byte-array emit-allot ]
-    [ [ $1 ] dip emit-literal ] bi
-    $2 1 emit-literal
-    $1 ^1 $2 byte-array tag-number %%set-slot emit ;
-
-! fixnum>bignum
-! bignum>fixnum
-! fixnum+
-! fixnum-
-! getenv, setenv
-! alien accessors
diff --git a/unfinished/compiler/vops/vops.factor b/unfinished/compiler/vops/vops.factor
deleted file mode 100644 (file)
index 839d4e0..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-! Copyright (C) 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: parser prettyprint.backend kernel accessors math
-math.order sequences namespaces arrays assocs ;
-IN: compiler.vops
-
-TUPLE: vreg n ;
-
-: VREG: scan-word vreg boa parsed ; parsing
-
-M: vreg pprint* \ VREG: pprint-word n>> pprint* ;
-
-SYMBOL: vreg-counter
-
-: init-counter ( -- )
-    { 0 } clone vreg-counter set ;
-
-: next-vreg ( -- n )
-    0 vreg-counter get [ dup 1+ ] change-nth vreg boa ;
-
-: emit ( ... class -- ) boa , ; inline
-
-! ! ! Instructions. Those prefixed with %% are high level
-! ! ! instructions eliminated during the elaboration phase.
-TUPLE: vop ;
-
-! Instruction which does not touch vregs.
-TUPLE: nullary-op < vop ;
-
-! Does nothing
-TUPLE: nop < nullary-op ;
-
-: nop ( -- vop ) T{ nop } ;
-
-: ?nop ( vop ? -- vop/nop ) [ drop nop ] unless ;
-
-! Instruction with no side effects; if 'out' is never read, we
-! can eliminate it.
-TUPLE: flushable-op < vop out ;
-
-! Instruction which is referentially transparent; we can replace
-! repeated computation with a reference to a previous value
-TUPLE: pure-op < flushable-op ;
-
-! Instruction only used for its side effect, produces no values
-TUPLE: effect-op < vop in ;
-
-TUPLE: binary-op < pure-op in1 in2 ;
-
-: inputs ( insn -- in1 in2 ) [ in1>> ] [ in2>> ] bi ; inline
-
-: in/out ( insn -- in out ) [ in>> ] [ out>> ] bi ; inline
-
-TUPLE: unary-op < pure-op in ;
-
-! Merge point; out is a sequence of vregs in a sequence of
-! sequences of vregs
-TUPLE: %phi < pure-op in ;
-
-! Integer, floating point, condition register copy
-TUPLE: %copy < unary-op ;
-
-! Constants
-TUPLE: constant-op < pure-op value ;
-
-TUPLE: %iconst < constant-op ; ! Integer
-TUPLE: %fconst < constant-op ; ! Float
-TUPLE: %cconst < constant-op ; ! Comparison result, +lt+ +eq+ +gt+
-
-! Load address of literal table into out
-TUPLE: %literal-table < pure-op ;
-
-! Load object literal from table.
-TUPLE: %literal < unary-op object ;
-
-! Read/write ops: candidates for alias analysis
-TUPLE: read-op < flushable-op ;
-TUPLE: write-op < effect-op ;
-
-! Stack shuffling
-SINGLETON: %data
-SINGLETON: %retain
-
-TUPLE: %peek < read-op n stack ;
-TUPLE: %replace < write-op n stack ;
-TUPLE: %height < nullary-op n stack ;
-
-: stack-loc ( insn -- pair ) [ n>> ] [ stack>> ] bi 2array ;
-
-TUPLE: commutative-op < binary-op ;
-
-! Integer arithmetic
-TUPLE: %iadd < commutative-op ;
-TUPLE: %isub < binary-op ;
-TUPLE: %imul < commutative-op ;
-TUPLE: %idiv < binary-op ;
-TUPLE: %imod < binary-op ;
-TUPLE: %icmp < binary-op ;
-
-! Bitwise ops
-TUPLE: %not < unary-op ;
-TUPLE: %and < commutative-op ;
-TUPLE: %or  < commutative-op ;
-TUPLE: %xor < commutative-op ;
-TUPLE: %shl < binary-op ;
-TUPLE: %shr < binary-op ;
-TUPLE: %sar < binary-op ;
-
-! Float arithmetic
-TUPLE: %fadd < commutative-op ;
-TUPLE: %fsub < binary-op ;
-TUPLE: %fmul < commutative-op ;
-TUPLE: %fdiv < binary-op ;
-TUPLE: %fcmp < binary-op ;
-
-! Float/integer conversion
-TUPLE: %f>i < unary-op ;
-TUPLE: %i>f < unary-op ;
-
-! Float boxing/unboxing
-TUPLE: %%box-float < unary-op ;
-TUPLE: %%unbox-float < unary-op ;
-
-! High level slot accessors for alias analysis
-! tag is f; if its not f, we can generate a faster sequence
-TUPLE: %%slot < read-op obj slot tag ;
-TUPLE: %%set-slot < write-op obj slot tag ;
-
-TUPLE: %write-barrier < effect-op ;
-
-! Memory
-TUPLE: %load < unary-op ;
-TUPLE: %store < effect-op addr ;
-
-! Control flow; they jump to either the first or second successor
-! of the BB
-
-! Unconditional transfer to first successor
-TUPLE: %b < nullary-op ;
-
-SYMBOL: cc<
-SYMBOL: cc<=
-SYMBOL: cc=
-SYMBOL: cc>
-SYMBOL: cc>=
-SYMBOL: cc/=
-
-: evaluate-cc ( result cc -- ? )
-    H{
-        { cc<  { +lt+           } }
-        { cc<= { +lt+ +eq+      } }
-        { cc=  {      +eq+      } }
-        { cc>= {      +eq+ +gt+ } }
-        { cc>  {           +gt+ } }
-        { cc/= { +lt+      +gt+ } }
-    } at memq? ;
-
-TUPLE: cond-branch < effect-op code ;
-
-TUPLE: %bi < cond-branch ;
-TUPLE: %bf < cond-branch ;
-
-! Convert condition register to a boolean
-TUPLE: boolean-op < unary-op code ;
-
-TUPLE: %%iboolean < boolean-op ;
-TUPLE: %%fboolean < boolean-op ;
-
-! Dispatch table, jumps to successor 0..n-1 depending value of
-! in, which must be in the range [0,n)
-TUPLE: %dispatch < effect-op ;
-
-! Procedures
-TUPLE: %return < nullary-op ;
-TUPLE: %prolog < nullary-op ;
-TUPLE: %epilog < nullary-op ;
-TUPLE: %jump < nullary-op word ;
-TUPLE: %call < nullary-op word ;
-
-! Heap allocation
-TUPLE: %%allot < flushable-op size tag type ;